[Fuego] [PATCH] m4: Add test cases for command m4.

Wang Mingyu wangmy at cn.fujitsu.com
Tue Sep 4 11:32:43 UTC 2018


Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.m4/fuego_test.sh  | 18 ++++++++++++++++++
 engine/tests/Functional.m4/m4_test.sh     |  4 ++++
 engine/tests/Functional.m4/parser.py      | 22 ++++++++++++++++++++++
 engine/tests/Functional.m4/spec.json      |  7 +++++++
 engine/tests/Functional.m4/tests/m4_01.sh | 13 +++++++++++++
 engine/tests/Functional.m4/tests/m4_02.sh | 19 +++++++++++++++++++
 6 files changed, 83 insertions(+)
 create mode 100644 engine/tests/Functional.m4/fuego_test.sh
 create mode 100644 engine/tests/Functional.m4/m4_test.sh
 create mode 100644 engine/tests/Functional.m4/parser.py
 create mode 100644 engine/tests/Functional.m4/spec.json
 create mode 100644 engine/tests/Functional.m4/tests/m4_01.sh
 create mode 100644 engine/tests/Functional.m4/tests/m4_02.sh

diff --git a/engine/tests/Functional.m4/fuego_test.sh b/engine/tests/Functional.m4/fuego_test.sh
new file mode 100644
index 0000000..bc9326f
--- /dev/null
+++ b/engine/tests/Functional.m4/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    is_on_target_path m4 PROGRAM_M4
+    assert_define PROGRAM_M4 "Missing 'm4' program on target board"
+}
+
+function test_deploy {
+    put $TEST_HOME/m4_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    sh -v m4_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.m4/m4_test.sh b/engine/tests/Functional.m4/m4_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.m4/m4_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.m4/parser.py b/engine/tests/Functional.m4/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.m4/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.m4/spec.json b/engine/tests/Functional.m4/spec.json
new file mode 100644
index 0000000..d891e82
--- /dev/null
+++ b/engine/tests/Functional.m4/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.m4",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.m4/tests/m4_01.sh b/engine/tests/Functional.m4/tests/m4_01.sh
new file mode 100644
index 0000000..0f77c17
--- /dev/null
+++ b/engine/tests/Functional.m4/tests/m4_01.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run comannd m4.
+#  option: --help
+
+test="m4_01"
+
+if m4 --help | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/engine/tests/Functional.m4/tests/m4_02.sh b/engine/tests/Functional.m4/tests/m4_02.sh
new file mode 100644
index 0000000..63a5b69
--- /dev/null
+++ b/engine/tests/Functional.m4/tests/m4_02.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+#  In target, run comannd m4.
+#  option: none
+
+test="m4_02"
+
+mkdir m4
+echo "define(\`STR', \`hello world')" > m4/m4.test
+echo "syscmd(\`echo' STR)" >> m4/m4.test
+
+if m4 m4/m4.test | grep "hello world"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+
+rm -fr m4
-- 
1.8.3.1





More information about the Fuego mailing list