From 77990cd7a984c5258a3c8fe5e43eeaf46170f074 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 3 Nov 2013 20:20:50 +0200 Subject: [PATCH] tests: Add test case for multi-BSS configuration file Verify that a single configuration file can be used to initiate multiple BSSes in hostapd and that these BSSes can then be dynamically removed. Signed-hostap: Jouni Malinen --- tests/hwsim/hostapd.py | 13 +++++++++++++ tests/hwsim/multi-bss.conf | 21 +++++++++++++++++++++ tests/hwsim/test_ap_dynamic.py | 20 ++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 tests/hwsim/multi-bss.conf diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index 678013f27..879059e66 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -24,6 +24,11 @@ class HostapdGlobal: if not "OK" in res: raise Exception("Could not add hostapd interface " + ifname) + def add_iface(self, ifname, confname): + res = self.ctrl.request("ADD " + ifname + " config=" + confname) + if not "OK" in res: + raise Exception("Could not add hostapd interface") + def add_bss(self, phy, confname, ignore_error=False): res = self.ctrl.request("ADD bss_config=" + phy + ":" + confname) if not "OK" in res: @@ -137,6 +142,14 @@ def add_bss(phy, ifname, confname, ignore_error=False): if not hapd.ping(): raise Exception("Could not ping hostapd") +def add_iface(ifname, confname): + logger.info("Starting interface " + ifname) + hapd_global = HostapdGlobal() + hapd_global.add_iface(ifname, confname) + hapd = Hostapd(ifname) + if not hapd.ping(): + raise Exception("Could not ping hostapd") + def remove_bss(ifname): logger.info("Removing BSS " + ifname) hapd_global = HostapdGlobal() diff --git a/tests/hwsim/multi-bss.conf b/tests/hwsim/multi-bss.conf new file mode 100644 index 000000000..64584b64b --- /dev/null +++ b/tests/hwsim/multi-bss.conf @@ -0,0 +1,21 @@ +driver=nl80211 + +hw_mode=g +channel=1 +ieee80211n=1 + +interface=wlan3 +ctrl_interface=/var/run/hostapd + +ssid=bss-1 + + +bss=wlan3-2 +bssid=02:00:00:00:03:01 +ctrl_interface=/var/run/hostapd +ssid=bss-2 + +bss=wlan3-3 +bssid=02:00:00:00:03:02 +ctrl_interface=/var/run/hostapd +ssid=bss-3 diff --git a/tests/hwsim/test_ap_dynamic.py b/tests/hwsim/test_ap_dynamic.py index fb150e5b5..5d3238e5b 100644 --- a/tests/hwsim/test_ap_dynamic.py +++ b/tests/hwsim/test_ap_dynamic.py @@ -127,6 +127,7 @@ def test_ap_bss_add_remove(dev, apdev): hostapd.remove_bss(ifname2) multi_check(dev, [ True, False, False ]) hostapd.remove_bss(ifname1) + multi_check(dev, [ False, False, False ]) hostapd.add_bss('phy3', ifname1, 'bss-1.conf') multi_check(dev, [ True, False, False ]) hostapd.add_bss('phy3', ifname2, 'bss-2.conf') @@ -138,6 +139,25 @@ def test_ap_bss_add_remove(dev, apdev): hostapd.add_bss('phy3', ifname3, 'bss-3.conf', ignore_error=True) multi_check(dev, [ True, True, True ]) +def test_ap_multi_bss_config(dev, apdev): + """hostapd start with a multi-BSS configuration file""" + for d in dev: + d.request("SET ignore_old_scan_res 1") + ifname1 = apdev[0]['ifname'] + ifname2 = apdev[0]['ifname'] + '-2' + ifname3 = apdev[0]['ifname'] + '-3' + logger.info("Set up three BSSes with one configuration file") + hostapd.add_iface(ifname1, 'multi-bss.conf') + hapd = hostapd.Hostapd(ifname1) + hapd.enable() + multi_check(dev, [ True, True, True ]) + hostapd.remove_bss(ifname1) + multi_check(dev, [ False, True, True ]) + hostapd.remove_bss(ifname2) + multi_check(dev, [ False, False, True ]) + hostapd.remove_bss(ifname3) + multi_check(dev, [ False, False, False ]) + def invalid_ap(hapd_global, ifname): logger.info("Trying to start AP " + ifname + " with invalid configuration") hapd_global.remove(ifname)