[Fuego] [PATCH] Add test cases for commands of busybox as follows: ash bunzip2 free wget

Tim.Bird at sony.com Tim.Bird at sony.com
Tue May 22 18:22:59 UTC 2018


Please change the use of 'testsuits', as I commented on my
previous response.

And see one inline comment below.

> -----Original Message-----
> From: fuego-bounces at lists.linuxfoundation.org [mailto:fuego-
> bounces at lists.linuxfoundation.org] On Behalf Of Wang Mingyu
> Sent: Tuesday, May 22, 2018 9:00 AM
> To: fuego at lists.linuxfoundation.org
> Subject: [Fuego] [PATCH] Add test cases for commands of busybox as
> follows: ash bunzip2 free wget
> 
> Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
> ---
>  engine/tests/Functional.busybox/busybox_test.sh        |  8 ++++++++
>  .../tests/Functional.busybox/testsuits/busybox_ash.sh  | 15
> +++++++++++++++
>  .../Functional.busybox/testsuits/busybox_bunzip2.sh    | 12 ++++++++++++
>  .../tests/Functional.busybox/testsuits/busybox_free.sh | 10 ++++++++++
>  .../tests/Functional.busybox/testsuits/busybox_wget.sh | 18
> ++++++++++++++++++
>  5 files changed, 63 insertions(+)
>  create mode 100644 engine/tests/Functional.busybox/busybox_test.sh
>  create mode 100644
> engine/tests/Functional.busybox/testsuits/busybox_ash.sh
>  create mode 100644
> engine/tests/Functional.busybox/testsuits/busybox_bunzip2.sh
>  create mode 100644
> engine/tests/Functional.busybox/testsuits/busybox_free.sh
>  create mode 100644
> engine/tests/Functional.busybox/testsuits/busybox_wget.sh
> 
> diff --git a/engine/tests/Functional.busybox/busybox_test.sh
> b/engine/tests/Functional.busybox/busybox_test.sh
> new file mode 100644
> index 0000000..d7c74d1
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/busybox_test.sh
> @@ -0,0 +1,8 @@
> +#!/bin/sh
> +for i in testsuits/*.sh; do
> +    if cat ./skiplist.txt | grep ${i##*/}; then
> +        echo "Skip test specified in SKIPFILE."
> +        continue
> +    fi
> +    sh $i
> +done
> diff --git a/engine/tests/Functional.busybox/testsuits/busybox_ash.sh
> b/engine/tests/Functional.busybox/testsuits/busybox_ash.sh
> new file mode 100644
> index 0000000..96550c1
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/testsuits/busybox_ash.sh
> @@ -0,0 +1,15 @@
> +#!/bin/sh
> +workdir=$(pwd)
> +test="ash"
> +
> +expect <<-EOF
> +spawn busybox ash
> +expect "*# "
> +send_user " -> $test: Opened ash shell succeeded.\n"
> +send "busybox pwd\r"
> +expect "$workdir"
> +send_user " -> $test: Executed pwd command ash shell succeeded.\n"
> +send "exit\r"
> +send_user " -> $test: TEST-PASS\n"
> +expect eof
> +EOF
> diff --git a/engine/tests/Functional.busybox/testsuits/busybox_bunzip2.sh
> b/engine/tests/Functional.busybox/testsuits/busybox_bunzip2.sh
> new file mode 100644
> index 0000000..599f7ea
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/testsuits/busybox_bunzip2.sh
> @@ -0,0 +1,12 @@
> +#!/bin/sh
> +test="bunzip2"
> +
> +echo "This is a test file">test1
> +bzip2 test1
> +if [ "`busybox bunzip2 -c test1.bz2`" == "This is a test file" ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +rm -rf test1.bz2;
> diff --git a/engine/tests/Functional.busybox/testsuits/busybox_free.sh
> b/engine/tests/Functional.busybox/testsuits/busybox_free.sh
> new file mode 100644
> index 0000000..1e00896
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/testsuits/busybox_free.sh
> @@ -0,0 +1,10 @@
> +#!/bin/sh
> +test="free"
> +
> +busybox free
> +if [ `echo $?` == 0 ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> diff --git a/engine/tests/Functional.busybox/testsuits/busybox_wget.sh
> b/engine/tests/Functional.busybox/testsuits/busybox_wget.sh
> new file mode 100644
> index 0000000..abf81bc
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/testsuits/busybox_wget.sh
> @@ -0,0 +1,18 @@
> +#!/bin/sh
> +test="wget"
> +
> +if [ -f ./readme.txt ]; then rm -f ./readme.txt ; fi
> +busybox wget
> http://$test_tcpip_host:$test_port_host/fuego/userContent/readme.txt -P
> ./
> +if ls  ./ | grep ".*readme.*"
> +then
> +    echo " -> $test: ls  ./ executed."
> +else
> +    echo " -> $test: ls  ./ failed."
> +fi;
The parser won't catch this as a separate testcase, since it has different success/failure strings.
Is it intentional for each test script to have only one result?

I like the general approach, but if you are performing multiple test operations in a
single script, it would be good if the echo had a description of
each individual test operation.  Often, people use numbers for sub-test cases,
but I prefer descriptions.

Maybe you could do something like:
test=wget-check-for-file-received
before the first test
(and change the lines to have TEST-PASS or TEST-FAIL as results)
and
test=wget-check-for-expected-data
before the second test?

This style will allow you to add additional testcases per script,
which can fail independently of the entire script.

Let me know what you think.

> +if cat ./readme.txt | grep ".*jenkins.*"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +rm ./readme.txt
> --
> 1.8.3.1

Thanks for the submission.
 -- Tim



More information about the Fuego mailing list