[PATCH 02/32] tests: Fix ap_track_sta false negative by using common finalizer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ap_track_sta fails with this message.

---------------
wlan0: Country code not reset back to 00: is US
wlan0: Country code cleared back to 00
---------------

Signed-off-by: Masashi Honma <masashi.honma@xxxxxxxxx>
---
 tests/hwsim/test_ap_track.py | 44 ++++++++++++++++++------------------
 tests/hwsim/utils.py         |  5 +++-
 2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/tests/hwsim/test_ap_track.py b/tests/hwsim/test_ap_track.py
index 25201e5b0..89f964245 100644
--- a/tests/hwsim/test_ap_track.py
+++ b/tests/hwsim/test_ap_track.py
@@ -11,34 +11,34 @@ import time
 
 import hostapd
 from wpasupplicant import WpaSupplicant
-from utils import parse_ie
+from utils import parse_ie, disable_hapd, clear_regdom_dev
 
 def test_ap_track_sta(dev, apdev):
     """Dualband AP tracking unconnected stations"""
+
     try:
-        _test_ap_track_sta(dev, apdev)
+        params = {"ssid": "track",
+                  "country_code": "US",
+                  "hw_mode": "g",
+                  "channel": "6",
+                  "track_sta_max_num": "2"}
+        hapd = hostapd.add_ap(apdev[0], params)
+
+        params = {"ssid": "track",
+                  "country_code": "US",
+                  "hw_mode": "a",
+                  "channel": "40",
+                  "track_sta_max_num": "100",
+                  "track_sta_max_age": "1"}
+        hapd2 = hostapd.add_ap(apdev[1], params)
+
+        _test_ap_track_sta(dev, hapd, apdev[0]['bssid'], hapd2, apdev[1]['bssid'])
     finally:
-        subprocess.call(['iw', 'reg', 'set', '00'])
-        time.sleep(0.1)
-
-def _test_ap_track_sta(dev, apdev):
-    params = {"ssid": "track",
-              "country_code": "US",
-              "hw_mode": "g",
-              "channel": "6",
-              "track_sta_max_num": "2"}
-    hapd = hostapd.add_ap(apdev[0], params)
-    bssid = apdev[0]['bssid']
-
-    params = {"ssid": "track",
-              "country_code": "US",
-              "hw_mode": "a",
-              "channel": "40",
-              "track_sta_max_num": "100",
-              "track_sta_max_age": "1"}
-    hapd2 = hostapd.add_ap(apdev[1], params)
-    bssid2 = apdev[1]['bssid']
+        disable_hapd(hapd)
+        disable_hapd(hapd2)
+        clear_regdom_dev(dev, 3)
 
+def _test_ap_track_sta(dev, hapd, bssid, hapd2, bssid2):
     for i in range(2):
         dev[0].scan_for_bss(bssid, freq=2437, force_scan=True)
         dev[0].scan_for_bss(bssid2, freq=5200, force_scan=True)
diff --git a/tests/hwsim/utils.py b/tests/hwsim/utils.py
index 868537527..26620a6ca 100644
--- a/tests/hwsim/utils.py
+++ b/tests/hwsim/utils.py
@@ -148,10 +148,13 @@ def clear_country(dev):
         dev[1].dump_monitor()
 
 def clear_regdom(hapd, dev, count=1):
+    disable_hapd(hapd)
+    clear_regdom_dev(dev, count)
+
+def disable_hapd(hapd):
     if hapd:
         hapd.request("DISABLE")
         time.sleep(0.1)
-    clear_regdom_dev(dev, count)
 
 def clear_regdom_dev(dev, count=1):
     for i in range(count):
-- 
2.17.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux