summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2024-10-19 09:59:21 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-02-11 11:44:19 +0000
commit261a1409b1dad8673bc9de68c2ee949e2ec1ca0b (patch)
treef42bc851a52463f1d2b4b7ffdca8c7e7651a4af3
parenta24b1786664ce8086f4e5b40843adc35bb2de736 (diff)
downloadpoky-261a1409b1dad8673bc9de68c2ee949e2ec1ca0b.tar.gz
oeqa/runtime: Add debugging if networking fails
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. (From OE-Core rev: 3291f9d07ecfe7d3301dc914f5e6a80577cf1d5d) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/runtime/case.py16
-rw-r--r--meta/lib/oeqa/runtime/cases/ping.py3
-rw-r--r--meta/lib/oeqa/runtime/cases/ssh.py3
3 files changed, 20 insertions, 2 deletions
diff --git a/meta/lib/oeqa/runtime/case.py b/meta/lib/oeqa/runtime/case.py
index f036982e1f..9515ca2f3d 100644
--- a/meta/lib/oeqa/runtime/case.py
+++ b/meta/lib/oeqa/runtime/case.py
@@ -4,6 +4,9 @@
4# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
5# 5#
6 6
7import os
8import subprocess
9import time
7from oeqa.core.case import OETestCase 10from oeqa.core.case import OETestCase
8from oeqa.utils.package_manager import install_package, uninstall_package 11from oeqa.utils.package_manager import install_package, uninstall_package
9 12
@@ -18,3 +21,16 @@ class OERuntimeTestCase(OETestCase):
18 def tearDown(self): 21 def tearDown(self):
19 super(OERuntimeTestCase, self).tearDown() 22 super(OERuntimeTestCase, self).tearDown()
20 uninstall_package(self) 23 uninstall_package(self)
24
25def run_network_serialdebug(runner):
26 status, output = runner.run_serial("ip addr")
27 print("ip addr on target: %s %s" % (output, status))
28 status, output = runner.run_serial("ping -c 1 %s" % self.target.server_ip)
29 print("ping on target for %s: %s %s" % (self.target.server_ip, output, status))
30 status, output = runner.run_serial("ping -c 1 %s" % self.target.ip)
31 print("ping on target for %s: %s %s" % (self.target.ip, output, status))
32 # Have to use a full path for netstat which isn't in HOSTTOOLS
33 subprocess.call(["/usr/bin/netstat", "-tunape"])
34 subprocess.call(["/usr/bin/netstat", "-ei"])
35 subprocess.call(["ps", "-awx"], shell=True)
36 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 bc543f6c41..efb91d4cc9 100644
--- a/meta/lib/oeqa/runtime/cases/ping.py
+++ b/meta/lib/oeqa/runtime/cases/ping.py
@@ -7,7 +7,7 @@
7from subprocess import Popen, PIPE 7from subprocess import Popen, PIPE
8from time import sleep 8from time import sleep
9 9
10from oeqa.runtime.case import OERuntimeTestCase 10from oeqa.runtime.case import OERuntimeTestCase, run_network_serialdebug
11from oeqa.core.decorator.oetimeout import OETimeout 11from oeqa.core.decorator.oetimeout import OETimeout
12from oeqa.core.exception import OEQATimeoutError 12from oeqa.core.exception import OEQATimeoutError
13 13
@@ -36,6 +36,7 @@ class PingTest(OERuntimeTestCase):
36 count = 0 36 count = 0
37 sleep(1) 37 sleep(1)
38 except OEQATimeoutError: 38 except OEQATimeoutError:
39 run_network_serialdebug(self.target.runner)
39 self.fail("Ping timeout error for address %s, count %s, output: %s" % (self.target.ip, count, output)) 40 self.fail("Ping timeout error for address %s, count %s, output: %s" % (self.target.ip, count, output))
40 msg = ('Expected 5 consecutive, got %d.\n' 41 msg = ('Expected 5 consecutive, got %d.\n'
41 'ping output is:\n%s' % (count,output)) 42 '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 89d64430e5..b632a29a01 100644
--- a/meta/lib/oeqa/runtime/cases/ssh.py
+++ b/meta/lib/oeqa/runtime/cases/ssh.py
@@ -7,7 +7,7 @@
7import time 7import time
8import signal 8import signal
9 9
10from oeqa.runtime.case import OERuntimeTestCase 10from oeqa.runtime.case import OERuntimeTestCase, run_network_serialdebug
11from oeqa.core.decorator.depends import OETestDepends 11from oeqa.core.decorator.depends import OETestDepends
12from oeqa.runtime.decorator.package import OEHasPackage 12from oeqa.runtime.decorator.package import OEHasPackage
13 13
@@ -32,6 +32,7 @@ class SSHTest(OERuntimeTestCase):
32 time.sleep(5) 32 time.sleep(5)
33 continue 33 continue
34 else: 34 else:
35 run_network_serialdebug(self.target.runner)
35 self.fail("uname failed with \"%s\" (exit code %s)" % (output, status)) 36 self.fail("uname failed with \"%s\" (exit code %s)" % (output, status))
36 if status != 0: 37 if status != 0:
37 self.fail("ssh failed with \"%s\" (exit code %s)" % (output, status)) 38 self.fail("ssh failed with \"%s\" (exit code %s)" % (output, status))