[Fuego] [PATCH] busybox: add support for command openvt/passwd/pidof/ping/ps/pwd

Wang Mingyu wangmy at cn.fujitsu.com
Mon Jul 30 05:49:51 UTC 2018


Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 .../Functional.busybox/tests/busybox_openvt.sh     | 25 +++++++++++++++
 .../Functional.busybox/tests/busybox_passwd.sh     | 37 ++++++++++++++++++++++
 .../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, 125 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..478feb8
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_passwd.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command passwd
+#  1) Option none
+
+#  /etc/shadowが0バイトの際のbusybox passwdがSegmentation faultで
+#  失敗しないことを確認する。
+
+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





More information about the Fuego mailing list