All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fuego] [PATCH v2] cross_compilation: Add test cases for commands of cross_compilation.
@ 2019-04-09 13:02 Wang Mingyu
  2019-04-09 13:02 ` [Fuego] [PATCH v2] acl: Add test cases for commands of ACL Wang Mingyu
  2019-04-09 13:02 ` [Fuego] [PATCH v3] samhain: Add test cases of command samhain Wang Mingyu
  0 siblings, 2 replies; 3+ messages in thread
From: Wang Mingyu @ 2019-04-09 13:02 UTC (permalink / raw)
  To: fuego

The test set is used to verify whether the cross compilation is normally performed.
The verification is performed on the binary format of the executable, whether it works as specified by the help option (or equivalent).

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 .../cross_compilation_test.sh                      |  4 ++++
 tests/Functional.cross_compilation/fuego_test.sh   | 28 ++++++++++++++++++++++
 tests/Functional.cross_compilation/parser.py       | 20 ++++++++++++++++
 tests/Functional.cross_compilation/spec.json       |  6 +++++
 .../tests/cross_compilation_dotlockfile.sh         | 15 ++++++++++++
 .../tests/cross_compilation_drbdsetup.sh           | 13 ++++++++++
 .../tests/cross_compilation_jpegtran.sh            | 15 ++++++++++++
 .../tests/cross_compilation_lockfile-create.sh     | 15 ++++++++++++
 .../tests/cross_compilation_logcheck.sh            | 13 ++++++++++
 .../tests/cross_compilation_mip6d.sh               | 15 ++++++++++++
 .../tests/cross_compilation_ntfsend.sh             | 13 ++++++++++
 .../tests/cross_compilation_openhpid.sh            | 13 ++++++++++
 .../tests/cross_compilation_openl2tpd.sh           | 15 ++++++++++++
 .../tests/cross_compilation_ptpd2.sh               | 13 ++++++++++
 .../tests/cross_compilation_setuidgid.sh           | 15 ++++++++++++
 .../tests/cross_compilation_smartctl.sh            | 13 ++++++++++
 16 files changed, 226 insertions(+)
 create mode 100644 tests/Functional.cross_compilation/cross_compilation_test.sh
 create mode 100644 tests/Functional.cross_compilation/fuego_test.sh
 create mode 100644 tests/Functional.cross_compilation/parser.py
 create mode 100644 tests/Functional.cross_compilation/spec.json
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_dotlockfile.sh
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_drbdsetup.sh
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_jpegtran.sh
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_lockfile-create.sh
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_logcheck.sh
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_mip6d.sh
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_ntfsend.sh
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_openhpid.sh
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_openl2tpd.sh
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_ptpd2.sh
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_setuidgid.sh
 create mode 100644 tests/Functional.cross_compilation/tests/cross_compilation_smartctl.sh

