Return-Path: From: Wang Mingyu Date: Wed, 1 Aug 2018 18:31:34 -0700 Message-ID: <1533173494-54832-1-git-send-email-wangmy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Fuego] [PATCH v2] busybox: add support for command openvt/passwd/pidof/ping/ps/pwd List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fuego@lists.linuxfoundation.org Signed-off-by: Wang Mingyu --- engine/tests/Functional.busybox/fuego_test.sh | 5 ++-- .../Functional.busybox/tests/busybox_openvt.sh | 25 ++++++++++++++++ .../Functional.busybox/tests/busybox_passwd.sh | 34 ++++++++++++++++++++++ .../Functional.busybox/tests/busybox_pidof.sh | 21 +++++++++++++ .../tests/Functional.busybox/tests/busybox_ping.sh | 16 ++++++++++ .../tests/Functional.busybox/tests/busybox_ps.sh | 13 +++++++++ .../tests/Functional.busybox/tests/busybox_pwd.sh | 13 +++++++++ 7 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 engine/tests/Functional.busybox/tests/busybox_openvt.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_passwd.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_pidof.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_ping.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_ps.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_pwd.sh diff --git a/engine/tests/Functional.busybox/fuego_test.sh b/engine/tests/Functional.busybox/fuego_test.sh index 2d2e8f6..4ee593c 100755 --- a/engine/tests/Functional.busybox/fuego_test.sh +++ b/engine/tests/Functional.busybox/fuego_test.sh @@ -39,9 +39,9 @@ function test_pre_check { assert_define PROGRAM_BUSYBOX "Missing 'busybox' program on target board" echo "Tests skipped depending on the availability of a command on the target" touch ${LOGDIR}/skiplist.txt - skip_if_command_unavailable expect "busybox_ash.sh" + skip_if_command_unavailable expect "busybox_ash.sh busybox_passwd.sh" skip_if_command_unavailable tr "busybox_chgrp1.sh busybox_chgrp2.sh busybox_chmod1.sh busybox_chmod2.sh busybox_chown1.sh busybox_chown2.sh" - skip_if_not_root "busybox_chgrp1.sh busybox_chgrp2.sh busybox_chown1.sh busybox_chown2.sh busybox_chroot.sh" + skip_if_not_root "busybox_chgrp1.sh busybox_chgrp2.sh busybox_chown1.sh busybox_chown2.sh busybox_chroot.sh busybox_passwd.sh" } function test_deploy { @@ -54,6 +54,7 @@ function test_run { report "cd $BOARD_TESTDIR/fuego.$TESTDIR; \ export test_tcpip_host=$SRV_IP; \ export test_port_host=${SRV_PORT:=8080}; \ + export test_ipaddr=$IPADDR;\ sh -v busybox_test.sh" } diff --git a/engine/tests/Functional.busybox/tests/busybox_openvt.sh b/engine/tests/Functional.busybox/tests/busybox_openvt.sh new file mode 100644 index 0000000..fb7a9f3 --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_openvt.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# The testscript checks the following options of the command openvt +# 1) Option none + +test="openvt" + +killall sleep +busybox openvt -f -c 2 sleep 15732 +if ps aux | grep "[s]leep 15732" +then + echo " -> $test: ps aux | grep "[s]leep 15732" executed." +else + echo " -> $test: ps aux | grep "[s]leep 15732" failed." + echo " -> $test: TEST-FAIL" + exit +fi; + +kill $(pgrep -f "[s]leep 15732") +if ps aux | grep "[s]leep 15732" +then + echo " -> $test: TEST-FAIL" +else + echo " -> $test: TEST-PASS" +fi; diff --git a/engine/tests/Functional.busybox/tests/busybox_passwd.sh b/engine/tests/Functional.busybox/tests/busybox_passwd.sh new file mode 100644 index 0000000..e383f56 --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_passwd.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# The testscript checks the following options of the command passwd +# 1) Option none + +test="passwd" + +if [ -e /etc/shadow ] +then + cp /etc/shadow /etc/shadow.backup +fi + +userdel -r test_busybox_passwd +ls / +useradd test_busybox_passwd + +expect <<-EOF +spawn busybox.suid passwd test_busybox_passwd +expect "New password:" +send_user " -> $test: busybox.suid passwd test_busybox_passwd executed.\n" +send "test123\r" +expect "Retype password:" +send_user " -> $test: retype passwd executed.\n" +send "test123\r" +expect "Password for test_busybox_passwd changed by root" +send_user " -> $test: TEST-PASS\n" +expect eof +EOF + +userdel -r test_busybox_passwd +if [ -e /etc/shadow.backup ] +then + mv -f /etc/shadow.backup /etc/shadow +fi diff --git a/engine/tests/Functional.busybox/tests/busybox_pidof.sh b/engine/tests/Functional.busybox/tests/busybox_pidof.sh new file mode 100644 index 0000000..38384b7 --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_pidof.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# The testscript checks the following options of the command pidof +# 1) Option none + +test="pidof" + +if busybox pidof $(ps -q 1 -o comm=) | grep 1 +then + echo " -> $test: get pid from process name succedded." +else + echo " -> $test: get pid from process name failed." + echo " -> $test: TEST-FAIL" +fi; + +if busybox pidof test_for_pidof +then + echo " -> $test: TEST-FAIL" +else + echo " -> $test: TEST-PASS" +fi; diff --git a/engine/tests/Functional.busybox/tests/busybox_ping.sh b/engine/tests/Functional.busybox/tests/busybox_ping.sh new file mode 100644 index 0000000..1e746d2 --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_ping.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# The testscript checks the following options of the command ping +# 1) Option none + +test="ping" + +busybox.suid ping -c 2 $test_ipaddr > log + +if head -n 1 log | grep "PING" && head -n 2 log | tail -n 1 | grep "seq=0." && head -n 3 log | tail -n 1 | grep "seq=1." +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; +rm log; diff --git a/engine/tests/Functional.busybox/tests/busybox_ps.sh b/engine/tests/Functional.busybox/tests/busybox_ps.sh new file mode 100644 index 0000000..9f31fc8 --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_ps.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# The testscript checks the following options of the command ps +# 1) Option none + +test="ps" + +if busybox ps | grep "[b]usybox ps" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; diff --git a/engine/tests/Functional.busybox/tests/busybox_pwd.sh b/engine/tests/Functional.busybox/tests/busybox_pwd.sh new file mode 100644 index 0000000..a0034df --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_pwd.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# The testscript checks the following options of the command pwd +# 1) Option none + +test="pwd" + +if busybox pwd +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; -- 1.8.3.1