aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanusz Dziedzic <janusz.dziedzic@tieto.com>2016-03-08 13:28:05 (GMT)
committerJouni Malinen <j@w1.fi>2016-03-20 19:49:35 (GMT)
commitd4944fad72859606ea9fb7a6cca23cd49f19fd91 (patch)
tree9b5023abd53855992aadf967bb132816a99ccb8c
parent8ce4855b234ef1ff93b3cb42837a4a95b0fbbf55 (diff)
downloadhostap-d4944fad72859606ea9fb7a6cca23cd49f19fd91.zip
hostap-d4944fad72859606ea9fb7a6cca23cd49f19fd91.tar.gz
hostap-d4944fad72859606ea9fb7a6cca23cd49f19fd91.tar.bz2
tests: Improve debug logs in hostapd/wpasupplicant with remote commands
Show more info when we are using remote wpaspy and UDP-based control interface. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
-rw-r--r--tests/hwsim/hostapd.py34
-rw-r--r--tests/hwsim/wpasupplicant.py16
2 files changed, 28 insertions, 22 deletions
diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index 17fe2b6..5be029e 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -27,20 +27,23 @@ class HostapdGlobal:
if hostname is None:
self.ctrl = wpaspy.Ctrl(hapd_global)
self.mon = wpaspy.Ctrl(hapd_global)
+ self.dbg = ""
else:
self.ctrl = wpaspy.Ctrl(hostname, port)
self.mon = wpaspy.Ctrl(hostname, port)
+ self.dbg = hostname + "/" + str(port)
self.mon.attach()
- def request(self, cmd):
- return self.ctrl.request(cmd)
+ def request(self, cmd, timeout=10):
+ logger.debug(self.dbg + ": CTRL(global): " + cmd)
+ return self.ctrl.request(cmd, timeout)
def wait_event(self, events, timeout):
start = os.times()[4]
while True:
while self.mon.pending():
ev = self.mon.recv()
- logger.debug("(global): " + ev)
+ logger.debug(self.dbg + "(global): " + ev)
for event in events:
if event in ev:
return ev
@@ -52,42 +55,39 @@ class HostapdGlobal:
break
return None
- def request(self, cmd):
- return self.ctrl.request(cmd)
-
def add(self, ifname, driver=None):
cmd = "ADD " + ifname + " " + hapd_ctrl
if driver:
cmd += " " + driver
- res = self.ctrl.request(cmd)
+ res = self.request(cmd)
if not "OK" in res:
raise Exception("Could not add hostapd interface " + ifname)
def add_iface(self, ifname, confname):
- res = self.ctrl.request("ADD " + ifname + " config=" + confname)
+ res = self.request("ADD " + ifname + " config=" + confname)
if not "OK" in res:
raise Exception("Could not add hostapd interface")
def add_bss(self, phy, confname, ignore_error=False):
- res = self.ctrl.request("ADD bss_config=" + phy + ":" + confname)
+ res = self.request("ADD bss_config=" + phy + ":" + confname)
if not "OK" in res:
if not ignore_error:
raise Exception("Could not add hostapd BSS")
def remove(self, ifname):
- self.ctrl.request("REMOVE " + ifname, timeout=30)
+ self.request("REMOVE " + ifname, timeout=30)
def relog(self):
- self.ctrl.request("RELOG")
+ self.request("RELOG")
def flush(self):
- self.ctrl.request("FLUSH")
+ self.request("FLUSH")
def get_ctrl_iface_port(self, ifname):
if self.hostname is None:
return None
- res = self.ctrl.request("INTERFACES ctrl")
+ res = self.request("INTERFACES ctrl")
lines = res.splitlines()
found = False
for line in lines:
@@ -117,9 +117,11 @@ class Hostapd:
if hostname is None:
self.ctrl = wpaspy.Ctrl(os.path.join(hapd_ctrl, ifname))
self.mon = wpaspy.Ctrl(os.path.join(hapd_ctrl, ifname))
+ self.dbg = ifname
else:
self.ctrl = wpaspy.Ctrl(hostname, port)
self.mon = wpaspy.Ctrl(hostname, port)
+ self.dbg = hostname + "/" + ifname
self.mon.attach()
self.bssid = None
self.bssidx = bssidx
@@ -138,7 +140,7 @@ class Hostapd:
return self.bssid
def request(self, cmd):
- logger.debug(self.ifname + ": CTRL: " + cmd)
+ logger.debug(self.dbg + ": CTRL: " + cmd)
return self.ctrl.request(cmd)
def ping(self):
@@ -201,14 +203,14 @@ class Hostapd:
def dump_monitor(self):
while self.mon.pending():
ev = self.mon.recv()
- logger.debug(self.ifname + ": " + ev)
+ logger.debug(self.dbg + ": " + ev)
def wait_event(self, events, timeout):
start = os.times()[4]
while True:
while self.mon.pending():
ev = self.mon.recv()
- logger.debug(self.ifname + ": " + ev)
+ logger.debug(self.dbg + ": " + ev)
for event in events:
if event in ev:
return ev
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index beae108..bc865b8 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -33,9 +33,11 @@ class WpaSupplicant:
if hostname != None:
self.global_ctrl = wpaspy.Ctrl(hostname, global_port)
self.global_mon = wpaspy.Ctrl(hostname, global_port)
+ self.global_dbg = hostname + "/" + str(global_port) + "/"
else:
self.global_ctrl = wpaspy.Ctrl(global_iface)
self.global_mon = wpaspy.Ctrl(global_iface)
+ self.global_dbg = ""
self.global_mon.attach()
else:
self.global_mon = None
@@ -60,9 +62,11 @@ class WpaSupplicant:
self.ctrl = wpaspy.Ctrl(hostname, port)
self.mon = wpaspy.Ctrl(hostname, port)
self.host = remotehost.Host(hostname, ifname)
+ self.dbg = hostname + "/" + ifname
else:
self.ctrl = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname))
self.mon = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname))
+ self.dbg = ifname
self.mon.attach()
def remove_ifname(self):
@@ -131,7 +135,7 @@ class WpaSupplicant:
self.global_request("INTERFACE_REMOVE " + ifname)
def request(self, cmd, timeout=10):
- logger.debug(self.ifname + ": CTRL: " + cmd)
+ logger.debug(self.dbg + ": CTRL: " + cmd)
return self.ctrl.request(cmd, timeout=timeout)
def global_request(self, cmd):
@@ -139,7 +143,7 @@ class WpaSupplicant:
return self.request(cmd)
else:
ifname = self.ifname or self.global_iface
- logger.debug(ifname + ": CTRL(global): " + cmd)
+ logger.debug(self.global_dbg + ifname + ": CTRL(global): " + cmd)
return self.global_ctrl.request(cmd)
def group_request(self, cmd):
@@ -680,7 +684,7 @@ class WpaSupplicant:
while True:
while self.mon.pending():
ev = self.mon.recv()
- logger.debug(self.ifname + ": " + ev)
+ logger.debug(self.dbg + ": " + ev)
for event in events:
if event in ev:
return ev
@@ -700,7 +704,7 @@ class WpaSupplicant:
while True:
while self.global_mon.pending():
ev = self.global_mon.recv()
- logger.debug(self.ifname + "(global): " + ev)
+ logger.debug(self.global_dbg + self.ifname + "(global): " + ev)
for event in events:
if event in ev:
return ev
@@ -752,11 +756,11 @@ class WpaSupplicant:
count_global = 0
while self.mon.pending():
ev = self.mon.recv()
- logger.debug(self.ifname + ": " + ev)
+ logger.debug(self.dbg + ": " + ev)
count_iface += 1
while self.global_mon and self.global_mon.pending():
ev = self.global_mon.recv()
- logger.debug(self.ifname + "(global): " + ev)
+ logger.debug(self.global_dbg + self.ifname + "(global): " + ev)
count_global += 1
return (count_iface, count_global)