diff --git a/tests/Functional.cross_compilation/cross_compilation_test.sh b/tests/Functional.cross_compilation/cross_compilation_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.cross_compilation/cross_compilation_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.cross_compilation/fuego_test.sh b/tests/Functional.cross_compilation/fuego_test.sh
new file mode 100644
index 0000000..1989831
--- /dev/null
+++ b/tests/Functional.cross_compilation/fuego_test.sh
@@ -0,0 +1,28 @@
+function test_pre_check {
+    assert_has_program dotlockfile
+    assert_has_program drbdsetup
+    assert_has_program jpegtran
+    assert_has_program lockfile-create
+    assert_has_program logcheck
+    assert_has_program mip6d
+    assert_has_program ntfsend
+    assert_has_program openhpid
+    assert_has_program openl2tpd
+    assert_has_program ptpd2
+    assert_has_program setuidgid
+    assert_has_program smartctl
+}
+
+function test_deploy {
+    put $TEST_HOME/cross_compilation_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./cross_compilation_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.cross_compilation/parser.py b/tests/Functional.cross_compilation/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.cross_compilation/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.cross_compilation/spec.json b/tests/Functional.cross_compilation/spec.json
new file mode 100644
index 0000000..87ebd21
--- /dev/null
+++ b/tests/Functional.cross_compilation/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.cross_compilation",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_dotlockfile.sh b/tests/Functional.cross_compilation/tests/cross_compilation_dotlockfile.sh
new file mode 100644
index 0000000..20b19b5
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_dotlockfile.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  The testscript checks the command dotlockfile.
+#  option: none
+
+test="dotlockfile"
+
+dotlockfile > log 2>&1
+if cat log | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm log
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_drbdsetup.sh b/tests/Functional.cross_compilation/tests/cross_compilation_drbdsetup.sh
new file mode 100644
index 0000000..29d2b9b
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_drbdsetup.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  The testscript checks the command drbdsetup.
+#  option: -h
+
+test="drbdsetup"
+
+if drbdsetup -h | grep USAGE
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_jpegtran.sh b/tests/Functional.cross_compilation/tests/cross_compilation_jpegtran.sh
new file mode 100644
index 0000000..4fce7ab
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_jpegtran.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  The testscript checks the command jpegtran.
+#  option: -h
+
+test="jpegtran"
+
+jpegtran -h > log 2>&1
+if cat log | grep usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm log
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_lockfile-create.sh b/tests/Functional.cross_compilation/tests/cross_compilation_lockfile-create.sh
new file mode 100644
index 0000000..e9c1286
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_lockfile-create.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  The testscript checks the command lockfile-create.
+#  option: none
+
+test="lockfile-create"
+
+lockfile-create > log 2>&1
+if cat log | grep usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm log
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_logcheck.sh b/tests/Functional.cross_compilation/tests/cross_compilation_logcheck.sh
new file mode 100644
index 0000000..269999d
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_logcheck.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  The testscript checks the command logcheck.
+#  option: -h
+
+test="logcheck"
+
+if sudo -u logcheck logcheck -h | grep usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_mip6d.sh b/tests/Functional.cross_compilation/tests/cross_compilation_mip6d.sh
new file mode 100644
index 0000000..4c6ee01
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_mip6d.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  The testscript checks the command mip6d.
+#  option: -h
+
+test="mip6d"
+
+mip6d -h > log 2>&1
+if cat log | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm log
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_ntfsend.sh b/tests/Functional.cross_compilation/tests/cross_compilation_ntfsend.sh
new file mode 100644
index 0000000..3f80215
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_ntfsend.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  The testscript checks the command ntfsend.
+#  option: --help
+
+test="ntfsend"
+
+if ntfsend --help | grep "ntfsend - send notification"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_openhpid.sh b/tests/Functional.cross_compilation/tests/cross_compilation_openhpid.sh
new file mode 100644
index 0000000..308497e
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_openhpid.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  The testscript checks the command openhpid.
+#  option: -h
+
+test="openhpid"
+
+if openhpid -h | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_openl2tpd.sh b/tests/Functional.cross_compilation/tests/cross_compilation_openl2tpd.sh
new file mode 100644
index 0000000..d49224a
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_openl2tpd.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  The testscript checks the command openl2tpd.
+#  option: -h
+
+test="openl2tpd"
+
+openl2tpd -h > log 2>&1
+if cat log | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm log
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_ptpd2.sh b/tests/Functional.cross_compilation/tests/cross_compilation_ptpd2.sh
new file mode 100644
index 0000000..f00d4ce
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_ptpd2.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  The testscript checks the command ptpd2.
+#  option: -h
+
+test="ptpd2"
+
+if ptpd2 -h | grep usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_setuidgid.sh b/tests/Functional.cross_compilation/tests/cross_compilation_setuidgid.sh
new file mode 100644
index 0000000..18acea7
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_setuidgid.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  The testscript checks the following options of the command setuidgid.
+#  option: --help
+
+test="setuidgid"
+
+setuidgid --help > log 2>&1
+if cat log | grep usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm log
diff --git a/tests/Functional.cross_compilation/tests/cross_compilation_smartctl.sh b/tests/Functional.cross_compilation/tests/cross_compilation_smartctl.sh
new file mode 100644
index 0000000..8188d1b
--- /dev/null
+++ b/tests/Functional.cross_compilation/tests/cross_compilation_smartctl.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  The testscript checks the command smartctl.
+#  option: -h
+
+test="smartctl"
+
+if smartctl -h | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Fuego] [PATCH v2] acl: Add test cases for commands of ACL.
  2019-04-09 13:02 [Fuego] [PATCH v2] cross_compilation: Add test cases for commands of cross_compilation Wang Mingyu
@ 2019-04-09 13:02 ` Wang Mingyu
  2019-04-09 13:02 ` [Fuego] [PATCH v3] samhain: Add test cases of command samhain Wang Mingyu
  1 sibling, 0 replies; 3+ messages in thread
From: Wang Mingyu @ 2019-04-09 13:02 UTC (permalink / raw)
  To: fuego

