[Fuego] [PATCH] Add new test cases to testset as follows: cat chgrp chmod chown chroot chvt clear cmp cp cut

Wang Mingyu wangmy at cn.fujitsu.com
Fri Jun 8 15:14:46 UTC 2018


Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 .../tests/Functional.busybox/tests/busybox_cat.sh  | 16 +++++++
 .../Functional.busybox/tests/busybox_chgrp1.sh     | 27 ++++++++++++
 .../Functional.busybox/tests/busybox_chgrp2.sh     | 32 ++++++++++++++
 .../Functional.busybox/tests/busybox_chmod1.sh     | 49 ++++++++++++++++++++++
 .../Functional.busybox/tests/busybox_chmod2.sh     | 32 ++++++++++++++
 .../Functional.busybox/tests/busybox_chown1.sh     | 34 +++++++++++++++
 .../Functional.busybox/tests/busybox_chown2.sh     | 43 +++++++++++++++++++
 .../Functional.busybox/tests/busybox_chroot.sh     | 34 +++++++++++++++
 .../tests/Functional.busybox/tests/busybox_chvt.sh | 22 ++++++++++
 .../Functional.busybox/tests/busybox_clear.sh      | 14 +++++++
 .../tests/Functional.busybox/tests/busybox_cmp.sh  | 37 ++++++++++++++++
 .../tests/Functional.busybox/tests/busybox_cp.sh   | 35 ++++++++++++++++
 .../tests/Functional.busybox/tests/busybox_cut.sh  | 13 ++++++
 13 files changed, 388 insertions(+)
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_cat.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_chgrp1.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_chgrp2.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_chmod1.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_chmod2.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_chown1.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_chown2.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_chroot.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_chvt.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_clear.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_cmp.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_cp.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_cut.sh

