aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJanusz Dziedzic <janusz.dziedzic@tieto.com>2016-04-07 05:38:02 (GMT)
committerJouni Malinen <j@w1.fi>2016-04-24 13:18:46 (GMT)
commit9cd6f4c015aad7f4f35b2507ab0ecc4efd92640c (patch)
treebe44b9bd6853b4d5477c5d72c4061daac7cf88c3 /tests
parent29444a0863086533905a54b1711fd74dfc85c218 (diff)
downloadhostap-9cd6f4c015aad7f4f35b2507ab0ecc4efd92640c.zip
hostap-9cd6f4c015aad7f4f35b2507ab0ecc4efd92640c.tar.gz
hostap-9cd6f4c015aad7f4f35b2507ab0ecc4efd92640c.tar.bz2
tests: Pass apdev to hostapd.add_bss()
Pass apdev param to hostapd.add_bss(). Kill hardcoded phy param and get phy base on apdev. These are needed to support operation with a remote test host. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/hwsim/hostapd.py14
-rw-r--r--tests/hwsim/test_ap_dynamic.py61
-rw-r--r--tests/hwsim/test_ap_ht.py6
-rw-r--r--tests/hwsim/test_ap_wps.py2
-rw-r--r--tests/hwsim/test_monitor_interface.py2
-rw-r--r--tests/hwsim/utils.py22
6 files changed, 68 insertions, 39 deletions
diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index e9eb822..3aecbee 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -11,6 +11,7 @@ import binascii
import struct
import wpaspy
import remotehost
+import utils
logger = logging.getLogger()
hapd_ctrl = '/var/run/hostapd'
@@ -389,9 +390,16 @@ def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30):
raise Exception("AP startup failed")
return hapd
-def add_bss(phy, ifname, confname, ignore_error=False, hostname=None,
- port=8878):
- logger.info("Starting BSS phy=" + phy + " ifname=" + ifname)
+def add_bss(apdev, ifname, confname, ignore_error=False):
+ phy = utils.get_phy(apdev)
+ try:
+ hostname = apdev['hostname']
+ port = apdev['port']
+ logger.info("Starting BSS " + hostname + "/" + port + " phy=" + phy + " ifname=" + ifname)
+ except:
+ logger.info("Starting BSS phy=" + phy + " ifname=" + ifname)
+ hostname = None
+ port = 8878
hapd_global = HostapdGlobal(hostname=hostname, port=port)
hapd_global.add_bss(phy, confname, ignore_error)
port = hapd_global.get_ctrl_iface_port(ifname)
diff --git a/tests/hwsim/test_ap_dynamic.py b/tests/hwsim/test_ap_dynamic.py
index 4d11222..cf73942 100644
--- a/tests/hwsim/test_ap_dynamic.py
+++ b/tests/hwsim/test_ap_dynamic.py
@@ -96,31 +96,31 @@ def _test_ap_bss_add_remove(dev, apdev):
ifname2 = apdev[0]['ifname'] + '-2'
ifname3 = apdev[0]['ifname'] + '-3'
logger.info("Set up three BSSes one by one")
- hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
+ hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
multi_check(dev, [ True, False, False ])
- hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
multi_check(dev, [ True, True, False ])
- hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+ hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
multi_check(dev, [ True, True, True ])
logger.info("Remove the last BSS and re-add it")
hostapd.remove_bss(apdev[0], ifname3)
multi_check(dev, [ True, True, False ])
- hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+ hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
multi_check(dev, [ True, True, True ])
logger.info("Remove the middle BSS and re-add it")
hostapd.remove_bss(apdev[0], ifname2)
multi_check(dev, [ True, False, True ])
- hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
multi_check(dev, [ True, True, True ])
logger.info("Remove the first BSS and re-add it and other BSSs")
hostapd.remove_bss(apdev[0], ifname1)
multi_check(dev, [ False, False, False ])
- hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
- hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
- hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+ hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
+ hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
multi_check(dev, [ True, True, True ])
logger.info("Remove two BSSes and re-add them")
@@ -128,9 +128,9 @@ def _test_ap_bss_add_remove(dev, apdev):
multi_check(dev, [ True, False, True ])
hostapd.remove_bss(apdev[0], ifname3)
multi_check(dev, [ True, False, False ])
- hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
multi_check(dev, [ True, True, False ])
- hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+ hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
multi_check(dev, [ True, True, True ])
logger.info("Remove three BSSes in and re-add them")
@@ -140,15 +140,15 @@ def _test_ap_bss_add_remove(dev, apdev):
multi_check(dev, [ True, False, False ])
hostapd.remove_bss(apdev[0], ifname1)
multi_check(dev, [ False, False, False ])
- hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
+ hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
multi_check(dev, [ True, False, False ])
- hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
multi_check(dev, [ True, True, False ])
- hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+ hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
multi_check(dev, [ True, True, True ])
logger.info("Test error handling if a duplicate ifname is tried")
- hostapd.add_bss('phy3', ifname3, 'bss-3.conf', ignore_error=True)
+ hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf', ignore_error=True)
multi_check(dev, [ True, True, True ])
def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
@@ -157,20 +157,20 @@ def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
dev[i].flush_scan_cache()
ifname1 = apdev[0]['ifname']
ifname2 = apdev[0]['ifname'] + '-2'
- hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
- hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
+ hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf')
multi_check(dev, [ True, True ], scan_opt=False)
hostapd.remove_bss(apdev[0], ifname2)
hostapd.remove_bss(apdev[0], ifname1)
- hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
- hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
+ hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf')
hostapd.remove_bss(apdev[0], ifname2)
multi_check(dev, [ True, False ], scan_opt=False)
hostapd.remove_bss(apdev[0], ifname1)
- hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
- hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
+ hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf')
hostapd.remove_bss(apdev[0], ifname1)
multi_check(dev, [ False, False ])
@@ -348,8 +348,8 @@ def test_ap_enable_disable_reenable(dev, apdev):
def test_ap_double_disable(dev, apdev):
"""Double DISABLE regression test"""
- hostapd.add_bss('phy3', apdev[0]['ifname'], 'bss-1.conf')
- hostapd.add_bss('phy3', apdev[0]['ifname'] + '-2', 'bss-2.conf')
+ hostapd.add_bss(apdev[0], apdev[0]['ifname'], 'bss-1.conf')
+ hostapd.add_bss(apdev[0], apdev[0]['ifname'] + '-2', 'bss-2.conf')
hapd = hostapd.Hostapd(apdev[0]['ifname'])
hapd.disable()
if "FAIL" not in hapd.request("DISABLE"):
@@ -378,8 +378,7 @@ def test_ap_bss_add_many(dev, apdev):
def _test_ap_bss_add_many(dev, apdev):
ifname = apdev[0]['ifname']
- phy = 'phy3'
- hostapd.add_bss(phy, ifname, 'bss-1.conf')
+ hostapd.add_bss(apdev[0], ifname, 'bss-1.conf')
hapd = hostapd.HostapdGlobal()
fname = '/tmp/hwsim-bss.conf'
for i in range(16):
@@ -393,7 +392,7 @@ def _test_ap_bss_add_many(dev, apdev):
f.write("bssid=02:00:00:00:03:%02x\n" % (i + 1))
f.write("ctrl_interface=/var/run/hostapd\n")
f.write("ssid=test-%d\n" % i)
- hostapd.add_bss(phy, ifname2, fname)
+ hostapd.add_bss(apdev[0], ifname2, fname)
os.remove(fname)
dev[0].request("SCAN_INTERVAL 1")
@@ -411,10 +410,10 @@ def test_ap_bss_add_reuse_existing(dev, apdev):
"""Dynamic BSS add operation reusing existing interface"""
ifname1 = apdev[0]['ifname']
ifname2 = apdev[0]['ifname'] + '-2'
- hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
+ hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
subprocess.check_call(["iw", "dev", ifname1, "interface", "add", ifname2,
"type", "__ap"])
- hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
hostapd.remove_bss(apdev[0], ifname2)
subprocess.check_call(["iw", "dev", ifname2, "del"])
@@ -439,14 +438,14 @@ def test_ap_bss_add_out_of_memory(dev, apdev):
hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-1.conf',
1, 'ieee802_11_build_ap_params')
- hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
+ hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-2.conf',
1, 'hostapd_interface_init_bss')
hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-2.conf',
1, 'ieee802_11_build_ap_params')
- hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
hostapd.remove_bss(apdev[0], ifname2)
hostapd.remove_bss(apdev[0], ifname1)
@@ -454,8 +453,8 @@ def test_ap_multi_bss(dev, apdev):
"""Multiple BSSes with hostapd"""
ifname1 = apdev[0]['ifname']
ifname2 = apdev[0]['ifname'] + '-2'
- hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
- hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+ hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
dev[0].connect("bss-1", key_mgmt="NONE", scan_freq="2412")
dev[1].connect("bss-2", key_mgmt="NONE", scan_freq="2412")
diff --git a/tests/hwsim/test_ap_ht.py b/tests/hwsim/test_ap_ht.py
index e66f7a9..cd52578 100644
--- a/tests/hwsim/test_ap_ht.py
+++ b/tests/hwsim/test_ap_ht.py
@@ -702,9 +702,9 @@ def test_olbc_table_limit(dev, apdev):
ifname1 = apdev[0]['ifname']
ifname2 = apdev[0]['ifname'] + '-2'
ifname3 = apdev[0]['ifname'] + '-3'
- hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
- hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
- hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+ hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
+ hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
+ hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
params = { "ssid": "test-olbc",
"channel": "1",
diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py
index ed1de58..aded40b 100644
--- a/tests/hwsim/test_ap_wps.py
+++ b/tests/hwsim/test_ap_wps.py
@@ -2287,7 +2287,7 @@ def test_ap_wps_auto_setup_with_config_file(dev, apdev):
f.write("ssid=wps\n")
f.write("eap_server=1\n")
f.write("wps_state=1\n")
- hostapd.add_bss('phy3', ifname, conffile)
+ hostapd.add_bss(apdev[0], ifname, conffile)
hapd = hostapd.Hostapd(ifname)
hapd.request("WPS_PBC")
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
diff --git a/tests/hwsim/test_monitor_interface.py b/tests/hwsim/test_monitor_interface.py
index 435afa7..cc8345b 100644
--- a/tests/hwsim/test_monitor_interface.py
+++ b/tests/hwsim/test_monitor_interface.py
@@ -46,7 +46,7 @@ def test_monitor_iface_multi_bss(dev, apdev):
"""AP mode mmonitor interface with hostapd multi-BSS setup"""
params = { "ssid": "monitor-iface", "driver_params": "use_monitor=1" }
hapd = hostapd.add_ap(apdev[0], params)
- hostapd.add_bss('phy3', apdev[0]['ifname'] + '-2', 'bss-2.conf')
+ hostapd.add_bss(apdev[0], apdev[0]['ifname'] + '-2', 'bss-2.conf')
dev[0].connect("monitor-iface", key_mgmt="NONE", scan_freq="2412")
dev[1].connect("bss-2", key_mgmt="NONE", scan_freq="2412")
diff --git a/tests/hwsim/utils.py b/tests/hwsim/utils.py
index 1661b20..5fb824e 100644
--- a/tests/hwsim/utils.py
+++ b/tests/hwsim/utils.py
@@ -6,6 +6,7 @@
import os
import time
+import remotehost
def get_ifnames():
ifnames = []
@@ -80,3 +81,24 @@ def skip_with_fips(dev, reason="Not supported in FIPS mode"):
res = dev.get_capability("fips")
if res and 'FIPS' in res:
raise HwsimSkip(reason)
+
+def get_phy(ap, ifname=None):
+ phy = "phy3"
+ try:
+ hostname = ap['hostname']
+ except:
+ hostname = None
+ host = remotehost.Host(hostname)
+
+ if ifname == None:
+ ifname = ap['ifname']
+ status, buf = host.execute("iw dev " + ifname + " info")
+ if status != 0:
+ raise Exception("iw " + ifname + " info failed")
+ lines = buf.split("\n")
+ for line in lines:
+ if "wiphy" in line:
+ words = line.split()
+ phy = "phy" + words[1]
+ break
+ return phy