All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fuego] [PATCH v2] Add test cases of command samhain.
@ 2018-11-06 13:56 Wang Mingyu
  2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases of command vconfig Wang Mingyu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Wang Mingyu @ 2018-11-06 13:56 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>
---
 engine/tests/Functional.samhain/fuego_test.sh      | 17 ++++++++
 engine/tests/Functional.samhain/parser.py          | 22 ++++++++++
 engine/tests/Functional.samhain/samhain_test.sh    |  4 ++
 engine/tests/Functional.samhain/spec.json          |  7 ++++
 .../Functional.samhain/tests/samhain_check.sh      | 48 ++++++++++++++++++++++
 .../tests/Functional.samhain/tests/samhain_help.sh | 13 ++++++
 .../tests/Functional.samhain/tests/samhain_init.sh | 32 +++++++++++++++
 7 files changed, 143 insertions(+)
 create mode 100644 engine/tests/Functional.samhain/fuego_test.sh
 create mode 100644 engine/tests/Functional.samhain/parser.py
 create mode 100755 engine/tests/Functional.samhain/samhain_test.sh
 create mode 100644 engine/tests/Functional.samhain/spec.json
 create mode 100644 engine/tests/Functional.samhain/tests/samhain_check.sh
 create mode 100644 engine/tests/Functional.samhain/tests/samhain_help.sh
 create mode 100644 engine/tests/Functional.samhain/tests/samhain_init.sh

