Return-Path: From: Wang Mingyu Date: Tue, 24 Jul 2018 04:33:21 -0700 Message-ID: <1532432002-4341-1-git-send-email-wangmy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Fuego] [PATCH] busybox: add support for command head/hexdump/hostname/id/ifconfig/install 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 --- .../tests/Functional.busybox/tests/busybox_head.sh | 21 +++++++++++++++++++++ .../Functional.busybox/tests/busybox_hexdump.sh | 19 +++++++++++++++++++ .../Functional.busybox/tests/busybox_hostname.sh | 13 +++++++++++++ engine/tests/Functional.busybox/tests/busybox_id.sh | 13 +++++++++++++ .../Functional.busybox/tests/busybox_ifconfig.sh | 13 +++++++++++++ .../Functional.busybox/tests/busybox_install.sh | 17 +++++++++++++++++ 6 files changed, 96 insertions(+) create mode 100644 engine/tests/Functional.busybox/tests/busybox_head.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_hexdump.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_hostname.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_id.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_ifconfig.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_install.sh diff --git a/engine/tests/Functional.busybox/tests/busybox_head.sh b/engine/tests/Functional.busybox/tests/busybox_head.sh new file mode 100644 index 0000000..8bd7c9d --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_head.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# The testscript checks the following options of the command head +# 1) Option -n + +test="head" + +mkdir test_dir +echo "This is the 1st line." > test_dir/test1 +echo "This is the 2nd line." >> test_dir/test1 +echo "This is the 3rd line." >> test_dir/test1 +busybox head -n 2 test_dir/test1 > log + +if [ "$(busybox head -n 1 log)" = "This is the 1st line." ] && [ "$(tail -n 1 log)" = "This is the 2nd line." ] +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; +rm log +rm -rf test_dir diff --git a/engine/tests/Functional.busybox/tests/busybox_hexdump.sh b/engine/tests/Functional.busybox/tests/busybox_hexdump.sh new file mode 100644 index 0000000..524262a --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_hexdump.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# The testscript checks the following options of the command hexdump +# 1) Option: -c + +test="hexdump" + +mkdir test_dir +touch test_dir/test1 +echo "HELLO WORLD" > test_dir/test1 +busybox hexdump -c test_dir/test1 > log +if head -n 1 log | grep "0000000 H E L L O W O R L D \\\n" && [ "$(tail -n 1 log)" = "000000c" ] +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; +rm log +rm -rf test_dir diff --git a/engine/tests/Functional.busybox/tests/busybox_hostname.sh b/engine/tests/Functional.busybox/tests/busybox_hostname.sh new file mode 100644 index 0000000..fce0b04 --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_hostname.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# The testscript checks the following options of the command hostname +# 1) Option none + +test="hostname" + +if [ $(busybox hostname) = $(cat /etc/hostname) ] +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; diff --git a/engine/tests/Functional.busybox/tests/busybox_id.sh b/engine/tests/Functional.busybox/tests/busybox_id.sh new file mode 100644 index 0000000..14ef385 --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_id.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# The testscript checks the following options of the command id +# 1) Option none + +test="id" + +if grep "^$(whoami)" /etc/passwd | grep "$(id -u):$(id -g)" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; diff --git a/engine/tests/Functional.busybox/tests/busybox_ifconfig.sh b/engine/tests/Functional.busybox/tests/busybox_ifconfig.sh new file mode 100644 index 0000000..31b07d2 --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_ifconfig.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# The testscript checks the following options of the command ifconfig +# 1) Option none + +test="ifconfig" + +if busybox ifconfig +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; diff --git a/engine/tests/Functional.busybox/tests/busybox_install.sh b/engine/tests/Functional.busybox/tests/busybox_install.sh new file mode 100644 index 0000000..6b1f83e --- /dev/null +++ b/engine/tests/Functional.busybox/tests/busybox_install.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# The testscript checks the following options of the command install +# 1) Option none + +test="install" + +mkdir test_dir test_install_dir +echo "test install" > test_dir/test1 +busybox install test_dir/test1 test_install_dir +if [ "$(ls test_install_dir)" = "test1" ] && [ "$(cat test_install_dir/test1)" = "test install" ] +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; +rm -rf test_dir test_install_dir; -- 1.8.3.1