ACLs are a second level of discretionary permissions, that may override the standard ugo/rwx ones.
This is a simple test to check the commands of ACL.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.acl/acl_test.sh           |  4 ++++
 tests/Functional.acl/fuego_test.sh         | 21 ++++++++++++++++++++
 tests/Functional.acl/parser.py             | 20 +++++++++++++++++++
 tests/Functional.acl/spec.json             |  6 ++++++
 tests/Functional.acl/test.yaml             | 32 ++++++++++++++++++++++++++++++
 tests/Functional.acl/tests/acl_chacl.sh    | 20 +++++++++++++++++++
 tests/Functional.acl/tests/acl_getfacl1.sh | 13 ++++++++++++
 tests/Functional.acl/tests/acl_getfacl2.sh | 20 +++++++++++++++++++
 tests/Functional.acl/tests/acl_getfacl3.sh | 20 +++++++++++++++++++
 tests/Functional.acl/tests/acl_setfacl1.sh | 13 ++++++++++++
 tests/Functional.acl/tests/acl_setfacl2.sh | 19 ++++++++++++++++++
 tests/Functional.acl/tests/acl_setfacl3.sh | 19 ++++++++++++++++++
 tests/Functional.acl/tests/acl_setfacl4.sh | 19 ++++++++++++++++++
 tests/Functional.acl/tests/acl_setfacl5.sh | 19 ++++++++++++++++++
 14 files changed, 245 insertions(+)
 create mode 100644 tests/Functional.acl/acl_test.sh
 create mode 100644 tests/Functional.acl/fuego_test.sh
 create mode 100644 tests/Functional.acl/parser.py
 create mode 100644 tests/Functional.acl/spec.json
 create mode 100644 tests/Functional.acl/test.yaml
 create mode 100644 tests/Functional.acl/tests/acl_chacl.sh
 create mode 100644 tests/Functional.acl/tests/acl_getfacl1.sh
 create mode 100644 tests/Functional.acl/tests/acl_getfacl2.sh
 create mode 100644 tests/Functional.acl/tests/acl_getfacl3.sh
 create mode 100644 tests/Functional.acl/tests/acl_setfacl1.sh
 create mode 100644 tests/Functional.acl/tests/acl_setfacl2.sh
 create mode 100644 tests/Functional.acl/tests/acl_setfacl3.sh
 create mode 100644 tests/Functional.acl/tests/acl_setfacl4.sh
 create mode 100644 tests/Functional.acl/tests/acl_setfacl5.sh

