Add the feature to execute shell commands on each supplicant/hostapd iface host. When executing remote tests then the interfaces are not all on a single host so when executing shell commands the test needs to execute the command on the host which the interface relevant for the command is on. This patch enables tests to execute the command on the relevant host. Signed-off-by: Jonathan Afek <jonathanx.afek@xxxxxxxxx> --- tests/hwsim/hostapd.py | 34 ++++++++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 15 +++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index 6d6d641..4fd2e13 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -12,6 +12,7 @@ import struct import wpaspy import remotehost import utils +import subprocess logger = logging.getLogger() hapd_ctrl = '/var/run/hostapd' @@ -41,6 +42,20 @@ class HostapdGlobal: self.dbg = hostname + "/" + str(port) self.mon.attach() + def cmd_execute(self, cmd_array): + if self.hostname is None: + cmd = "" + for arg in cmd_array: + cmd += arg + " " + cmd = cmd.strip() + proc = subprocess.Popen(cmd, stderr=subprocess.STDOUT, + stdout=subprocess.PIPE, shell=True) + out = proc.communicate()[0] + ret = proc.returncode + return ret, out + else: + return self.host.execute(cmd_array) + def request(self, cmd, timeout=10): logger.debug(self.dbg + ": CTRL(global): " + cmd) return self.ctrl.request(cmd, timeout) @@ -133,6 +148,21 @@ class Hostapd: self.mon.attach() self.bssid = None self.bssidx = bssidx + self.hostname = hostname + + def cmd_execute(self, cmd_array): + if self.hostname is None: + cmd = "" + for arg in cmd_array: + cmd += arg + " " + cmd = cmd.strip() + proc = subprocess.Popen(cmd, stderr=subprocess.STDOUT, + stdout=subprocess.PIPE, shell=True) + out = proc.communicate()[0] + ret = proc.returncode + return ret, out + else: + return self.host.execute(cmd_array) def close_ctrl(self): if self.mon is not None: @@ -561,3 +591,7 @@ def ht40_minus_params(channel="1", ssid=None, country=None): params = ht20_params(channel, ssid, country) params['ht_capab'] = "[HT40-]" return params + +def cmd_execute(apdev, cmd): + hapd_global = HostapdGlobal(apdev) + return hapd_global.cmd_execute(cmd) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 46d38f2..0c8a76a 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -12,6 +12,7 @@ import re import struct import wpaspy import remotehost +import subprocess logger = logging.getLogger() wpas_ctrl = '/var/run/wpa_supplicant' @@ -48,6 +49,20 @@ class WpaSupplicant: else: self.global_mon = None + def cmd_execute(self, cmd_array): + if self.hostname is None: + cmd = "" + for arg in cmd_array: + cmd += arg + " " + cmd = cmd.strip() + proc = subprocess.Popen(cmd, stderr=subprocess.STDOUT, + stdout=subprocess.PIPE, shell=True) + out = proc.communicate()[0] + ret = proc.returncode + return ret, out + else: + return self.host.execute(cmd_array) + def terminate(self): if self.global_mon: self.global_mon.detach() -- 1.9.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap