Skip to contentSkip to conversation

oeqa-runtime: fix run_network_serialdebug

PATCH New Peter Marko 1 participant 2 messages Jan 13

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 oeqa-runtime: fix run_network_serialdebug

From: Peter Marko <[email protected]>

This is a global function and thus does not have self object. Executing it leads to "NameError: name 'self' is not defined".

Change it to take parent object which contains all data which is needed to execute it.

---
 meta/lib/oeqa/runtime/case.py       | 14 +++++++-------
 meta/lib/oeqa/runtime/cases/ping.py |  2 +-
 meta/lib/oeqa/runtime/cases/ssh.py  |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)
meta/lib/oeqa/runtime/case.py +7 -7
index 2a47771a3d..095bcf434a 100644
@@ -22,15 +22,15 @@ class OERuntimeTestCase(OETestCase):
         super(OERuntimeTestCase, self).tearDown()
         uninstall_package(self)
 
-def run_network_serialdebug(runner):
-    if not runner:
+def run_network_serialdebug(target):
+    if not target.runner:
         return
-    status, output = runner.run_serial("ip addr")
+    status, output = target.runner.run_serial("ip addr")
     print("ip addr on target: %s %s" % (output, status))
-    status, output = runner.run_serial("ping -c 1 %s" % self.target.server_ip)
-    print("ping on target for %s: %s %s" % (self.target.server_ip, output, status))
-    status, output = runner.run_serial("ping -c 1 %s" % self.target.ip)
-    print("ping on target for %s: %s %s" % (self.target.ip, output, status))
+    status, output = target.runner.run_serial("ping -c 1 %s" % target.server_ip)
+    print("ping on target for %s: %s %s" % (target.server_ip, output, status))
+    status, output = target.runner.run_serial("ping -c 1 %s" % target.ip)
+    print("ping on target for %s: %s %s" % (target.ip, output, status))
     # Have to use a full path for netstat which isn't in HOSTTOOLS
     subprocess.call(["/usr/bin/netstat", "-tunape"])
     subprocess.call(["/usr/bin/netstat", "-ei"])
meta/lib/oeqa/runtime/cases/ping.py +1 -1
index efb91d4cc9..baea1b385b 100644
@@ -36,7 +36,7 @@ class PingTest(OERuntimeTestCase):
                     count = 0
                     sleep(1)
         except OEQATimeoutError:
-            run_network_serialdebug(self.target.runner)
+            run_network_serialdebug(self.target)
             self.fail("Ping timeout error for address %s, count %s, output: %s" % (self.target.ip, count, output))
         msg = ('Expected 5 consecutive, got %d.\n'
                'ping output is:\n%s' % (count,output))
meta/lib/oeqa/runtime/cases/ssh.py +1 -1
index 3e9503277e..5fa4bb98b5 100644
@@ -32,7 +32,7 @@ class SSHTest(OERuntimeTestCase):
               time.sleep(5)
               continue
           else:
-              run_network_serialdebug(self.target.runner)
+              run_network_serialdebug(self.target)
               self.fail("uname failed with \"%s\" (exit code %s)" % (output, status))
         if status != 0:
             self.fail("ssh failed with \"%s\" (exit code %s)" % (output, status))
#1 lore raw

PATCH 2/2 oeqa-runtime: avoid crash in run_network_serialdebug for missing netstat

From: Peter Marko <[email protected]>

If netstat is not installed on the host, the function fails.

---
 meta/lib/oeqa/runtime/case.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
meta/lib/oeqa/runtime/case.py +5 -2
index 095bcf434a..23796c0cdf 100644
@@ -32,7 +32,10 @@ def run_network_serialdebug(target):
     status, output = target.runner.run_serial("ping -c 1 %s" % target.ip)
     print("ping on target for %s: %s %s" % (target.ip, output, status))
     # Have to use a full path for netstat which isn't in HOSTTOOLS
-    subprocess.call(["/usr/bin/netstat", "-tunape"])
-    subprocess.call(["/usr/bin/netstat", "-ei"])
+    try:
+        subprocess.call(["/usr/bin/netstat", "-tunape"])
+        subprocess.call(["/usr/bin/netstat", "-ei"])
+    except (OSError, subprocess.SubprocessError) as e:
+        print("netstat failed: %s" % e)
     subprocess.call(["ps", "-awx"], shell=True)
     print("PID: %s %s" % (str(os.getpid()), time.time()))