]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Add test case for multi-BSS configuration file
authorJouni Malinen <j@w1.fi>
Sun, 3 Nov 2013 18:20:50 +0000 (20:20 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Nov 2013 18:20:50 +0000 (20:20 +0200)
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 <j@w1.fi>

tests/hwsim/hostapd.py
tests/hwsim/multi-bss.conf [new file with mode: 0644]
tests/hwsim/test_ap_dynamic.py

index 678013f277968e34d302499c9b9be50d8eba51d3..879059e664e9128549a5a88d1e2e9aaf517c63a7 100644 (file)
@@ -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 (file)
index 0000000..64584b6
--- /dev/null
@@ -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
index fb150e5b54f1631704fc02c9132d7e2da90a5916..5d3238e5baed72c8579676375dfa52b528d04ece 100644 (file)
@@ -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)