[Fuego] [PATCH] Add test cases for commands of sysklogd.

Wang Mingyu wangmy at cn.fujitsu.com
Wed Nov 14 09:30:19 UTC 2018


sysklogd is Linux system logging utilities.
This test set is used to test the command klogd and syslogd of sysklogd.

Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.sysklogd/fuego_test.sh     | 18 ++++++++++++++++++
 engine/tests/Functional.sysklogd/parser.py         | 22 ++++++++++++++++++++++
 engine/tests/Functional.sysklogd/spec.json         |  7 +++++++
 engine/tests/Functional.sysklogd/sysklogd_test.sh  |  4 ++++
 .../Functional.sysklogd/tests/sysklogd_klogd.sh    | 16 ++++++++++++++++
 .../Functional.sysklogd/tests/sysklogd_syslogd.sh  | 12 ++++++++++++
 6 files changed, 79 insertions(+)
 create mode 100644 engine/tests/Functional.sysklogd/fuego_test.sh
 create mode 100644 engine/tests/Functional.sysklogd/parser.py
 create mode 100644 engine/tests/Functional.sysklogd/spec.json
 create mode 100755 engine/tests/Functional.sysklogd/sysklogd_test.sh
 create mode 100644 engine/tests/Functional.sysklogd/tests/sysklogd_klogd.sh
 create mode 100644 engine/tests/Functional.sysklogd/tests/sysklogd_syslogd.sh

diff --git a/engine/tests/Functional.sysklogd/fuego_test.sh b/engine/tests/Functional.sysklogd/fuego_test.sh
new file mode 100644
index 0000000..0ffaf5d
--- /dev/null
+++ b/engine/tests/Functional.sysklogd/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    assert_has_program klogd
+    assert_has_program logger
+}
+
+function test_deploy {
+    put $TEST_HOME/sysklogd_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./sysklogd_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.sysklogd/parser.py b/engine/tests/Functional.sysklogd/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.sysklogd/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.sysklogd/spec.json b/engine/tests/Functional.sysklogd/spec.json
new file mode 100644
index 0000000..68d9c00
--- /dev/null
+++ b/engine/tests/Functional.sysklogd/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.sysklogd",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.sysklogd/sysklogd_test.sh b/engine/tests/Functional.sysklogd/sysklogd_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.sysklogd/sysklogd_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.sysklogd/tests/sysklogd_klogd.sh b/engine/tests/Functional.sysklogd/tests/sysklogd_klogd.sh
new file mode 100644
index 0000000..bd056a0
--- /dev/null
+++ b/engine/tests/Functional.sysklogd/tests/sysklogd_klogd.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+#  In target, run command klogd.
+
+test="klogd"
+
+klogd
+
+if ps aux | grep [k]logd
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+
+killall klogd
diff --git a/engine/tests/Functional.sysklogd/tests/sysklogd_syslogd.sh b/engine/tests/Functional.sysklogd/tests/sysklogd_syslogd.sh
new file mode 100644
index 0000000..2d5db43
--- /dev/null
+++ b/engine/tests/Functional.sysklogd/tests/sysklogd_syslogd.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+#  In target, run command syslogd.
+
+test="syslogd"
+
+if logger "Log message"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
-- 
1.8.3.1





More information about the Fuego mailing list