[Fuego] [PATCH] Add test cases of command vconfig.

Tim.Bird at sony.com Tim.Bird at sony.com
Wed Oct 31 18:31:12 UTC 2018


Please see comments inline below:

> -----Original Message-----
> From: Wang Mingyu
>
There is no description in the commit message.  The body of the
commit message should not be empty. Please at least describe
the test a little bit here.

 
> Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
> ---
>  engine/tests/Functional.vconfig/fuego_test.sh      | 19
> ++++++++++++++++++
>  engine/tests/Functional.vconfig/parser.py          | 22
> +++++++++++++++++++++
>  engine/tests/Functional.vconfig/spec.json          |  7 +++++++
>  .../Functional.vconfig/tests/vconfig_VLAN_tag.sh   | 23
> ++++++++++++++++++++++
>  .../tests/Functional.vconfig/tests/vconfig_add.sh  | 16 +++++++++++++++
>  .../Functional.vconfig/tests/vconfig_addaddr.sh    | 17 ++++++++++++++++
>  .../tests/Functional.vconfig/tests/vconfig_help.sh | 13 ++++++++++++
>  .../Functional.vconfig/tests/vconfig_remove.sh     | 15 ++++++++++++++
>  .../Functional.vconfig/tests/vconfig_set_flag.sh   | 16 +++++++++++++++
>  engine/tests/Functional.vconfig/vconfig_test.sh    |  4 ++++
>  10 files changed, 152 insertions(+)
>  create mode 100644 engine/tests/Functional.vconfig/fuego_test.sh
>  create mode 100644 engine/tests/Functional.vconfig/parser.py
>  create mode 100644 engine/tests/Functional.vconfig/spec.json
>  create mode 100644
> engine/tests/Functional.vconfig/tests/vconfig_VLAN_tag.sh
>  create mode 100644 engine/tests/Functional.vconfig/tests/vconfig_add.sh
>  create mode 100644
> engine/tests/Functional.vconfig/tests/vconfig_addaddr.sh
>  create mode 100644 engine/tests/Functional.vconfig/tests/vconfig_help.sh
>  create mode 100644
> engine/tests/Functional.vconfig/tests/vconfig_remove.sh
>  create mode 100644
> engine/tests/Functional.vconfig/tests/vconfig_set_flag.sh
>  create mode 100755 engine/tests/Functional.vconfig/vconfig_test.sh
> 
> diff --git a/engine/tests/Functional.vconfig/fuego_test.sh
> b/engine/tests/Functional.vconfig/fuego_test.sh
> new file mode 100644
> index 0000000..cda39c7
> --- /dev/null
> +++ b/engine/tests/Functional.vconfig/fuego_test.sh
> @@ -0,0 +1,19 @@
> +function test_pre_check {
> +    is_on_target_path vconfig PROGRAM_VCONFIG
> +    assert_define PROGRAM_VCONFIG "Missing 'vconfig' program on target
> board"
Should be:
assert_has_program vconfig

> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/vconfig_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
> +    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
> +}
> +
> +function test_run {
> +    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
> +    export vcon_remote_ifeth=$IFETH;\
Where does $IFETH come from?

If the test requires a variable defined in the board file, then this
should be documented in a test.yaml file.

> +    ./vconfig_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/engine/tests/Functional.vconfig/parser.py
> b/engine/tests/Functional.vconfig/parser.py
> new file mode 100644
> index 0000000..d85abd7
> --- /dev/null
> +++ b/engine/tests/Functional.vconfig/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))
I'm still interested in adding a generic parser for this.

But that will likely have to wait until we do an overhaul of the parser
code for the 1.5 release.

