Return-Path: From: Wang Mingyu Date: Sun, 29 Jul 2018 23:59:55 -0700 Message-ID: <1532933995-125763-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 --- .../Functional.busybox/tests/busybox_openvt.sh | 25 ++++++++++++++++ .../Functional.busybox/tests/busybox_passwd.sh | 34 ++++++++++++++++++++++ .../Functional.busybox/tests/busybox_pidof.sh | 15 ++++++++++ .../tests/Functional.busybox/tests/busybox_ping.sh | 22 ++++++++++++++ .../tests/Functional.busybox/tests/busybox_ps.sh | 13 +++++++++ .../tests/Functional.busybox/tests/busybox_pwd.sh | 13 +++++++++ 6 files changed, 122 insertions(+) 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/tests/busybox_openvt.sh b/engine/tests/Functional.busybox/tests/busybox_openvt.sh new file mode 100644 index 0000000..c596569 --- /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 15000 +if ps aux | grep sleep | grep -v grep | grep ".*sleep 15000" +then + echo " -> $test: ps aux | grep sleep | grep -v grep executed." +else + echo " -> $test: ps aux | grep sleep | grep -v grep failed." + echo " -> $test: TEST-FAIL" + exit +fi; + +killall sleep +if ps aux | grep sleep | grep -v grep | grep ".*sleep.*" +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..838864c --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_pidof.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# The testscript checks the following options of the command pidof +# 1) Option none + +test="pidof" + +busybox pidof `ps -e | awk '{if($1 == 1) print $4}'` + +if busybox pidof xyz || echo fail +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +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..289f265 --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_ping.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# The testscript checks the following options of the command ping +# 1) Option none + +test="ping" + +busybox.suid ping -c 2 $IPADDR > log +log1=$(head -n 1 log) +log2=$(head -n 2 log | head -n 1) +log3=$(tail -n 1 log) +pair1="PING" +pair2="seq=0." +pair3="seq=0." + +if [[ $log1 = *$pari1* ]] && [[ $log2 = *$pari2* ]] && [[ $log3 = *$pari3* ]] +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..1dfe4e4 --- /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 -v grep | grep "busybox 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