tests: Pass full apdev to add_ap() function (7)

Pass the full apdev to the add_ap() function instead of just ifname.
This allows us to handle also remote hosts while we can check
apdev['hostname'], apdev['port'].

This step (7) converts the cases where a local variable is used to store
apdev[#]['ifname'] before passing it as the argument to hostapd.add_ap().

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
This commit is contained in:
Janusz Dziedzic 2016-03-30 10:55:56 +02:00 committed by Jouni Malinen
parent eb2af30ac2
commit 41ba40e74d
4 changed files with 18 additions and 18 deletions

View file

@ -13,35 +13,35 @@ def test_ap_config_errors(dev, apdev):
# IEEE 802.11d without country code # IEEE 802.11d without country code
params = { "ssid": "foo", "ieee80211d": "1" } params = { "ssid": "foo", "ieee80211d": "1" }
hapd = hostapd.add_ap(ifname, params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (ieee80211d without country_code)") raise Exception("Unexpected ENABLE success (ieee80211d without country_code)")
hapd_global.remove(ifname) hapd_global.remove(ifname)
# IEEE 802.11h without IEEE 802.11d # IEEE 802.11h without IEEE 802.11d
params = { "ssid": "foo", "ieee80211h": "1" } params = { "ssid": "foo", "ieee80211h": "1" }
hapd = hostapd.add_ap(ifname, params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d") raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d")
hapd_global.remove(ifname) hapd_global.remove(ifname)
# Power Constraint without IEEE 802.11d # Power Constraint without IEEE 802.11d
params = { "ssid": "foo", "local_pwr_constraint": "1" } params = { "ssid": "foo", "local_pwr_constraint": "1" }
hapd = hostapd.add_ap(ifname, params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)") raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)")
hapd_global.remove(ifname) hapd_global.remove(ifname)
# Spectrum management without Power Constraint # Spectrum management without Power Constraint
params = { "ssid": "foo", "spectrum_mgmt_required": "1" } params = { "ssid": "foo", "spectrum_mgmt_required": "1" }
hapd = hostapd.add_ap(ifname, params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (spectrum_mgmt_required without local_pwr_constraint)") raise Exception("Unexpected ENABLE success (spectrum_mgmt_required without local_pwr_constraint)")
hapd_global.remove(ifname) hapd_global.remove(ifname)
# IEEE 802.1X without authentication server # IEEE 802.1X without authentication server
params = { "ssid": "foo", "ieee8021x": "1" } params = { "ssid": "foo", "ieee8021x": "1" }
hapd = hostapd.add_ap(ifname, params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (ieee8021x)") raise Exception("Unexpected ENABLE success (ieee8021x)")
hapd_global.remove(ifname) hapd_global.remove(ifname)
@ -49,7 +49,7 @@ def test_ap_config_errors(dev, apdev):
# RADIUS-PSK without macaddr_acl=2 # RADIUS-PSK without macaddr_acl=2
params = hostapd.wpa2_params(ssid="foo", passphrase="12345678") params = hostapd.wpa2_params(ssid="foo", passphrase="12345678")
params["wpa_psk_radius"] = "1" params["wpa_psk_radius"] = "1"
hapd = hostapd.add_ap(ifname, params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (wpa_psk_radius)") raise Exception("Unexpected ENABLE success (wpa_psk_radius)")
hapd_global.remove(ifname) hapd_global.remove(ifname)
@ -59,7 +59,7 @@ def test_ap_config_errors(dev, apdev):
"wpa_key_mgmt": "FT-PSK", "wpa_key_mgmt": "FT-PSK",
"rsn_pairwise": "CCMP", "rsn_pairwise": "CCMP",
"wpa_passphrase": "12345678" } "wpa_passphrase": "12345678" }
hapd = hostapd.add_ap(ifname, params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (FT without nas_identifier)") raise Exception("Unexpected ENABLE success (FT without nas_identifier)")
hapd_global.remove(ifname) hapd_global.remove(ifname)
@ -74,7 +74,7 @@ def test_ap_config_errors(dev, apdev):
params['interworking'] = "1" params['interworking'] = "1"
params['hs20'] = "1" params['hs20'] = "1"
params['wpa'] = "1" params['wpa'] = "1"
hapd = hostapd.add_ap(ifname, params, no_enable=True) hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
if "FAIL" not in hapd.request("ENABLE"): if "FAIL" not in hapd.request("ENABLE"):
raise Exception("Unexpected ENABLE success (HS 2.0 without WPA2/CCMP)") raise Exception("Unexpected ENABLE success (HS 2.0 without WPA2/CCMP)")
hapd_global.remove(ifname) hapd_global.remove(ifname)

View file

@ -244,7 +244,7 @@ def test_ap_remove_during_acs(dev, apdev):
params['channel'] = '0' params['channel'] = '0'
ifname = apdev[0]['ifname'] ifname = apdev[0]['ifname']
hapd = hostapd.HostapdGlobal() hapd = hostapd.HostapdGlobal()
hostapd.add_ap(ifname, params) hostapd.add_ap(apdev[0], params)
hapd.remove(ifname) hapd.remove(ifname)
def test_ap_remove_during_acs2(dev, apdev): def test_ap_remove_during_acs2(dev, apdev):
@ -286,7 +286,7 @@ def test_ap_remove_during_ht_coex_scan(dev, apdev):
params['ht_capab'] = "[HT40+]" params['ht_capab'] = "[HT40+]"
ifname = apdev[0]['ifname'] ifname = apdev[0]['ifname']
hapd = hostapd.HostapdGlobal() hapd = hostapd.HostapdGlobal()
hostapd.add_ap(ifname, params) hostapd.add_ap(apdev[0], params)
hapd.remove(ifname) hapd.remove(ifname)
def test_ap_remove_during_ht_coex_scan2(dev, apdev): def test_ap_remove_during_ht_coex_scan2(dev, apdev):

View file

@ -387,7 +387,7 @@ def test_ap_wpa2_already_in_bridge(dev, apdev):
subprocess.call(['iw', ifname, 'set', 'type', '__ap']) subprocess.call(['iw', ifname, 'set', 'type', '__ap'])
subprocess.call(['brctl', 'addif', br_ifname, ifname]) subprocess.call(['brctl', 'addif', br_ifname, ifname])
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
hapd = hostapd.add_ap(ifname, params) hapd = hostapd.add_ap(apdev[0], params)
if hapd.get_driver_status_field('brname') != br_ifname: if hapd.get_driver_status_field('brname') != br_ifname:
raise Exception("Bridge name not identified correctly") raise Exception("Bridge name not identified correctly")
dev[0].connect(ssid, psk=passphrase, scan_freq="2412") dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
@ -412,7 +412,7 @@ def test_ap_wpa2_in_different_bridge(dev, apdev):
time.sleep(0.5) time.sleep(0.5)
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
params['bridge'] = 'ap-br0' params['bridge'] = 'ap-br0'
hapd = hostapd.add_ap(ifname, params) hapd = hostapd.add_ap(apdev[0], params)
subprocess.call(['brctl', 'setfd', 'ap-br0', '0']) subprocess.call(['brctl', 'setfd', 'ap-br0', '0'])
subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'up']) subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'up'])
brname = hapd.get_driver_status_field('brname') brname = hapd.get_driver_status_field('brname')
@ -440,7 +440,7 @@ def test_ap_wpa2_ext_add_to_bridge(dev, apdev):
ssid = "test-wpa2-psk" ssid = "test-wpa2-psk"
passphrase = "12345678" passphrase = "12345678"
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
hapd = hostapd.add_ap(ifname, params) hapd = hostapd.add_ap(apdev[0], params)
subprocess.call(['brctl', 'addbr', br_ifname]) subprocess.call(['brctl', 'addbr', br_ifname])
subprocess.call(['brctl', 'setfd', br_ifname, '0']) subprocess.call(['brctl', 'setfd', br_ifname, '0'])

