tests: Mark 525 tests as remote compatible
[mech_eap.git] / tests / hwsim / test_ap_ht.py
index e66f7a9..8ebd865 100644 (file)
@@ -4,26 +4,36 @@
 # This software may be distributed under the terms of the BSD license.
 # See README for more details.
 
+from remotehost import remote_compatible
 import time
 import logging
 logger = logging.getLogger()
 import struct
-import subprocess
 
 import hostapd
 from utils import HwsimSkip, alloc_fail
 import hwsim_utils
 from test_ap_csa import csa_supported
 
-def clear_scan_cache(ifname):
-    subprocess.call(['ifconfig', ifname, 'up'])
-    subprocess.call(['iw', ifname, 'scan', 'trigger', 'freq', '2412', 'flush'])
+def clear_scan_cache(apdev):
+    ifname = apdev['ifname']
+    hostapd.cmd_execute(apdev, ['ifconfig', ifname, 'up'])
+    hostapd.cmd_execute(apdev, ['iw', ifname, 'scan', 'trigger', 'freq', '2412',
+                                'flush'])
     time.sleep(0.1)
-    subprocess.call(['ifconfig', ifname, 'down'])
+    hostapd.cmd_execute(apdev, ['ifconfig', ifname, 'down'])
+
+def set_world_reg(apdev0=None, apdev1=None, dev0=None):
+    if apdev0:
+        hostapd.cmd_execute(apdev0, ['iw', 'reg', 'set', '00'])
+    if apdev1:
+        hostapd.cmd_execute(apdev1, ['iw', 'reg', 'set', '00'])
+    if dev0:
+        dev0.cmd_execute(['iw', 'reg', 'set', '00'])
 
 def test_ap_ht40_scan(dev, apdev):
     """HT40 co-ex scan"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "test-ht40",
                "channel": "5",
                "ht_capab": "[HT40-]"}
@@ -56,9 +66,10 @@ def test_ap_ht40_scan(dev, apdev):
 
     dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)
 
+@remote_compatible
 def test_ap_ht40_scan_conflict(dev, apdev):
     """HT40 co-ex scan conflict"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "test-ht40",
                "channel": "6",
                "ht_capab": "[HT40+]"}
@@ -96,9 +107,10 @@ def test_ap_ht40_scan_conflict(dev, apdev):
 
     dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)
 
+@remote_compatible
 def test_ap_ht40_scan_conflict2(dev, apdev):
     """HT40 co-ex scan conflict (HT40-)"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "test-ht40",
                "channel": "11",
                "ht_capab": "[HT40-]"}
@@ -138,18 +150,18 @@ def test_ap_ht40_scan_conflict2(dev, apdev):
 
 def test_ap_ht40_scan_not_affected(dev, apdev):
     """HT40 co-ex scan and other BSS not affected"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "test-ht20",
                "channel": "11" }
     hostapd.add_ap(apdev[1], params)
 
-    subprocess.call(['ifconfig', apdev[0]['ifname'], 'up'])
-    subprocess.call(['iw', apdev[0]['ifname'], 'scan', 'trigger', 'freq', '2462'])
+    hostapd.cmd_execute(apdev[0], ['ifconfig', apdev[0]['ifname'], 'up'])
+    hostapd.cmd_execute(apdev[0], ['iw', apdev[0]['ifname'], 'scan', 'trigger',
+                                   'freq', '2462'])
     time.sleep(0.5)
-    subprocess.call(['iw', apdev[0]['ifname'], 'scan', 'dump'],
-                    stdout=open('/dev/null', 'w'))
+    hostapd.cmd_execute(apdev[0], ['iw', apdev[0]['ifname'], 'scan', 'dump'])
     time.sleep(0.1)
-    subprocess.call(['ifconfig', apdev[0]['ifname'], 'down'])
+    hostapd.cmd_execute(apdev[0], ['ifconfig', apdev[0]['ifname'], 'down'])
 
     params = { "ssid": "test-ht40",
                "channel": "1",
@@ -183,9 +195,10 @@ def test_ap_ht40_scan_not_affected(dev, apdev):
 
     dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)
 
+@remote_compatible
 def test_ap_ht40_scan_legacy_conflict(dev, apdev):
     """HT40 co-ex scan conflict with legacy 20 MHz AP"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "legacy-20",
                "channel": "7", "ieee80211n": "0" }
     hostapd.add_ap(apdev[1], params)
@@ -222,9 +235,10 @@ def test_ap_ht40_scan_legacy_conflict(dev, apdev):
 
     dev[0].connect("test-ht40", key_mgmt="NONE", scan_freq=freq)
 
+@remote_compatible
 def test_ap_ht40_scan_ht20_conflict(dev, apdev):
     """HT40 co-ex scan conflict with HT 20 MHz AP"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "ht-20",
                "channel": "7", "ieee80211n": "1" }
     hostapd.add_ap(apdev[1], params)
