[Fuego] [PATCH v2] batch: add test case for batch.

Tim.Bird at sony.com Tim.Bird at sony.com
Fri Nov 16 01:29:05 UTC 2018


See comments inline below:

> -----Original Message-----
> From: Zheng Ruoqin
>
There should be a description in the commit body, describing,
at least briefly, what the test does.
 
> Signed-off-by: Zheng Ruoqin <zhengrq.fnst at cn.fujitsu.com>
> ---
>  engine/tests/Functional.batch/batch.sh       |  4 ++++
>  engine/tests/Functional.batch/fuego_test.sh  | 20
> ++++++++++++++++++++
>  engine/tests/Functional.batch/parser.py      | 22
> ++++++++++++++++++++++
>  engine/tests/Functional.batch/spec.json      |  6 ++++++
>  engine/tests/Functional.batch/tests/batch.sh | 21
> +++++++++++++++++++++
>  5 files changed, 73 insertions(+)
>  create mode 100644 engine/tests/Functional.batch/batch.sh
>  create mode 100644 engine/tests/Functional.batch/fuego_test.sh
>  create mode 100644 engine/tests/Functional.batch/parser.py
>  create mode 100644 engine/tests/Functional.batch/spec.json
>  create mode 100644 engine/tests/Functional.batch/tests/batch.sh
> 
> diff --git a/engine/tests/Functional.batch/batch.sh
> b/engine/tests/Functional.batch/batch.sh
> new file mode 100644
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/engine/tests/Functional.batch/batch.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> diff --git a/engine/tests/Functional.batch/fuego_test.sh
> b/engine/tests/Functional.batch/fuego_test.sh
> new file mode 100644
> index 0000000..976d6fb
> --- /dev/null
> +++ b/engine/tests/Functional.batch/fuego_test.sh
> @@ -0,0 +1,20 @@
> +NEED_ROOT=1
> +
> +function test_pre_check {
> +    is_on_target_path batch PROGRAM_BATCH
> +    assert_define PROGRAM_BATCH "Missing 'batch' program on target
> board"

Should use assert_has_program here.

> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/batch.sh $BOARD_TESTDIR/fuego.$TESTDIR/
> +    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
> +}
> +
> +function test_run {
> +    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
> +    sh -v batch.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "1" "TEST-PASS" "p"
> +}
> diff --git a/engine/tests/Functional.batch/parser.py
> b/engine/tests/Functional.batch/parser.py
> new file mode 100644
> index 0000000..d85abd7
> --- /dev/null
> +++ b/engine/tests/Functional.batch/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.batch/spec.json
> b/engine/tests/Functional.batch/spec.json
> new file mode 100644
> index 0000000..7c3e1f5
> --- /dev/null
> +++ b/engine/tests/Functional.batch/spec.json
> @@ -0,0 +1,6 @@
> +{
> +    "testName": "Functional.batch",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> diff --git a/engine/tests/Functional.batch/tests/batch.sh
> b/engine/tests/Functional.batch/tests/batch.sh
> new file mode 100644
> index 0000000..47fbe26
> --- /dev/null
> +++ b/engine/tests/Functional.batch/tests/batch.sh
> @@ -0,0 +1,21 @@
> +#!/bin/sh
> +
> +# In target, run comannd batch.
comannd should be command.

> +# Ensure that batch can work normally.
> +
> +test="batch"
> +
> +expect <<-EOF
> +spawn batch
> +expect {
> + -re ".*at.*" {
> +           send_user " -> $test: batch executed.\n"
> +           send_user " -> $test: TEST-PASS\n"
> +          }
> + default { send_user " -> $test: TEST-FAIL\n" }

This is a fairly shallow test.  I would prefer something actually
executed a command, and checked that the command 
was performed.  It could be something simple like "echo batch test done >/tmp/batch_result"

It looks like this tests batch's interactive mode.  If expect
is required, you should have an assert_has_program for 'expect'.

> + }
> +send "\003\r"
> +send_user " -> $test: batch executed succeeded.\n"
> +expect eof
> +EOF
> +
> --
> 1.8.3.1

Please address these comments and re-submit.

Thanks,
 -- Tim




More information about the Fuego mailing list