[Fuego] [PATCH] Add test cases of command setserial.

Wang Mingyu wangmy at cn.fujitsu.com
Wed Nov 28 15:47:41 UTC 2018


The command setserial is used to get/set Linux serial port information.
This test set checks help message of setserial and print all the configuration information of the serial port.

Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.setserial/fuego_test.sh    | 17 +++++++++++++++++
 engine/tests/Functional.setserial/parser.py        | 22 ++++++++++++++++++++++
 .../tests/Functional.setserial/setserial_test.sh   |  4 ++++
 engine/tests/Functional.setserial/spec.json        |  7 +++++++
 .../Functional.setserial/tests/setserial_help.sh   | 16 ++++++++++++++++
 .../Functional.setserial/tests/setserial_show.sh   | 21 +++++++++++++++++++++
 6 files changed, 87 insertions(+)
 create mode 100644 engine/tests/Functional.setserial/fuego_test.sh
 create mode 100644 engine/tests/Functional.setserial/parser.py
 create mode 100755 engine/tests/Functional.setserial/setserial_test.sh
 create mode 100644 engine/tests/Functional.setserial/spec.json
 create mode 100644 engine/tests/Functional.setserial/tests/setserial_help.sh
 create mode 100644 engine/tests/Functional.setserial/tests/setserial_show.sh

diff --git a/engine/tests/Functional.setserial/fuego_test.sh b/engine/tests/Functional.setserial/fuego_test.sh
new file mode 100644
index 0000000..3480ad9
--- /dev/null
+++ b/engine/tests/Functional.setserial/fuego_test.sh
@@ -0,0 +1,17 @@
+function test_pre_check {
+    assert_has_program setserial
+}
+
+function test_deploy {
+    put $TEST_HOME/setserial_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./setserial_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.setserial/parser.py b/engine/tests/Functional.setserial/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.setserial/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.setserial/setserial_test.sh b/engine/tests/Functional.setserial/setserial_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.setserial/setserial_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.setserial/spec.json b/engine/tests/Functional.setserial/spec.json
new file mode 100644
index 0000000..958c978
--- /dev/null
+++ b/engine/tests/Functional.setserial/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.setserial",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.setserial/tests/setserial_help.sh b/engine/tests/Functional.setserial/tests/setserial_help.sh
new file mode 100644
index 0000000..9ebb47b
--- /dev/null
+++ b/engine/tests/Functional.setserial/tests/setserial_help.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+#  In target, run comannd setserial.
+#  To make sure that there is string "usage" in output.
+#  option: --help
+
+test="help"
+
+setserial --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.setserial/tests/setserial_show.sh b/engine/tests/Functional.setserial/tests/setserial_show.sh
new file mode 100644
index 0000000..fa47385
--- /dev/null
+++ b/engine/tests/Functional.setserial/tests/setserial_show.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+#  In target, run comannd setserial.
+#  option: -g, -a
+
+test="show"
+
+if setserial -g /dev/ttyS0 | grep "Port"
+then
+    echo " -> the arguments to setserial are interpreted."
+else
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if setserial -g -a /dev/ttyS0 | grep "Port"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
-- 
1.8.3.1





More information about the Fuego mailing list