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 <masashi.honma@gmail.com>
This commit is contained in:
Masashi Honma 2019-06-25 10:50:39 +09:00 committed by Jouni Malinen
parent e0eb6e536d
commit 41318114b6
2 changed files with 27 additions and 23 deletions

View file

@ -11,24 +11,18 @@ 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)
finally:
subprocess.call(['iw', 'reg', 'set', '00'])
time.sleep(0.1)
def _test_ap_track_sta(dev, apdev):
try:
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",
@ -37,8 +31,15 @@ def _test_ap_track_sta(dev, apdev):
"track_sta_max_num": "100",
"track_sta_max_age": "1"}
hapd2 = hostapd.add_ap(apdev[1], params)
bssid2 = apdev[1]['bssid']
_test_ap_track_sta(dev, hapd, apdev[0]['bssid'], hapd2,
apdev[1]['bssid'])
finally:
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)

View file

@ -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):