@@ -263,7 +277,7 @@ def test_ap_ht40_scan_ht20_conflict(dev, apdev):
 
 def test_ap_ht40_scan_intolerant(dev, apdev):
     """HT40 co-ex scan finding an AP advertising 40 MHz intolerant"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "another-bss",
                "channel": "1",
                "ht_capab": "[40-INTOLERANT]" }
@@ -303,7 +317,7 @@ def test_ap_ht40_scan_intolerant(dev, apdev):
 
 def test_ap_ht40_scan_match(dev, apdev):
     """HT40 co-ex scan matching configuration"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "test-ht40",
                "channel": "5",
                "ht_capab": "[HT40-]"}
@@ -343,7 +357,7 @@ def test_ap_ht40_scan_match(dev, apdev):
 
 def test_ap_ht40_5ghz_match(dev, apdev):
     """HT40 co-ex scan on 5 GHz with matching pri/sec channel"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     try:
         hapd = None
         hapd2 = None
@@ -392,12 +406,12 @@ def test_ap_ht40_5ghz_match(dev, apdev):
             hapd.request("DISABLE")
         if hapd2:
             hapd2.request("DISABLE")
-        subprocess.call(['iw', 'reg', 'set', '00'])
+        set_world_reg(apdev[0], apdev[1], dev[0])
         dev[0].flush_scan_cache()
 
 def test_ap_ht40_5ghz_switch(dev, apdev):
     """HT40 co-ex scan on 5 GHz switching pri/sec channel"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     try:
         hapd = None
         hapd2 = None
@@ -446,11 +460,11 @@ def test_ap_ht40_5ghz_switch(dev, apdev):
             hapd.request("DISABLE")
         if hapd2:
             hapd2.request("DISABLE")
-        subprocess.call(['iw', 'reg', 'set', '00'])
+        set_world_reg(apdev[0], apdev[1], dev[0])
 
 def test_ap_ht40_5ghz_switch2(dev, apdev):
     """HT40 co-ex scan on 5 GHz switching pri/sec channel (2)"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     try:
         hapd = None
         hapd2 = None
@@ -508,7 +522,7 @@ def test_ap_ht40_5ghz_switch2(dev, apdev):
             hapd.request("DISABLE")
         if hapd2:
             hapd2.request("DISABLE")
-        subprocess.call(['iw', 'reg', 'set', '00'])
+        set_world_reg(apdev[0], apdev[1], dev[0])
         dev[0].flush_scan_cache()
 
 def test_obss_scan(dev, apdev):
@@ -601,7 +615,7 @@ def test_obss_scan_40_intolerant(dev, apdev):
 
 def test_obss_coex_report_handling(dev, apdev):
     """Overlapping BSS scan report handling with obss_interval=0"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "obss-scan",
                "channel": "6",
                "ht_capab": "[HT40-]" }
@@ -630,7 +644,7 @@ def test_obss_coex_report_handling(dev, apdev):
 
 def test_obss_coex_report_handling1(dev, apdev):
     """Overlapping BSS scan report handling with obss_interval=1"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "obss-scan",
                "channel": "6",
                "ht_capab": "[HT40+]",
@@ -683,8 +697,7 @@ def test_olbc(dev, apdev):
     if status['olbc'] != '1' or status['olbc_ht'] != '1':
         raise Exception("Missing OLBC information")
 
-    hapd_global = hostapd.HostapdGlobal()
-    hapd_global.remove(apdev[1]['ifname'])
+    hostapd.remove_bss(apdev[1])
 
     logger.info("Waiting for OLBC state to time out")
     cleared = False
@@ -702,9 +715,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",
@@ -756,7 +769,7 @@ def test_olbc_5ghz(dev, apdev):
             hapd.request("DISABLE")
         if hapd2:
             hapd2.request("DISABLE")
-        subprocess.call(['iw', 'reg', 'set', '00'])
+        set_world_reg(apdev[0], apdev[1], None)
 
 def test_ap_require_ht(dev, apdev):
     """Require HT"""
@@ -779,6 +792,7 @@ def test_ap_require_ht(dev, apdev):
                    ampdu_density="1", disable_ht40="1", disable_sgi="1",
                    disable_ldpc="1")
 
+@remote_compatible
 def test_ap_require_ht_limited_rates(dev, apdev):
     """Require HT with limited supported rates"""
     params = { "ssid": "require-ht",
@@ -796,6 +810,7 @@ def test_ap_require_ht_limited_rates(dev, apdev):
     if "status_code=27" not in ev:
         raise Exception("Unexpected rejection status code")
 
+@remote_compatible
 def test_ap_ht_capab_not_supported(dev, apdev):
     """HT configuration with driver not supporting all ht_capab entries"""
     params = { "ssid": "test-ht40",
@@ -807,7 +822,7 @@ def test_ap_ht_capab_not_supported(dev, apdev):
 
 def test_ap_ht_40mhz_intolerant_sta(dev, apdev):
     """Associated STA indicating 40 MHz intolerant"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "intolerant",
                "channel": "6",
                "ht_capab": "[HT40-]" }
@@ -840,7 +855,7 @@ def test_ap_ht_40mhz_intolerant_sta(dev, apdev):
 
 def test_ap_ht_40mhz_intolerant_ap(dev, apdev):
     """Associated STA reports 40 MHz intolerant AP after association"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     params = { "ssid": "ht",
                "channel": "6",
                "ht_capab": "[HT40-]",
@@ -929,7 +944,7 @@ def test_ap_ht40_csa(dev, apdev):
         dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
-        subprocess.call(['iw', 'reg', 'set', '00'])
+        set_world_reg(apdev[0], None, dev[0])
         dev[0].flush_scan_cache()
 
 def test_ap_ht40_csa2(dev, apdev):
@@ -973,7 +988,7 @@ def test_ap_ht40_csa2(dev, apdev):
         dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
-        subprocess.call(['iw', 'reg', 'set', '00'])
+        set_world_reg(apdev[0], None, dev[0])
         dev[0].flush_scan_cache()
 
 def test_ap_ht40_csa3(dev, apdev):
@@ -1017,9 +1032,10 @@ def test_ap_ht40_csa3(dev, apdev):
         dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
-        subprocess.call(['iw', 'reg', 'set', '00'])
+        set_world_reg(apdev[0], None, dev[0])
         dev[0].flush_scan_cache()
 
+@remote_compatible
 def test_ap_ht_smps(dev, apdev):
     """SMPS AP configuration options"""
     params = { "ssid": "ht1", "ht_capab": "[SMPS-STATIC]" }
@@ -1035,6 +1051,7 @@ def test_ap_ht_smps(dev, apdev):
     hwsim_utils.test_connectivity(dev[0], hapd)
     hwsim_utils.test_connectivity(dev[1], hapd2)
 
+@remote_compatible
 def test_prefer_ht20(dev, apdev):
     """Preference on HT20 over no-HT"""
     params = { "ssid": "test",
@@ -1090,6 +1107,7 @@ def test_prefer_ht40(dev, apdev):
     if est != "135000":
         raise Exception("Unexpected BSS1 est_throughput: " + est)
 
+@remote_compatible
 def test_prefer_ht20_during_roam(dev, apdev):
     """Preference on HT20 over no-HT in roaming consideration"""
     params = { "ssid": "test",
@@ -1109,20 +1127,21 @@ def test_prefer_ht20_during_roam(dev, apdev):
     dev[0].scan_for_bss(bssid2, freq=2412)
     dev[0].scan(freq=2412)
     dev[0].wait_connected()
-    
+
     if dev[0].get_status_field('bssid') != bssid2:
         raise Exception("Unexpected BSS selected")
 
+@remote_compatible
 def test_ap_ht40_5ghz_invalid_pair(dev, apdev):
     """HT40 on 5 GHz with invalid channel pair"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     try:
         params = { "ssid": "test-ht40",
                    "hw_mode": "a",
                    "channel": "40",
                    "country_code": "US",
                    "ht_capab": "[HT40+]"}
-        hapd = hostapd.add_ap(apdev[1], params, wait_enabled=False)
+        hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
         ev = hapd.wait_event(["AP-DISABLED", "AP-ENABLED"], timeout=10)
         if not ev:
             raise Exception("AP setup failure timed out")
@@ -1131,18 +1150,19 @@ def test_ap_ht40_5ghz_invalid_pair(dev, apdev):
             if sec != "0":
                 raise Exception("Invalid 40 MHz channel accepted")
     finally:
-        subprocess.call(['iw', 'reg', 'set', '00'])
+        set_world_reg(apdev[0], None, None)
 
+@remote_compatible
 def test_ap_ht40_5ghz_disabled_sec(dev, apdev):
     """HT40 on 5 GHz with disabled secondary channel"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
     try:
         params = { "ssid": "test-ht40",
                    "hw_mode": "a",
                    "channel": "48",
                    "country_code": "US",
                    "ht_capab": "[HT40+]"}
-        hapd = hostapd.add_ap(apdev[1], params, wait_enabled=False)
+        hapd = hostapd.add_ap(apdev[0], params, wait_enabled=False)
         ev = hapd.wait_event(["AP-DISABLED", "AP-ENABLED"], timeout=10)
         if not ev:
             raise Exception("AP setup failure timed out")
@@ -1151,11 +1171,11 @@ def test_ap_ht40_5ghz_disabled_sec(dev, apdev):
             if sec != "0":
                 raise Exception("Invalid 40 MHz channel accepted")
     finally:
-        subprocess.call(['iw', 'reg', 'set', '00'])
+        set_world_reg(apdev[0], None, None)
 
 def test_ap_ht40_scan_broken_ap(dev, apdev):
     """HT40 co-ex scan and broken legacy/HT AP"""
-    clear_scan_cache(apdev[0]['ifname'])
+    clear_scan_cache(apdev[0])
 
     # Broken AP: Include HT Capabilities element but not HT Operation element
     params = { "ssid": "legacy-20",