[Fuego] [PATCH] iperf3: Add test cases for command iperf3 in server mode.

Wang Mingyu wangmy at cn.fujitsu.com
Thu Apr 18 23:39:09 UTC 2019


This test set is used to check if the network connection is OK when iperf is started with server mode.

Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 tests/Functional.iperf3_server/fuego_test.sh       | 18 ++++++++++++++++
 .../Functional.iperf3_server/iperf3_server_test.sh |  4 ++++
 tests/Functional.iperf3_server/parser.py           | 20 +++++++++++++++++
 tests/Functional.iperf3_server/spec.json           |  6 ++++++
 .../Functional.iperf3_server/tests/iperf3_help.sh  | 13 +++++++++++
 .../tests/iperf3_server_TCP.sh                     | 22 +++++++++++++++++++
 .../tests/iperf3_server_TCP_port.sh                | 22 +++++++++++++++++++
 .../tests/iperf3_server_UDP.sh                     | 18 ++++++++++++++++
 .../tests/iperf3_server_client.sh                  | 22 +++++++++++++++++++
 .../tests/iperf3_server_client_UDP.sh              | 20 +++++++++++++++++
 .../tests/iperf3_server_client_port.sh             | 25 ++++++++++++++++++++++
 .../tests/iperf3_version.sh                        | 13 +++++++++++
 12 files changed, 203 insertions(+)
 create mode 100644 tests/Functional.iperf3_server/fuego_test.sh
 create mode 100644 tests/Functional.iperf3_server/iperf3_server_test.sh
 create mode 100644 tests/Functional.iperf3_server/parser.py
 create mode 100644 tests/Functional.iperf3_server/spec.json
 create mode 100644 tests/Functional.iperf3_server/tests/iperf3_help.sh
 create mode 100644 tests/Functional.iperf3_server/tests/iperf3_server_TCP.sh
 create mode 100644 tests/Functional.iperf3_server/tests/iperf3_server_TCP_port.sh
 create mode 100644 tests/Functional.iperf3_server/tests/iperf3_server_UDP.sh
 create mode 100644 tests/Functional.iperf3_server/tests/iperf3_server_client.sh
 create mode 100644 tests/Functional.iperf3_server/tests/iperf3_server_client_UDP.sh
 create mode 100644 tests/Functional.iperf3_server/tests/iperf3_server_client_port.sh
 create mode 100644 tests/Functional.iperf3_server/tests/iperf3_version.sh

