[Fuego] [PATCH] Add new test cases of command that can change permission.

Wang Mingyu wangmy at cn.fujitsu.com
Thu May 31 08:24:14 UTC 2018


Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 .../Functional.busybox/tests/busybox_basename.sh   | 17 ++++++++
 .../Functional.busybox/tests/busybox_busybox.sh    | 14 +++++++
 .../Functional.busybox/tests/busybox_bzcat.sh      | 16 +++++++
 .../tests/Functional.busybox/tests/busybox_cat.sh  | 16 +++++++
 .../Functional.busybox/tests/busybox_chgrp1.sh     | 25 +++++++++++
 .../Functional.busybox/tests/busybox_chgrp2.sh     | 31 ++++++++++++++
 .../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     | 14 +++++++
 .../tests/Functional.busybox/tests/busybox_chvt.sh | 14 +++++++
 12 files changed, 305 insertions(+)
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_basename.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_busybox.sh
 create mode 100644 engine/tests/Functional.busybox/tests/busybox_bzcat.sh
 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

diff --git a/engine/tests/Functional.busybox/tests/busybox_basename.sh b/engine/tests/Functional.busybox/tests/busybox_basename.sh
new file mode 100644
index 0000000..6fdab06
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_basename.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command basename
+#  1) Option none
+
+workdir=$(pwd)
+test="basename"
+
+busybox mkdir -p $workdir/test_dir
+busybox echo "This is a test file." > ./test_dir/test1
+if [ $(busybox basename ./test_dir/test1) = "test1" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+busybox rm -rf test_dir;
diff --git a/engine/tests/Functional.busybox/tests/busybox_busybox.sh b/engine/tests/Functional.busybox/tests/busybox_busybox.sh
new file mode 100644
index 0000000..22545b3
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_busybox.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command busybox
+#  1) Option none
+
+workdir=$(pwd)
+test="busybox"
+
+if [ $(busybox pwd) = ${workdir} ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/engine/tests/Functional.busybox/tests/busybox_bzcat.sh b/engine/tests/Functional.busybox/tests/busybox_bzcat.sh
new file mode 100644
index 0000000..93ce7f0
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_bzcat.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command bzcat
+#  1) Option none
+
+test="bzcat"
+
+echo "This is a test file">test1
+bzip2 test1
+if [ "$(busybox bzcat 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/tests/busybox_cat.sh b/engine/tests/Functional.busybox/tests/busybox_cat.sh
new file mode 100644
index 0000000..ee09a8e
--- /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"
+
+busybox echo "hello" > test1
+busybox echo "world" > test2
+if [ "$(busybox cat test1 test2 | sed -n '1p')" = "hello" ] && [ "$(busybox cat test1 test2 | sed -n '2p')" = "world" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+busybox 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..7a72fac
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chgrp1.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chgrp
+#  1) Option: none
+
+test="chgrp1"
+
+busybox mkdir test_dir
+busybox touch test_dir/test1
+if [ "$(busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f4,9)" = "root test1" ]
+then
+    echo " -> $test: Group info display succedded."
+else
+    echo " -> $test: FAIL"
+    busybox rm -rf test_dir;
+    exit
+fi;
+
+if [ "$(busybox chgrp bin ./test_dir/test1; busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f4,9)" = "bin test1" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+busybox 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..4b27e76
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chgrp2.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chgrp
+#  1) Option: -R
+
+test="chgrp2"
+
+busybox mkdir test_dir
+busybox touch test_dir/test1
+busybox touch test_dir/test2
+busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f4,9 > log1
+if [ "$(sed -n '1p' log1)" = "root test1" ] && [  "$(sed -n '2p' log1)" = "root test2" ]
+then
+    echo " -> $test: Group info display succedded."
+else
+    echo " -> $test: TEST-FAIL"
+    busybox rm log1
+    busybox rm -rf test_dir
+    exit
+fi;
+
+busybox chgrp -R bin ./test_dir
+busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f4,9 > log2
+if [ "$(sed -n '1p' log2)" = "bin test1" ] && [ "$(sed -n '2p' log2)" = "bin test2" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+busybox rm log1 log2;
+busybox 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..17f22e6
--- /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"
+
+busybox mkdir test_dir
+busybox touch test_dir/test1
+
+if [[ $(busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f1,9) = *test1 ]]
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    busybox rm -rf ./test_dir
+    exit
+fi;
+
+busybox chmod g+x ./test_dir/test1
+if [[ $(busybox ls -l ./test_dir|busybox tr -s ' '|busybox cut -d' ' -f1) = -rw* ]]
+then
+    echo " -> $test: Changed file permissions verification2 succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    busybox rm -rf ./test_dir
+    exit
+fi;
+
+busybox chmod o+x ./test_dir/test1
+if [[ $(busybox ls -l ./test_dir|busybox tr -s ' '|busybox cut -d' ' -f1,9) = -*x*test1 ]]
+then
+    echo " -> $test: Changed file permissions verification3 succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    busybox rm -rf ./test_dir
+    exit
+fi;
+
+busybox chmod a-x ./test_dir/test1
+if [[ $(busybox ls -l ./test_dir|busybox tr -s ' '|busybox cut -d' ' -f1,9) = -**-**-**-*test1 ]]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+busybox 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..d82452f
--- /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"
+
+busybox mkdir test_dir
+busybox touch test_dir/test1
+busybox touch test_dir/test2
+busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f1,9 > log1
+
+if [[ $(sed -n '1p' log1) = *test1 ]] && [[ $(sed -n '2p' log1) = *test2 ]]
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    busybox rm -rf ./test_dir;
+    busybox rm log1;
+    exit
+fi;
+
+busybox chmod -R a-r ./test_dir
+busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f1,9 > log2
+if [[ $(sed -n '1p' log2) = --**-**-*test1 ]] && [[ $(sed -n '2p' log2) = --**-**-*test2 ]]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+busybox rm log1 log2;
+busybox 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..6adc0f1
--- /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"
+
+busybox mkdir test_dir
+busybox touch test_dir/test1
+if [[ "$(busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f1,3,4,9)" =~ " root root test1" ]] 
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    busybox rm -rf ./test_dir;
+    exit
+fi;
+
+if [[ "$(busybox chown bin ./test_dir/test1; busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f1,3,4,9)" =~ " bin root test1" ]]
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    busybox rm -rf ./test_dir;
+    exit
+fi;
+
+if [[ "$(busybox chown bin.bin ./test_dir/test1; busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f1,3,4,9)" =~ " bin bin test1" ]]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+busybox 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..25e241b
--- /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"
+
+busybox mkdir test_dir
+busybox touch test_dir/test1
+busybox touch test_dir/test2
+busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f1,3,4,9 > log1
+if [[ "$(sed -n '1p' log1)" =~ " root root test1" ]] && [[ "$(sed -n '2p' log1)" =~ " root root test2" ]]
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    busybox rm log1
+    busybox rm -rf ./test_dir
+    exit
+fi;
+
+busybox chown -R bin ./test_dir
+busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f1,3,4,9 > log2
+if [[ "$(sed -n '1p' log2)" =~ " bin root test1" ]] && [[ "$(sed -n '2p' log2)" =~ " bin root test2" ]] 
+then
+    echo " -> $test: test_dir contents verification succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    busybox rm log1 log2
+    busybox rm -rf ./test_dir
+    exit
+fi;
+
+busybox chown -R bin.bin ./test_dir
+busybox ls -l ./test_dir | busybox tr -s ' ' | busybox cut -d' ' -f1,3,4,9 > log3
+if [[ "$(sed -n '1p' log3)" =~ " bin bin test1" ]] && [[ "$(sed -n '2p' log3)" =~ " bin bin test2" ]]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+busybox rm log1 log2 log3;
+busybox 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..60fb461
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chroot.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chroot
+#  1) Option none
+
+test="chroot"
+
+busybox chroot / /bin/true
+if [ $? = 0 ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
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..a3fdb08
--- /dev/null
+++ b/engine/tests/Functional.busybox/tests/busybox_chvt.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command chvt
+#  1) Option none
+
+test="chvt"
+
+busybox chvt 10
+if [ $? = 0 ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
-- 
1.8.3.1





More information about the Fuego mailing list