All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wang Mingyu <wangmy@cn.fujitsu.com>
To: fuego@lists.linuxfoundation.org
Subject: [Fuego] [PATCH v2] Add test cases of command vconfig.
Date: Tue, 6 Nov 2018 05:56:03 -0800	[thread overview]
Message-ID: <1541512565-7858-2-git-send-email-wangmy@cn.fujitsu.com> (raw)
In-Reply-To: <1541512565-7858-1-git-send-email-wangmy@cn.fujitsu.com>

Command vconfig is VLAN (802.1q) configuration program.
This test set is used to check the option add/rem/set_flag of vconfig.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 engine/tests/Functional.vconfig/fuego_test.sh      | 22 +++++++++++++++
 engine/tests/Functional.vconfig/parser.py          | 22 +++++++++++++++
 engine/tests/Functional.vconfig/spec.json          |  7 +++++
 engine/tests/Functional.vconfig/test.yaml          | 31 ++++++++++++++++++++++
 .../Functional.vconfig/tests/vconfig_VLAN_tag.sh   | 29 ++++++++++++++++++++
 .../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 +++
 11 files changed, 192 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/test.yaml
 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..a73fdca
--- /dev/null
+++ b/engine/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=$VLAN_IP1;\
+    export vcon_ip2=$VLAN_IP2;\
+    ./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))
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/test.yaml b/engine/tests/Functional.vconfig/test.yaml
new file mode 100644
index 0000000..e7cded3
--- /dev/null
+++ b/engine/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 <wangmy@cn.fujitsu.com>
+maintainer: Tim Bird <tim.bird@sony.com> 
+version: 1.00
+fuego_release: 1
+type: Functional
+tags: ['vlan']
+params:
+      IFETH="the eth interface in your target board" Defined in board file
+      VLAN_IP1="IP address configured for eth interface" Defined in board file
+      VLAN_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_VLAN_tag.sh
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..ffc5dc7
--- /dev/null
+++ b/engine/tests/Functional.vconfig/tests/vconfig_VLAN_tag.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+#  In target, run command vconfig.
+#  option: add/rem
+
+test="VLAN_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/engine/tests/Functional.vconfig/tests/vconfig_add.sh b/engine/tests/Functional.vconfig/tests/vconfig_add.sh
new file mode 100644
index 0000000..1e2da17
--- /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_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/engine/tests/Functional.vconfig/tests/vconfig_addaddr.sh b/engine/tests/Functional.vconfig/tests/vconfig_addaddr.sh
new file mode 100644
index 0000000..c434e19
--- /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_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/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..76a1047
--- /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_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/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..9194278
--- /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_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/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




  reply	other threads:[~2018-11-06 13:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 13:56 [Fuego] [PATCH v2] Add test cases of command samhain Wang Mingyu
2018-11-06 13:56 ` Wang Mingyu [this message]
2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases of service tcsd Wang Mingyu
2018-11-09  4:48   ` Tim.Bird
2018-11-06 13:56 ` [Fuego] [PATCH v2] Add test cases for commands of at Wang Mingyu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1541512565-7858-2-git-send-email-wangmy@cn.fujitsu.com \
    --to=wangmy@cn.fujitsu.com \
    --cc=fuego@lists.linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.