[Fuego] [PATCH] busybox: add support for command head/hexdump/hostname/id/ifconfig/install

Tim.Bird at sony.com Tim.Bird at sony.com
Mon Jul 23 23:34: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_head.sh | 22
> ++++++++++++++++++++++
>  .../Functional.busybox/tests/busybox_hexdump.sh    | 19
> +++++++++++++++++++
>  .../Functional.busybox/tests/busybox_hostname.sh   | 13 +++++++++++++
>  .../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, 97 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..be0269e
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_head.sh
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command head
> +#  1) Option -n
> +
> +test="head"
> +
> +mkdir test_dir
> +touch test_dir/test1
This is not needed (the 'touch')

> +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
Please use a space before the redirection operator.

> +
> +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..d598c72
> --- /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..f854515
> --- /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) = $(hostname) ]
On a busybox-based system, this just tests the program against itself.
Maybe compare with $(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..9f53fcc
> --- /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 [ "$(busybox id)" = "$(id)" ]
Same issue here.  If busybox is the main tool for a board, then
'id' will just be a symlink to busybox, and this test just verifies
that the same command produces the same output.

This one I'm not sure what to do with this one.  Maybe
see if there's a shell variable that has the UID?

Or, check that 'id' is not 'busybox id'?

Let me know what you think.

> +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..a8cba56
> --- /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 "ls test_install_dir">test_dir/test1
I'm not sure what's going on here.
test1 should have the contents: 'ls test_install_dir'.
It's not clear to me that this is executable.

> +busybox install test_dir/test1 test_install_dir
> +if [ $(./test_install_dir/test1) = test1 ]
Are you trying to execute the script?

I'm confused.

> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +rm -rf test_dir test_install_dir;
> --
> 1.8.3.1

Thanks for the patch.
Please address my feedback and re-submit.

(Note: Sorry - but I will be out-of-the-office the rest of this week,
so my responses will be delayed until next week.)

Regards,
 -- Tim



More information about the Fuego mailing list