Re: [PATCH 2/2] tests: kill subprocess from test_ap_acs.py

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Apr 02, 2016 at 08:24:22AM +0200, Janusz Dziedzic wrote:
> diff --git a/tests/hwsim/test_ap_acs.py b/tests/hwsim/test_ap_acs.py
> @@ -145,7 +144,8 @@ def test_ap_acs_5ghz(dev, apdev):
> -        subprocess.call(['iw', 'reg', 'set', '00'])
> +            hapd.host.execute("iw reg set 00")
> +        dev[0].host.execute("iw reg set 00")

I'm dropping these two patches to avoid going from the list of arguments
to a single string with all those arguments. Instead, I'm applying the
following changes to get to a point where we do not add any more such
backwards changes. Please feel free to re-submit these two patches
rebased on top of that change, i.e., with maintaining the list of
arguments from the existing call.


diff --git a/tests/hwsim/remotehost.py b/tests/hwsim/remotehost.py
index cab2045..213c2fc 100644
--- a/tests/hwsim/remotehost.py
+++ b/tests/hwsim/remotehost.py
@@ -38,14 +38,10 @@ class Host():
             self.name = host
 
     def local_execute(self, command):
-        logger.debug("execute: " + command)
-        words = command.split()
-        cmd = []
-        for word in words:
-            cmd.append(word)
+        logger.debug("execute: " + str(command))
         try:
             status = 0;
-            buf = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+            buf = subprocess.check_output(command, stderr=subprocess.STDOUT)
         except subprocess.CalledProcessError as e:
             status = e.returncode
             buf = e.output
@@ -58,7 +54,7 @@ class Host():
         if self.host is None:
             return self.local_execute(command)
 
-        cmd = ["ssh", self.user + "@" + self.host, command]
+        cmd = ["ssh", self.user + "@" + self.host, ' '.join(command)]
         _cmd = self.name + " execute: "
         for c in cmd:
             _cmd = _cmd + " " + c
@@ -77,9 +73,9 @@ class Host():
     # async execute
     def execute_run(self, command, res):
         if self.host is None:
-            cmd = [command]
+            cmd = command
         else:
-            cmd = ["ssh",  self.user + "@" + self.host, command]
+            cmd = ["ssh",  self.user + "@" + self.host, ' '.join(command)]
         _cmd = self.name + " execute_run: "
         for c in cmd:
             _cmd = _cmd + " " + c
diff --git a/tests/hwsim/utils.py b/tests/hwsim/utils.py
index 5fb824e..479923c 100644
--- a/tests/hwsim/utils.py
+++ b/tests/hwsim/utils.py
@@ -92,7 +92,7 @@ def get_phy(ap, ifname=None):
 
     if ifname == None:
         ifname = ap['ifname']
-    status, buf = host.execute("iw dev " + ifname + " info")
+    status, buf = host.execute(["iw", "dev", ifname, "info"])
     if status != 0:
         raise Exception("iw " + ifname + " info failed")
     lines = buf.split("\n")
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index bc865b8..b164fe0 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -99,7 +99,7 @@ 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):
-        status, groups = self.host.execute("id")
+        status, groups = self.host.execute(["id"])
         if status != 0:
             group = "admin"
         group = "admin" if "(admin)" in groups else "adm"
@@ -191,11 +191,11 @@ class WpaSupplicant:
         if iter == 60:
             logger.error(self.ifname + ": Driver scan state did not clear")
             print "Trying to clear cfg80211/mac80211 scan state"
-            status, buf = self.host.execute("ifconfig " + self.ifname + " down")
+            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")
+            status, buf = self.host.execute(["ifconfig", self.ifname, "up"])
             if status != 0:
                 logger.info("ifconfig failed: " + buf)
                 logger.info(status)
-- 
1.9.1

 
-- 
Jouni Malinen                                            PGP id EFC895FA

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux