Commit | Line | Data |
---|---|---|
b3300ee2 DG |
1 | #!/bin/bash |
2 | # | |
9d16b343 | 3 | # Copyright (C) 2013 David Goulet <dgoulet@efficios.com> |
b3300ee2 | 4 | # |
9d16b343 | 5 | # SPDX-License-Identifier: LGPL-2.1-only |
b3300ee2 | 6 | # |
b3300ee2 DG |
7 | |
8 | CURDIR=$(dirname $0)/ | |
9 | TESTDIR=$CURDIR/.. | |
10 | # We use the .libs/ binary since it's run from the repository. | |
11 | REPO_RELAYD_BIN="lt-lttng-relayd" | |
12 | ||
13 | # Number of seconds the we sleep before killing the relayd. If RANDOM_KILL is | |
14 | # defined, it's between 1 and 10 seconds. | |
15 | NR_SEC=10 | |
16 | ||
17 | KILL_LOOP=0 | |
18 | RANDOM_KILL=0 | |
19 | ||
20 | source $TESTDIR/utils/utils.sh | |
21 | ||
22 | function get_random() | |
23 | { | |
24 | return $(echo $RANDOM % $NR_SEC + 1 | bc) | |
25 | } | |
26 | ||
27 | function kill_relayd() | |
28 | { | |
29 | if [ $RANDOM_KILL -eq 1 ]; then | |
30 | # Something between 1 and NR_SEC seconds. | |
31 | get_random | |
32 | sleep $? | |
33 | else | |
34 | sleep $NR_SEC | |
35 | fi | |
36 | killall -q -9 $REPO_RELAYD_BIN >/dev/null 2>&1 | |
37 | } | |
38 | ||
39 | # Do we have to run in an infinite loop ? | |
40 | if [ -n "$1" ]; then | |
41 | KILL_LOOP=1 | |
42 | fi | |
43 | ||
44 | # Should it be a random kill or not ? | |
45 | if [ -n "$2" ]; then | |
46 | RANDOM_KILL=1 | |
47 | fi | |
48 | ||
49 | # MUST set TESTDIR before this point. | |
50 | ||
51 | if [ $KILL_LOOP -eq 0 ]; then | |
52 | kill_relayd | |
53 | else | |
54 | while :; do | |
55 | kill_relayd | |
56 | done | |
57 | fi |