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

Wang Mingyu wangmy at cn.fujitsu.com
Tue Oct 9 06:43:25 UTC 2018


Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.lm_sensors/fuego_test.sh   | 20 +++++++
 .../tests/Functional.lm_sensors/lm_sensors_test.sh |  4 ++
 engine/tests/Functional.lm_sensors/parser.py       | 22 ++++++++
 engine/tests/Functional.lm_sensors/spec.json       |  7 +++
 .../tests/lm_sensors_detect.sh                     | 61 ++++++++++++++++++++++
 .../Functional.lm_sensors/tests/lm_sensors_help.sh | 13 +++++
 6 files changed, 127 insertions(+)
 create mode 100644 engine/tests/Functional.lm_sensors/fuego_test.sh
 create mode 100755 engine/tests/Functional.lm_sensors/lm_sensors_test.sh
 create mode 100644 engine/tests/Functional.lm_sensors/parser.py
 create mode 100644 engine/tests/Functional.lm_sensors/spec.json
 create mode 100644 engine/tests/Functional.lm_sensors/tests/lm_sensors_detect.sh
 create mode 100644 engine/tests/Functional.lm_sensors/tests/lm_sensors_help.sh

diff --git a/engine/tests/Functional.lm_sensors/fuego_test.sh b/engine/tests/Functional.lm_sensors/fuego_test.sh
new file mode 100644
index 0000000..e48d012
--- /dev/null
+++ b/engine/tests/Functional.lm_sensors/fuego_test.sh
@@ -0,0 +1,20 @@
+function test_pre_check {
+    is_on_target_path sensors PROGRAM_SENSORS
+    assert_define PROGRAM_SENSORS "Missing 'sensors' program on target board"
+    is_on_target_path sensors-detect PROGRAM_SENSORSDETECT
+    assert_define PROGRAM_SENSORSDETECT "Missing 'sensors-detect' program on target board"
+}
+
+function test_deploy {
+    put $TEST_HOME/lm_sensors_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./lm_sensors_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.lm_sensors/lm_sensors_test.sh b/engine/tests/Functional.lm_sensors/lm_sensors_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.lm_sensors/lm_sensors_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.lm_sensors/parser.py b/engine/tests/Functional.lm_sensors/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.lm_sensors/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.lm_sensors/spec.json b/engine/tests/Functional.lm_sensors/spec.json
new file mode 100644
index 0000000..f1d295e
--- /dev/null
+++ b/engine/tests/Functional.lm_sensors/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.lm_sensors",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.lm_sensors/tests/lm_sensors_detect.sh b/engine/tests/Functional.lm_sensors/tests/lm_sensors_detect.sh
new file mode 100644
index 0000000..bd753a8
--- /dev/null
+++ b/engine/tests/Functional.lm_sensors/tests/lm_sensors_detect.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+#  In target, run command sensors-detect to scan hardware monitoring chips, or sensors.
+#  option: none
+
+test="sensors-detect"
+
+flag=0
+
+expect <<-EOF
+spawn sensors-detect
+expect {
+    -re ".*YES/no.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*YES/no/selectively.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*yes/NO/selectively.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*yes/NO.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*Just press ENTER to continue.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*root # " {
+        exp_send "\r"
+        if { $flag=0 } {
+            flag=1
+            exp_continue
+        }
+    }
+    timeout {
+        exp_send "\003\r"
+    }
+}
+EOF
+
+if sensors | grep "Adapter"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+
+expect <<-EOF
+spawn ssh 192.168.246.61
+expect {
+    ".*yes/no.*" {send "yes\r"; exp_continue}
+    ".*password.*" {send "123456\r"}
+}
+expect eof
+EOF
+
diff --git a/engine/tests/Functional.lm_sensors/tests/lm_sensors_help.sh b/engine/tests/Functional.lm_sensors/tests/lm_sensors_help.sh
new file mode 100644
index 0000000..7c27cbb
--- /dev/null
+++ b/engine/tests/Functional.lm_sensors/tests/lm_sensors_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command sensors.
+#  option: -h
+
+test="help"
+
+if sensors -h | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
-- 
1.8.3.1





More information about the Fuego mailing list