@@ -285,8 +285,11 @@ def test_wpas_config_file(dev, apdev, params):
except:
pass
wpas.dump_monitor()
- wpas.request("SET country 00")
- wpas.wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=1)
+ try:
+ # FIXME: this doesn't work after wpas.interface_remove()!
+ clear_regdom_global(wpas)
+ except:
+ pass
def test_wpas_config_file_wps(dev, apdev):
"""wpa_supplicant config file parsing/writing with WPS"""
@@ -209,6 +209,15 @@ def clear_regdom_dev(dev, count=1):
for i in range(count):
dev[i].flush_scan_cache()
+def clear_regdom_global(dev):
+ dev.cmd_execute(['iw', 'reg', 'set', '00'])
+ for j in range(5):
+ ev = dev.wait_global_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=1)
+ if ev is None:
+ raise Exception("No regdom change event")
+ if "type=WORLD" in ev:
+ break
+
def radiotap_build():
radiotap_payload = struct.pack('BB', 0x08, 0)
radiotap_payload += struct.pack('BB', 0, 0)
@@ -912,13 +912,14 @@ class WpaSupplicant:
def dump_monitor(self, mon=True, global_mon=True):
count_iface = 0
count_global = 0
- while mon and self.monitor and self.mon.pending():
+ ifname = self.ifname or self.global_iface
+ while mon and self.monitor and self.mon and self.mon.pending():
ev = self.mon.recv()
logger.debug(self.dbg + ": " + ev)
count_iface += 1
while global_mon and self.monitor and self.global_mon and self.global_mon.pending():
ev = self.global_mon.recv()
- logger.debug(self.global_dbg + self.ifname + "(global): " + ev)
+ logger.debug(self.global_dbg + ifname + "(global): " + ev)
count_global += 1
return (count_iface, count_global)
At some point during wpas_config_file we remove the interface then check the config. If an exception occurs there we'll hit an exception later when wpas.dump_monitor() expects self.mon or self.ifname. wpas.request() and wpas.wait_event() also expect an interface to be present. Work around these and correctly reset the country code when wpas_config_file fails by introducing a helper to reset the regdomain globally. TODO: this doesn't actually work as the self.global_mon stops receiving events after wpas.interface_remove("wlan5"), specifically self.global_request("INTERFACE_REMOVE " + ifname), so waiting for regdomain change will always fail, but at least the regulatory domain does get reset. Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com> --- tests/hwsim/test_wpas_config.py | 7 +++++-- tests/hwsim/utils.py | 9 +++++++++ tests/hwsim/wpasupplicant.py | 5 +++-- 3 files changed, 17 insertions(+), 4 deletions(-)