Return-Path: From: Wang Mingyu Date: Wed, 9 Jan 2019 01:45:06 -0800 Message-ID: <1547027108-2222-1-git-send-email-wangmy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Fuego] [PATCH] Add test cases of service openct. List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fuego@lists.linuxfoundation.org OpenCT implements drivers for several smart card readers. This test set is used to check the command openct-tool and openct-control of service openct. Signed-off-by: Wang Mingyu --- engine/tests/Functional.openct/fuego_test.sh | 19 ++++++++++ engine/tests/Functional.openct/openct_test.sh | 4 ++ engine/tests/Functional.openct/parser.py | 22 +++++++++++ engine/tests/Functional.openct/spec.json | 7 ++++ .../tests/Functional.openct/tests/openct_help.sh | 12 ++++++ engine/tests/Functional.openct/tests/openct_ps.sh | 44 ++++++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 engine/tests/Functional.openct/fuego_test.sh create mode 100755 engine/tests/Functional.openct/openct_test.sh create mode 100644 engine/tests/Functional.openct/parser.py create mode 100644 engine/tests/Functional.openct/spec.json create mode 100644 engine/tests/Functional.openct/tests/openct_help.sh create mode 100644 engine/tests/Functional.openct/tests/openct_ps.sh diff --git a/engine/tests/Functional.openct/fuego_test.sh b/engine/tests/Functional.openct/fuego_test.sh new file mode 100644 index 0000000..e008fdf --- /dev/null +++ b/engine/tests/Functional.openct/fuego_test.sh @@ -0,0 +1,19 @@ +function test_pre_check { + assert_has_program openct-control + assert_has_program openct-tool +} + +function test_deploy { + put $TEST_HOME/openct_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/ + put $FUEGO_CORE/engine/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;\ + ./openct_test.sh" +} + +function test_processing { + log_compare "$TESTDIR" "0" "TEST-FAIL" "n" +} diff --git a/engine/tests/Functional.openct/openct_test.sh b/engine/tests/Functional.openct/openct_test.sh new file mode 100755 index 0000000..dd5ce37 --- /dev/null +++ b/engine/tests/Functional.openct/openct_test.sh @@ -0,0 +1,4 @@ +#!/bin/sh +for i in tests/*.sh; do + sh $i +done diff --git a/engine/tests/Functional.openct/parser.py b/engine/tests/Functional.openct/parser.py new file mode 100644 index 0000000..d85abd7 --- /dev/null +++ b/engine/tests/Functional.openct/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.openct/spec.json b/engine/tests/Functional.openct/spec.json new file mode 100644 index 0000000..e758b68 --- /dev/null +++ b/engine/tests/Functional.openct/spec.json @@ -0,0 +1,7 @@ +{ + "testName": "Functional.openct", + "specs": { + "default": {} + } +} + diff --git a/engine/tests/Functional.openct/tests/openct_help.sh b/engine/tests/Functional.openct/tests/openct_help.sh new file mode 100644 index 0000000..e7f6c9f --- /dev/null +++ b/engine/tests/Functional.openct/tests/openct_help.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# Check the help message of command openct-control. + +test="help" + +if openct-control -h | grep "usage" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi diff --git a/engine/tests/Functional.openct/tests/openct_ps.sh b/engine/tests/Functional.openct/tests/openct_ps.sh new file mode 100644 index 0000000..cbb8ab4 --- /dev/null +++ b/engine/tests/Functional.openct/tests/openct_ps.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +# In the target start openct, and confirm the process condition by command ps. + +test="ps" + +. ./fuego_board_function_lib.sh + +set_init_manager + +service_status=$(exec_service_on_target openct is-active) + +exec_service_on_target openct stop + +if exec_service_on_target openct start +then + echo " -> start of openct succeeded." +else + echo " -> start of openct failed." + echo " -> $test: TEST-FAIL" + exit +fi + +if [ "$init_manager" = "systemd" ] +then + if exec_service_on_target openct is-active + then + echo " -> $test: TEST-PASS" + else + echo " -> $test: TEST-FAIL" + fi +else + if exec_service_on_target openct status | grep "Waiting for reader attach/detach events" + then + echo " -> $test: TEST-PASS" + else + echo " -> $test: TEST-FAIL" + fi +fi + +if [ $service_status != "active" ] +then + exec_service_on_target openct stop +fi -- 1.8.3.1