diff --git a/tests/Functional.iperf3_server/fuego_test.sh b/tests/Functional.iperf3_server/fuego_test.sh
new file mode 100644
index 0000000..3cc380e
--- /dev/null
+++ b/tests/Functional.iperf3_server/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    assert_has_program iperf3
+    assert_has_program netstat
+}
+
+function test_deploy {
+    put $TEST_HOME/iperf3_server_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./iperf3_server_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.iperf3_server/iperf3_server_test.sh b/tests/Functional.iperf3_server/iperf3_server_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.iperf3_server/iperf3_server_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.iperf3_server/parser.py b/tests/Functional.iperf3_server/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.iperf3_server/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.iperf3_server/spec.json b/tests/Functional.iperf3_server/spec.json
new file mode 100644
index 0000000..dbd6d04
--- /dev/null
+++ b/tests/Functional.iperf3_server/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.iperf3_server",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.iperf3_server/tests/iperf3_help.sh b/tests/Functional.iperf3_server/tests/iperf3_help.sh
new file mode 100644
index 0000000..6928699
--- /dev/null
+++ b/tests/Functional.iperf3_server/tests/iperf3_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  Test command iperf3 on target.
+#  Option : --help
+
+test="help"
+
+if iperf3 --help | grep "Usage"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/tests/Functional.iperf3_server/tests/iperf3_server_TCP.sh b/tests/Functional.iperf3_server/tests/iperf3_server_TCP.sh
new file mode 100644
index 0000000..f181445
--- /dev/null
+++ b/tests/Functional.iperf3_server/tests/iperf3_server_TCP.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+#  Test command iperf3 on target.
+#  Option : server(TCP)
+
+test="TCP"
+
+killall -KILL iperf3
+iperf3 -s -D&
+
+ls .
+netstat -l > iperf-test
+
+if cat iperf-test | grep "5201"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+
+killall -KILL iperf3
+rm -f iperf-test
diff --git a/tests/Functional.iperf3_server/tests/iperf3_server_TCP_port.sh b/tests/Functional.iperf3_server/tests/iperf3_server_TCP_port.sh
new file mode 100644
index 0000000..865af0e
--- /dev/null
+++ b/tests/Functional.iperf3_server/tests/iperf3_server_TCP_port.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Test command iperf3 on target.
+# Option : server( TCP port 6000 )
+
+test="TCP port"
+
+killall -KILL iperf3
+
+iperf3 -s -p 6000 >iperf.log &
+
+sleep 3
+
+killall iperf3
+
+if grep "Server listening on 6000" iperf.log
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm iperf.log
diff --git a/tests/Functional.iperf3_server/tests/iperf3_server_UDP.sh b/tests/Functional.iperf3_server/tests/iperf3_server_UDP.sh
new file mode 100644
index 0000000..a5c7ea5
--- /dev/null
+++ b/tests/Functional.iperf3_server/tests/iperf3_server_UDP.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+#  Test command iperf3 on target.
+#  Option : server(UDP)
+
+test="UDP"
+
+killall -KILL iperf3
+iperf3 -s -D
+
+if netstat -l | grep "5201"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+
+killall -KILL iperf3
diff --git a/tests/Functional.iperf3_server/tests/iperf3_server_client.sh b/tests/Functional.iperf3_server/tests/iperf3_server_client.sh
new file mode 100644
index 0000000..e7e1306
--- /dev/null
+++ b/tests/Functional.iperf3_server/tests/iperf3_server_client.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+#  Test command iperf3 on target.
+#  Option : -c
+
+test="client"
+
+killall -KILL iperf3
+iperf3 -s -D&
+
+iperf3 -c 127.0.0.1 > log
+sleep 5
+
+if grep "connected" log
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+
+killall -KILL iperf3
+rm log
diff --git a/tests/Functional.iperf3_server/tests/iperf3_server_client_UDP.sh b/tests/Functional.iperf3_server/tests/iperf3_server_client_UDP.sh
new file mode 100644
index 0000000..ca4b57f
--- /dev/null
+++ b/tests/Functional.iperf3_server/tests/iperf3_server_client_UDP.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+#  Test command iperf3 on target.
+#  Option : -c (UDP)
+
+test="client_UDP"
+
+killall -KILL iperf3
+iperf3 -s -D&
+
+sleep 3
+
+if iperf3 -c 127.0.0.1 -u | grep "connected"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+
+killall -KILL iperf3
diff --git a/tests/Functional.iperf3_server/tests/iperf3_server_client_port.sh b/tests/Functional.iperf3_server/tests/iperf3_server_client_port.sh
new file mode 100644
index 0000000..b26f659
--- /dev/null
+++ b/tests/Functional.iperf3_server/tests/iperf3_server_client_port.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+#  Test command iperf3 on target.
+#  Option : -c(port opt)
+
+test="client_port"
+
+killall -KILL iperf3
+iperf3 -s -D -p 6000&
+
+sleep 3
+
+iperf3 -c 127.0.0.1 -p 6000 >iperf.log &
+
+sleep 3
+
+killall iperf3
+if grep "connected" iperf.log
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+rm iperf.log
diff --git a/tests/Functional.iperf3_server/tests/iperf3_version.sh b/tests/Functional.iperf3_server/tests/iperf3_version.sh
new file mode 100644
index 0000000..7327ecc
--- /dev/null
+++ b/tests/Functional.iperf3_server/tests/iperf3_version.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  Test command iperf3 on target.
+#  Option : version
+
+test="version"
+
+if iperf3 --version | grep "iperf 3.*"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
-- 
1.8.3.1





More information about the Fuego mailing list