If networking fails, we can get useful informaiton over the serial connection. 
Add
this fallback code so that any issues can be more easily debugged by showing the
host and target networking states.

Signed-off-by: Richard Purdie <richard.pur...@linuxfoundation.org>
---
 meta/lib/oeqa/runtime/case.py       | 16 ++++++++++++++++
 meta/lib/oeqa/runtime/cases/ping.py |  3 ++-
 meta/lib/oeqa/runtime/cases/ssh.py  |  3 ++-
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/meta/lib/oeqa/runtime/case.py b/meta/lib/oeqa/runtime/case.py
index f036982e1f8..9515ca2f3d6 100644
--- a/meta/lib/oeqa/runtime/case.py
+++ b/meta/lib/oeqa/runtime/case.py
@@ -4,6 +4,9 @@
 # SPDX-License-Identifier: MIT
 #
 
+import os
+import subprocess
+import time
 from oeqa.core.case import OETestCase
 from oeqa.utils.package_manager import install_package, uninstall_package
 
@@ -18,3 +21,16 @@ class OERuntimeTestCase(OETestCase):
     def tearDown(self):
         super(OERuntimeTestCase, self).tearDown()
         uninstall_package(self)
+
+def run_network_serialdebug(runner):
+    status, output = 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))
+    # 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"])
+    subprocess.call(["ps", "-awx"], shell=True)
+    print("PID: %s %s" % (str(os.getpid()), time.time()))
diff --git a/meta/lib/oeqa/runtime/cases/ping.py 
b/meta/lib/oeqa/runtime/cases/ping.py
index bc543f6c41e..efb91d4cc9d 100644
--- a/meta/lib/oeqa/runtime/cases/ping.py
+++ b/meta/lib/oeqa/runtime/cases/ping.py
@@ -7,7 +7,7 @@
 from subprocess import Popen, PIPE
 from time import sleep
 
-from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.runtime.case import OERuntimeTestCase, run_network_serialdebug
 from oeqa.core.decorator.oetimeout import OETimeout
 from oeqa.core.exception import OEQATimeoutError
 
@@ -36,6 +36,7 @@ class PingTest(OERuntimeTestCase):
                     count = 0
                     sleep(1)
         except OEQATimeoutError:
+            run_network_serialdebug(self.target.runner)
             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))
diff --git a/meta/lib/oeqa/runtime/cases/ssh.py 
b/meta/lib/oeqa/runtime/cases/ssh.py
index 89d64430e5c..b632a29a017 100644
--- a/meta/lib/oeqa/runtime/cases/ssh.py
+++ b/meta/lib/oeqa/runtime/cases/ssh.py
@@ -7,7 +7,7 @@
 import time
 import signal
 
-from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.runtime.case import OERuntimeTestCase, run_network_serialdebug
 from oeqa.core.decorator.depends import OETestDepends
 from oeqa.runtime.decorator.package import OEHasPackage
 
@@ -32,6 +32,7 @@ class SSHTest(OERuntimeTestCase):
               time.sleep(5)
               continue
           else:
+              run_network_serialdebug(self.target.runner)
               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))
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#211103): 
https://lists.openembedded.org/g/openembedded-core/message/211103
Mute This Topic: https://lists.openembedded.org/mt/111104829/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to