[Fuego] [PATCH v2] hostapd: Add test cases of command hostapd.

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


Hostapd is a user space software access point capable of turning normal network interface cards into access points
and authentication servers.
This is a simple test to check if the service of hostapd can work.

Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 tests/Functional.hostapd/fuego_test.sh         | 19 ++++++++++++
 tests/Functional.hostapd/hostapd_test.sh       |  4 +++
 tests/Functional.hostapd/parser.py             | 20 ++++++++++++
 tests/Functional.hostapd/spec.json             |  6 ++++
 tests/Functional.hostapd/test.yaml             | 24 ++++++++++++++
 tests/Functional.hostapd/tests/hostapd_help.sh | 15 +++++++++
 tests/Functional.hostapd/tests/hostapd_ps.sh   | 43 ++++++++++++++++++++++++++
 7 files changed, 131 insertions(+)
 create mode 100644 tests/Functional.hostapd/fuego_test.sh
 create mode 100644 tests/Functional.hostapd/hostapd_test.sh
 create mode 100644 tests/Functional.hostapd/parser.py
 create mode 100644 tests/Functional.hostapd/spec.json
 create mode 100644 tests/Functional.hostapd/test.yaml
 create mode 100644 tests/Functional.hostapd/tests/hostapd_help.sh
 create mode 100644 tests/Functional.hostapd/tests/hostapd_ps.sh

diff --git a/tests/Functional.hostapd/fuego_test.sh b/tests/Functional.hostapd/fuego_test.sh
new file mode 100644
index 0000000..a9d7197
--- /dev/null
+++ b/tests/Functional.hostapd/fuego_test.sh
@@ -0,0 +1,19 @@
+function test_pre_check {
+    assert_has_program hostapd
+}
+
+function test_deploy {
+    put $TEST_HOME/hostapd_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put $FUEGO_CORE/scripts/fuego_board_function_lib.sh $BOARD_TESTDIR/fuego.$TESTDIR
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export test_wlan=$BOARD_WLAN;\
+    ./hostapd_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.hostapd/hostapd_test.sh b/tests/Functional.hostapd/hostapd_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.hostapd/hostapd_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.hostapd/parser.py b/tests/Functional.hostapd/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.hostapd/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.hostapd/spec.json b/tests/Functional.hostapd/spec.json
new file mode 100644
index 0000000..447448e
--- /dev/null
+++ b/tests/Functional.hostapd/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.hostapd",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.hostapd/test.yaml b/tests/Functional.hostapd/test.yaml
new file mode 100644
index 0000000..c76e2e1
--- /dev/null
+++ b/tests/Functional.hostapd/test.yaml
@@ -0,0 +1,24 @@
+fuego_package_version: 1
+name: Functional.hostapd
+description: |
+      Hostapd (Host access point daemon) is a user space software access point capable of turning normal network interface cards into access points
+      and authentication servers.
+      This is a simple test to check if the service of hostapd can work.
+license: Unknown
+author: Wang Mingyu <wangmy at cn.fujitsu.com>
+maintainer: Tim Bird <tim.bird at sony.com>
+version: 1.00
+fuego_release: 1
+type: Functional
+tags: ['vlan']
+params:
+      BOARD_WLAN="the name of WLAN in your target board" Defined in board file
+data_files:
+ - hostapd_test.sh
+ - fuego_test.sh
+ - parser.py
+ - spec.json
+ - test.yaml
+ - tests
+   hostapd_help.sh
+   hostapd_ps.sh
diff --git a/tests/Functional.hostapd/tests/hostapd_help.sh b/tests/Functional.hostapd/tests/hostapd_help.sh
new file mode 100644
index 0000000..a5b904b
--- /dev/null
+++ b/tests/Functional.hostapd/tests/hostapd_help.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  In target, run command hostapd.
+#  option: --help.
+
+test="help"
+
+hostapd --help > help_log 2>&1
+if cat help_log | grep usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm help_log
diff --git a/tests/Functional.hostapd/tests/hostapd_ps.sh b/tests/Functional.hostapd/tests/hostapd_ps.sh
new file mode 100644
index 0000000..b67b5c7
--- /dev/null
+++ b/tests/Functional.hostapd/tests/hostapd_ps.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#  In the target start hostapd, and check if the service can execute.
+
+test="ps"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+service_status=$(get_service_status hostapd)
+
+exec_service_on_target hostapd stop
+
+if [ -f /etc/hostapd.conf ]
+then
+    cp /etc/hostapd.conf /etc/hostapd.conf_bak
+fi
+
+sed -i 's/wlan0/'"$test_wlan"'/g' /etc/hostapd.conf
+
+sleep 5
+
+if exec_service_on_target hostapd start
+then
+    echo " -> start of hostapd succeeded."
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> start of hostapd failed."
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target hostapd stop
+
+if [ -f /etc/hostapd.conf_bak ]
+then
+    mv /etc/hostapd.conf_bak /etc/hostapd.conf
+fi
+
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target hostapd start
+fi
-- 
1.8.3.1





More information about the Fuego mailing list