diff options
9 files changed, 588 insertions, 0 deletions
diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/ethernet b/recipes-test/ddt-runner/files/scripts/t1042rdb/ethernet new file mode 100755 index 0000000..107d102 --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/ethernet | |||
@@ -0,0 +1,83 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | ethernet_interface="eth3" | ||
4 | ethernet_ping_ipaddr="172.21.3.22" | ||
5 | ethernet_ipaddr=$1 | ||
6 | |||
7 | IFCONFIG=`which ifconfig` | ||
8 | |||
9 | $IFCONFIG $ethernet_interface up > /dev/null 2>&1 | ||
10 | $IFCONFIG | grep $ethernet_interface > /dev/null 2>&1 | ||
11 | if [ $? -ne 0 ]; then | ||
12 | echo "FAIL: $ethernet_interface is not up" | ||
13 | exit 1 | ||
14 | else | ||
15 | echo "PASS: $ethernet_interface is up" | ||
16 | fi | ||
17 | |||
18 | if [ "x$ethernet_ipaddr" != "x" ]; then | ||
19 | $IFCONFIG $ethernet_interface $ethernet_ipaddr | ||
20 | fi | ||
21 | |||
22 | $IFCONFIG $ethernet_interface |grep 'inet addr:' |sed -e 's@inet addr:@@' |sed q | awk '{print $1}' >/dev/null 2>&1 | ||
23 | if [ $? -ne 0 ]; then | ||
24 | echo "FAIL: setup $ethernet_interface ipaddr failed" | ||
25 | exit 1 | ||
26 | else | ||
27 | echo "PASS: setup $ethernet_interface ipaddr succeeded" | ||
28 | fi | ||
29 | |||
30 | mindatasize=56 | ||
31 | maxdatasize=650 | ||
32 | stepsize=100 | ||
33 | iteration=1 | ||
34 | datasize=$mindatasize | ||
35 | logfile=`/bin/mktemp` | ||
36 | statistics=`/bin/mktemp` | ||
37 | error=0 | ||
38 | |||
39 | trap cleanup SIGHUP SIGINT SIGTERM | ||
40 | |||
41 | clean_tasks() { | ||
42 | rm -f $logfile $statistics | ||
43 | } | ||
44 | |||
45 | cleanup() { | ||
46 | echo "Aborting script execution" | ||
47 | clean_tasks | ||
48 | exit 0 | ||
49 | } | ||
50 | |||
51 | while [ $datasize -le $maxdatasize ]; do | ||
52 | for i in `seq 1 $iteration`; do | ||
53 | ping -c 1 -s $datasize $ethernet_ping_ipaddr > $statistics | ||
54 | ping_err=$? | ||
55 | cat $statistics | grep "PING" > /dev/null 2>&1 | ||
56 | cat $statistics | grep "received" > /dev/null 2>&1 | ||
57 | [ `echo $?` -eq 0 ] || packets_received=0 && \ | ||
58 | packets_received=`cat $statistics | \ | ||
59 | grep "received" | awk '{print$4}'` | ||
60 | |||
61 | # Evaluate possible errors on the ping operation | ||
62 | if [ $ping_err -ne 0 ] || [ $packets_received -eq 0 ]; then | ||
63 | error=1 | ||
64 | echo -e `cat $statistics | grep PING` >> $logfile 2>/dev/null | ||
65 | fi | ||
66 | done | ||
67 | let datasize=$datasize+$stepsize | ||
68 | done | ||
69 | |||
70 | # Report failures | ||
71 | if [ $error -eq 1 ]; then | ||
72 | echo "=================== error report ===================" | ||
73 | cat $logfile | ||
74 | echo "====================================================" | ||
75 | clean_tasks | ||
76 | echo -e "FAIL: $ethernet_interface test failed\n" | ||
77 | exit 1 | ||
78 | else | ||
79 | clean_tasks | ||
80 | echo -e "PASS: $ethernet_interface test passed" | ||
81 | fi | ||
82 | |||
83 | exit 0 | ||
diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/flash b/recipes-test/ddt-runner/files/scripts/t1042rdb/flash new file mode 100755 index 0000000..dffac6b --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/flash | |||
@@ -0,0 +1,49 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # This script is used to test flash driver functionality. I removed the write | ||
4 | # operations since all partition are in use in p2041rdb and there might be | ||
5 | # possibility of corrupting data even if we backup in test script. | ||
6 | |||
7 | if part_num=`cat /proc/mtd | grep -c 'mtd'`; then | ||
8 | echo "PASS: show $part_num partitions" | ||
9 | else | ||
10 | echo "FAIL: show $part_num partitions" | ||
11 | exit 1 | ||
12 | fi | ||
13 | |||
14 | for((part=0; part<$part_num; part++)); | ||
15 | do | ||
16 | if [ $(mtd_debug info /dev/mtd$part | grep -c 'mtd.type') ]; then | ||
17 | echo "PASS: show partition $part debug info" | ||
18 | else | ||
19 | echo "FAIL: show partition $part debug info" | ||
20 | exit 1 | ||
21 | fi | ||
22 | done | ||
23 | |||
24 | READ_TEST=`find / -name mtd_readtest.ko -print` | ||
25 | |||
26 | if [ ! -e $READ_TEST ]; then | ||
27 | echo "FAIL: $READ_TEST does not exist" | ||
28 | exit 1 | ||
29 | else | ||
30 | echo "PASS: $READ_TEST exists" | ||
31 | fi | ||
32 | |||
33 | for((part=0; part<$part_num; part++)); | ||
34 | do | ||
35 | dmesg -c | ||
36 | |||
37 | insmod $READ_TEST dev=$part | ||
38 | |||
39 | finish=`dmesg | grep -c 'mtd_readtest: finished'` | ||
40 | if [ $finish -eq 1 ]; then | ||
41 | echo "PASS: read test $part" | ||
42 | else | ||
43 | echo "FAIL: read test $part" | ||
44 | rmmod $READ_TEST | ||
45 | exit 1 | ||
46 | fi | ||
47 | |||
48 | rmmod $READ_TEST | ||
49 | done | ||
diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/i2c b/recipes-test/ddt-runner/files/scripts/t1042rdb/i2c new file mode 100755 index 0000000..7766e43 --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/i2c | |||
@@ -0,0 +1,43 @@ | |||
1 | #!/bin/sh | ||
2 | # This script is used to test i2c bus functionality for p2041rdb board. | ||
3 | |||
4 | if I2C_ADAPTERS=$(i2cdetect -l |wc -l); then | ||
5 | echo "PASS: found $I2C_ADAPTERS i2c adapters" | ||
6 | else | ||
7 | echo "FAIL: no i2c adapters found" | ||
8 | exit 1 | ||
9 | fi | ||
10 | |||
11 | if [ -z "$adapters" ]; then | ||
12 | adapters=0 | ||
13 | fi | ||
14 | |||
15 | while [ $adapters -lt $I2C_ADAPTERS ] | ||
16 | do | ||
17 | i2cdetect -y $adapters | ||
18 | if [ $? -ne 0 ]; then | ||
19 | echo "FAIL: detect i2c adapter $adapters failed" | ||
20 | else | ||
21 | echo "PASS: detect i2c adapter $adapters success" | ||
22 | fi | ||
23 | adapters=`expr $adapters + 1` | ||
24 | sleep 1 | ||
25 | done | ||
26 | |||
27 | i2cdetect -y 0 | ||
28 | if [ $? -ne 0 ]; then | ||
29 | echo "FAIL: detect i2c bus 0 fail" | ||
30 | exit 1 | ||
31 | else | ||
32 | echo "PASS: detect i2c bus 0 success" | ||
33 | fi | ||
34 | |||
35 | #i2c bus 0, device address 0x52, DDR3 DIMM Socket 1, SPD EEPROM | ||
36 | i2cdump -f -y 0 0x51 | grep "EDPAR22QA01" | ||
37 | if [ $? -ne 0 ]; then | ||
38 | echo "FAIL: read SPD EEPROM on i2c bus 0 fail" | ||
39 | exit 1 | ||
40 | else | ||
41 | echo "PASS: read SPD EEPROM on i2c bus 0 success" | ||
42 | fi | ||
43 | |||
diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/pci-express b/recipes-test/ddt-runner/files/scripts/t1042rdb/pci-express new file mode 100755 index 0000000..c3f720d --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/pci-express | |||
@@ -0,0 +1,109 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | ethernet_interface="eth3" | ||
4 | #sestord02 ip address | ||
5 | ethernet_ping_ipaddr="172.21.3.22" | ||
6 | ethernet_ipaddr=$1 | ||
7 | |||
8 | #Intel Corporation 82574L Gigabit Network Card (intel e1000e) | ||
9 | vendor_id="8086" | ||
10 | product_id="10d3" | ||
11 | |||
12 | #find vendor id & product id | ||
13 | lspci -nn | grep $vendor_id:$product_id | ||
14 | if [ $? -ne 0 ]; then | ||
15 | echo "SKIP: no pci-e ethernet card device found" | ||
16 | exit 1 | ||
17 | else | ||
18 | echo "PASS: got pci-e ethernet card device" | ||
19 | fi | ||
20 | |||
21 | setpci -v -d $vendor_id:$product_id latency_timer=b0 | ||
22 | if [ $? -ne 0 ]; then | ||
23 | echo "FAIL: parameter changes to pci config space failed" | ||
24 | exit 1 | ||
25 | else | ||
26 | echo "PASS: parameter changes to pci config space success" | ||
27 | fi | ||
28 | |||
29 | IFCONFIG=`which ifconfig` | ||
30 | |||
31 | $IFCONFIG $ethernet_interface up | ||
32 | $IFCONFIG | grep $ethernet_interface | ||
33 | if [ $? -ne 0 ]; then | ||
34 | echo "FAIL: pci-e ethernet card device $ethernet_interface is not up" | ||
35 | exit 1 | ||
36 | else | ||
37 | echo "PASS: pci-e ethernet card device $ethernet_interface is up" | ||
38 | fi | ||
39 | |||
40 | if [ "x$ethernet_ipaddr" != "x" ]; then | ||
41 | $IFCONFIG $ethernet_interface $ethernet_ipaddr | ||
42 | fi | ||
43 | |||
44 | $IFCONFIG $ethernet_interface | grep 'inet addr:' |sed -e 's@inet addr:@@' |sed q | awk '{print $1}' | ||
45 | if [ $? -ne 0 ]; then | ||
46 | echo "FAIL: ipaddr of pci-e ethernet card device $ethernet_interface setup failed" | ||
47 | exit 1 | ||
48 | else | ||
49 | echo "PASS: ipaddr of pci-e ethernet card device $ethernet_interface setup success" | ||
50 | fi | ||
51 | |||
52 | mindatasize=56 | ||
53 | maxdatasize=650 | ||
54 | stepsize=100 | ||
55 | iteration=1 | ||
56 | datasize=$mindatasize | ||
57 | logfile=`/bin/mktemp` | ||
58 | statistics=`/bin/mktemp` | ||
59 | error=0 | ||
60 | |||
61 | trap cleanup SIGHUP SIGINT SIGTERM | ||
62 | |||
63 | clean_tasks() { | ||
64 | echo "Executing clean up tasks" | ||
65 | rm -f $logfile $statistics | ||
66 | } | ||
67 | |||
68 | cleanup() { | ||
69 | echo "Aborting script execution" | ||
70 | clean_tasks | ||
71 | exit 0 | ||
72 | } | ||
73 | |||
74 | echo "start ping test for pci-e ethernet card device $ethernet_interface..." | ||
75 | |||
76 | while [ $datasize -le $maxdatasize ]; do | ||
77 | for i in `seq 1 $iteration`; do | ||
78 | ping -c 1 -s $datasize $ethernet_ping_ipaddr > $statistics | ||
79 | ping_err=`echo $?` | ||
80 | echo "" && cat $statistics | grep "PING" | ||
81 | cat $statistics | grep "received" | ||
82 | [ `echo $?` -eq 0 ] || packets_received=0 && \ | ||
83 | packets_received=`cat $statistics | \ | ||
84 | grep "received" | awk '{print$4}'` | ||
85 | |||
86 | # Evaluate possible errors on the ping operation | ||
87 | if [ $ping_err -ne 0 ] || [ $packets_received -eq 0 ]; then | ||
88 | error=1 | ||
89 | echo -e `cat $statistics | grep PING` >> $logfile | ||
90 | echo -e "Size: $datasize Iteration: $i\n" >> $logfile | ||
91 | fi | ||
92 | done | ||
93 | let datasize=$datasize+$stepsize | ||
94 | done | ||
95 | |||
96 | # Report failures | ||
97 | if [ $error -eq 1 ]; then | ||
98 | echo -e "=================== error report ===================\n" | ||
99 | cat $logfile | ||
100 | echo -e "====================================================\n" | ||
101 | clean_tasks | ||
102 | echo -e "FAIL: ping test for pci-e ethernet card device $ethernet_interface failed\n" | ||
103 | exit 1 | ||
104 | else | ||
105 | clean_tasks | ||
106 | echo -e "PASS: ping test for pci-e ethernet card device $ethernet_interface success\n" | ||
107 | fi | ||
108 | |||
109 | exit 0 | ||
diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/sata b/recipes-test/ddt-runner/files/scripts/t1042rdb/sata new file mode 100755 index 0000000..62766b0 --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/sata | |||
@@ -0,0 +1,86 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # | ||
4 | #This script is to test sata devices on target | ||
5 | # | ||
6 | |||
7 | result=0 | ||
8 | devpath="" | ||
9 | satainfo="" | ||
10 | |||
11 | SD=`ls -l /dev/sd[^0-9] 2> /dev/null | awk '{print $5 $6 "," $10}'` | ||
12 | if [ -z "$SD" ]; then | ||
13 | echo "SKIP: no sata device found" | ||
14 | exit 1 | ||
15 | else | ||
16 | echo "PASS: find sata device" | ||
17 | fi | ||
18 | |||
19 | HDPARM=`which hdparm` | ||
20 | if [ -z $HDPARM ]; then | ||
21 | result=$? | ||
22 | echo "FAIL: find hdparm" | ||
23 | exit 1 | ||
24 | else | ||
25 | echo "PASS: find hdparm" | ||
26 | fi | ||
27 | |||
28 | for s in $SD | ||
29 | do | ||
30 | devpath=`echo "$s" | awk -F "," '{print "/sys/dev/block/" $1 ":" $2}'` | ||
31 | satainfo=`ls -l $devpath | grep sata` | ||
32 | |||
33 | if [ -z "$satainfo" ] ; then | ||
34 | continue | ||
35 | fi | ||
36 | s=`echo "$s" | awk -F "," '{print $3}'` | ||
37 | |||
38 | echo "testing $s" | ||
39 | $HDPARM -I $s | ||
40 | if [ $? -ne 0 ]; then | ||
41 | result=$? | ||
42 | echo "FAIL: $HDPARM -I $s Detailed/current information directly from $s" | ||
43 | else | ||
44 | echo "PASS: $HDPARM -I $s Detailed/current information directly from $s" | ||
45 | fi | ||
46 | $HDPARM -tT $s | ||
47 | if [ $? -ne 0 ]; then | ||
48 | result=$? | ||
49 | echo "FAIL: $HDPARM -tT $s Perform device/cache read timings on $s" | ||
50 | else | ||
51 | echo "PASS: $HDPARM -tT $s Perform device/cache read timings on $s" | ||
52 | fi | ||
53 | |||
54 | |||
55 | mkdir -p /mnt/sata_tmp | ||
56 | for partition in `ls "$s"[1-9]` | ||
57 | do | ||
58 | mount "$partition" /mnt/sata_tmp | ||
59 | if [ $? -ne 0 ]; then | ||
60 | result=$? | ||
61 | echo "FAIL: Mount $s" | ||
62 | else | ||
63 | echo "PASS: Mount $s" | ||
64 | dd if=/dev/urandom of=/mnt/sata_tmp/writefile bs=1M count=50 | ||
65 | if [ $? -ne 0 ]; then | ||
66 | result=$? | ||
67 | echo "FAIL: write test on $s" | ||
68 | else | ||
69 | echo "PASS: write test on $s" | ||
70 | rm -f /mnt/sata_tmp/writefile | ||
71 | fi | ||
72 | dd if=$s of=/mnt/sata_tmp/readfile bs=1M count=10 | ||
73 | if [ $? -ne 0 ]; then | ||
74 | result=$? | ||
75 | echo "FAIL: read test on $s" | ||
76 | else | ||
77 | echo "PASS: read test on $s" | ||
78 | rm -f /mnt/sata_tmp/readfile | ||
79 | fi | ||
80 | umount /mnt/sata_tmp | ||
81 | fi | ||
82 | done | ||
83 | |||
84 | rm -fr /mnt/sata_tmp | ||
85 | done | ||
86 | exit $result | ||
diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/sdhc b/recipes-test/ddt-runner/files/scripts/t1042rdb/sdhc new file mode 100755 index 0000000..883c572 --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/sdhc | |||
@@ -0,0 +1,42 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # the content of SD will be lost by running this test case. | ||
4 | |||
5 | SDHC_DEVICE="/dev/mmcblk0" | ||
6 | |||
7 | if [ -b "$SDHC_DEVICE" ]; then | ||
8 | echo "PASS: $SDHC_DEVICE device exists" | ||
9 | else | ||
10 | echo "SKIP: $SDHC_DEVICE does not exist" | ||
11 | exit 1 | ||
12 | fi | ||
13 | |||
14 | mount | grep mmcblk0p1 > /dev/null 2>&1 | ||
15 | |||
16 | if [ $? -eq 0 ]; then | ||
17 | umount $SDHC_DEVICE > /dev/null 2>&1 | ||
18 | fi | ||
19 | |||
20 | /sbin/mkfs.ext2 $SDHC_DEVICE > /dev/null 2>&1 | ||
21 | |||
22 | if [ $? -ne 0 ]; then | ||
23 | echo "FAIL: format $SDHC_DEVICE fail" | ||
24 | exit 1 | ||
25 | else | ||
26 | mkdir -p /mnt/sdhc > /dev/null 2>&1 | ||
27 | mount $SDHC_DEVICE /mnt/sdhc > /dev/null 2>&1 | ||
28 | if [ $? -ne 0 ]; then | ||
29 | echo "FAIL: mount $SDHC_DEVICE fail" | ||
30 | exit 1 | ||
31 | else | ||
32 | cp /bin/busybox /mnt/sdhc > /dev/null 2>&1 | ||
33 | ls /mnt/sdhc |grep busybox > /dev/null 2>&1 | ||
34 | if [ $? -ne 0 ]; then | ||
35 | echo "FAIL: read or write $SDHC_DEVICE fail" | ||
36 | exit 1 | ||
37 | else | ||
38 | umount $SDHC_DEVICE > /dev/null 2>&1 | ||
39 | echo "PASS: read or write $SDHC_DEVICE success" | ||
40 | fi | ||
41 | fi | ||
42 | fi | ||
diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/spi b/recipes-test/ddt-runner/files/scripts/t1042rdb/spi new file mode 100755 index 0000000..06475a7 --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/spi | |||
@@ -0,0 +1,35 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | SPIDEVS=`cat /proc/mtd | grep -e "^mtd" | grep -i spi | gawk -e '{print $1}' | sed 's/://'` | ||
4 | if [ -z "$SPIDEVS" ]; then | ||
5 | echo "SKIP: no spi device found" | ||
6 | exit 1 | ||
7 | fi | ||
8 | |||
9 | |||
10 | MTD_DEBUG=`which mtd_debug` | ||
11 | if [ -z "$MTD_DEBUG" ] ; then | ||
12 | echo "FAIL: mtd_debug utility not found on the system" | ||
13 | exit 1 | ||
14 | fi | ||
15 | |||
16 | ERRCODE=0 | ||
17 | |||
18 | for DV in $SPIDEVS ; do | ||
19 | FNAME=`cat /proc/mtd | grep $DV | gawk -F\" '{print $2}'` | ||
20 | FDEV=/dev/$DV | ||
21 | MTDSIZE=`$MTD_DEBUG info $FDEV | grep "mtd.size" | gawk -e '{print $3}'` | ||
22 | if [ $MTDSIZE -eq 0 ] ; then | ||
23 | echo "SKIP: $FNAME size is $MTDSIZE (skipped)" | ||
24 | else | ||
25 | $MTD_DEBUG read $FDEV 0 $MTDSIZE /dev/null > /dev/null 2>&1 | ||
26 | if [ $? -eq 0 ] ; then | ||
27 | echo "PASS: \"$FNAME\" read $MTDSIZE bytes" | ||
28 | else | ||
29 | echo "FAIL: \"$FNAME\" trying to read $MTDSIZE bytes" | ||
30 | ERRCODE=2 | ||
31 | fi | ||
32 | fi | ||
33 | done | ||
34 | |||
35 | exit $ERRCODE | ||
diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/usb b/recipes-test/ddt-runner/files/scripts/t1042rdb/usb new file mode 100755 index 0000000..017287f --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/usb | |||
@@ -0,0 +1,48 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | #This script is to test usb devices on p2041rdb target | ||
4 | # | ||
5 | |||
6 | USB_DISK=`ls /dev/sd*[1-9] | sort | tail -n 1` | ||
7 | |||
8 | usbutils_is_installed=`which lsusb` | ||
9 | if [ -z $usbutils_is_installed ]; then | ||
10 | echo "FAIL: Cannot find lsusb" | ||
11 | exit 1 | ||
12 | else | ||
13 | echo "PASS: usbutils found" | ||
14 | fi | ||
15 | |||
16 | usbdev_num=`lsusb | grep -v root\ hub | wc -l` | ||
17 | if [ $usbdev_num -eq 0 ]; then | ||
18 | echo "FAIL: USB device is not connected" | ||
19 | exit 1 | ||
20 | else | ||
21 | echo "PASS: $usbdev_num USB device(s) connected" | ||
22 | fi | ||
23 | |||
24 | lsusb | grep -v root\ hub | ||
25 | mkdir -p /mnt/usb_ehci | ||
26 | mount $USB_DISK /mnt/usb_ehci | ||
27 | if [ $? -ne 0 ]; then | ||
28 | echo "FAIL: Mount USB device failed" | ||
29 | exit 1 | ||
30 | else | ||
31 | echo "PASS: Mount USB device succeed" | ||
32 | fi | ||
33 | |||
34 | echo "Begin test usb device..." | ||
35 | dd if=/dev/urandom of=/mnt/usb_ehci/testfile bs=1M count=50 | ||
36 | if [ $? -ne 0 ]; then | ||
37 | echo "FAIL: test failed" | ||
38 | rm -f /mnt/usb_ehci_testfile | ||
39 | umount /mnt/usb_ehci | ||
40 | rm -fr /mnt/usb_ehci | ||
41 | exit 1 | ||
42 | fi | ||
43 | |||
44 | echo "PASS: test succeed" | ||
45 | rm -f /mnt/usb_ehci_testfile | ||
46 | umount /mnt/usb_ehci | ||
47 | rm -fr /mnt/usb_ehci | ||
48 | exit 0 | ||
diff --git a/recipes-test/ddt-runner/files/scripts/t1042rdb/watchdog b/recipes-test/ddt-runner/files/scripts/t1042rdb/watchdog new file mode 100755 index 0000000..2010e3c --- /dev/null +++ b/recipes-test/ddt-runner/files/scripts/t1042rdb/watchdog | |||
@@ -0,0 +1,93 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # This script is used to test watchdog functionality. | ||
4 | |||
5 | WAITTIME=10 | ||
6 | WDPID=0 | ||
7 | |||
8 | WATCHDOG=`which watchdog` | ||
9 | if [ "x$WATCHDOG" != "x" ]; then | ||
10 | echo "PASS: watchdog found" | ||
11 | else | ||
12 | echo "FAIL: watchdog not found" | ||
13 | exit 1 | ||
14 | fi | ||
15 | |||
16 | WATCHDOG_CONF=/etc/watchdog.conf | ||
17 | if [ -f $WATCHDOG_CONF ]; then | ||
18 | echo "PASS: watchdog config file found" | ||
19 | sed -i '23,23 s/#//' $WATCHDOG_CONF | ||
20 | else | ||
21 | echo "FAIL: watchdog config file not found" | ||
22 | exit 1 | ||
23 | fi | ||
24 | |||
25 | # kill any previous instance of watchdog (pkill may be used as well) | ||
26 | for wpid in `ps ax | grep $WATCHDOG | grep -v grep | awk -e '{print $1}'` ; do | ||
27 | kill -KILL $wpid | ||
28 | done | ||
29 | |||
30 | # wait until all processes are gone | ||
31 | for wt in `seq 1 $WAITTIME ` ; do | ||
32 | sleep 1 | ||
33 | wd_running=`ps ax | grep $WATCHDOG | grep -v grep | awk -e '{print $1}'` | ||
34 | |||
35 | if [ -z $wd_running ] ; then | ||
36 | break | ||
37 | fi | ||
38 | done | ||
39 | |||
40 | if [ $wt -ge $WAITTIME ] ; then | ||
41 | echo "FAIL: Failed to stop the watchdog daemon" | ||
42 | exit 1 | ||
43 | fi | ||
44 | |||
45 | # start a fresh watchdog | ||
46 | $WATCHDOG -v /dev/watchdog | ||
47 | |||
48 | # wait up to $WAITTIME seconds for the process to start | ||
49 | for wt in `seq 1 $WAITTIME ` ; do | ||
50 | sleep 1 | ||
51 | wd_running=`ps ax | grep $WATCHDOG | grep -v grep | awk -e '{print $1}'` | ||
52 | if [ ! -z $wd_running ] ; then | ||
53 | WDPID=$wd_running | ||
54 | echo "PASS: Watchdog daemon started successfully [$WDPID]" | ||
55 | break | ||
56 | fi | ||
57 | |||
58 | echo $wt | ||
59 | done | ||
60 | |||
61 | if [ $wt -ge $WAITTIME ] ; then | ||
62 | echo "FAIL: Failed to start watchdog daemon" | ||
63 | exit 1 | ||
64 | fi | ||
65 | |||
66 | logmsg_test() | ||
67 | { | ||
68 | WDCOUNTER1=`cat /var/log/messages | grep watchdog | grep $WDPID | wc -l` | ||
69 | sleep 5 | ||
70 | WDCOUNTER2=`cat /var/log/messages | grep watchdog | grep $WDPID | wc -l` | ||
71 | |||
72 | if [ $WDCOUNTER2 -gt $WDCOUNTER1 ] ; then | ||
73 | return 0 | ||
74 | fi | ||
75 | |||
76 | return 1 | ||
77 | } | ||
78 | |||
79 | exit_code=1 | ||
80 | |||
81 | # test is performed 2 times because logrotate may step in during those 5sec | ||
82 | if logmsg_test || logmsg_test ; then | ||
83 | echo "PASS: Watchdog is alive" | ||
84 | kill -KILL $WDPID > /dev/null 2>&1 | ||
85 | exit_code=0 | ||
86 | else | ||
87 | echo "FAIL: Watchdog is not working" | ||
88 | kill -KILL $WDPID > /dev/null 2>&1 | ||
89 | exit_code=1 | ||
90 | fi | ||
91 | |||
92 | kill -KILL $WDPID > /dev/null 2>&1 | ||
93 | exit $exit_code | ||