diff options
Diffstat (limited to 'scripts/qemuimage-tests/sanity/shutdown')
-rwxr-xr-x | scripts/qemuimage-tests/sanity/shutdown | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/scripts/qemuimage-tests/sanity/shutdown b/scripts/qemuimage-tests/sanity/shutdown new file mode 100755 index 0000000000..e36b4a983d --- /dev/null +++ b/scripts/qemuimage-tests/sanity/shutdown | |||
@@ -0,0 +1,70 @@ | |||
1 | #!/bin/bash | ||
2 | # Shutdown Test Case for Sanity Test | ||
3 | # The case boot up the Qemu target with `poky-qemu qemuxxx`. | ||
4 | # Then check if target can shutdown | ||
5 | # For qemux86/x86-64, we use command "poweroff" for target shutdown | ||
6 | # For non-x86 targets, we use command "reboot" for target shutdown | ||
7 | # | ||
8 | # Author: Jiajun Xu <jiajun.xu@intel.com> | ||
9 | # | ||
10 | # This file is licensed under the GNU General Public License, | ||
11 | # Version 2. | ||
12 | # | ||
13 | |||
14 | . $POKYBASE/scripts/qemuimage-testlib | ||
15 | |||
16 | TIMEOUT=360 | ||
17 | RET=1 | ||
18 | i=0 | ||
19 | |||
20 | # Start qemu and check its network | ||
21 | Test_Create_Qemu ${TIMEOUT} | ||
22 | |||
23 | # If qemu network is up, check ssh service in qemu | ||
24 | if [ $? -eq 0 ]; then | ||
25 | Test_Info "Begin to Test SSH Service in Qemu" | ||
26 | Test_SSH_UP ${TARGET_IPADDR} ${TIMEOUT} | ||
27 | RET=$? | ||
28 | else | ||
29 | RET=1 | ||
30 | fi | ||
31 | |||
32 | # Check if target can shutdown | ||
33 | if [ $RET -eq 0 ]; then | ||
34 | echo $QEMUARCH | grep -q "qemux86" | ||
35 | |||
36 | # For qemux86/x86-64, command "poweroff" is used | ||
37 | # For non x86 qemu targets, command "reboot" is used because of BUG #100 | ||
38 | if [ $? -eq 0 ]; then | ||
39 | Test_SSH ${TARGET_IPADDR} "/sbin/poweroff" | ||
40 | else | ||
41 | Test_SSH ${TARGET_IPADDR} "/sbin/reboot" | ||
42 | fi | ||
43 | |||
44 | # If qemu start up process ends up, it means shutdown completes | ||
45 | while [ $i -lt $TIMEOUT ] | ||
46 | do | ||
47 | ps -fp $PID > /dev/null | ||
48 | if [ $? -ne 0 ]; then | ||
49 | RET=0 | ||
50 | break | ||
51 | fi | ||
52 | i=$((i+5)) | ||
53 | sleep 5 | ||
54 | done | ||
55 | |||
56 | if [ $i -ge $TIMEOUT ]; then | ||
57 | RET=1 | ||
58 | fi | ||
59 | fi | ||
60 | |||
61 | if [ ${RET} -eq 0 ]; then | ||
62 | Test_Info "Shutdown Test PASS" | ||
63 | Test_Print_Result "shutdown" 0 | ||
64 | exit 0 | ||
65 | else | ||
66 | Test_Info "Shutdown Test FAIL" | ||
67 | Test_Kill_Qemu | ||
68 | Test_Print_Result "shutdown" 1 | ||
69 | exit 1 | ||
70 | fi | ||