aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanusz Dziedzic <janusz.dziedzic@tieto.com>2016-03-08 13:28:04 (GMT)
committerJouni Malinen <j@w1.fi>2016-03-20 19:49:26 (GMT)
commit8ce4855b234ef1ff93b3cb42837a4a95b0fbbf55 (patch)
treea8c60c859696753d8cf7486eb7512252d9340e6f
parent2fa26715730f105fb0748b104a175ed9bcdc6379 (diff)
downloadhostap-8ce4855b234ef1ff93b3cb42837a4a95b0fbbf55.zip
hostap-8ce4855b234ef1ff93b3cb42837a4a95b0fbbf55.tar.gz
hostap-8ce4855b234ef1ff93b3cb42837a4a95b0fbbf55.tar.bz2
tests: hostapd.py/wpasupplicant.py use Host when executing commands
Execute commands using the Host class. This enables use of remote hosts as well. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
-rw-r--r--tests/hwsim/hostapd.py3
-rw-r--r--tests/hwsim/wpasupplicant.py31
2 files changed, 17 insertions, 17 deletions
diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index 1282e71..17fe2b6 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -10,6 +10,7 @@ import logging
import binascii
import struct
import wpaspy
+import remotehost
logger = logging.getLogger()
hapd_ctrl = '/var/run/hostapd'
@@ -20,6 +21,7 @@ def mac2tuple(mac):
class HostapdGlobal:
def __init__(self, hostname=None, port=8878):
+ self.host = remotehost.Host(hostname)
self.hostname = hostname
self.port = port
if hostname is None:
@@ -110,6 +112,7 @@ class HostapdGlobal:
class Hostapd:
def __init__(self, ifname, bssidx=0, hostname=None, port=8877):
+ self.host = remotehost.Host(hostname, ifname)
self.ifname = ifname
if hostname is None:
self.ctrl = wpaspy.Ctrl(os.path.join(hapd_ctrl, ifname))
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index 4856d3f..beae108 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -10,8 +10,8 @@ import logging
import binascii
import re
import struct
-import subprocess
import wpaspy
+import remotehost
logger = logging.getLogger()
wpas_ctrl = '/var/run/wpa_supplicant'
@@ -22,6 +22,7 @@ class WpaSupplicant:
self.hostname = hostname
self.group_ifname = None
self.gctrl_mon = None
+ self.host = remotehost.Host(hostname, ifname)
if ifname:
self.set_ifname(ifname, hostname, port)
else:
@@ -58,6 +59,7 @@ class WpaSupplicant:
if hostname != None:
self.ctrl = wpaspy.Ctrl(hostname, port)
self.mon = wpaspy.Ctrl(hostname, port)
+ self.host = remotehost.Host(hostname, ifname)
else:
self.ctrl = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname))
self.mon = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname))
@@ -93,11 +95,10 @@ class WpaSupplicant:
def interface_add(self, ifname, config="", driver="nl80211",
drv_params=None, br_ifname=None, create=False,
set_ifname=True, all_params=False, if_type=None):
- try:
- groups = subprocess.check_output(["id"])
- group = "admin" if "(admin)" in groups else "adm"
- except Exception, e:
+ status, groups = self.host.execute("id")
+ if status != 0:
group = "admin"
+ group = "admin" if "(admin)" in groups else "adm"
cmd = "INTERFACE_ADD " + ifname + "\t" + config + "\t" + driver + "\tDIR=/var/run/wpa_supplicant GROUP=" + group
if drv_params:
cmd = cmd + '\t' + drv_params
@@ -186,18 +187,14 @@ class WpaSupplicant:
if iter == 60:
logger.error(self.ifname + ": Driver scan state did not clear")
print "Trying to clear cfg80211/mac80211 scan state"
- try:
- cmd = ["ifconfig", self.ifname, "down"]
- subprocess.call(cmd)
- except subprocess.CalledProcessError, e:
- logger.info("ifconfig failed: " + str(e.returncode))
- logger.info(e.output)
- try:
- cmd = ["ifconfig", self.ifname, "up"]
- subprocess.call(cmd)
- except subprocess.CalledProcessError, e:
- logger.info("ifconfig failed: " + str(e.returncode))
- logger.info(e.output)
+ status, buf = self.host.execute("ifconfig " + self.ifname + " down")
+ if status != 0:
+ logger.info("ifconfig failed: " + buf)
+ logger.info(status)
+ status, buf = self.host.execute("ifconfig " + self.ifname + " up")
+ if status != 0:
+ logger.info("ifconfig failed: " + buf)
+ logger.info(status)
if iter > 0:
# The ongoing scan could have discovered BSSes or P2P peers
logger.info("Run FLUSH again since scan was in progress")