View file

@ -442,7 +442,7 @@ def test_hapd_ctrl_global(dev, apdev):
ssid = "hapd-ctrl" ssid = "hapd-ctrl"
params = { "ssid": ssid } params = { "ssid": ssid }
ifname = apdev[0]['ifname'] ifname = apdev[0]['ifname']
hapd = hostapd.add_ap(ifname, params) hapd = hostapd.add_ap(apdev[0], params)
hapd_global = hostapd.HostapdGlobal() hapd_global = hostapd.HostapdGlobal()
res = hapd_global.request("IFNAME=" + ifname + " PING") res = hapd_global.request("IFNAME=" + ifname + " PING")
if "PONG" not in res: if "PONG" not in res:
@ -465,11 +465,11 @@ def test_hapd_dup_network_global_wpa2(dev, apdev):
src_params = hostapd.wpa2_params(ssid=src_ssid, passphrase=passphrase) src_params = hostapd.wpa2_params(ssid=src_ssid, passphrase=passphrase)
src_ifname = apdev[0]['ifname'] src_ifname = apdev[0]['ifname']
src_hapd = hostapd.add_ap(src_ifname, src_params) src_hapd = hostapd.add_ap(apdev[0], src_params)
dst_params = { "ssid": dst_ssid } dst_params = { "ssid": dst_ssid }
dst_ifname = apdev[1]['ifname'] dst_ifname = apdev[1]['ifname']
dst_hapd = hostapd.add_ap(dst_ifname, dst_params, no_enable=True) dst_hapd = hostapd.add_ap(apdev[1], dst_params, no_enable=True)
hapd_global = hostapd.HostapdGlobal() hapd_global = hostapd.HostapdGlobal()
@ -494,11 +494,11 @@ def test_hapd_dup_network_global_wpa(dev, apdev):
src_params = hostapd.wpa_params(ssid=src_ssid) src_params = hostapd.wpa_params(ssid=src_ssid)
src_params['wpa_psk'] = psk src_params['wpa_psk'] = psk
src_ifname = apdev[0]['ifname'] src_ifname = apdev[0]['ifname']
src_hapd = hostapd.add_ap(src_ifname, src_params) src_hapd = hostapd.add_ap(apdev[0], src_params)
dst_params = { "ssid": dst_ssid } dst_params = { "ssid": dst_ssid }
dst_ifname = apdev[1]['ifname'] dst_ifname = apdev[1]['ifname']
dst_hapd = hostapd.add_ap(dst_ifname, dst_params, no_enable=True) dst_hapd = hostapd.add_ap(apdev[1], dst_params, no_enable=True)
hapd_global = hostapd.HostapdGlobal() hapd_global = hostapd.HostapdGlobal()