[Fuego] [PATCH] busybox: add support for command tail/tar/tee/test/time/touch/tr/true/tty

Tim Bird tbird20d at gmail.com
Thu Aug 30 19:19:14 UTC 2018


On Thu, Aug 2, 2018 at 6:27 PM Wang Mingyu <wangmy at cn.fujitsu.com> wrote:
>
> Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
> ---
>  .../tests/Functional.busybox/tests/busybox_tail.sh | 21 +++++++++++++
>  .../tests/Functional.busybox/tests/busybox_tar.sh  | 36 ++++++++++++++++++++++
>  .../tests/Functional.busybox/tests/busybox_tee.sh  | 26 ++++++++++++++++
>  .../tests/Functional.busybox/tests/busybox_test.sh | 22 +++++++++++++
>  .../tests/Functional.busybox/tests/busybox_time.sh | 16 ++++++++++
>  .../Functional.busybox/tests/busybox_touch.sh      | 17 ++++++++++
>  .../tests/Functional.busybox/tests/busybox_tr.sh   | 13 ++++++++
>  .../tests/Functional.busybox/tests/busybox_true.sh | 13 ++++++++
>  .../tests/Functional.busybox/tests/busybox_tty.sh  | 13 ++++++++
>  9 files changed, 177 insertions(+)
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_tail.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_tar.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_tee.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_test.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_time.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_touch.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_tr.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_true.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_tty.sh
>
> diff --git a/engine/tests/Functional.busybox/tests/busybox_tail.sh b/engine/tests/Functional.busybox/tests/busybox_tail.sh
> new file mode 100644
> index 0000000..2d40d6f
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_tail.sh
> @@ -0,0 +1,21 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command tail
> +#  1) Option: -n
> +
> +test="tail"
> +
> +mkdir test_dir
> +touch test_dir/test1
> +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 tail -n 2 test_dir/test1 > log
> +if [ "$(head -n 1 log)" = "This is the 2nd line." ] && [ "$(tail -n 1 log)" = "This is the 3rd line." ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +rm -rf test_dir;
> +rm log;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_tar.sh b/engine/tests/Functional.busybox/tests/busybox_tar.sh
> new file mode 100644
> index 0000000..e747241
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_tar.sh
> @@ -0,0 +1,36 @@
> +#!/bin/bh
> +
> +#  The testscript checks the following options of the command tar
> +#  1) Option: -cvf -xvf
> +
> +tar_tst_dir=test/test_dir
> +test="tar"
> +
> +if [ -f $tar_tst_dir ]
> +then
> +    rm -rf $tar_tst_dir
> +fi;
> +
> +mkdir -p $tar_tst_dir
> +mkdir -p $tar_tst_dir/test_dir1
> +echo This is a test file to test tar.> $tar_tst_dir/test_dir1/test_tar
> +busybox tar -cvf $tar_tst_dir/test.tar $tar_tst_dir/test_dir1
> +if [ "$(ls -l $tar_tst_dir | grep ".*test.tar.*")" ]
> +then
> +    echo " -> $test: tar -cvf executed."
> +else
> +    echo " -> $test: tar -cvf failed."
> +    echo " -> $test: TEST-FAIL"
> +    rm -rf $tar_tst_dir
> +    exit
> +fi;
> +
> +rm -rf $tar_tst_dir/test_dir1
> +busybox tar -xvf $tar_tst_dir/test.tar -C .
> +if [ "$(ls -l $tar_tst_dir/test_dir1/test_tar | grep ".*\/test_dir1\/test_tar.*")" ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +rm -rf $tar_tst_dir;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_tee.sh b/engine/tests/Functional.busybox/tests/busybox_tee.sh
> new file mode 100644
> index 0000000..0e55c7c
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_tee.sh
> @@ -0,0 +1,26 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command tee
> +#  1) Option: none
> +
> +test="tee"
> +
> +rm -rf ./test_dir
> +mkdir ./test_dir
> +if [ "$(echo "Hello World" | busybox tee ./test_dir/test1)" = "Hello World" ]
> +then
> +    echo " -> $test: echo "Hello World" | busybox tee ./test_dir/test1 executed."
> +else
> +    echo " -> $test: echo "Hello World" | busybox tee ./test_dir/test1 failed."
> +    echo " -> $test: TEST-FAIL"
> +    rm -fr ./test_dir
> +    exit
> +fi;
> +
> +if [ "$(cat ./test_dir/test1)" = "Hello World" ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +rm -fr ./test_dir
> diff --git a/engine/tests/Functional.busybox/tests/busybox_test.sh b/engine/tests/Functional.busybox/tests/busybox_test.sh
> new file mode 100644
> index 0000000..9d3e873
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_test.sh
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command test
> +#  1) Option: none
> +
> +test="test"
> +
> +if ! busybox test 1 -eq 2
This line had a trailing space in it.
Please check your lines for whitespace at the end (do something like
'grep " $" *' and
fix any issues, before committing.

> +then
> +    echo " -> $test: busybox test 1 -eq 2 verification succeeded."
> +else
> +    echo " -> $test: busybox test 1 -eq 2 verification failed."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi;
> +
> +if busybox test 1 -eq 1
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_time.sh b/engine/tests/Functional.busybox/tests/busybox_time.sh
> new file mode 100644
> index 0000000..a398cb9
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_time.sh
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command tar
> +#  1) Option: none
> +
> +test="time"
> +
> +busybox time pwd > log 2>&1
> +if [ "$(head -n 1 log | grep ".*")" ] && [ "$(head -n 2 log | tail -n 1 | grep "real.*m.*s")" ] \
> +&& [ "$(tail -n 2 log | head -n 1 | grep "user.*m.*s")" ] && [ "$(tail -n 1 log | grep "sys.*m.*s")" ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +rm log;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_touch.sh b/engine/tests/Functional.busybox/tests/busybox_touch.sh
> new file mode 100644
> index 0000000..9259201
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_touch.sh
> @@ -0,0 +1,17 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command touch
> +#  1) Option: none
> +
> +test="touch"
> +
> +rm -fr test_dir
> +mkdir test_dir
> +busybox touch ./test_dir/test1
> +if [ "$(ls ./test_dir)" = "test1" ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +rm -fr test_dir
> diff --git a/engine/tests/Functional.busybox/tests/busybox_tr.sh b/engine/tests/Functional.busybox/tests/busybox_tr.sh
> new file mode 100644
> index 0000000..ccef6de
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_tr.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command tr
> +#  1) Option: none
> +
> +test="tr"
> +
> +if [ "$(echo "gdkkn vnqkc" | busybox tr [a-y] [b-z])" = "hello world" ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_true.sh b/engine/tests/Functional.busybox/tests/busybox_true.sh
> new file mode 100644
> index 0000000..ccafd65
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_true.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command true
> +#  1) Option: none
> +
> +test="true"
> +
> +if busybox true
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_tty.sh b/engine/tests/Functional.busybox/tests/busybox_tty.sh
> new file mode 100644
> index 0000000..8b15535
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_tty.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command tty
> +#  1) Option: none
> +
> +test="tty"
> +
> +if busybox tty
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;

This last one doesn't test any actual functionality.  But it's a placeholder
where additional testing can be added in the future, and validates the command
is present, I guess.

> --
> 1.8.3.1

Patch applied.

Thanks,
 -- Tim


More information about the Fuego mailing list