Return-Path: From: Wang Mingyu Date: Mon, 25 Mar 2019 02:19:20 -0700 Message-ID: <1553505567-3221-2-git-send-email-wangmy@cn.fujitsu.com> In-Reply-To: <1553505567-3221-1-git-send-email-wangmy@cn.fujitsu.com> References: <1553505567-3221-1-git-send-email-wangmy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Fuego] [PATCH v2] lm_sensors: Add test cases for commands of lm_sensors. List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fuego@lists.linuxfoundation.org This test set is used to monitor hardware and check the process of lm_sensors. Signed-off-by: Wang Mingyu --- tests/Functional.lm_sensors/fuego_test.sh | 19 ++++++ tests/Functional.lm_sensors/lm_sensors_test.sh | 4 ++ tests/Functional.lm_sensors/parser.py | 20 ++++++ tests/Functional.lm_sensors/spec.json | 6 ++ .../tests/lm_sensors_detect.sh | 51 ++++++++++++++++ .../Functional.lm_sensors/tests/lm_sensors_help.sh | 13 ++++ tests/Functional.lm_sensors/tests/lm_sensors_ps.sh | 71 ++++++++++++++++++++++ 7 files changed, 184 insertions(+) create mode 100644 tests/Functional.lm_sensors/fuego_test.sh create mode 100755 tests/Functional.lm_sensors/lm_sensors_test.sh create mode 100644 tests/Functional.lm_sensors/parser.py create mode 100644 tests/Functional.lm_sensors/spec.json create mode 100644 tests/Functional.lm_sensors/tests/lm_sensors_detect.sh create mode 100644 tests/Functional.lm_sensors/tests/lm_sensors_help.sh create mode 100644 tests/Functional.lm_sensors/tests/lm_sensors_ps.sh diff --git a/tests/Functional.lm_sensors/fuego_test.sh b/tests/Functional.lm_sensors/fuego_test.sh new file mode 100644 index 0000000..b514528 --- /dev/null +++ b/tests/Functional.lm_sensors/fuego_test.sh @@ -0,0 +1,19 @@ +function test_pre_check { + assert_has_program sensors + assert_has_program sensors-detect +} + +function test_deploy { + put $TEST_HOME/lm_sensors_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/ + put $FUEGO_CORE/scripts/fuego_board_function_lib.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/tests/Functional.lm_sensors/lm_sensors_test.sh b/tests/Functional.lm_sensors/lm_sensors_test.sh new file mode 100755 index 0000000..dd5ce37 --- /dev/null +++ b/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/tests/Functional.lm_sensors/parser.py b/tests/Functional.lm_sensors/parser.py new file mode 100644 index 0000000..f25a608 --- /dev/null +++ b/tests/Functional.lm_sensors/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.lm_sensors/spec.json b/tests/Functional.lm_sensors/spec.json new file mode 100644 index 0000000..d1afe34 --- /dev/null +++ b/tests/Functional.lm_sensors/spec.json @@ -0,0 +1,6 @@ +{ + "testName": "Functional.lm_sensors", + "specs": { + "default": {} + } +} diff --git a/tests/Functional.lm_sensors/tests/lm_sensors_detect.sh b/tests/Functional.lm_sensors/tests/lm_sensors_detect.sh new file mode 100644 index 0000000..0a60472 --- /dev/null +++ b/tests/Functional.lm_sensors/tests/lm_sensors_detect.sh @@ -0,0 +1,51 @@ +#!/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; diff --git a/tests/Functional.lm_sensors/tests/lm_sensors_help.sh b/tests/Functional.lm_sensors/tests/lm_sensors_help.sh new file mode 100644 index 0000000..7c27cbb --- /dev/null +++ b/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; diff --git a/tests/Functional.lm_sensors/tests/lm_sensors_ps.sh b/tests/Functional.lm_sensors/tests/lm_sensors_ps.sh new file mode 100644 index 0000000..9c51647 --- /dev/null +++ b/tests/Functional.lm_sensors/tests/lm_sensors_ps.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +# In the target start lm_sensors, and confirm the process condition by command ps. + +test="ps" + +. ./fuego_board_function_lib.sh + +set_init_manager + +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 + +sleep 5 + +service_status=$(get_service_status lm_sensors) +if exec_service_on_target lm_sensors start +then + echo " -> start of lm_sensors succeeded." +else + echo " -> start of lm_sensors failed." + echo " -> $test: TEST-FAIL" + exit +fi + +if exec_service_on_target lm_sensors stop +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi + +if [ "$service_status" = "active" -o "$service_status" = "unknown" ] +then + exec_service_on_target lm_sensors start +fi -- 1.8.3.1