[Fuego] [PATCH v2] Add test cases of service tcsd.

Tim.Bird at sony.com Tim.Bird at sony.com
Fri Nov 9 04:48:37 UTC 2018



> -----Original Message-----
> From: Wang Mingyu
> 
> The tcsd is a user space daemon that manages Trusted Computing resources.
> This test set is used to check if the service tcsd can be started.
Thanks for the explanation, as requested.

It would be nice to know why this test is called 'trousers',
but oh well.

> 
> Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
> ---
>  engine/tests/Functional.trousers/fuego_test.sh     | 18
> ++++++++++++++++++
>  engine/tests/Functional.trousers/parser.py         | 22
> ++++++++++++++++++++++
>  engine/tests/Functional.trousers/spec.json         |  7 +++++++
>  .../Functional.trousers/tests/trousers_help.sh     | 15 +++++++++++++++
>  .../Functional.trousers/tests/trousers_start.sh    | 18 ++++++++++++++++++
>  engine/tests/Functional.trousers/trousers_test.sh  |  4 ++++
>  6 files changed, 84 insertions(+)
>  create mode 100644 engine/tests/Functional.trousers/fuego_test.sh
>  create mode 100644 engine/tests/Functional.trousers/parser.py
>  create mode 100644 engine/tests/Functional.trousers/spec.json
>  create mode 100644
> engine/tests/Functional.trousers/tests/trousers_help.sh
>  create mode 100644
> engine/tests/Functional.trousers/tests/trousers_start.sh
>  create mode 100755 engine/tests/Functional.trousers/trousers_test.sh
> 
> diff --git a/engine/tests/Functional.trousers/fuego_test.sh
> b/engine/tests/Functional.trousers/fuego_test.sh
> new file mode 100644
> index 0000000..d8627f7
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/fuego_test.sh
> @@ -0,0 +1,18 @@
> +function test_pre_check {
> +    assert_has_program tcsd
> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/trousers_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;\
> +    ./trousers_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/engine/tests/Functional.trousers/parser.py
> b/engine/tests/Functional.trousers/parser.py
> new file mode 100644
> index 0000000..d85abd7
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/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.trousers/spec.json
> b/engine/tests/Functional.trousers/spec.json
> new file mode 100644
> index 0000000..668c438
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/spec.json
> @@ -0,0 +1,7 @@
> +{
> +    "testName": "Functional.trousers",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> +
> diff --git a/engine/tests/Functional.trousers/tests/trousers_help.sh
> b/engine/tests/Functional.trousers/tests/trousers_help.sh
> new file mode 100644
> index 0000000..41a6a5d
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/tests/trousers_help.sh
> @@ -0,0 +1,15 @@
> +#!/bin/sh
> +
> +#  In target, run command tcsd.
> +#  option: -h
> +
> +test="help"
> +
> +tcsd --help > log 2>&1
> +if cat log | grep "usage"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +rm log
> diff --git a/engine/tests/Functional.trousers/tests/trousers_start.sh
> b/engine/tests/Functional.trousers/tests/trousers_start.sh
> new file mode 100644
> index 0000000..d85c532
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/tests/trousers_start.sh
> @@ -0,0 +1,18 @@
> +#!/bin/sh
> +
> +#  In target, start the service tcsd.
> +
> +test="start"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +exec_service_on_target tcsd stop
> +
> +if exec_service_on_target tcsd start
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> diff --git a/engine/tests/Functional.trousers/trousers_test.sh
> b/engine/tests/Functional.trousers/trousers_test.sh
> new file mode 100755
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/engine/tests/Functional.trousers/trousers_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> --
> 1.8.3.1

Thanks for the fixups.

Applied.
 -- Tim



More information about the Fuego mailing list