busybox: add support for command for sed/sh/sleep/sort/strings/swap/sync
PATCH 1/1 busybox: add support for command for sed/sh/sleep/sort/strings/swap/sync
--- engine/tests/Functional.busybox/fuego_test.sh | 2 +- .../tests/Functional.busybox/tests/busybox_sed.sh | 13 ++++++++ .../tests/Functional.busybox/tests/busybox_sh.sh | 21 ++++++++++++ .../Functional.busybox/tests/busybox_sleep.sh | 22 +++++++++++++ .../tests/Functional.busybox/tests/busybox_sort.sh | 24 ++++++++++++++ .../Functional.busybox/tests/busybox_strings.sh | 24 ++++++++++++++ .../tests/Functional.busybox/tests/busybox_swap.sh | 38 ++++++++++++++++++++++ .../tests/Functional.busybox/tests/busybox_sync.sh | 13 ++++++++ 8 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 engine/tests/Functional.busybox/tests/busybox_sed.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_sh.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_sleep.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_sort.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_strings.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_swap.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_sync.sh
engine/tests/Functional.busybox/fuego_test.sh +1 -1
@@ -53,7 +53,7 @@ function test_pre_check { touch ${LOGDIR}/skiplist.txt skip_if_command_unavailable expect "busybox_ash.sh busybox_passwd.sh" skip_if_command_unavailable tr "busybox_chgrp1.sh busybox_chgrp2.sh busybox_chmod1.sh busybox_chmod2.sh busybox_chown1.sh busybox_chown2.sh" - skip_if_not_root "busybox_chgrp1.sh busybox_chgrp2.sh busybox_chown1.sh busybox_chown2.sh busybox_chroot.sh busybox_passwd.sh" + skip_if_not_root "busybox_chgrp1.sh busybox_chgrp2.sh busybox_chown1.sh busybox_chown2.sh busybox_chroot.sh busybox_passwd.sh busybox_swap.sh" skip_if_subcommand_unsupported "$BUSYBOX_SKIPLIST" }
engine/tests/Functional.busybox/tests/busybox_sed.sh new file +13 -0
@@ -0,0 +1,13 @@ +#!/bin/sh + +# The testscript checks the following options of the command sed +# 1) Option -e + +test="sed" + +if [ "$(echo "test case" | busybox sed -e 's/case/result/g')" = "test result" ] +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi;
engine/tests/Functional.busybox/tests/busybox_sh.sh new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/sh + +# The testscript checks the following options of the command sh +# 1) Option none + +test="sh" + +mkdir test_dir +touch test_dir/test1 + +cat >> test_dir/test1 <<EOF +#!/bin/bash +echo "this is test bash!" +EOF + +if busybox sh test_dir/test1 | grep "this is test bash!" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi;
engine/tests/Functional.busybox/tests/busybox_sleep.sh new file +22 -0
@@ -0,0 +1,22 @@ +#!/bin/sh + +# The testscript checks the following options of the command sleep +# 1) Option none + +test="sleep" + +if sleep 0 | ps aux | grep "[s]leep 0" +then + echo " -> $test: sleep 0 failed." + echo " -> $test: TEST-FAIL" + exit +else + echo " -> $test: sleep 0 succeeded." +fi; + +if sleep 1 | ps aux | grep "[s]leep 1" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi;
engine/tests/Functional.busybox/tests/busybox_sort.sh new file +24 -0
@@ -0,0 +1,24 @@ +#!/bin/sh + +# The testscript checks the following options of the command sort +# 1) Option none + +test="sort" + +echo "e" > test1 +echo "f" >> test1 +echo "b" >> test1 +echo "d" >> test1 +echo "c" >> test1 +echo "a" >> test1 + +busybox sort test1 > log +if [ "$(head -n 1 log)" = "a" ] && [ "$(head -n 2 log | tail -n 1)" = "b" ] && [ "$(head -n 3 log | tail -n 1)" = "c" ] \ +&& [ "$(head -n 4 log | tail -n 1)" = "d" ] && [ "$(head -n 5 log | tail -n 1)" = "e" ] && [ "$(tail -n 1 log)" = "f" ] +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; +rm -rf test1; +rm log;
engine/tests/Functional.busybox/tests/busybox_strings.sh new file +24 -0
@@ -0,0 +1,24 @@ +#!/bin/sh + +# The testscript checks the following options of the command strings +# 1) Option none + +test="strings" + +cat >> test1.c <<EOF +#include <stdio.h> +void main() +{ + printf("Hello World \n"); +} +EOF + +gcc test1.c -o test1 + +if busybox strings test1 | grep "Hello World" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; +rm test1 test1.c;
engine/tests/Functional.busybox/tests/busybox_swap.sh new file +38 -0
@@ -0,0 +1,38 @@ +#!/bin/sh + +# The testscript checks the following options of the command swapon&swapoff +# 1) Option -a + +test="swapon/swapoff" + +function check_if_succeeded { + if $1 + then + echo " -> $test: $1 succeeded." + else + echo " -> $test: $1 failed." + echo " -> $test: TEST-FAIL" + fi +} + +if [ $(cat /proc/swaps | wc -l) = 1 ] +then + check_if_succeeded "busybox swapon -a" + check_if_succeeded "busybox swapoff -a" + if [ $(cat /proc/swaps | wc -l) = 1 ] + then + echo " -> $test: TEST-PASS" + else + echo " -> $test: TEST-FAIL" + fi +else + swap_name=$(cat /proc/swaps | tail -n 1| tr -s " " | cut -d ' ' -f1) + check_if_succeeded "busybox swapoff $swap_name" + check_if_succeeded "busybox swapon $swap_name" + if cat /proc/swaps | grep $swap_name + then + echo " -> $test: TEST-PASS" + else + echo " -> $test: TEST-FAIL" + fi +fi;
engine/tests/Functional.busybox/tests/busybox_sync.sh new file +13 -0
@@ -0,0 +1,13 @@ +#!/bin/sh + +# The testscript checks the following options of the command sync +# 1) Option none + +test="sync" + +if busybox sync +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi;
Signature · 1 line
1.8.3.1
Comments inline below.
Quoted 61 lines · Wang Mingyu
Signed-off-by Wang Mingyu <[email protected]>--- engine/tests/Functional.busybox/fuego_test.sh | 2 +- .../tests/Functional.busybox/tests/busybox_sed.sh | 13 ++++++++ .../tests/Functional.busybox/tests/busybox_sh.sh | 21 ++++++++++++ .../Functional.busybox/tests/busybox_sleep.sh | 22 +++++++++++++ .../tests/Functional.busybox/tests/busybox_sort.sh | 24 ++++++++++++++ .../Functional.busybox/tests/busybox_strings.sh | 24 ++++++++++++++ .../tests/Functional.busybox/tests/busybox_swap.sh | 38 ++++++++++++++++++++++ .../tests/Functional.busybox/tests/busybox_sync.sh | 13 ++++++++ 8 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 engine/tests/Functional.busybox/tests/busybox_sed.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_sh.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_sleep.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_sort.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_strings.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_swap.sh create mode 100644 engine/tests/Functional.busybox/tests/busybox_sync.shengine/tests/Functional.busybox/fuego_test.sh +1
-1@@ -53,7 +53,7 @@ function test_pre_check { touch ${LOGDIR}/skiplist.txt skip_if_command_unavailable expect "busybox_ash.sh busybox_passwd.sh" skip_if_command_unavailable tr "busybox_chgrp1.sh busybox_chgrp2.sh busybox_chmod1.sh busybox_chmod2.sh busybox_chown1.sh busybox_chown2.sh" - skip_if_not_root "busybox_chgrp1.sh busybox_chgrp2.sh busybox_chown1.sh busybox_chown2.sh busybox_chroot.sh busybox_passwd.sh" + skip_if_not_root "busybox_chgrp1.sh busybox_chgrp2.sh busybox_chown1.sh busybox_chown2.sh busybox_chroot.sh busybox_passwd.sh busybox_swap.sh" skip_if_subcommand_unsupported "$BUSYBOX_SKIPLIST" }engine/tests/Functional.busybox/tests/busybox_sed.sh new file +13
-0@@ -0,0 +1,13 @@ +#!/bin/sh + +# The testscript checks the following options of the command sed +# 1) Option -e + +test="sed" + +if [ "$(echo "test case" | busybox sed -e 's/case/result/g')" = "test result" ] +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi;engine/tests/Functional.busybox/tests/busybox_sh.sh new file +4
-0@@ -0,0 +1,21 @@ +#!/bin/sh + +# The testscript checks the following options of the command sh +# 1) Option none
engine/tests/Functional.busybox/tests/busybox_sh.sh line 14
Quoted 10 lines
engine/tests/Functional.busybox/tests/busybox_sh.sh new file +10
-0+ +test="sh" + +mkdir test_dir +touch test_dir/test1 + +cat >> test_dir/test1 <<EOF +#!/bin/bash +echo "this is test bash!" +EOF
OK - that's kind of tricky - saying it's a bash script but executing it with busybox sh. I like it.
Quoted 77 lines
engine/tests/Functional.busybox/tests/busybox_sh.sh new file +7
-0+ +if busybox sh test_dir/test1 | grep "this is test bash!" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi;engine/tests/Functional.busybox/tests/busybox_sleep.sh new file +22
-0@@ -0,0 +1,22 @@ +#!/bin/sh + +# The testscript checks the following options of the command sleep +# 1) Option none + +test="sleep" + +if sleep 0 | ps aux | grep "[s]leep 0" +then + echo " -> $test: sleep 0 failed." + echo " -> $test: TEST-FAIL" + exit +else + echo " -> $test: sleep 0 succeeded." +fi; + +if sleep 1 | ps aux | grep "[s]leep 1" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi;engine/tests/Functional.busybox/tests/busybox_sort.sh new file +24
-0@@ -0,0 +1,24 @@ +#!/bin/sh + +# The testscript checks the following options of the command sort +# 1) Option none + +test="sort" + +echo "e" > test1 +echo "f" >> test1 +echo "b" >> test1 +echo "d" >> test1 +echo "c" >> test1 +echo "a" >> test1 + +busybox sort test1 > log +if [ "$(head -n 1 log)" = "a" ] && [ "$(head -n 2 log | tail -n 1)" = "b" ] && [ "$(head -n 3 log | tail -n 1)" = "c" ] \ +&& [ "$(head -n 4 log | tail -n 1)" = "d" ] && [ "$(head -n 5 log | tail -n 1)" = "e" ] && [ "$(tail -n 1 log)" = "f" ] +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; +rm -rf test1; +rm log;engine/tests/Functional.busybox/tests/busybox_strings.sh new file +6
-0@@ -0,0 +1,24 @@ +#!/bin/sh + +# The testscript checks the following options of the command strings +# 1) Option none + +test="strings"
engine/tests/Functional.busybox/tests/busybox_strings.sh line 16
Quoted 10 lines
engine/tests/Functional.busybox/tests/busybox_strings.sh new file +10
-0+ +cat >> test1.c <<EOF +#include <stdio.h> +void main() +{ + printf("Hello World \n"); +} +EOF + +gcc test1.c -o test1
It's unlikely there will be 'gcc' on the board. You need to use a different method of
creating the data file.
I manually created on using printf on the host. I'll put some code to generate a file with binary data, as well a "Hello World\n" on the host, and transfer it to the board in deploy.
Quoted 80 lines
engine/tests/Functional.busybox/tests/busybox_strings.sh new file +8
-0+ +if busybox strings test1 | grep "Hello World" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; +rm test1 test1.c;engine/tests/Functional.busybox/tests/busybox_swap.sh new file +38
-0@@ -0,0 +1,38 @@ +#!/bin/sh + +# The testscript checks the following options of the command swapon&swapoff +# 1) Option -a + +test="swapon/swapoff" + +function check_if_succeeded { + if $1 + then + echo " -> $test: $1 succeeded." + else + echo " -> $test: $1 failed." + echo " -> $test: TEST-FAIL" + fi +} + +if [ $(cat /proc/swaps | wc -l) = 1 ] +then + check_if_succeeded "busybox swapon -a" + check_if_succeeded "busybox swapoff -a" + if [ $(cat /proc/swaps | wc -l) = 1 ] + then + echo " -> $test: TEST-PASS" + else + echo " -> $test: TEST-FAIL" + fi +else + swap_name=$(cat /proc/swaps | tail -n 1| tr -s " " | cut -d ' ' -f1) + check_if_succeeded "busybox swapoff $swap_name" + check_if_succeeded "busybox swapon $swap_name" + if cat /proc/swaps | grep $swap_name + then + echo " -> $test: TEST-PASS" + else + echo " -> $test: TEST-FAIL" + fi +fi;engine/tests/Functional.busybox/tests/busybox_sync.sh new file +13
-1@@ -0,0 +1,13 @@ +#!/bin/sh + +# The testscript checks the following options of the command sync +# 1) Option none + +test="sync" + +if busybox sync +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; --1.8.3.1
_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego
Signature · 3 lines
-- Tim Bird Senior Staff Software Engineer, Sony Corporation Architecture Group Chair, Core Embedded Linux Project, Linux Foundation