Return-Path: From: Wang Mingyu Date: Mon, 25 Mar 2019 02:19:26 -0700 Message-ID: <1553505567-3221-8-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] powertop: Add test cases for command powertop. 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 analyze power consumption and show help message of command powertop. Signed-off-by: Wang Mingyu --- tests/Functional.powertop/fuego_test.sh | 17 +++++++++++++++++ tests/Functional.powertop/parser.py | 20 ++++++++++++++++++++ tests/Functional.powertop/powertop_test.sh | 4 ++++ tests/Functional.powertop/spec.json | 6 ++++++ tests/Functional.powertop/tests/powertop_csv.sh | 13 +++++++++++++ tests/Functional.powertop/tests/powertop_help.sh | 13 +++++++++++++ 6 files changed, 73 insertions(+) create mode 100644 tests/Functional.powertop/fuego_test.sh create mode 100644 tests/Functional.powertop/parser.py create mode 100755 tests/Functional.powertop/powertop_test.sh create mode 100644 tests/Functional.powertop/spec.json create mode 100644 tests/Functional.powertop/tests/powertop_csv.sh create mode 100644 tests/Functional.powertop/tests/powertop_help.sh diff --git a/tests/Functional.powertop/fuego_test.sh b/tests/Functional.powertop/fuego_test.sh new file mode 100644 index 0000000..377fc62 --- /dev/null +++ b/tests/Functional.powertop/fuego_test.sh @@ -0,0 +1,17 @@ +function test_pre_check { + assert_has_program powertop +} + +function test_deploy { + put $TEST_HOME/powertop_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/ + put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/ +} + +function test_run { + report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\ + ./powertop_test.sh" +} + +function test_processing { + log_compare "$TESTDIR" "0" "TEST-FAIL" "n" +} diff --git a/tests/Functional.powertop/parser.py b/tests/Functional.powertop/parser.py new file mode 100644 index 0000000..f25a608 --- /dev/null +++ b/tests/Functional.powertop/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.powertop/powertop_test.sh b/tests/Functional.powertop/powertop_test.sh new file mode 100755 index 0000000..dd5ce37 --- /dev/null +++ b/tests/Functional.powertop/powertop_test.sh @@ -0,0 +1,4 @@ +#!/bin/sh +for i in tests/*.sh; do + sh $i +done diff --git a/tests/Functional.powertop/spec.json b/tests/Functional.powertop/spec.json new file mode 100644 index 0000000..3c5e680 --- /dev/null +++ b/tests/Functional.powertop/spec.json @@ -0,0 +1,6 @@ +{ + "testName": "Functional.powertop", + "specs": { + "default": {} + } +} diff --git a/tests/Functional.powertop/tests/powertop_csv.sh b/tests/Functional.powertop/tests/powertop_csv.sh new file mode 100644 index 0000000..9199a89 --- /dev/null +++ b/tests/Functional.powertop/tests/powertop_csv.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# In target, run command powertop. +# option: --csv + +test="csv" + +if powertop --csv --time=1 | grep powertop +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; diff --git a/tests/Functional.powertop/tests/powertop_help.sh b/tests/Functional.powertop/tests/powertop_help.sh new file mode 100644 index 0000000..5128289 --- /dev/null +++ b/tests/Functional.powertop/tests/powertop_help.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# In target, run command powertop. +# option: --help + +test="help" + +if powertop --help | grep Usage +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; -- 1.8.3.1