Fix: make dist fails on sdt-probe test with autotools v1.16+
[lttng-tools.git] / tests / stress / kill_relayd
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
18 CURDIR=$(dirname $0)/
19 TESTDIR=$CURDIR/..
20 # We use the .libs/ binary since it's run from the repository.
21 REPO_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.
25 NR_SEC=10
26
27 KILL_LOOP=0
28 RANDOM_KILL=0
29
30 source $TESTDIR/utils/utils.sh
31
32 function get_random()
33 {
34 return $(echo $RANDOM % $NR_SEC + 1 | bc)
35 }
36
37 function 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 ?
50 if [ -n "$1" ]; then
51 KILL_LOOP=1
52 fi
53
54 # Should it be a random kill or not ?
55 if [ -n "$2" ]; then
56 RANDOM_KILL=1
57 fi
58
59 # MUST set TESTDIR before this point.
60
61 if [ $KILL_LOOP -eq 0 ]; then
62 kill_relayd
63 else
64 while :; do
65 kill_relayd
66 done
67 fi
This page took 0.033677 seconds and 5 git commands to generate.