[Fuego] [PATCH] cpufreq-info: Add test cases of command cpufreq-info.

Yuan Chao yuanc.fnst at cn.fujitsu.com
Tue Jun 4 06:47:00 UTC 2019


This is a simple test to check the option help/human/proc of command cpufreq-info.

Signed-off-by: Yuan Chao <yuanc.fnst at cn.fujitsu.com>
---
 tests/Functional.cpufreq-info/cpufreq-info_test.sh   |  4 ++++
 tests/Functional.cpufreq-info/fuego_test.sh          | 17 +++++++++++++++++
 tests/Functional.cpufreq-info/parser.py              | 20 ++++++++++++++++++++
 tests/Functional.cpufreq-info/spec.json              |  6 ++++++
 tests/Functional.cpufreq-info/test.yaml              | 19 +++++++++++++++++++
 .../tests/cpufreq-info_help.sh                       | 13 +++++++++++++
 .../tests/cpufreq-info_human.sh                      | 13 +++++++++++++
 .../tests/cpufreq-info_proc.sh                       | 13 +++++++++++++
 8 files changed, 105 insertions(+)
 create mode 100644 tests/Functional.cpufreq-info/cpufreq-info_test.sh
 create mode 100644 tests/Functional.cpufreq-info/fuego_test.sh
 create mode 100644 tests/Functional.cpufreq-info/parser.py
 create mode 100644 tests/Functional.cpufreq-info/spec.json
 create mode 100644 tests/Functional.cpufreq-info/test.yaml
 create mode 100644 tests/Functional.cpufreq-info/tests/cpufreq-info_help.sh
 create mode 100644 tests/Functional.cpufreq-info/tests/cpufreq-info_human.sh
 create mode 100644 tests/Functional.cpufreq-info/tests/cpufreq-info_proc.sh

diff --git a/tests/Functional.cpufreq-info/cpufreq-info_test.sh b/tests/Functional.cpufreq-info/cpufreq-info_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.cpufreq-info/cpufreq-info_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.cpufreq-info/fuego_test.sh b/tests/Functional.cpufreq-info/fuego_test.sh
new file mode 100644
index 0000000..44c74d6
--- /dev/null
+++ b/tests/Functional.cpufreq-info/fuego_test.sh
@@ -0,0 +1,17 @@
+function test_pre_check {
+    assert_has_program cpufreq-info
+}
+
+function test_deploy {
+    put $TEST_HOME/cpufreq-info_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./cpufreq-info_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.cpufreq-info/parser.py b/tests/Functional.cpufreq-info/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.cpufreq-info/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+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/tests/Functional.cpufreq-info/spec.json b/tests/Functional.cpufreq-info/spec.json
new file mode 100644
index 0000000..1b09662
--- /dev/null
+++ b/tests/Functional.cpufreq-info/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.cpufreq-info",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.cpufreq-info/test.yaml b/tests/Functional.cpufreq-info/test.yaml
new file mode 100644
index 0000000..9af91e8
--- /dev/null
+++ b/tests/Functional.cpufreq-info/test.yaml
@@ -0,0 +1,19 @@
+fuego_package_version: 1
+name: Functional.cpufreq-info
+description: |
+        Cpufreq-info a tool for retrieving cpufreq kernel information.
+        This is a simple test to check the option help/human/proc of command cpufreq-info.
+license: BSD-3-Clause
+author: Yuan Chao <yuanc.fnst at cn.fujitsu.com>
+maintainer: Wang Mingyu <wangmy at cn.fujitsu.com>
+version: 1.00
+fuego_release: 1
+type: Functional
+tags: ['cpu']
+data_files:
+ - cpufreq-info_test.sh
+ - fuego_test.sh
+ - parser.py
+ - spec.json
+ - test.yaml
+ - tests
diff --git a/tests/Functional.cpufreq-info/tests/cpufreq-info_help.sh b/tests/Functional.cpufreq-info/tests/cpufreq-info_help.sh
new file mode 100644
index 0000000..619d077
--- /dev/null
+++ b/tests/Functional.cpufreq-info/tests/cpufreq-info_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command cpufreq-info, and check if help option can execute.
+#  1) Option: -h
+
+test="cpufreq-info"
+
+if  cpufreq-info -h | grep "[uU]sage"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.cpufreq-info/tests/cpufreq-info_human.sh b/tests/Functional.cpufreq-info/tests/cpufreq-info_human.sh
new file mode 100644
index 0000000..421b8f0
--- /dev/null
+++ b/tests/Functional.cpufreq-info/tests/cpufreq-info_human.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command cpufreq-info, and check if print is human-readable output.
+#  1) Option: -m
+
+test="cpufreq-info"
+
+if  cpufreq-info -m | grep "analyzing"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.cpufreq-info/tests/cpufreq-info_proc.sh b/tests/Functional.cpufreq-info/tests/cpufreq-info_proc.sh
new file mode 100644
index 0000000..b46dce3
--- /dev/null
+++ b/tests/Functional.cpufreq-info/tests/cpufreq-info_proc.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command cpufreq-info, and check if proc option can execute.
+#  1) Option: -o
+
+test="cpufreq-info"
+
+if  cpufreq-info -o | grep "frequency"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
-- 
1.8.3.1





More information about the Fuego mailing list