diff --git a/engine/tests/Functional.busybox/tests/busybox_cat.sh b/engine/tests/Functional.busybox/tests/busybox_cat.sh
new file mode 100644
index 0000000..424528d
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_cat.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command cat
+#  1) Option none
+
+test="cat"
+
+echo "hello" > test1
+echo "world" > test2
+if [ "$(busybox cat test1 test2 | head -n 1)" = "hello" ] && [ "$(busybox cat test1 test2 | tail -n 1)" = "world" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -rf test1 test2;
diff --git a/engine/tests/Functional.busybox/tests/busybox_chgrp1.sh b/engine/tests/Functional.busybox/tests/busybox_chgrp1.sh
new file mode 100644
index 0000000..8c7fcf6
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chgrp1.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chgrp
+#  1) Option: none
+
+test="chgrp1"
+
+mkdir test_dir
+touch test_dir/test1
+group=$(id -n -g | cut -b -8)
+if [ "$(busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f4 | cut -b -8)" = "$group" ]
+then
+    echo " -> $test: Group info display succedded."
+else
+    echo " -> $test: FAIL"
+    rm -rf test_dir
+    exit
+fi;
+
+if [ "$(chgrp bin ./test_dir/test1; busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f4 | cut -b -8)" = "bin" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -rf test_dir
+
diff --git a/engine/tests/Functional.busybox/tests/busybox_chgrp2.sh b/engine/tests/Functional.busybox/tests/busybox_chgrp2.sh
new file mode 100644
index 0000000..fc7073b
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chgrp2.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chgrp
+#  1) Option: -R
+
+test="chgrp2"
+
+mkdir test_dir
+touch test_dir/test1
+touch test_dir/test2
+group=$(id -n -g | cut -b -8)
+busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f4 | cut -b -8 > log1
+if [ "$(head -n 1 log1)" = "$group" ] && [  "$(tail -n 1 log1)" = "$group" ]
+then
+    echo " -> $test: Group info display succedded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm log1
+    rm -rf test_dir
+    exit
+fi
+
+busybox chgrp -R bin ./test_dir
+busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f4 | cut -b -8 > log2
+if [ "$(head -n 1 log2)" = "bin" ] && [ "$(tail -n 1 log2)" = "bin" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm log1 log2
+rm -rf test_dir
diff --git a/engine/tests/Functional.busybox/tests/busybox_chmod1.sh b/engine/tests/Functional.busybox/tests/busybox_chmod1.sh
new file mode 100644
index 0000000..0395745
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chmod1.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chmod
+#  1) Option: g+x
+#  2) Option: o+x
+#  3) Option: a-x
+
+test="chmod1"
+
+mkdir test_dir
+touch test_dir/test1
+
+if [ $(busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f9) = "test1" ]
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm -rf ./test_dir
+    exit
+fi;
+
+busybox chmod g+x ./test_dir/test1
+if [ "$(busybox ls -l ./test_dir | cut -b 1-3)" = "-rw" ]
+then
+    echo " -> $test: Changed file permissions verification2 succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm -rf ./test_dir
+    exit
+fi;
+
+busybox chmod o+x ./test_dir/test1
+if [ "$(busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f1,9  | cut -b 9-16)" = "-x test1" ]
+then
+    echo " -> $test: Changed file permissions verification3 succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm -rf ./test_dir
+    exit
+fi;
+
+busybox chmod a-x ./test_dir/test1
+if [ "$(busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f1,9 | cut -b 1,4,7,10-16 )" = "---- test1" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -rf ./test_dir;
diff --git a/engine/tests/Functional.busybox/tests/busybox_chmod2.sh b/engine/tests/Functional.busybox/tests/busybox_chmod2.sh
new file mode 100644
index 0000000..ca48f79
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chmod2.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chmod
+#  1) Option: -R
+
+test="chmod2"
+
+mkdir test_dir
+touch test_dir/test1
+touch test_dir/test2
+busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f1,9 > log1
+
+if [ "$(head -n 1 log1 | cut -b 12-16)" = "test1" ] && [ "$(tail -n 1 log1 | cut -b 12-16)" = "test2" ]
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm -rf ./test_dir;
+    rm log1;
+    exit
+fi;
+
+busybox chmod -R a-r ./test_dir
+busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f1,9 > log2
+if [ "$(head -n 1 log2 | cut -b 1,2,5,8,12-16)" = "----test1" ] && [ "$(tail -n 1 log2 | cut -b 1,2,5,8,12-16)" = "----test2" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm log1 log2;
+rm -rf ./test_dir;
diff --git a/engine/tests/Functional.busybox/tests/busybox_chown1.sh b/engine/tests/Functional.busybox/tests/busybox_chown1.sh
new file mode 100644
index 0000000..8d17a72
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chown1.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chown
+#  1) Option none
+
+test="chown1"
+
+mkdir test_dir
+touch test_dir/test1
+if [ "$(busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f1,3,4,9 | cut -b 12-26)" = "root root test1" ] 
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm -rf ./test_dir;
+    exit
+fi;
+
+if [ "$(busybox chown bin ./test_dir/test1; busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f1,3,4,9 | cut -b 12-26)" = "bin root test1" ]
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm -rf ./test_dir;
+    exit
+fi;
+
+if [ "$(busybox chown bin.bin ./test_dir/test1; busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f1,3,4,9 | cut -b 12-26)" = "bin bin test1" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -rf ./test_dir;
diff --git a/engine/tests/Functional.busybox/tests/busybox_chown2.sh b/engine/tests/Functional.busybox/tests/busybox_chown2.sh
new file mode 100644
index 0000000..87c928a
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chown2.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chown
+#  1) Option: -R
+
+test="chown2"
+
+mkdir test_dir
+touch test_dir/test1
+touch test_dir/test2
+busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f1,3,4,9 > log1
+if [ "$(head -n 1 log1 | cut -b 12-26)" = "root root test1" ] && [ "$(tail -n 1 log1 | cut -b 12-26)" = "root root test2" ]
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm log1
+    rm -rf ./test_dir
+    exit
+fi;
+
+busybox chown -R bin ./test_dir
+busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f1,3,4,9 > log2
+if [ "$(head -n 1 log2 | cut -b 12-26)" = "bin root test1" ] && [ "$(tail -n 1 log2 | cut -b 12-26)" = "bin root test2" ]
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm log1 log2
+    rm -rf ./test_dir
+    exit
+fi;
+
+busybox chown -R bin.bin ./test_dir
+busybox ls -l ./test_dir | tr -s ' ' | cut -d' ' -f1,3,4,9 > log3
+if [ "$(head -n 1 log3 | cut -b 12-26)" = "bin bin test1" ] && [ "$(tail -n 1 log3 | cut -b 12-26)" = "bin bin test2" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm log1 log2 log3;
+rm -rf ./test_dir;
diff --git a/engine/tests/Functional.busybox/tests/busybox_chroot.sh b/engine/tests/Functional.busybox/tests/busybox_chroot.sh
new file mode 100644
index 0000000..e9bb8a2
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chroot.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chroot
+#  1) Option none
+
+test="chroot"
+
+test_dir=test_dir
+
+mkdir -p $test_dir
+mkdir -p $test_dir/bin
+mkdir -p $test_dir/lib64
+mkdir -p $test_dir/lib
+cp -v /bin/ls $test_dir/bin/
+list="$(ldd /bin/ls | egrep -o '/lib.*\.[0-9]')"
+for i in $list; do 
+   j=${i:1:5}
+   if $j = lib64
+   then    
+       echo "lib64"
+       cp  -v "$i" $test_dir/lib64/
+   else 
+       echo "lib"
+       cp  -v "$i" $test_dir/lib/
+   fi
+done
+busybox chroot $test_dir /bin/ls
+if [ $? = 0 ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -fr $test_dir
diff --git a/engine/tests/Functional.busybox/tests/busybox_chvt.sh b/engine/tests/Functional.busybox/tests/busybox_chvt.sh
new file mode 100644
index 0000000..b31bf81
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chvt.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chvt
+#  1) Option none
+
+test="chvt"
+
+anum=$(tty | cut -b 9-10)
+if [ $anum -eq 1 ]
+then
+    bnum=$(($anum+1))
+else
+    bnum=$(($anum-1))
+fi
+busybox chvt $bnum
+if [ $? = 0 ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+busybox chvt $anum
diff --git a/engine/tests/Functional.busybox/tests/busybox_clear.sh b/engine/tests/Functional.busybox/tests/busybox_clear.sh
new file mode 100644
index 0000000..aaa1d06
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_clear.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command clear
+#  1) Option none
+
+test="clear"
+
+busybox clear
+if [ $? = 0 ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/engine/tests/Functional.busybox/tests/busybox_cmp.sh b/engine/tests/Functional.busybox/tests/busybox_cmp.sh
new file mode 100644
index 0000000..0322ba1
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_cmp.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command cmp
+#  1) Option: -l -s
+
+test="cmp"
+
+mkdir test_dir
+echo "This is test file 1." > ./test_dir/test1
+echo "This is test file 2." > ./test_dir/test2
+if [ "$(busybox cmp test_dir/test1 test_dir/test2)" = "test_dir/test1 test_dir/test2 differ: char 19, line 1" ]
+then
+    echo " -> $test: command cmp succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm -rf test_dir
+    exit
+fi
+
+
+
+if [ "$(busybox cmp -l test_dir/test1 test_dir/test2)" = "19  61  62" ] 
+then
+    echo " -> $test: command cmp -l succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm -rf test_dir
+    exit
+fi
+
+if [ "$(busybox cmp -s test_dir/test1 test_dir/test2)" = "" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -rf test_dir
diff --git a/engine/tests/Functional.busybox/tests/busybox_cp.sh b/engine/tests/Functional.busybox/tests/busybox_cp.sh
new file mode 100644
index 0000000..2eea250
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_cp.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command cp
+#  1) Option: -i
+
+test="cp"
+
+mkdir test_dir_src
+mkdir test_dir_dest
+echo "cp test" > test_dir_src/test1
+busybox cp test_dir_src/test1 test_dir_dest/
+if [ "$(cat test_dir_dest/test1)" = "cp test" ]
+then
+    echo " -> $test: cp succeed."
+else
+    echo " -> &test: TEST-FAIL"
+    rm -rf test_dir_src
+    rm -rf test_dir_dest
+    exit
+fi;
+
+yes | busybox cp -i test_dir_dest/test1 test_dir_src/ 2>cp.log 
+if cat cp.log | grep "cp: overwrite 'test_dir_src/test1'?" 
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo "-> $test: TEST-FAIL"
+    rm cp.log
+    rm -rf test_dir_src
+    rm -rf test_dir_dest
+    exit
+fi
+rm cp.log
+rm -rf test_dir_src
+rm -rf test_dir_dest
diff --git a/engine/tests/Functional.busybox/tests/busybox_cut.sh b/engine/tests/Functional.busybox/tests/busybox_cut.sh
new file mode 100644
index 0000000..228e12c
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_cut.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command cut
+#  1) Option: -f -d
+
+test="cut"
+
+if [ "$(echo "Hello world" | busybox cut -f 1 -d ' ')" = "Hello" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
-- 
1.8.3.1





More information about the Fuego mailing list