[Fuego] [PATCH] busybox: add support for command umount/uname/uniq/uptime/usleep

Tim Bird tbird20d at gmail.com
Thu Aug 30 20:47:32 UTC 2018


See comments inline below.
On Sun, Aug 5, 2018 at 6:40 PM Wang Mingyu <wangmy at cn.fujitsu.com> wrote:
>
> Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
> ---
>  .../Functional.busybox/tests/busybox_umount.sh     | 25 ++++++++++++++++++++++
>  .../Functional.busybox/tests/busybox_uname.sh      | 14 ++++++++++++
>  .../tests/Functional.busybox/tests/busybox_uniq.sh | 23 ++++++++++++++++++++
>  .../Functional.busybox/tests/busybox_uptime.sh     | 13 +++++++++++
>  .../Functional.busybox/tests/busybox_usleep.sh     | 22 +++++++++++++++++++
>  5 files changed, 97 insertions(+)
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_umount.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_uname.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_uniq.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_uptime.sh
>  create mode 100644 engine/tests/Functional.busybox/tests/busybox_usleep.sh
>
> diff --git a/engine/tests/Functional.busybox/tests/busybox_umount.sh b/engine/tests/Functional.busybox/tests/busybox_umount.sh
> new file mode 100644
> index 0000000..5e3a951
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_umount.sh
> @@ -0,0 +1,25 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command umount
> +#  1) Option none
> +
> +test="umount"
> +
> +mount -n -t tmpfs none  /dev/shm
> +
> +if mount | grep "none on /dev/shm"
> +then
> +    echo " -> $test: mount successed."
Should be "succeeded".  I changed it.

> +else
> +    echo " -> $test: mount failed."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi;
> +
> +busybox umount /dev/shm
> +if mount | grep "none on /dev/shm"
> +then
> +    echo " -> $test: TEST-FAIL"
> +else
> +    echo " -> $test: TEST-PASS"
> +fi;

This test doesn't check to see if /dev/shm is already in use, and leaves
it unmounted when it is done.  this should be changed to leave any existing
or possibly in-use mount points alone.  So, I'm changing this to mount
tmpfs on a newly created directory, and unmount it, and remove the directory,
to avoid this issue.

> diff --git a/engine/tests/Functional.busybox/tests/busybox_uname.sh b/engine/tests/Functional.busybox/tests/busybox_uname.sh
> new file mode 100644
> index 0000000..e640a0f
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_uname.sh
> @@ -0,0 +1,14 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command uname
> +#  1) Option: -r
> +
> +test="uname"
> +
> +if cat /proc/version | grep "$(busybox uname -r)"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_uniq.sh b/engine/tests/Functional.busybox/tests/busybox_uniq.sh
> new file mode 100644
> index 0000000..66b90e7
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_uniq.sh
> @@ -0,0 +1,23 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command uniq
> +#  1) Option none
> +
> +test="uniq"
> +
> +echo "a" > test1
> +echo "a" >> test1
> +echo "b" >> test1
> +echo "c" >> test1
> +echo "c" >> test1
> +echo "a" >> test1
> +sort test1 | busybox uniq > log
> +
> +if [ "$(head -n 1 log)" = "a" ] && [ "$(head -n 2 log | tail -n 1)" = "b" ] && [ "$(tail -n 1 log)" = "c" ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> +rm test1;
> +rm log;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_uptime.sh b/engine/tests/Functional.busybox/tests/busybox_uptime.sh
> new file mode 100644
> index 0000000..aa44d24
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_uptime.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command uptime
> +#  1) Option none
> +
> +test="uptime"
> +
> +if [ "$(busybox uptime | grep ".*average.*")" ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> diff --git a/engine/tests/Functional.busybox/tests/busybox_usleep.sh b/engine/tests/Functional.busybox/tests/busybox_usleep.sh
> new file mode 100644
> index 0000000..344a45e
> --- /dev/null
> +++ b/engine/tests/Functional.busybox/tests/busybox_usleep.sh
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +
> +#  The testscript checks the following options of the command usleep
> +#  1) Option none
> +
> +test="usleep"
> +
> +if busybox usleep 0 | ps aux | grep "[b]usybox usleep 0"
> +then
> +    echo " -> $test: sleep 0 failed."
Should say "usleep" here instead of "sleep".  I changed it.

> +    echo " -> $test: TEST-FAIL"
> +    exit
> +else
> +    echo " -> $test: sleep 0 successed."
Should be "succeeded".  I changed it.

> +fi;
> +
> +if busybox usleep 1000000 | ps aux | grep "[b]usybox usleep 1000000"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> --

Applied.  And then I applied a fixup patch on top.  Please review
my changes and see if you agree.

Thanks,
 -- Tim


More information about the Fuego mailing list