diff --git a/tests/Functional.acl/acl_test.sh b/tests/Functional.acl/acl_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.acl/acl_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.acl/fuego_test.sh b/tests/Functional.acl/fuego_test.sh
new file mode 100644
index 0000000..a65e39c
--- /dev/null
+++ b/tests/Functional.acl/fuego_test.sh
@@ -0,0 +1,21 @@
+function test_pre_check {
+    assert_has_program chacl
+    assert_has_program setfacl
+    assert_has_program getfacl
+}
+
+function test_deploy {
+    put $TEST_HOME/acl_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export tst_acl_ram=$DISK_DEV;\
+    export tst_acl_media=$DISK_MEDIA;\
+    ./acl_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.acl/parser.py b/tests/Functional.acl/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.acl/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.acl/spec.json b/tests/Functional.acl/spec.json
new file mode 100644
index 0000000..e3432a2
--- /dev/null
+++ b/tests/Functional.acl/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.acl",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.acl/test.yaml b/tests/Functional.acl/test.yaml
new file mode 100644
index 0000000..9959fb3
--- /dev/null
+++ b/tests/Functional.acl/test.yaml
@@ -0,0 +1,32 @@
+fuego_package_version: 1
+name: Functional.acl
+description: |
+      ACLs are a second level of discretionary permissions, that may override the standard ugo/rwx ones.
+      When used correctly they can grant you a better granularity in setting access to a file or a directory.
+      This is a simple test to check the commands of ACL.
+license: Unknown
+author: Wang Mingyu <wangmy@cn.fujitsu.com>
+maintainer: Tim Bird <tim.bird@sony.com>
+version: 1.00
+fuego_release: 1
+type: Functional
+tags: ['vlan']
+params:
+      DISK_DEV="the device file in your target board" Defined in board file
+      DISK_MEDIA="the mount point of device in your target board" Defined in board file
+data_files:
+ - acl_test.sh
+ - fuego_test.sh
+ - parser.py
+ - spec.json
+ - test.yaml
+ - tests
+    acl_chacl.sh
+    acl_getfacl1.sh
+    acl_getfacl2.sh
+    acl_getfacl3.sh
+    acl_setfacl1.sh
+    acl_setfacl2.sh
+    acl_setfacl3.sh
+    acl_setfacl4.sh
+    acl_setfacl5.sh
diff --git a/tests/Functional.acl/tests/acl_chacl.sh b/tests/Functional.acl/tests/acl_chacl.sh
new file mode 100644
index 0000000..df4fde5
--- /dev/null
+++ b/tests/Functional.acl/tests/acl_chacl.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+#  Create a new file and run getfacl to check the string "user:: RWX".
+test="chacl"
+
+modprobe brd
+yes | mke2fs -j $tst_acl_ram
+mkdir $tst_acl_media
+mount -t ext3 -o acl $tst_acl_ram $tst_acl_media
+touch $tst_acl_media/testfile
+chacl u::rwx,g::r-x,o::r-- $tst_acl_media/testfile
+if getfacl $tst_acl_media/testfile | grep "user::rwx"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f $tst_acl_media/testfile
+umount $tst_acl_media
+rm -rf $tst_acl_media
diff --git a/tests/Functional.acl/tests/acl_getfacl1.sh b/tests/Functional.acl/tests/acl_getfacl1.sh
new file mode 100644
index 0000000..5d183a6
--- /dev/null
+++ b/tests/Functional.acl/tests/acl_getfacl1.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Check the help message of command getfacl.
+# option: --help
+
+test="getfacl"
+
+if getfacl --help | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.acl/tests/acl_getfacl2.sh b/tests/Functional.acl/tests/acl_getfacl2.sh
new file mode 100644
index 0000000..c2daf9a
--- /dev/null
+++ b/tests/Functional.acl/tests/acl_getfacl2.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Create a new file with the target and execute setfacl (allow RW for user FTP) to execute getfacl to check output.
+test="getfacl2"
+
+modprobe brd
+yes | mke2fs -j $tst_acl_ram
+mkdir $tst_acl_media
+mount -t ext3 -o acl $tst_acl_ram $tst_acl_media
+touch $tst_acl_media/testfile
+setfacl -m u:ftp:rw $tst_acl_media/testfile
+if getfacl $tst_acl_media/testfile | grep "user:ftp"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f $tst_acl_media/testfile
+umount $tst_acl_media
+rm -rf $tst_acl_media
diff --git a/tests/Functional.acl/tests/acl_getfacl3.sh b/tests/Functional.acl/tests/acl_getfacl3.sh
new file mode 100644
index 0000000..0fdac59
--- /dev/null
+++ b/tests/Functional.acl/tests/acl_getfacl3.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# After a new file is created, and setfacl is executed, all the ACLS specified in the file are deleted, and getfacl is executed to check the output.
+test="getfacl3"
+
+yes | mke2fs -j /dev/ram
+mkdir /media/ram
+mount -t ext3 -o acl /dev/ram /media/ram
+touch /media/ram/testfile
+setfacl -m u:ftp:rw /media/ram/testfile
+setfacl -b /media/ram/testfile
+if getfacl /media/ram/testfile | grep "user::"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f /media/ram/testfile
+umount /media/ram
+rm -rf /media/ram
diff --git a/tests/Functional.acl/tests/acl_setfacl1.sh b/tests/Functional.acl/tests/acl_setfacl1.sh
new file mode 100644
index 0000000..00db23d
--- /dev/null
+++ b/tests/Functional.acl/tests/acl_setfacl1.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Check the help message of command setfacl.
+# option: --help
+
+test="setfacl1"
+
+if setfacl --help | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.acl/tests/acl_setfacl2.sh b/tests/Functional.acl/tests/acl_setfacl2.sh
new file mode 100644
index 0000000..ee72bb6
--- /dev/null
+++ b/tests/Functional.acl/tests/acl_setfacl2.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Create a new file with the target and execute setfacl (allow RW for user FTP) to verify the end of the operation.
+test="setfacl2"
+
+modprobe brd
+yes | mke2fs -j $tst_acl_ram
+mkdir $tst_acl_media
+mount -t ext3 -o acl $tst_acl_ram $tst_acl_media
+touch $tst_acl_media/testfile
+if setfacl -m u:ftp:rw $tst_acl_media/testfile
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f $tst_acl_media/testfile
+umount $tst_acl_media
+rm -rf $tst_acl_media
diff --git a/tests/Functional.acl/tests/acl_setfacl3.sh b/tests/Functional.acl/tests/acl_setfacl3.sh
new file mode 100644
index 0000000..44f6b3e
--- /dev/null
+++ b/tests/Functional.acl/tests/acl_setfacl3.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# After a new file is created by the target and setfacl is executed, delete the ACL specified in the file.
+test="setfacl3"
+
+yes | mke2fs -j /dev/ram
+mkdir /media/ram
+mount -t ext3 -o acl /dev/ram /media/ram
+touch /media/ram/testfile
+setfacl -m u:ftp:rw /media/ram/testfile
+if setfacl -x u:ftp /media/ram/testfile
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f /media/ram/testfile
+umount /media/ram
+rm -rf /media/ram
diff --git a/tests/Functional.acl/tests/acl_setfacl4.sh b/tests/Functional.acl/tests/acl_setfacl4.sh
new file mode 100644
index 0000000..2e03f72
--- /dev/null
+++ b/tests/Functional.acl/tests/acl_setfacl4.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Create a new file with the target and execute setfacl (allow r for group FTP).
+test="setfacl4"
+
+modprobe brd
+yes | mke2fs -j $tst_acl_ram
+mkdir $tst_acl_media
+mount -t ext3 -o acl $tst_acl_ram $tst_acl_media
+touch $tst_acl_media/testfile
+if setfacl -m g:ftp:r $tst_acl_media/testfile
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f /meida/ram/testfile
+umount $tst_acl_media
+rm -rf $tst_acl_media
diff --git a/tests/Functional.acl/tests/acl_setfacl5.sh b/tests/Functional.acl/tests/acl_setfacl5.sh
new file mode 100644
index 0000000..9ccf676
--- /dev/null
+++ b/tests/Functional.acl/tests/acl_setfacl5.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# After a new file is created by the target and setfacl is executed, delete all the ACLS specified in the file.
+test="setfacl5"
+
+yes | mke2fs -j /dev/ram
+mkdir /media/ram
+mount -t ext3 -o acl /dev/ram /media/ram
+touch /media/ram/testfile
+setfacl -m u:ftp:rw /media/ram/testfile
+if setfacl -b /media/ram/testfile
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f /media/ram/testfile
+umount /media/ram
+rm -rf /media/ram
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Fuego] [PATCH v3] samhain: Add test cases of command samhain.
  2019-04-09 13:02 [Fuego] [PATCH v2] cross_compilation: Add test cases for commands of cross_compilation Wang Mingyu
  2019-04-09 13:02 ` [Fuego] [PATCH v2] acl: Add test cases for commands of ACL Wang Mingyu
@ 2019-04-09 13:02 ` Wang Mingyu
  1 sibling, 0 replies; 3+ messages in thread
