[Fuego] [PATCH] Add test cases for service hostapd, ip6tables, ipmi and iptables.

Wang Mingyu wangmy at cn.fujitsu.com
Wed Nov 21 08:08:50 UTC 2018


Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.demo/tests/demo_hostapd.sh | 35 +++++++++++
 .../tests/Functional.demo/tests/demo_ip6tables.sh  | 69 ++++++++++++++++++++++
 engine/tests/Functional.demo/tests/demo_ipmi.sh    | 19 ++++++
 .../tests/Functional.demo/tests/demo_iptables.sh   | 62 +++++++++++++++++++
 4 files changed, 185 insertions(+)
 create mode 100644 engine/tests/Functional.demo/tests/demo_hostapd.sh
 create mode 100644 engine/tests/Functional.demo/tests/demo_ip6tables.sh
 create mode 100644 engine/tests/Functional.demo/tests/demo_ipmi.sh
 create mode 100644 engine/tests/Functional.demo/tests/demo_iptables.sh

diff --git a/engine/tests/Functional.demo/tests/demo_hostapd.sh b/engine/tests/Functional.demo/tests/demo_hostapd.sh
new file mode 100644
index 0000000..c360542
--- /dev/null
+++ b/engine/tests/Functional.demo/tests/demo_hostapd.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+#  In the target start hostapd, and confirm the process condition by command ps.
+
+test="hostapd"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target hostapd stop
+exec_service_on_target NetworkManager 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
+
+if [ -f /etc/hostapd.conf_bak ]
+then
+    mv /etc/hostapd.conf_bak /etc/hostapd.conf
+fi
diff --git a/engine/tests/Functional.demo/tests/demo_ip6tables.sh b/engine/tests/Functional.demo/tests/demo_ip6tables.sh
new file mode 100644
index 0000000..ef77471
--- /dev/null
+++ b/engine/tests/Functional.demo/tests/demo_ip6tables.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+#  In the target start ip6tables, and confirm the process condition by command ps.
+
+test="ip6tables"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target ip6tables stop
+
+cp /etc/iptables/ip6tables /etc/iptables/ip6tables_bak
+cp data/ip6tables /etc/iptables/ip6tables
+ip6tables-restore /etc/iptables/ip6tables
+
+restore_target() {
+    mv /etc/iptables/ip6tables_bak /etc/iptables/ip6tables
+}
+
+if exec_service_on_target ip6tables start
+then
+    echo " -> start of ip6tables succeeded."
+else
+    echo " -> start of ip6tables failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if [ "$init_manager" = "systemd" ]
+then
+    if exec_service_on_target ip6tables status | grep "Applying firewall rules.*OK"
+    then
+        echo " -> get status of ip6tables succeeded."
+    else
+        echo " -> get status of ip6tables failed."
+        echo " -> $test: TEST-FAIL"
+        restore_target
+        exit
+    fi
+    exec_service_on_target ip6tables stop
+    if exec_service_on_target ip6tables status | grep "Unloading modules.*OK"
+    then
+        echo " -> $test: TEST-PASS"
+    else
+        echo " -> get status of ip6tables failed."
+        echo " -> $test: TEST-FAIL"
+    fi
+else
+    if /etc/init.d/ip6tables status | grep "ACCEPT"
+    then
+        echo " -> get status of ip6tables succeeded."
+    else
+        echo " -> get status of ip6tables failed."
+        echo " -> $test: TEST-FAIL"
+        restore_target
+        exit
+    fi
+    exec_service_on_target ip6tables stop
+    if /etc/init.d/ip6tables status | grep "Unloading modules.*OK"
+    then
+        echo " -> $test: TEST-PASS"
+    else
+        echo " -> get status of ip6tables failed."
+        echo " -> $test: TEST-FAIL"
+    fi
+fi
+restore_target
diff --git a/engine/tests/Functional.demo/tests/demo_ipmi.sh b/engine/tests/Functional.demo/tests/demo_ipmi.sh
new file mode 100644
index 0000000..84fcbfe
--- /dev/null
+++ b/engine/tests/Functional.demo/tests/demo_ipmi.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+#  In the target start ipmi, and confirm the process condition by command ps.
+
+test="ipmi"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target ipmi stop
+
+if exec_service_on_target ipmi start
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> start of ipmi failed."
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/engine/tests/Functional.demo/tests/demo_iptables.sh b/engine/tests/Functional.demo/tests/demo_iptables.sh
new file mode 100644
index 0000000..a4d32cc
--- /dev/null
+++ b/engine/tests/Functional.demo/tests/demo_iptables.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+#  In the target start iptables, and confirm the process condition by command ps.
+
+test="iptables"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target iptables stop
+
+cp /etc/iptables/iptables /etc/iptables/iptables_bak
+cp data/iptables /etc/iptables/iptables
+iptables-restore /etc/iptables/iptables
+
+if exec_service_on_target iptables start
+then
+    echo " -> start of iptables succeeded."
+else
+    echo " -> start of iptables failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if [ "$init_manager" = "systemd" ]
+then
+    if exec_service_on_target iptables status | grep "Applying firewall rules.*OK"
+    then
+        echo " -> get status of iptables succeeded."
+    else
+        echo " -> get status of iptables failed."
+        echo " -> $test: TEST-FAIL"
+        exit
+    fi
+    exec_service_on_target iptables stop
+    if exec_service_on_target iptables status | grep "Unloading modules.*OK"
+    then
+        echo " -> $test: TEST-PASS"
+    else
+        echo " -> get status of iptables failed."
+        echo " -> $test: TEST-FAIL"
+    fi
+else
+    if /etc/init.d/iptables status | grep "ACCEPT"
+    then
+        echo " -> get status of iptables succeeded."
+    else
+        echo " -> get status of iptables failed."
+        echo " -> $test: TEST-FAIL"
+        exit
+    fi
+    exec_service_on_target iptables stop
+    if /etc/init.d/iptables status | grep "Unloading modules.*OK"
+    then
+        echo " -> $test: TEST-PASS"
+    else
+        echo " -> get status of iptables failed."
+        echo " -> $test: TEST-FAIL"
+        exit
+    fi
+fi
-- 
1.8.3.1





More information about the Fuego mailing list