diff options
Diffstat (limited to 'recipes-test/ddt-runner/files/scripts/bsc9131rdb/watchdog')
-rwxr-xr-x | recipes-test/ddt-runner/files/scripts/bsc9131rdb/watchdog | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/recipes-test/ddt-runner/files/scripts/bsc9131rdb/watchdog b/recipes-test/ddt-runner/files/scripts/bsc9131rdb/watchdog new file mode 100755 index 0000000..71429fc --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/bsc9131rdb/watchdog | |||
@@ -0,0 +1,64 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # This script is used to test watchdog functionality for bsc9131rdb. | ||
4 | |||
5 | WATCHDOG=`which watchdog` | ||
6 | if [ "x$WATCHDOG" != "x" ]; then | ||
7 | echo "PASS: watchdog found" | ||
8 | else | ||
9 | echo "FAIL: watchdog not found" | ||
10 | exit 1 | ||
11 | fi | ||
12 | |||
13 | WATCHDOG_CONF=/etc/watchdog.conf | ||
14 | if [ -f $WATCHDOG_CONF ]; then | ||
15 | echo "PASS: watchdog config file found" | ||
16 | sed -i '23,23 s/#//' $WATCHDOG_CONF | ||
17 | else | ||
18 | echo "FAIL: watchdog config file not found" | ||
19 | exit 1 | ||
20 | fi | ||
21 | |||
22 | $WATCHDOG -v /dev/watchdog | ||
23 | watchdog_thread=`ps | grep -c 'watchdog -v /dev/watchdog'` | ||
24 | if [ $watchdog_thread -eq 2 ]; then | ||
25 | echo "PASS: Watchdog daemon started successfully" | ||
26 | else | ||
27 | echo "FAIL: Failed to start watchdog daemon" | ||
28 | exit 1 | ||
29 | fi | ||
30 | |||
31 | sleep 5s | ||
32 | |||
33 | killall watchdog | ||
34 | |||
35 | retry=0 | ||
36 | while [ $retry -lt 10 ] | ||
37 | do | ||
38 | watchdog_thread=`ps | grep -c 'watchdog -v /dev/watchdog'` | ||
39 | if [ $watchdog_thread -eq 1 ]; then | ||
40 | echo "PASS: Watchdog daemon stopped successfully" | ||
41 | break; | ||
42 | fi | ||
43 | sleep 1s | ||
44 | retry=`expr $retry + 1` | ||
45 | done | ||
46 | |||
47 | if [ $retry -eq 10 ]; then | ||
48 | echo "FAIL: Failed to stop watchdog daemon" | ||
49 | fi | ||
50 | |||
51 | found=0 | ||
52 | while read line | ||
53 | do | ||
54 | result=`echo $line | grep -c 'still alive after 1 interval'` | ||
55 | if [ $result -eq 1 ]; then | ||
56 | echo "PASS: Watchdog is still alive after 1 interval" | ||
57 | found=1 | ||
58 | fi | ||
59 | done < /var/log/messages | ||
60 | |||
61 | if [ $found -eq 0 ]; then | ||
62 | echo "FAIL: Watchdog is not alive after 1 interval" | ||
63 | fi | ||
64 | |||