From: Wang Mingyu @ 2019-04-09 13:02 UTC (permalink / raw)
  To: fuego

Command samhain is used to check file integrity.
This test set is to check the initialization of the database of file signatures.
And check the filesystem against the database of file signatures.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.samhain/fuego_test.sh          | 20 ++++++++
 tests/Functional.samhain/parser.py              | 20 ++++++++
 tests/Functional.samhain/samhain_test.sh        |  4 ++
 tests/Functional.samhain/spec.json              |  6 +++
 tests/Functional.samhain/tests/samhain_check.sh | 64 +++++++++++++++++++++++++
 tests/Functional.samhain/tests/samhain_help.sh  | 13 +++++
 tests/Functional.samhain/tests/samhain_init.sh  | 49 +++++++++++++++++++
 7 files changed, 176 insertions(+)
 create mode 100644 tests/Functional.samhain/fuego_test.sh
 create mode 100644 tests/Functional.samhain/parser.py
 create mode 100644 tests/Functional.samhain/samhain_test.sh
 create mode 100644 tests/Functional.samhain/spec.json
 create mode 100644 tests/Functional.samhain/tests/samhain_check.sh
 create mode 100644 tests/Functional.samhain/tests/samhain_help.sh
 create mode 100644 tests/Functional.samhain/tests/samhain_init.sh