> diff --git a/engine/tests/Functional.vconfig/spec.json
> b/engine/tests/Functional.vconfig/spec.json
> new file mode 100644
> index 0000000..e45af81
> --- /dev/null
> +++ b/engine/tests/Functional.vconfig/spec.json
> @@ -0,0 +1,7 @@
> +{
> +    "testName": "Functional.vconfig",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> +
> diff --git a/engine/tests/Functional.vconfig/tests/vconfig_VLAN_tag.sh
> b/engine/tests/Functional.vconfig/tests/vconfig_VLAN_tag.sh
> new file mode 100644
> index 0000000..14d1b86
> --- /dev/null
> +++ b/engine/tests/Functional.vconfig/tests/vconfig_VLAN_tag.sh
> @@ -0,0 +1,23 @@
> +#!/bin/sh
> +
> +#  In target, run command vconfig.
> +#  option: add/rem
> +
> +test="VLAN_tag"
> +
> +mkdir test_dir
> +
> +ifconfig $vcon_remote_ifeth up
I'm confused by the variable naming here.
Is 'vcon_remote_ifeth' the board's Ethernet device?
Why does it have 'remote' in the name?

> +vconfig add $vcon_remote_ifeth 100
> +ifconfig $vcon_remote_ifeth.100 inet 192.168.255.1 netmask 0xffffff00
These addresses look suspiciously hardcoded for a particular network.
Will this work in other people's labs, or does the board have to
already be on a 192.168.255 network?

Please explain what this test is actually doing (possibly by
putting something in a comment in this test).

> +ping -q -c 50 -I $vcon_remote_ifeth.100 192.168.255.2 &
> +tcpdump -c 10 -ex -i $vcon_remote_ifeth ether broadcast >
> test_dir/dumpdata
Should check that ping and tcpdump are on the board with 'assert_has_program'

> +
> +if cat test_dir/dumpdata | grep "vlan 100"

This is an intriguing test.  I look forward to adding it.

> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +rm -f test_dir/dumpdata
> +vconfig rem $vcon_remote_ifeth.100
> diff --git a/engine/tests/Functional.vconfig/tests/vconfig_add.sh
> b/engine/tests/Functional.vconfig/tests/vconfig_add.sh
> new file mode 100644
> index 0000000..d2c5ad5
> --- /dev/null
> +++ b/engine/tests/Functional.vconfig/tests/vconfig_add.sh
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +
> +#  In target, run command vconfig.
> +#  option: add
> +
> +test="add"
> +
> +vconfig add $vcon_remote_ifeth 4
> +
> +if ifconfig $vcon_remote_ifeth.4 | grep "$vcon_remote_ifeth.4"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +vconfig rem $vcon_remote_ifeth.4
> diff --git a/engine/tests/Functional.vconfig/tests/vconfig_addaddr.sh
> b/engine/tests/Functional.vconfig/tests/vconfig_addaddr.sh
> new file mode 100644
> index 0000000..aa98b56
> --- /dev/null
> +++ b/engine/tests/Functional.vconfig/tests/vconfig_addaddr.sh
> @@ -0,0 +1,17 @@
> +#!/bin/sh
> +
> +#  In target, run command vconfig.
> +#  option: add/rem
> +
> +test="addaddr"
> +
> +vconfig add $vcon_remote_ifeth 100
> +ifconfig $vcon_remote_ifeth.100 inet 192.168.255.1 netmask 0xffffff00
> +
> +if ifconfig $vcon_remote_ifeth.100 | grep "192.168.255.1"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +vconfig rem $vcon_remote_ifeth.100
> diff --git a/engine/tests/Functional.vconfig/tests/vconfig_help.sh
> b/engine/tests/Functional.vconfig/tests/vconfig_help.sh
> new file mode 100644
> index 0000000..43314f3
> --- /dev/null
> +++ b/engine/tests/Functional.vconfig/tests/vconfig_help.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +#  In target, run command vconfig.
> +#  option: none
> +
> +test="help"
> +
> +if vconfig | grep Usage
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi;
> diff --git a/engine/tests/Functional.vconfig/tests/vconfig_remove.sh
> b/engine/tests/Functional.vconfig/tests/vconfig_remove.sh
> new file mode 100644
> index 0000000..d3696ef
> --- /dev/null
> +++ b/engine/tests/Functional.vconfig/tests/vconfig_remove.sh
> @@ -0,0 +1,15 @@
> +#!/bin/sh
> +
> +#  In target, run command vconfig.
> +#  option: rem
> +
> +test="remove"
> +
> +vconfig add $vcon_remote_ifeth 4
> +
> +if vconfig rem $vcon_remote_ifeth.4 | grep "Removed VLAN"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> diff --git a/engine/tests/Functional.vconfig/tests/vconfig_set_flag.sh
> b/engine/tests/Functional.vconfig/tests/vconfig_set_flag.sh
> new file mode 100644
> index 0000000..b8b11a5
> --- /dev/null
> +++ b/engine/tests/Functional.vconfig/tests/vconfig_set_flag.sh
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +
> +#  In target, run command vconfig.
> +#  option: set_flag
> +
> +test="set_flag"
> +
> +vconfig add $vcon_remote_ifeth 4
> +
> +if vconfig set_flag $vcon_remote_ifeth.4 1 | grep "Set flag on device"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +vconfig rem $vcon_remote_ifeth.4
> diff --git a/engine/tests/Functional.vconfig/vconfig_test.sh
> b/engine/tests/Functional.vconfig/vconfig_test.sh
> new file mode 100755
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/engine/tests/Functional.vconfig/vconfig_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> --
> 1.8.3.1


Most of this looks good.  But please address the comments above
and re-submit.

Thanks,
 -- Tim



More information about the Fuego mailing list