[Fuego] [PATCH] Add test cases for command rpcbind.

Wang Mingyu wangmy at cn.fujitsu.com
Tue Aug 28 11:35:56 UTC 2018


Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.rpcbind/datas/testfunc.sh  | 13 ++++++++++++
 engine/tests/Functional.rpcbind/fuego_test.sh      | 22 +++++++++++++++++++++
 engine/tests/Functional.rpcbind/parser.py          | 22 +++++++++++++++++++++
 engine/tests/Functional.rpcbind/rpcbind_test.sh    |  4 ++++
 engine/tests/Functional.rpcbind/spec.json          |  7 +++++++
 .../Functional.rpcbind/tests/rpcbind_rpcinfo.sh    | 23 ++++++++++++++++++++++
 .../Functional.rpcbind/tests/rpcbind_status.sh     | 14 +++++++++++++
 7 files changed, 105 insertions(+)
 create mode 100644 engine/tests/Functional.rpcbind/datas/testfunc.sh
 create mode 100644 engine/tests/Functional.rpcbind/fuego_test.sh
 create mode 100644 engine/tests/Functional.rpcbind/parser.py
 create mode 100644 engine/tests/Functional.rpcbind/rpcbind_test.sh
 create mode 100644 engine/tests/Functional.rpcbind/spec.json
 create mode 100644 engine/tests/Functional.rpcbind/tests/rpcbind_rpcinfo.sh
 create mode 100644 engine/tests/Functional.rpcbind/tests/rpcbind_status.sh

diff --git a/engine/tests/Functional.rpcbind/datas/testfunc.sh b/engine/tests/Functional.rpcbind/datas/testfunc.sh
new file mode 100644
index 0000000..b13041c
--- /dev/null
+++ b/engine/tests/Functional.rpcbind/datas/testfunc.sh
@@ -0,0 +1,13 @@
+# $1: Used to determine whether the command line execution result is correct or not
+function exec_service_on_target {
+local service_name="$1"
+local action="$2"
+if [ "$init_manager" = "sysvinit" ]
+then 
+    $service_name $action
+elif [ "$init_manager" = "systemd" ]
+then
+    systemctl $action $service_name
+fi
+return
+}
diff --git a/engine/tests/Functional.rpcbind/fuego_test.sh b/engine/tests/Functional.rpcbind/fuego_test.sh
new file mode 100644
index 0000000..0f63055
--- /dev/null
+++ b/engine/tests/Functional.rpcbind/fuego_test.sh
@@ -0,0 +1,22 @@
+function test_pre_check {
+    is_on_target_path rpcbind PROGRAM_RPCBIND
+    assert_define PROGRAM_RPCBIND "Missing 'rpcbind' program on target board"
+    is_on_target_path rpcinfo PROGRAM_RPCINFO
+    assert_define PROGRAM_RPCINFO "Missing 'rpcinfo' program on target board"
+}
+
+function test_deploy {
+    put $TEST_HOME/rpcbind_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/datas $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export init_manager=systemd;\
+    sh -v rpcbind_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.rpcbind/parser.py b/engine/tests/Functional.rpcbind/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.rpcbind/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.rpcbind/rpcbind_test.sh b/engine/tests/Functional.rpcbind/rpcbind_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.rpcbind/rpcbind_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.rpcbind/spec.json b/engine/tests/Functional.rpcbind/spec.json
new file mode 100644
index 0000000..516c7c2
--- /dev/null
+++ b/engine/tests/Functional.rpcbind/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.rpcbind",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.rpcbind/tests/rpcbind_rpcinfo.sh b/engine/tests/Functional.rpcbind/tests/rpcbind_rpcinfo.sh
new file mode 100644
index 0000000..2d1aaa2
--- /dev/null
+++ b/engine/tests/Functional.rpcbind/tests/rpcbind_rpcinfo.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Verify that the rpcbind daemon can displays information.
+
+test="rpcinfo"
+
+source "datas/testfunc.sh"
+
+if exec_service_on_target rpcbind start
+then
+    echo " -> start of rpcbind succeeded."
+else
+    echo " -> start of rpcbind failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if rpcinfo -p 
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/engine/tests/Functional.rpcbind/tests/rpcbind_status.sh b/engine/tests/Functional.rpcbind/tests/rpcbind_status.sh
new file mode 100644
index 0000000..0ad831c
--- /dev/null
+++ b/engine/tests/Functional.rpcbind/tests/rpcbind_status.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Verify that the rpcbind daemon is started.
+
+test="status"
+
+source "datas/testfunc.sh"
+
+if exec_service_on_target rpcbind status | grep running
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
-- 
1.8.3.1





More information about the Fuego mailing list