diff --git a/tests/Functional.samhain/fuego_test.sh b/tests/Functional.samhain/fuego_test.sh
new file mode 100644
index 0000000..186a74e
--- /dev/null
+++ b/tests/Functional.samhain/fuego_test.sh
@@ -0,0 +1,20 @@
+function test_pre_check {
+    assert_has_program samhain
+}
+
+function test_deploy {
+    put $TEST_HOME/samhain_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put $FUEGO_CORE/scripts/fuego_board_function_lib.sh $BOARD_TESTDIR/fuego.$TESTDIR
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export board=$BOARD_TESTDIR;\
+    export testdir=$TESTDIR;\
+    ./samhain_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.samhain/parser.py b/tests/Functional.samhain/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.samhain/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.samhain/samhain_test.sh b/tests/Functional.samhain/samhain_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.samhain/samhain_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.samhain/spec.json b/tests/Functional.samhain/spec.json
new file mode 100644
index 0000000..da029b3
--- /dev/null
+++ b/tests/Functional.samhain/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.samhain",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.samhain/tests/samhain_check.sh b/tests/Functional.samhain/tests/samhain_check.sh
new file mode 100644
index 0000000..b94263c
--- /dev/null
+++ b/tests/Functional.samhain/tests/samhain_check.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+#  In target, run command samhain.
+#  Check the filesystem against the database of file signatures.
+#  option: -t
+
+test="check"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+logger_service=$(detect_logger_service)
+
+cp /etc/samhainrc /etc/samhainrc_bak
+sed -i "s%dir = 99/usr%dir = 99$board/fuego.$testdir/test_dir/samhain_test%" /etc/samhainrc
+
+rm -fr /var/samhain/* /var/lib/samhain/*
+
+exec_service_on_target $logger_service stop
+if [ -f /var/log/syslog ]
+then
+    mv /var/log/syslog /var/log/syslog_bak
+fi
+
+exec_service_on_target $logger_service restart
+
+sleep 1
+
+mkdir -p test_dir/samhain_test/
+touch test_dir/samhain_test/test.txt
+
+samhain -t init -p info > /dev/null 2&> 1
+
+sleep 1
+
+echo test > test_dir/samhain_test/test.txt
+
+sleep 1
+
+if samhain -t check
+then
+    echo " -> samhain -t check succeeded."
+else
+    echo " -> $test: TEST-FAIL"
+    rm -fr test_dir
+    mv /etc/samhainrc_bak /etc/samhainrc
+    exit
+fi
+
+sleep 10
+
+if cat /var/log/syslog | grep "test_dir/samhain_test"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+rm -fr test_dir
+mv /etc/samhainrc_bak /etc/samhainrc
+if [ -f /var/log/syslog_bak ]
+then
+    mv /var/log/syslog_bak /var/log/syslog
+fi
diff --git a/tests/Functional.samhain/tests/samhain_help.sh b/tests/Functional.samhain/tests/samhain_help.sh
new file mode 100644
index 0000000..f16b680
--- /dev/null
+++ b/tests/Functional.samhain/tests/samhain_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command samhain.
+#  option: --help
+
+test="help"
+
+if samhain --help | grep "Usage"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.samhain/tests/samhain_init.sh b/tests/Functional.samhain/tests/samhain_init.sh
new file mode 100644
index 0000000..b15297d
--- /dev/null
+++ b/tests/Functional.samhain/tests/samhain_init.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+#  In target, run command samhain.
+#  Initialize the database of file signatures.
+#  option: -t
+
+test="init"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+logger_service=$(detect_logger_service)
+
+cp /etc/samhainrc /etc/samhainrc_bak
+sed -i "s%dir = 99/usr%dir = 99$board/fuego.$testdir/test_dir/samhain_test%" /etc/samhainrc
+
+rm -fr /var/samhain/* /var/lib/samhain/*
+
+exec_service_on_target $logger_service stop
+
+if [ -f /var/log/syslog ]
+then
+    mv /var/log/syslog /var/log/syslog_bak
+fi
+
+exec_service_on_target $logger_service restart
+
+sleep 1
+
+mkdir -p test_dir/samhain_test/
+touch test_dir/samhain_test/test.txt
+
+samhain -t init -p info > /dev/null 2&> 1
+
+sleep 1
+
+if cat /var/log/syslog | grep "ALRT.*-.*-.*T.*:.*:.*msg=\"EXIT\""
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+rm -fr test_dir
+mv /etc/samhainrc_bak /etc/samhainrc
+if [ -f /var/log/syslog_bak ]
+then
+    mv /var/log/syslog_bak /var/log/syslog
+fi
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-09 13:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-09 13:02 [Fuego] [PATCH v2] cross_compilation: Add test cases for commands of cross_compilation Wang Mingyu
2019-04-09 13:02 ` [Fuego] [PATCH v2] acl: Add test cases for commands of ACL Wang Mingyu
2019-04-09 13:02 ` [Fuego] [PATCH v3] samhain: Add test cases of command samhain Wang Mingyu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.