Refactor: test: wrapper for destroy_lttng_session
[lttng-tools.git] / tests / stress / kill_relayd
CommitLineData
b3300ee2
DG
1#!/bin/bash
2#
3# Copyright (C) - 2013 David Goulet <dgoulet@efficios.com>
4#
5# This library is free software; you can redistribute it and/or modify it under
6# the terms of the GNU Lesser General Public License as published by the Free
7# Software Foundation; version 2.1 of the License.
8#
9# This library is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12# details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this library; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18CURDIR=$(dirname $0)/
19TESTDIR=$CURDIR/..
20# We use the .libs/ binary since it's run from the repository.
21REPO_RELAYD_BIN="lt-lttng-relayd"
22
23# Number of seconds the we sleep before killing the relayd. If RANDOM_KILL is
24# defined, it's between 1 and 10 seconds.
25NR_SEC=10
26
27KILL_LOOP=0
28RANDOM_KILL=0
29
30source $TESTDIR/utils/utils.sh
31
32function get_random()
33{
34 return $(echo $RANDOM % $NR_SEC + 1 | bc)
35}
36
37function kill_relayd()
38{
39 if [ $RANDOM_KILL -eq 1 ]; then
40 # Something between 1 and NR_SEC seconds.
41 get_random
42 sleep $?
43 else
44 sleep $NR_SEC
45 fi
46 killall -q -9 $REPO_RELAYD_BIN >/dev/null 2>&1
47}
48
49# Do we have to run in an infinite loop ?
50if [ -n "$1" ]; then
51 KILL_LOOP=1
52fi
53
54# Should it be a random kill or not ?
55if [ -n "$2" ]; then
56 RANDOM_KILL=1
57fi
58
59# MUST set TESTDIR before this point.
60
61if [ $KILL_LOOP -eq 0 ]; then
62 kill_relayd
63else
64 while :; do
65 kill_relayd
66 done
67fi
This page took 0.037935 seconds and 4 git commands to generate.