diff --git a/engine/tests/Functional.samhain/fuego_test.sh b/engine/tests/Functional.samhain/fuego_test.sh
new file mode 100644
index 0000000..cb35d2b
--- /dev/null
+++ b/engine/tests/Functional.samhain/fuego_test.sh
@@ -0,0 +1,17 @@
+function test_pre_check {
+    assert_has_program samhain
+}
+
+function test_deploy {
+    put $TEST_HOME/samhain_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./samhain_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.samhain/parser.py b/engine/tests/Functional.samhain/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.samhain/parser.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+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/engine/tests/Functional.samhain/samhain_test.sh b/engine/tests/Functional.samhain/samhain_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.samhain/samhain_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.samhain/spec.json b/engine/tests/Functional.samhain/spec.json
new file mode 100644
index 0000000..5e2f023
--- /dev/null
+++ b/engine/tests/Functional.samhain/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.samhain",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.samhain/tests/samhain_check.sh b/engine/tests/Functional.samhain/tests/samhain_check.sh
new file mode 100644
index 0000000..4689135
--- /dev/null
+++ b/engine/tests/Functional.samhain/tests/samhain_check.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+#  In target, run command samhain.
+#  Check the filesystem against the database of file signatures.
+#  option: -t
+
+test="check"
+
+cp /etc/samhainrc /etc/samhainrc_bak
+sed -i 's/dir = 99\/usr/dir = 99$BOARD_TESTDIR\/fuego.$TESTDIR\/test_dir\/samhain_test/' /etc/samhainrc
+
+rm -fr /var/samhain/*
+rm -f /var/log/samhain_log
+
+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 2
+
+if cat /var/log/samhain_log | grep "path=</home/test/samhain_test/test.txt>, size_old=<0>, size_new=<5>"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+rm -fr test_dir
+mv /etc/samhainrc_bak /etc/samhainrc
diff --git a/engine/tests/Functional.samhain/tests/samhain_help.sh b/engine/tests/Functional.samhain/tests/samhain_help.sh
new file mode 100644
index 0000000..f16b680
--- /dev/null
+++ b/engine/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/engine/tests/Functional.samhain/tests/samhain_init.sh b/engine/tests/Functional.samhain/tests/samhain_init.sh
new file mode 100644
index 0000000..e46515b
--- /dev/null
+++ b/engine/tests/Functional.samhain/tests/samhain_init.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#  In target, run command samhain.
+#  Initialize the database of file signatures.
+#  option: -t
+
+test="init"
+
+cp /etc/samhainrc /etc/samhainrc_bak
+sed -i 's/dir = 99\/usr/dir = 99$BOARD_TESTDIR\/fuego.$TESTDIR\/test_dir\/samhain_test/' /etc/samhainrc
+
+rm -fr /var/samhain/*
+rm -f /var/log/samhain_log
+
+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/samhain_log | grep "ALRT.*-.*-.*T.*:.*:.*msg=\"EXIT\""
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+rm -fr test_dir/samhain_test
+mv /etc/samhainrc_bak /etc/samhainrc
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] Add test cases of command vconfig.
  2018-11-06 13:56 [Fuego] [PATCH v2] Add test cases of command samhain Wang Mingyu
@ 2018-11-06 13:56 ` Wang Mingyu
  2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases of service tcsd Wang Mingyu
  2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases for commands of at Wang Mingyu
  2 siblings, 0 replies; 5+ messages in thread
From: Wang Mingyu @ 2018-11-06 13:56 UTC (permalink / raw)
  To: fuego

Command vconfig is VLAN (802.1q) configuration program.
This test set is used to check the option add/rem/set_flag of vconfig.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 engine/tests/Functional.vconfig/fuego_test.sh      | 22 +++++++++++++++
 engine/tests/Functional.vconfig/parser.py          | 22 +++++++++++++++
 engine/tests/Functional.vconfig/spec.json          |  7 +++++
 engine/tests/Functional.vconfig/test.yaml          | 31 ++++++++++++++++++++++
 .../Functional.vconfig/tests/vconfig_VLAN_tag.sh   | 29 ++++++++++++++++++++
 .../tests/Functional.vconfig/tests/vconfig_add.sh  | 16 +++++++++++
 .../Functional.vconfig/tests/vconfig_addaddr.sh    | 17 ++++++++++++
 .../tests/Functional.vconfig/tests/vconfig_help.sh | 13 +++++++++
 .../Functional.vconfig/tests/vconfig_remove.sh     | 15 +++++++++++
 .../Functional.vconfig/tests/vconfig_set_flag.sh   | 16 +++++++++++
 engine/tests/Functional.vconfig/vconfig_test.sh    |  4 +++
 11 files changed, 192 insertions(+)
 create mode 100644 engine/tests/Functional.vconfig/fuego_test.sh
 create mode 100644 engine/tests/Functional.vconfig/parser.py
 create mode 100644 engine/tests/Functional.vconfig/spec.json
 create mode 100644 engine/tests/Functional.vconfig/test.yaml
 create mode 100644 engine/tests/Functional.vconfig/tests/vconfig_VLAN_tag.sh
 create mode 100644 engine/tests/Functional.vconfig/tests/vconfig_add.sh
 create mode 100644 engine/tests/Functional.vconfig/tests/vconfig_addaddr.sh
 create mode 100644 engine/tests/Functional.vconfig/tests/vconfig_help.sh
 create mode 100644 engine/tests/Functional.vconfig/tests/vconfig_remove.sh
 create mode 100644 engine/tests/Functional.vconfig/tests/vconfig_set_flag.sh
 create mode 100755 engine/tests/Functional.vconfig/vconfig_test.sh

diff --git a/engine/tests/Functional.vconfig/fuego_test.sh b/engine/tests/Functional.vconfig/fuego_test.sh
new file mode 100644
index 0000000..a73fdca
--- /dev/null
+++ b/engine/tests/Functional.vconfig/fuego_test.sh
@@ -0,0 +1,22 @@
+function test_pre_check {
+    assert_has_program vconfig
+    assert_has_program tcpdump
+    assert_has_program ping
+}
+
+function test_deploy {
+    put $TEST_HOME/vconfig_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 vcon_ifeth=$IFETH;\
+    export vcon_ip1=$VLAN_IP1;\
+    export vcon_ip2=$VLAN_IP2;\
+    ./vconfig_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.vconfig/parser.py b/engine/tests/Functional.vconfig/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.vconfig/parser.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+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/engine/tests/Functional.vconfig/spec.json b/engine/tests/Functional.vconfig/spec.json
new file mode 100644
index 0000000..e45af81
--- /dev/null
+++ b/engine/tests/Functional.vconfig/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.vconfig",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.vconfig/test.yaml b/engine/tests/Functional.vconfig/test.yaml
new file mode 100644
index 0000000..e7cded3
--- /dev/null
+++ b/engine/tests/Functional.vconfig/test.yaml
@@ -0,0 +1,31 @@
+fuego_package_version: 1
+name: Functional.vconfig
+description: |
+      The vconfig program allows you to create and remove vlan-devices on a vlan enabled kernel. 
+      Vlan-devices are virtual ethernet devices which represents the virtual lans on the physical lan.
+      This is a simple test to check the option help/add/rem/set_flag
+      of command vconfig.
+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:
+      IFETH="the eth interface in your target board" Defined in board file
+      VLAN_IP1="IP address configured for eth interface" Defined in board file
+      VLAN_IP2="IP address which the eth to access" Defined in board file
+data_files:
+ - vconfig_test.sh
+ - fuego_test.sh
+ - parser.py
+ - spec.json
+ - test.yaml
+ - tests
+   vconfig_addaddr.sh
+   vconfig_add.sh
+   vconfig_help.sh
+   vconfig_remove.sh
+   vconfig_set_flag.sh
+   vconfig_VLAN_tag.sh
diff --git a/engine/tests/Functional.vconfig/tests/vconfig_VLAN_tag.sh b/engine/tests/Functional.vconfig/tests/vconfig_VLAN_tag.sh
new file mode 100644
index 0000000..ffc5dc7
--- /dev/null
+++ b/engine/tests/Functional.vconfig/tests/vconfig_VLAN_tag.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+#  In target, run command vconfig.
+#  option: add/rem
+
+test="VLAN_tag"
+
+mkdir test_dir
+
+ifconfig $vcon_ifeth up
+vconfig add $vcon_ifeth 100
+
+# specify the address to vlanif by ifconfig. 
+ifconfig $vcon_ifeth.100 inet $vcon_ip1 netmask 0xffffff00
+
+# to verify the IP address exists and can accept requests.
+ping -q -c 50 -I $vcon_ifeth.100 $vcon_ip2 &
+
+# check the VLAN tag by tcpdump.
+tcpdump -c 10 -ex -i $vcon_ifeth ether broadcast > test_dir/dumpdata
+
+if cat test_dir/dumpdata | grep "vlan 100"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -fr test_dir
+vconfig rem $vcon_ifeth.100
diff --git a/engine/tests/Functional.vconfig/tests/vconfig_add.sh b/engine/tests/Functional.vconfig/tests/vconfig_add.sh
new file mode 100644
index 0000000..1e2da17
--- /dev/null
+++ b/engine/tests/Functional.vconfig/tests/vconfig_add.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+#  In target, run command vconfig.
+#  option: add
+
+test="add"
+
+vconfig add $vcon_ifeth 4
+
+if ifconfig $vcon_ifeth.4 | grep "$vcon_ifeth.4"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+vconfig rem $vcon_ifeth.4
diff --git a/engine/tests/Functional.vconfig/tests/vconfig_addaddr.sh b/engine/tests/Functional.vconfig/tests/vconfig_addaddr.sh
new file mode 100644
index 0000000..c434e19
--- /dev/null
+++ b/engine/tests/Functional.vconfig/tests/vconfig_addaddr.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+#  In target, run command vconfig.
+#  option: add/rem
+
+test="addaddr"
+
+vconfig add $vcon_ifeth 100
+ifconfig $vcon_ifeth.100 inet 192.168.255.1 netmask 0xffffff00
+
+if ifconfig $vcon_ifeth.100 | grep "192.168.255.1"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+vconfig rem $vcon_ifeth.100
diff --git a/engine/tests/Functional.vconfig/tests/vconfig_help.sh b/engine/tests/Functional.vconfig/tests/vconfig_help.sh
new file mode 100644
index 0000000..43314f3
--- /dev/null
+++ b/engine/tests/Functional.vconfig/tests/vconfig_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command vconfig.
+#  option: none
+
+test="help"
+
+if vconfig | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/engine/tests/Functional.vconfig/tests/vconfig_remove.sh b/engine/tests/Functional.vconfig/tests/vconfig_remove.sh
new file mode 100644
index 0000000..76a1047
--- /dev/null
+++ b/engine/tests/Functional.vconfig/tests/vconfig_remove.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  In target, run command vconfig.
+#  option: rem
+
+test="remove"
+
+vconfig add $vcon_ifeth 4
+
+if vconfig rem $vcon_ifeth.4 | grep "Removed VLAN"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/engine/tests/Functional.vconfig/tests/vconfig_set_flag.sh b/engine/tests/Functional.vconfig/tests/vconfig_set_flag.sh
new file mode 100644
index 0000000..9194278
--- /dev/null
+++ b/engine/tests/Functional.vconfig/tests/vconfig_set_flag.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+#  In target, run command vconfig.
+#  option: set_flag
+
+test="set_flag"
+
+vconfig add $vcon_ifeth 4
+
+if vconfig set_flag $vcon_ifeth.4 1 | grep "Set flag on device"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+vconfig rem $vcon_ifeth.4
diff --git a/engine/tests/Functional.vconfig/vconfig_test.sh b/engine/tests/Functional.vconfig/vconfig_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.vconfig/vconfig_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] Add test cases of service tcsd.
  2018-11-06 13:56 [Fuego] [PATCH v2] Add test cases of command samhain Wang Mingyu
  2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases of command vconfig Wang Mingyu
@ 2018-11-06 13:56 ` Wang Mingyu
  2018-11-09  4:48   ` Tim.Bird
  2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases for commands of at Wang Mingyu
  2 siblings, 1 reply; 5+ messages in thread
From: Wang Mingyu @ 2018-11-06 13:56 UTC (permalink / raw)
  To: fuego

The tcsd is a user space daemon that manages Trusted Computing resources.
This test set is used to check if the service tcsd can be started.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 engine/tests/Functional.trousers/fuego_test.sh     | 18 ++++++++++++++++++
 engine/tests/Functional.trousers/parser.py         | 22 ++++++++++++++++++++++
 engine/tests/Functional.trousers/spec.json         |  7 +++++++
 .../Functional.trousers/tests/trousers_help.sh     | 15 +++++++++++++++
 .../Functional.trousers/tests/trousers_start.sh    | 18 ++++++++++++++++++
 engine/tests/Functional.trousers/trousers_test.sh  |  4 ++++
 6 files changed, 84 insertions(+)
 create mode 100644 engine/tests/Functional.trousers/fuego_test.sh
 create mode 100644 engine/tests/Functional.trousers/parser.py
 create mode 100644 engine/tests/Functional.trousers/spec.json
 create mode 100644 engine/tests/Functional.trousers/tests/trousers_help.sh
 create mode 100644 engine/tests/Functional.trousers/tests/trousers_start.sh
 create mode 100755 engine/tests/Functional.trousers/trousers_test.sh

diff --git a/engine/tests/Functional.trousers/fuego_test.sh b/engine/tests/Functional.trousers/fuego_test.sh
new file mode 100644
index 0000000..d8627f7
--- /dev/null
+++ b/engine/tests/Functional.trousers/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    assert_has_program tcsd
+}
+
+function test_deploy {
+    put $TEST_HOME/trousers_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put $FUEGO_CORE/engine/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;\
+    ./trousers_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.trousers/parser.py b/engine/tests/Functional.trousers/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.trousers/parser.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+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/engine/tests/Functional.trousers/spec.json b/engine/tests/Functional.trousers/spec.json
new file mode 100644
index 0000000..668c438
--- /dev/null
+++ b/engine/tests/Functional.trousers/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.trousers",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.trousers/tests/trousers_help.sh b/engine/tests/Functional.trousers/tests/trousers_help.sh
new file mode 100644
index 0000000..41a6a5d
--- /dev/null
+++ b/engine/tests/Functional.trousers/tests/trousers_help.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  In target, run command tcsd.
+#  option: -h
+
+test="help"
+
+tcsd --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/engine/tests/Functional.trousers/tests/trousers_start.sh b/engine/tests/Functional.trousers/tests/trousers_start.sh
new file mode 100644
index 0000000..d85c532
--- /dev/null
+++ b/engine/tests/Functional.trousers/tests/trousers_start.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+#  In target, start the service tcsd.
+
+test="start"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target tcsd stop
+
+if exec_service_on_target tcsd start
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/engine/tests/Functional.trousers/trousers_test.sh b/engine/tests/Functional.trousers/trousers_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.trousers/trousers_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] Add test cases for commands of at.
  2018-11-06 13:56 [Fuego] [PATCH v2] Add test cases of command samhain Wang Mingyu
  2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases of command vconfig Wang Mingyu
  2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases of service tcsd Wang Mingyu
@ 2018-11-06 13:56 ` Wang Mingyu
  2 siblings, 0 replies; 5+ messages in thread
From: Wang Mingyu @ 2018-11-06 13:56 UTC (permalink / raw)
  To: fuego

commands list:
  at
  atq
  atrm

This test set is to check the service atd and command at/atq/atrm
that if they can examine or delete jobs for later execution successfully.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 engine/tests/Functional.at/at_test.sh              |  4 ++
 engine/tests/Functional.at/data/at_no.allow        |  2 +
 engine/tests/Functional.at/data/at_no.deny         |  0
 engine/tests/Functional.at/data/at_test.allow      |  2 +
 engine/tests/Functional.at/data/at_test.deny       |  2 +
 engine/tests/Functional.at/data/test_add.sh        |  3 +
 engine/tests/Functional.at/fuego_test.sh           | 23 ++++++++
 engine/tests/Functional.at/parser.py               | 22 +++++++
 engine/tests/Functional.at/spec.json               |  7 +++
 engine/tests/Functional.at/tests/atd_allow_deny.sh | 44 ++++++++++++++
 .../Functional.at/tests/atd_allow_deny_no_user.sh  | 45 ++++++++++++++
 .../tests/Functional.at/tests/atd_allow_no_user.sh | 43 ++++++++++++++
 engine/tests/Functional.at/tests/atd_atq.sh        | 39 +++++++++++++
 engine/tests/Functional.at/tests/atd_atrm.sh       | 39 +++++++++++++
 .../tests/Functional.at/tests/atd_deny_no_user.sh  | 43 ++++++++++++++
 engine/tests/Functional.at/tests/atd_job.sh        | 68 ++++++++++++++++++++++
 engine/tests/Functional.at/tests/atd_pidfile.sh    | 55 +++++++++++++++++
 engine/tests/Functional.at/tests/atd_ps.sh         | 51 ++++++++++++++++
 engine/tests/Functional.at/tests/atd_syslog.sh     | 49 ++++++++++++++++
 19 files changed, 541 insertions(+)
 create mode 100755 engine/tests/Functional.at/at_test.sh
 create mode 100644 engine/tests/Functional.at/data/at_no.allow
 create mode 100644 engine/tests/Functional.at/data/at_no.deny
 create mode 100644 engine/tests/Functional.at/data/at_test.allow
 create mode 100644 engine/tests/Functional.at/data/at_test.deny
 create mode 100755 engine/tests/Functional.at/data/test_add.sh
 create mode 100644 engine/tests/Functional.at/fuego_test.sh
 create mode 100644 engine/tests/Functional.at/parser.py
 create mode 100644 engine/tests/Functional.at/spec.json
 create mode 100644 engine/tests/Functional.at/tests/atd_allow_deny.sh
 create mode 100644 engine/tests/Functional.at/tests/atd_allow_deny_no_user.sh
 create mode 100644 engine/tests/Functional.at/tests/atd_allow_no_user.sh
 create mode 100644 engine/tests/Functional.at/tests/atd_atq.sh
 create mode 100644 engine/tests/Functional.at/tests/atd_atrm.sh
 create mode 100644 engine/tests/Functional.at/tests/atd_deny_no_user.sh
 create mode 100644 engine/tests/Functional.at/tests/atd_job.sh
 create mode 100644 engine/tests/Functional.at/tests/atd_pidfile.sh
 create mode 100644 engine/tests/Functional.at/tests/atd_ps.sh
 create mode 100644 engine/tests/Functional.at/tests/atd_syslog.sh

diff --git a/engine/tests/Functional.at/at_test.sh b/engine/tests/Functional.at/at_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.at/at_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.at/data/at_no.allow b/engine/tests/Functional.at/data/at_no.allow
new file mode 100644
index 0000000..139597f
--- /dev/null
+++ b/engine/tests/Functional.at/data/at_no.allow
@@ -0,0 +1,2 @@
+
+
diff --git a/engine/tests/Functional.at/data/at_no.deny b/engine/tests/Functional.at/data/at_no.deny
new file mode 100644
index 0000000..e69de29
diff --git a/engine/tests/Functional.at/data/at_test.allow b/engine/tests/Functional.at/data/at_test.allow
new file mode 100644
index 0000000..cf79c53
--- /dev/null
+++ b/engine/tests/Functional.at/data/at_test.allow
@@ -0,0 +1,2 @@
+test_for_fuego
+
diff --git a/engine/tests/Functional.at/data/at_test.deny b/engine/tests/Functional.at/data/at_test.deny
new file mode 100644
index 0000000..cf79c53
--- /dev/null
+++ b/engine/tests/Functional.at/data/at_test.deny
@@ -0,0 +1,2 @@
+test_for_fuego
+
diff --git a/engine/tests/Functional.at/data/test_add.sh b/engine/tests/Functional.at/data/test_add.sh
new file mode 100755
index 0000000..3fb66d4
--- /dev/null
+++ b/engine/tests/Functional.at/data/test_add.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+/usr/bin/logger -i "hello fuego autotest! from at"
diff --git a/engine/tests/Functional.at/fuego_test.sh b/engine/tests/Functional.at/fuego_test.sh
new file mode 100644
index 0000000..6d523c9
--- /dev/null
+++ b/engine/tests/Functional.at/fuego_test.sh
@@ -0,0 +1,23 @@
+function test_pre_check {
+    assert_has_program at
+    assert_has_program atq
+    assert_has_program atrm
+    assert_has_program useradd
+    assert_has_program userdel
+}
+
+function test_deploy {
+    put $TEST_HOME/at_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put $FUEGO_CORE/engine/scripts/fuego_board_function_lib.sh $BOARD_TESTDIR/fuego.$TESTDIR
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./at_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.at/parser.py b/engine/tests/Functional.at/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.at/parser.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+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/engine/tests/Functional.at/spec.json b/engine/tests/Functional.at/spec.json
new file mode 100644
index 0000000..2a9d359
--- /dev/null
+++ b/engine/tests/Functional.at/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.at",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.at/tests/atd_allow_deny.sh b/engine/tests/Functional.at/tests/atd_allow_deny.sh
new file mode 100644
index 0000000..21c930e
--- /dev/null
+++ b/engine/tests/Functional.at/tests/atd_allow_deny.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+#  In the target start atd, check the operation allow and deny.
+
+test="allow_deny"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target atd stop
+
+if exec_service_on_target atd start
+then
+    echo " -> start atd succeeded."
+else
+    echo " -> start atd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+cp data/at_test.allow /etc/at.allow
+cp data/at_test.deny /etc/at.deny
+
+useradd test_for_fuego
+cp data/test_add.sh /home/test_for_fuego/
+
+su - test_for_fuego -c "at -f /home/test_for_fuego/test_add.sh now + 5 minutes" > log 2>&1
+if cat log | grep "job"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm log
+
+sleep 5
+
+rm -fr /home/test_for_fuego
+userdel -f test_for_fuego
+rm -f /etc/at.allow
+rm -f /etc/at.deny
+at -d $(at -l | cut -b 1-2)
+exec_service_on_target atd stop
diff --git a/engine/tests/Functional.at/tests/atd_allow_deny_no_user.sh b/engine/tests/Functional.at/tests/atd_allow_deny_no_user.sh
new file mode 100644
index 0000000..9040e93
--- /dev/null
+++ b/engine/tests/Functional.at/tests/atd_allow_deny_no_user.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+#  In the target start atd, check the operation if no user .
+
+test="allow_deny_no_user"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target atd stop
+
+if exec_service_on_target atd start
+then
+    echo " -> start atd succeeded."
+else
+    echo " -> start atd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+cp data/at_no.allow /etc/at.allow
+cp data/at_no.deny /etc/at.deny
+
+useradd test_for_fuego
+cp data/test_add.sh /home/test_for_fuego/
+
+su - test_for_fuego -c "at -f /home/test_for_fuego/test_add.sh now + 5 minutes || echo error" > log 2>&1
+if cat log | grep "error"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm log
+
+sleep 5
+
+rm -fr /home/test_for_fuego
+userdel -f test_for_fuego
+rm -f /etc/at.allow
+rm -f /etc/at.deny
+at -d $(at -l | cut -b 1-2)
+
+exec_service_on_target atd stop
diff --git a/engine/tests/Functional.at/tests/atd_allow_no_user.sh b/engine/tests/Functional.at/tests/atd_allow_no_user.sh
new file mode 100644
index 0000000..e368ee5
--- /dev/null
+++ b/engine/tests/Functional.at/tests/atd_allow_no_user.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#  In the target start atd, check the operation if no user .
+
+test="allow_no_user"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target atd stop
+
+if exec_service_on_target atd start
+then
+    echo " -> start atd succeeded."
+else
+    echo " -> start atd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+cp data/at_no.allow /etc/at.allow
+
+useradd test_for_fuego
+cp data/test_add.sh /home/test_for_fuego/
+
+su - test_for_fuego -c "at -f /home/test_for_fuego/test_add.sh now + 5 minutes || echo error" > log 2>&1
+if cat log | grep "error"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm log
+
+sleep 5
+
+rm -fr /home/test_for_fuego
+userdel -f test_for_fuego
+rm -f /etc/at.allow
+at -d $(at -l | cut -b 1-2)
+
+exec_service_on_target atd stop
diff --git a/engine/tests/Functional.at/tests/atd_atq.sh b/engine/tests/Functional.at/tests/atd_atq.sh
new file mode 100644
index 0000000..aefe284
--- /dev/null
+++ b/engine/tests/Functional.at/tests/atd_atq.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+#  In the target start atd, check the status of job.
+
+test="atq"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target atd stop
+
+if exec_service_on_target atd start
+then
+    echo " -> start atd succeeded."
+else
+    echo " -> start atd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+mkdir test_dir
+cp data/test_add.sh test_dir/
+
+at -f test_dir/test_add.sh now + 5 minutes
+
+if atq
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> list job failed."
+    echo " -> $test: TEST-FAIL"
+fi
+
+rm -fr test_dir
+
+at -d $(at -l | cut -b 1-2)
+
+exec_service_on_target atd stop
diff --git a/engine/tests/Functional.at/tests/atd_atrm.sh b/engine/tests/Functional.at/tests/atd_atrm.sh
new file mode 100644
index 0000000..f23a94d
--- /dev/null
+++ b/engine/tests/Functional.at/tests/atd_atrm.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+#  In the target start atd, check the status of job.
+
+test="atrm"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target atd stop
+
+if exec_service_on_target atd start
+then
+    echo " -> start atd succeeded."
+else
+    echo " -> start atd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+mkdir test_dir
+cp data/test_add.sh test_dir/
+
+at -f test_dir/test_add.sh now + 5 minutes
+
+if atrm $(at -l | cut -b 1-2)
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> remove the job failed."
+    echo " -> $test: TEST-FAIL"
+fi
+
+rm -fr test_dir
+
+at -d $(at -l | cut -b 1-2)
+
+exec_service_on_target atd stop
diff --git a/engine/tests/Functional.at/tests/atd_deny_no_user.sh b/engine/tests/Functional.at/tests/atd_deny_no_user.sh
new file mode 100644
index 0000000..13ebae8
--- /dev/null
+++ b/engine/tests/Functional.at/tests/atd_deny_no_user.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#  In the target start atd, check the operation if no user .
+
+test="deny_no_user"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target atd stop
+
+if exec_service_on_target atd start
+then
+    echo " -> start atd succeeded."
+else
+    echo " -> start atd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+cp data/at_no.deny /etc/at.deny
+
+useradd test_for_fuego
+cp data/test_add.sh /home/test_for_fuego/
+
+su - test_for_fuego -c "at -f /home/test_for_fuego/test_add.sh now + 5 minutes" > log 2>&1
+if cat log | grep "job"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm log
+
+sleep 5
+
+rm -fr /home/test_for_fuego
+userdel -f test_for_fuego
+rm -f /etc/at.deny
+at -d $(at -l | cut -b 1-2)
+
+exec_service_on_target atd stop
diff --git a/engine/tests/Functional.at/tests/atd_job.sh b/engine/tests/Functional.at/tests/atd_job.sh
new file mode 100644
index 0000000..ce8078f
--- /dev/null
+++ b/engine/tests/Functional.at/tests/atd_job.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+#  In the target start atd, check the operation of add, list and remove job.
+
+test="job"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target atd stop
+
+if exec_service_on_target atd start
+then
+    echo " -> start atd succeeded."
+else
+    echo " -> start atd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+mkdir test_dir
+cp data/test_add.sh test_dir/
+
+if at -f test_dir/test_add.sh now + 5 minutes
+then
+    echo " -> add job succeeded."
+else
+    echo " -> add job failed."
+    echo " -> $test: TEST-FAIL"
+    rm -fr test_dir
+    exec_service_on_target atd stop
+    exit
+fi
+
+if at -c $(at -l | cut -b 1-2) | grep "fuego autotest"
+then
+    echo " -> cats the jobs listed on the command line succeeded."
+else
+    echo " -> cats the jobs listed on the command line failed."
+    echo " -> $test: TEST-FAIL"
+    rm -fr test_dir
+    exec_service_on_target atd stop
+    exit
+fi
+
+if at -l
+then
+    echo " -> list job succeeded."
+else
+    echo " -> list job failed."
+    echo " -> $test: TEST-FAIL"
+    rm -fr test_dir
+    exec_service_on_target atd stop
+    exit
+fi
+
+rm -fr test_dir
+
+if at -d $(at -l | cut -b 1-2)
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> remove job failed."
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target atd stop
diff --git a/engine/tests/Functional.at/tests/atd_pidfile.sh b/engine/tests/Functional.at/tests/atd_pidfile.sh
new file mode 100644
index 0000000..3e4d191
--- /dev/null
+++ b/engine/tests/Functional.at/tests/atd_pidfile.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+#  In the target start atd, and check if the /var/run/atd.pid is exist.
+
+test="pidfile"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target atd stop
+
+if [ -f /var/run/atd.pid ]
+then
+    rm -f /var/run/atd.pid
+fi
+
+if exec_service_on_target atd start
+then
+    echo " -> start atd succeeded."
+else
+    echo " -> start atd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+sleep 5
+
+if ls /var/run/atd.pid
+then
+    echo " -> /var/run/atd.pid exists."
+else
+    echo " -> /var/run/atd.pid dose not exist."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target atd stop
+    exit
+fi
+
+if exec_service_on_target atd stop
+then
+    echo " -> stop atd succeeded."
+else
+    echo " -> stop atd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+sleep 5
+
+if test -f /var/run/atd.pid
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
diff --git a/engine/tests/Functional.at/tests/atd_ps.sh b/engine/tests/Functional.at/tests/atd_ps.sh
new file mode 100644
index 0000000..57674c3
--- /dev/null
+++ b/engine/tests/Functional.at/tests/atd_ps.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+#  In the target start atd, and confirm the process condition by command ps.
+#  check the keyword "atd".
+
+test="ps"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target atd stop
+
+if exec_service_on_target atd start
+then
+    echo " -> start atd succeeded."
+else
+    echo " -> start atd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+sleep 5
+
+if ps -N a | grep "[/]usr/sbin/atd"
+then
+    echo " -> get the pid of atd."
+else
+    echo " -> can't get the pid of atd."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target atd stop
+    exit
+fi
+
+if exec_service_on_target atd stop
+then
+    echo " -> stop atd succeeded."
+else
+    echo " -> stop atd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+sleep 5
+
+if ps -N a | grep "[/]usr/sbin/atd"
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
diff --git a/engine/tests/Functional.at/tests/atd_syslog.sh b/engine/tests/Functional.at/tests/atd_syslog.sh
new file mode 100644
index 0000000..ddf9794
--- /dev/null
+++ b/engine/tests/Functional.at/tests/atd_syslog.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+#  In the target start atd, add job and verify job completion.
+#  Check the syslog string "fuego autotest".
+
+test="syslog"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+logger_service=$(detect_logger_service)
+
+exec_service_on_target $logger_service stop
+exec_service_on_target atd stop
+
+if [ -f /var/log/syslog ]
+then
+    mv /var/log/syslog /var/log/syslog_bak
+fi
+exec_service_on_target $logger_service restart
+
+if exec_service_on_target atd start
+then
+    echo " -> start atd succeeded."
+else
+    echo " -> start atd failed."
+fi
+
+mkdir test_dir
+cp data/test_add.sh test_dir/
+
+at -f test_dir/test_add.sh now + 1 minutes
+
+echo "sleep 60s!"
+sleep 60
+
+if cat /var/log/syslog | grep "hello fuego autotest"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+rm -fr test_dir
+
+at -d $(at -l | cut -b 1-2)
+exec_service_on_target atd stop
+exec_service_on_target $logger_service stop
-- 
1.8.3.1




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

* Re: [Fuego] [PATCH v2] Add test cases of service tcsd.
  2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases of service tcsd Wang Mingyu
@ 2018-11-09  4:48   ` Tim.Bird
  0 siblings, 0 replies; 5+ messages in thread
From: Tim.Bird @ 2018-11-09  4:48 UTC (permalink / raw)
  To: wangmy, fuego



> -----Original Message-----
> From: Wang Mingyu
> 
> The tcsd is a user space daemon that manages Trusted Computing resources.
> This test set is used to check if the service tcsd can be started.
Thanks for the explanation, as requested.

It would be nice to know why this test is called 'trousers',
but oh well.

> 
> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> ---
>  engine/tests/Functional.trousers/fuego_test.sh     | 18
> ++++++++++++++++++
>  engine/tests/Functional.trousers/parser.py         | 22
> ++++++++++++++++++++++
>  engine/tests/Functional.trousers/spec.json         |  7 +++++++
>  .../Functional.trousers/tests/trousers_help.sh     | 15 +++++++++++++++
>  .../Functional.trousers/tests/trousers_start.sh    | 18 ++++++++++++++++++
>  engine/tests/Functional.trousers/trousers_test.sh  |  4 ++++
>  6 files changed, 84 insertions(+)
>  create mode 100644 engine/tests/Functional.trousers/fuego_test.sh
>  create mode 100644 engine/tests/Functional.trousers/parser.py
>  create mode 100644 engine/tests/Functional.trousers/spec.json
>  create mode 100644
> engine/tests/Functional.trousers/tests/trousers_help.sh
>  create mode 100644
> engine/tests/Functional.trousers/tests/trousers_start.sh
>  create mode 100755 engine/tests/Functional.trousers/trousers_test.sh
> 
> diff --git a/engine/tests/Functional.trousers/fuego_test.sh
> b/engine/tests/Functional.trousers/fuego_test.sh
> new file mode 100644
> index 0000000..d8627f7
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/fuego_test.sh
> @@ -0,0 +1,18 @@
> +function test_pre_check {
> +    assert_has_program tcsd
> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/trousers_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
> +    put $FUEGO_CORE/engine/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;\
> +    ./trousers_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/engine/tests/Functional.trousers/parser.py
> b/engine/tests/Functional.trousers/parser.py
> new file mode 100644
> index 0000000..d85abd7
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/parser.py
> @@ -0,0 +1,22 @@
> +#!/usr/bin/python
> +# See common.py for description of command-line arguments
> +
> +import os, sys, collections
> +
> +sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
> +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/engine/tests/Functional.trousers/spec.json
> b/engine/tests/Functional.trousers/spec.json
> new file mode 100644
> index 0000000..668c438
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/spec.json
> @@ -0,0 +1,7 @@
> +{
> +    "testName": "Functional.trousers",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> +
> diff --git a/engine/tests/Functional.trousers/tests/trousers_help.sh
> b/engine/tests/Functional.trousers/tests/trousers_help.sh
> new file mode 100644
> index 0000000..41a6a5d
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/tests/trousers_help.sh
> @@ -0,0 +1,15 @@
> +#!/bin/sh
> +
> +#  In target, run command tcsd.
> +#  option: -h
> +
> +test="help"
> +
> +tcsd --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/engine/tests/Functional.trousers/tests/trousers_start.sh
> b/engine/tests/Functional.trousers/tests/trousers_start.sh
> new file mode 100644
> index 0000000..d85c532
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/tests/trousers_start.sh
> @@ -0,0 +1,18 @@
> +#!/bin/sh
> +
> +#  In target, start the service tcsd.
> +
> +test="start"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +exec_service_on_target tcsd stop
> +
> +if exec_service_on_target tcsd start
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> diff --git a/engine/tests/Functional.trousers/trousers_test.sh
> b/engine/tests/Functional.trousers/trousers_test.sh
> new file mode 100755
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/trousers_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> --
> 1.8.3.1

Thanks for the fixups.

Applied.
 -- Tim


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

end of thread, other threads:[~2018-11-09  4:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06 13:56 [Fuego] [PATCH v2] Add test cases of command samhain Wang Mingyu
2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases of command vconfig Wang Mingyu
2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases of service tcsd Wang Mingyu
2018-11-09  4:48   ` Tim.Bird
2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases for commands of at 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.