[Fuego] [PATCH] Add new test cases of date, dd, deallocvt, df, dirname, dmesg and du to busybox.
Tim.Bird at sony.com
Tim.Bird at sony.com
Wed Jun 6 00:09:57 UTC 2018
See comments inline below.
> -----Original Message-----
> From: Wang Mingyu
> Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
> ---
> .../tests/Functional.busybox/tests/busybox_date.sh | 14 ++++++++++
> .../tests/Functional.busybox/tests/busybox_dd.sh | 31
> ++++++++++++++++++++++
> .../Functional.busybox/tests/busybox_deallocvt.sh | 14 ++++++++++
> .../tests/Functional.busybox/tests/busybox_df.sh | 14 ++++++++++
> .../Functional.busybox/tests/busybox_dirname.sh | 16 +++++++++++
> .../Functional.busybox/tests/busybox_dmesg.sh | 13 +++++++++
> .../tests/Functional.busybox/tests/busybox_du.sh | 17 ++++++++++++
> 7 files changed, 119 insertions(+)
> create mode 100644
> engine/tests/Functional.busybox/tests/busybox_date.sh
> create mode 100644 engine/tests/Functional.busybox/tests/busybox_dd.sh
> create mode 100644
> engine/tests/Functional.busybox/tests/busybox_deallocvt.sh
> create mode 100644 engine/tests/Functional.busybox/tests/busybox_df.sh
> create mode 100644
> engine/tests/Functional.busybox/tests/busybox_dirname.sh
> create mode 100644
> engine/tests/Functional.busybox/tests/busybox_dmesg.sh
> create mode 100644 engine/tests/Functional.busybox/tests/busybox_du.sh
>
> diff --git a/engine/tests/Functional.busybox/tests/busybox_date.sh
> b/engine/tests/Functional.busybox/tests/busybox_date.sh
> new file mode 100644
> index 0000000..7d15131
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_date.sh
> @@ -0,0 +1,14 @@
> +#!/bin/sh
> +
> +# The testscript checks the following options of the command date
> +# 1) Option none
> +
> +test="date"
> +
> +busybox date
This doesn't test very much. I know it would be difficult to parse
the date output for the current time and date, without having to
continually update the test, but maybe you could test *some*
date functionality:
TZ="UTC" busybox date -d "@1" >date.log
if grep "Thu Jan 1 00:00:01 UTC 1970" date.log ;
> +if [ $? = 0 ]
> +then
> + echo " -> $test: TEST-PASS"
> +else
> + echo " -> $test: TEST-FAIL"
> +fi;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_dd.sh
> b/engine/tests/Functional.busybox/tests/busybox_dd.sh
> new file mode 100644
> index 0000000..d58201b
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_dd.sh
> @@ -0,0 +1,31 @@
> +#!/bin/sh
> +
> +# The testscript checks the following options of the command dd
> +# 1) Option none
> +
> +test="dd"
> +
> +sleep 1
Why is this sleep here?
> +busybox echo "hello world" > test1
> +busybox touch test2
can use "echo" and "touch", without the 'busybox' prefix here.
> +busybox dd if=test1 of=test2 2>>log
What is this double-redirection doing? Shouldn't this be
"2>&1 >log" ? Maybe this is something I'm not familiar with.
Please explain.
> +
> +if sed -n '2p' log | grep "0+1\ records\ out" && sed -n '1p' log | grep "0+1\
> records\ in"
Please use head and tail instead of sed here.
> +then
> + echo " -> $test: grep succeeded."
> +else
> + echo " -> $test: TEST-FAIL"
> + busybox rm -fr test1 test2
> + busybox rm log
> + exit
> +fi;
> +
> +if [ "$(busybox more test2)" == "hello world" ]
> +then
> + echo " -> $test: TEST-PASS"
> +else
> + echo " -> $test: TEST-FAIL"
> +fi;
> +
> +busybox rm -fr test1 test2;
> +busybox rm log;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_deallocvt.sh
> b/engine/tests/Functional.busybox/tests/busybox_deallocvt.sh
> new file mode 100644
> index 0000000..1564122
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_deallocvt.sh
> @@ -0,0 +1,14 @@
> +#!/bin/sh
> +
> +# The testscript checks the following options of the command deallocvt
> +# 1) Option none
> +
> +test="deallocvt"
> +
> +busybox deallocvt
Would be nice to test actual functionality here.
> +if [ $? = 0 ]
> +then
> + echo " -> $test: TEST-PASS"
> +else
> + echo " -> $test: TEST-FAIL"
> +fi;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_df.sh
> b/engine/tests/Functional.busybox/tests/busybox_df.sh
> new file mode 100644
> index 0000000..6ca2bb0
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_df.sh
> @@ -0,0 +1,14 @@
> +#!/bin/sh
> +
> +# The testscript checks the following options of the command df
> +# 1) Option none
> +
> +test="df"
> +
> +busybox df
This doesn't test much. How about at least checking for one
of the headers:?
if busybox df | head -n 1 | grep 1K-blocks ;
> +if [ $? = 0 ]
> +then
> + echo " -> $test: TEST-PASS"
> +else
> + echo " -> $test: TEST-FAIL"
> +fi;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_dirname.sh
> b/engine/tests/Functional.busybox/tests/busybox_dirname.sh
> new file mode 100644
> index 0000000..acd09de
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_dirname.sh
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +
> +# The testscript checks the following options of the command dirname
> +# 1) Option none
> +
> +test="dirname"
> +
> +busybox mkdir test_dir
> +busybox echo "This is a test file." > ./test_dir/test1
There is no need to create a directory and file. dirname is just
a string operation. Please remove these.
> +if [ "$(busybox dirname ./test_dir/test1)" == "./test_dir" ]
> +then
> + echo " -> $test: TEST-PASS"
> +else
> + echo " -> $test: TEST-FAIL"
> +fi;
> +busybox rm -rf test_dir;
Please remove this cleanup as well.
> diff --git a/engine/tests/Functional.busybox/tests/busybox_dmesg.sh
> b/engine/tests/Functional.busybox/tests/busybox_dmesg.sh
> new file mode 100644
> index 0000000..fdf0546
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_dmesg.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +# The testscript checks the following options of the command dmesg
> +# 1) Option none
> +
> +test="dmesg"
> +
> +if busybox dmesg | grep "Linux version"
> +then
> + echo " -> $test: TEST-PASS"
> +else
> + echo " -> $test: TEST-FAIL"
> +fi;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_du.sh
> b/engine/tests/Functional.busybox/tests/busybox_du.sh
> new file mode 100644
> index 0000000..c3d8a7f
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_du.sh
> @@ -0,0 +1,17 @@
> +#!/bin/sh
> +
> +# The testscript checks the following options of the command du
> +# 1) Option: -k
> +
> +test="du"
> +
> +busybox mkdir test_dir
> +busybox touch ./test_dir/test1
> +busybox touch ./test_dir/test2
> +if busybox du -k test_dir | grep "0.*test_dir"
> +then
> + echo " -> $test: TEST-PASS"
> +else
> + echo " -> $test: TEST-FAIL"
> +fi;
> +busybox rm -rf test_dir;
> --
> 1.8.3.1
Please address the issues and re-submit.
Thanks!
-- Tim
More information about the Fuego
mailing list