From 41318114b63062f232a0ff35397d3ffaae596362 Mon Sep 17 00:00:00 2001 From: Masashi Honma Date: Tue, 25 Jun 2019 10:50:39 +0900 Subject: [PATCH] tests: Fix ap_track_sta false negative by using common finalizer 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 --- tests/hwsim/test_ap_track.py | 45 ++++++++++++++++++------------------ tests/hwsim/utils.py | 5 +++- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/tests/hwsim/test_ap_track.py b/tests/hwsim/test_ap_track.py index 25201e5b0..560e14181 100644 --- a/tests/hwsim/test_ap_track.py +++ b/tests/hwsim/test_ap_track.py @@ -11,34 +11,35 @@ 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):