tests: Pass full apdev to add_ap() function (7)
authorJanusz Dziedzic <janusz.dziedzic@tieto.com>
Wed, 30 Mar 2016 08:55:56 +0000 (10:55 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Apr 2016 19:46:14 +0000 (22:46 +0300)
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>
tests/hwsim/test_ap_config.py
tests/hwsim/test_ap_dynamic.py
tests/hwsim/test_ap_psk.py
tests/hwsim/test_hapd_ctrl.py

index aec70f7..18ab5c2 100644 (file)
@@ -13,35 +13,35 @@ def test_ap_config_errors(dev, apdev):
 
     # IEEE 802.11d without country code
     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"):
         raise Exception("Unexpected ENABLE success (ieee80211d without country_code)")
     hapd_global.remove(ifname)
 
     # IEEE 802.11h without IEEE 802.11d
     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"):
         raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d")
     hapd_global.remove(ifname)
 
     # Power Constraint without IEEE 802.11d
     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"):
         raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)")
     hapd_global.remove(ifname)
 
     # Spectrum management without Power Constraint
     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"):
         raise Exception("Unexpected ENABLE success (spectrum_mgmt_required without local_pwr_constraint)")
     hapd_global.remove(ifname)
 
     # IEEE 802.1X without authentication server
     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"):
         raise Exception("Unexpected ENABLE success (ieee8021x)")
     hapd_global.remove(ifname)
@@ -49,7 +49,7 @@ def test_ap_config_errors(dev, apdev):
     # RADIUS-PSK without macaddr_acl=2
     params = hostapd.wpa2_params(ssid="foo", passphrase="12345678")
     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"):
         raise Exception("Unexpected ENABLE success (wpa_psk_radius)")
     hapd_global.remove(ifname)
@@ -59,7 +59,7 @@ def test_ap_config_errors(dev, apdev):
                "wpa_key_mgmt": "FT-PSK",
                "rsn_pairwise": "CCMP",
                "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"):
         raise Exception("Unexpected ENABLE success (FT without nas_identifier)")
     hapd_global.remove(ifname)
@@ -74,7 +74,7 @@ def test_ap_config_errors(dev, apdev):
     params['interworking'] = "1"
     params['hs20'] = "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"):
         raise Exception("Unexpected ENABLE success (HS 2.0 without WPA2/CCMP)")
     hapd_global.remove(ifname)
index 35692f0..de1c4d9 100644 (file)
@@ -244,7 +244,7 @@ def test_ap_remove_during_acs(dev, apdev):
     params['channel'] = '0'
     ifname = apdev[0]['ifname']
     hapd = hostapd.HostapdGlobal()
-    hostapd.add_ap(ifname, params)
+    hostapd.add_ap(apdev[0], params)
     hapd.remove(ifname)
 
 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+]"
     ifname = apdev[0]['ifname']
     hapd = hostapd.HostapdGlobal()
-    hostapd.add_ap(ifname, params)
+    hostapd.add_ap(apdev[0], params)
     hapd.remove(ifname)
 
 def test_ap_remove_during_ht_coex_scan2(dev, apdev):
index 48a3239..d5c22af 100644 (file)
@@ -387,7 +387,7 @@ def test_ap_wpa2_already_in_bridge(dev, apdev):
         subprocess.call(['iw', ifname, 'set', 'type', '__ap'])
         subprocess.call(['brctl', 'addif', br_ifname, ifname])
         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:
             raise Exception("Bridge name not identified correctly")
         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)
         params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
         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(['ip', 'link', 'set', 'dev', 'ap-br0', 'up'])
         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"
         passphrase = "12345678"
         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', 'setfd', br_ifname, '0'])
index 39ff917..d148b65 100644 (file)
@@ -442,7 +442,7 @@ def test_hapd_ctrl_global(dev, apdev):
     ssid = "hapd-ctrl"
     params = { "ssid": ssid }
     ifname = apdev[0]['ifname']
-    hapd = hostapd.add_ap(ifname, params)
+    hapd = hostapd.add_ap(apdev[0], params)
     hapd_global = hostapd.HostapdGlobal()
     res = hapd_global.request("IFNAME=" + ifname + " PING")
     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_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_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()
 
@@ -494,11 +494,11 @@ def test_hapd_dup_network_global_wpa(dev, apdev):
     src_params = hostapd.wpa_params(ssid=src_ssid)
     src_params['wpa_psk'] = psk
     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_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()