Return-Path: From: Wang Mingyu Date: Wed, 6 Mar 2019 02:07:43 -0800 Message-ID: <1551866866-130361-1-git-send-email-wangmy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Fuego] [PATCH v2] Add test case 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 --- tests/Functional.openct/fuego_test.sh | 19 +++++++++++ tests/Functional.openct/openct_test.sh | 4 +++ tests/Functional.openct/parser.py | 22 +++++++++++++ tests/Functional.openct/spec.json | 7 ++++ tests/Functional.openct/tests/openct_help.sh | 12 +++++++ tests/Functional.openct/tests/openct_status.sh | 44 ++++++++++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 tests/Functional.openct/fuego_test.sh create mode 100755 tests/Functional.openct/openct_test.sh create mode 100644 tests/Functional.openct/parser.py create mode 100644 tests/Functional.openct/spec.json create mode 100644 tests/Functional.openct/tests/openct_help.sh create mode 100644 tests/Functional.openct/tests/openct_status.sh diff --git a/tests/Functional.openct/fuego_test.sh b/tests/Functional.openct/fuego_test.sh new file mode 100644 index 0000000..55881e3 --- /dev/null +++ b/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/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/tests/Functional.openct/openct_test.sh b/tests/Functional.openct/openct_test.sh new file mode 100755 index 0000000..dd5ce37 --- /dev/null +++ b/tests/Functional.openct/openct_test.sh @@ -0,0 +1,4 @@ +#!/bin/sh +for i in tests/*.sh; do + sh $i +done diff --git a/tests/Functional.openct/parser.py b/tests/Functional.openct/parser.py new file mode 100644 index 0000000..d85abd7 --- /dev/null +++ b/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/tests/Functional.openct/spec.json b/tests/Functional.openct/spec.json new file mode 100644 index 0000000..e758b687 --- /dev/null +++ b/tests/Functional.openct/spec.json @@ -0,0 +1,7 @@ +{ + "testName": "Functional.openct", + "specs": { + "default": {} + } +} + diff --git a/tests/Functional.openct/tests/openct_help.sh b/tests/Functional.openct/tests/openct_help.sh new file mode 100644 index 0000000..e7f6c9f --- /dev/null +++ b/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/tests/Functional.openct/tests/openct_status.sh b/tests/Functional.openct/tests/openct_status.sh new file mode 100644 index 0000000..ce59cb7 --- /dev/null +++ b/tests/Functional.openct/tests/openct_status.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +# In the target start openct, and confirm the status. + +test="status" + +. ./fuego_board_function_lib.sh + +set_init_manager + +service_status=$(get_service_status openct) + +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 systemctl is-active openct + then + echo " -> $test: TEST-PASS" + else + echo " -> $test: TEST-FAIL" + fi +else + if service openct status | grep "Waiting for reader attach/detach events" + then + echo " -> $test: TEST-PASS" + else + echo " -> $test: TEST-FAIL" + fi +fi + +if [ "$service_status" = "inactive" ] +then + exec_service_on_target openct stop +fi -- 1.8.3.1