[Fuego] [PATCH] Add test case of command iostat.

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


iostat is used to report CPU statistics and input/output statistics for devices, partitions and network filesystems.
This test set is used to check the option -C that can display the CPU utilization report or not.

Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.iostat/fuego_test.sh   | 17 +++++++++++++++++
 engine/tests/Functional.iostat/iostat_test.sh  |  4 ++++
 engine/tests/Functional.iostat/parser.py       | 22 ++++++++++++++++++++++
 engine/tests/Functional.iostat/spec.json       |  7 +++++++
 engine/tests/Functional.iostat/tests/iostat.sh | 12 ++++++++++++
 5 files changed, 62 insertions(+)
 create mode 100644 engine/tests/Functional.iostat/fuego_test.sh
 create mode 100755 engine/tests/Functional.iostat/iostat_test.sh
 create mode 100644 engine/tests/Functional.iostat/parser.py
 create mode 100644 engine/tests/Functional.iostat/spec.json
 create mode 100644 engine/tests/Functional.iostat/tests/iostat.sh

diff --git a/engine/tests/Functional.iostat/fuego_test.sh b/engine/tests/Functional.iostat/fuego_test.sh
new file mode 100644
index 0000000..7876707
--- /dev/null
+++ b/engine/tests/Functional.iostat/fuego_test.sh
@@ -0,0 +1,17 @@
+function test_pre_check {
+    assert_has_program iostat
+}
+
+function test_deploy {
+    put $TEST_HOME/iostat_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./iostat_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.iostat/iostat_test.sh b/engine/tests/Functional.iostat/iostat_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.iostat/iostat_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.iostat/parser.py b/engine/tests/Functional.iostat/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.iostat/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.iostat/spec.json b/engine/tests/Functional.iostat/spec.json
new file mode 100644
index 0000000..13c32d3
--- /dev/null
+++ b/engine/tests/Functional.iostat/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.iostat",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.iostat/tests/iostat.sh b/engine/tests/Functional.iostat/tests/iostat.sh
new file mode 100644
index 0000000..1b17381
--- /dev/null
+++ b/engine/tests/Functional.iostat/tests/iostat.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+#  In target, run command iostat.
+
+test="iostat"
+
+if iostat -c | grep "cpu"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
-- 
1.8.3.1





More information about the Fuego mailing list