Return-Path: From: Wang Mingyu Date: Thu, 4 Apr 2019 03:34:22 -0700 Message-ID: <1554374062-75879-3-git-send-email-wangmy@cn.fujitsu.com> In-Reply-To: <1554374062-75879-1-git-send-email-wangmy@cn.fujitsu.com> References: <1554374062-75879-1-git-send-email-wangmy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Fuego] [PATCH v3] vconfig: Add test cases of command vconfig. List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fuego@lists.linuxfoundation.org Command vconfig is VLAN (802.1q) configuration program. This test set is used to check the option to add/remove the vlan-device and set flat for it. Signed-off-by: Wang Mingyu --- tests/Functional.vconfig/fuego_test.sh | 22 +++++++++++++++ tests/Functional.vconfig/parser.py | 20 ++++++++++++++ tests/Functional.vconfig/spec.json | 6 +++++ tests/Functional.vconfig/test.yaml | 31 ++++++++++++++++++++++ tests/Functional.vconfig/tests/vconfig_add.sh | 16 +++++++++++ tests/Functional.vconfig/tests/vconfig_addaddr.sh | 17 ++++++++++++ tests/Functional.vconfig/tests/vconfig_help.sh | 13 +++++++++ tests/Functional.vconfig/tests/vconfig_remove.sh | 15 +++++++++++ tests/Functional.vconfig/tests/vconfig_set_flag.sh | 16 +++++++++++ tests/Functional.vconfig/tests/vconfig_tag.sh | 29 ++++++++++++++++++++ tests/Functional.vconfig/vconfig_test.sh | 4 +++ 11 files changed, 189 insertions(+) create mode 100644 tests/Functional.vconfig/fuego_test.sh create mode 100644 tests/Functional.vconfig/parser.py create mode 100644 tests/Functional.vconfig/spec.json create mode 100644 tests/Functional.vconfig/test.yaml create mode 100644 tests/Functional.vconfig/tests/vconfig_add.sh create mode 100644 tests/Functional.vconfig/tests/vconfig_addaddr.sh create mode 100644 tests/Functional.vconfig/tests/vconfig_help.sh create mode 100644 tests/Functional.vconfig/tests/vconfig_remove.sh create mode 100644 tests/Functional.vconfig/tests/vconfig_set_flag.sh create mode 100644 tests/Functional.vconfig/tests/vconfig_tag.sh create mode 100755 tests/Functional.vconfig/vconfig_test.sh diff --git a/tests/Functional.vconfig/fuego_test.sh b/tests/Functional.vconfig/fuego_test.sh new file mode 100644 index 0000000..a73fdca --- /dev/null +++ b/tests/Functional.vconfig/fuego_test.sh @@ -0,0 +1,22 @@ +function test_pre_check { + assert_has_program vconfig + assert_has_program tcpdump + assert_has_program ping +} + +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_ifeth=$IFETH;\ + export vcon_ip1=$VCON_IP1;\ + export vcon_ip2=$VCON_IP2;\ + ./vconfig_test.sh" +} + +function test_processing { + log_compare "$TESTDIR" "0" "TEST-FAIL" "n" +} diff --git a/tests/Functional.vconfig/parser.py b/tests/Functional.vconfig/parser.py new file mode 100644 index 0000000..f25a608 --- /dev/null +++ b/tests/Functional.vconfig/parser.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +# See common.py for description of command-line arguments + +import os, sys, collections +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.vconfig/spec.json b/tests/Functional.vconfig/spec.json new file mode 100644 index 0000000..a7a2618 --- /dev/null +++ b/tests/Functional.vconfig/spec.json @@ -0,0 +1,6 @@ +{ + "testName": "Functional.vconfig", + "specs": { + "default": {} + } +} diff --git a/tests/Functional.vconfig/test.yaml b/tests/Functional.vconfig/test.yaml new file mode 100644 index 0000000..4b562e8 --- /dev/null +++ b/tests/Functional.vconfig/test.yaml @@ -0,0 +1,31 @@ +fuego_package_version: 1 +name: Functional.vconfig +description: | + The vconfig program allows you to create and remove vlan-devices on a vlan enabled kernel. + Vlan-devices are virtual ethernet devices which represents the virtual lans on the physical lan. + This is a simple test to check the option help/add/rem/set_flag + of command vconfig. +license: Unknown +author: Wang Mingyu +maintainer: Tim Bird +version: 1.00 +fuego_release: 1 +type: Functional +tags: ['vlan'] +params: + IFETH="the eth interface in your target board" Defined in board file + VCON_IP1="IP address configured for eth interface" Defined in board file + VCON_IP2="IP address which the eth to access" Defined in board file +data_files: + - vconfig_test.sh + - fuego_test.sh + - parser.py + - spec.json + - test.yaml + - tests + vconfig_addaddr.sh + vconfig_add.sh + vconfig_help.sh + vconfig_remove.sh + vconfig_set_flag.sh + vconfig_tag.sh diff --git a/tests/Functional.vconfig/tests/vconfig_add.sh b/tests/Functional.vconfig/tests/vconfig_add.sh new file mode 100644 index 0000000..1e2da17 --- /dev/null +++ b/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_ifeth 4 + +if ifconfig $vcon_ifeth.4 | grep "$vcon_ifeth.4" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi +vconfig rem $vcon_ifeth.4 diff --git a/tests/Functional.vconfig/tests/vconfig_addaddr.sh b/tests/Functional.vconfig/tests/vconfig_addaddr.sh new file mode 100644 index 0000000..c434e19 --- /dev/null +++ b/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_ifeth 100 +ifconfig $vcon_ifeth.100 inet 192.168.255.1 netmask 0xffffff00 + +if ifconfig $vcon_ifeth.100 | grep "192.168.255.1" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi +vconfig rem $vcon_ifeth.100 diff --git a/tests/Functional.vconfig/tests/vconfig_help.sh b/tests/Functional.vconfig/tests/vconfig_help.sh new file mode 100644 index 0000000..43314f3 --- /dev/null +++ b/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/tests/Functional.vconfig/tests/vconfig_remove.sh b/tests/Functional.vconfig/tests/vconfig_remove.sh new file mode 100644 index 0000000..76a1047 --- /dev/null +++ b/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_ifeth 4 + +if vconfig rem $vcon_ifeth.4 | grep "Removed VLAN" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi diff --git a/tests/Functional.vconfig/tests/vconfig_set_flag.sh b/tests/Functional.vconfig/tests/vconfig_set_flag.sh new file mode 100644 index 0000000..9194278 --- /dev/null +++ b/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_ifeth 4 + +if vconfig set_flag $vcon_ifeth.4 1 | grep "Set flag on device" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi +vconfig rem $vcon_ifeth.4 diff --git a/tests/Functional.vconfig/tests/vconfig_tag.sh b/tests/Functional.vconfig/tests/vconfig_tag.sh new file mode 100644 index 0000000..f1298fd --- /dev/null +++ b/tests/Functional.vconfig/tests/vconfig_tag.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# In target, run command vconfig. +# option: add/rem + +test="tag" + +mkdir test_dir + +ifconfig $vcon_ifeth up +vconfig add $vcon_ifeth 100 + +# specify the address to vlanif by ifconfig. +ifconfig $vcon_ifeth.100 inet $vcon_ip1 netmask 0xffffff00 + +# to verify the IP address exists and can accept requests. +ping -q -c 50 -I $vcon_ifeth.100 $vcon_ip2 & + +# check the VLAN tag by tcpdump. +tcpdump -c 10 -ex -i $vcon_ifeth ether broadcast > test_dir/dumpdata + +if cat test_dir/dumpdata | grep "vlan 100" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi +rm -fr test_dir +vconfig rem $vcon_ifeth.100 diff --git a/tests/Functional.vconfig/vconfig_test.sh b/tests/Functional.vconfig/vconfig_test.sh new file mode 100755 index 0000000..dd5ce37 --- /dev/null +++ b/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