From 7ba23b1c1189978655c3eddf44b91dee2aa2ef0d Mon Sep 17 00:00:00 2001 From: Adrian Freihofer Date: Mon, 7 Jul 2025 22:34:18 +0200 Subject: oe-selftest: devtool: split tap detection into function Make the check for tap devices available as a function which can be used by other tests as well. Remove /etc/runqemu-nosudo check for tap device detection. The /etc/runqemu-nosudo file is a state file created by the runqemu-gen-tapdevs script. Tap device detection now relies only on the presence of tap interfaces, making the check more robust and not dependent on the runqemu-gen-tapdevs script, which is just one way of creating the tap interfaces. Simplify the code by removing the fallback to ifconfig if the ip command is not available. ip commands are nowadays available on all host machines. The transition from ifconfig to ip has taken place long time ago e.g. for the runqemu-gen-tapdevs script. (From OE-Core rev: 75b149ce465486834d081ffdfcbfece7fdb03591) Signed-off-by: Adrian Freihofer Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- meta/lib/oeqa/selftest/cases/devtool.py | 14 ++------------ meta/lib/oeqa/utils/commands.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py index 9fc3eaa311..a11934852a 100644 --- a/meta/lib/oeqa/selftest/cases/devtool.py +++ b/meta/lib/oeqa/selftest/cases/devtool.py @@ -16,7 +16,7 @@ import json from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer -from oeqa.utils.commands import get_bb_vars, runqemu, get_test_layer +from oeqa.utils.commands import get_bb_vars, runqemu, runqemu_check_taps, get_test_layer from oeqa.core.decorator import OETestTag oldmetapath = None @@ -277,18 +277,8 @@ class DevtoolTestCase(OESelftestTestCase): machine = get_bb_var('MACHINE') if not machine.startswith('qemu'): self.skipTest('This test only works with qemu machines') - if not os.path.exists('/etc/runqemu-nosudo'): + if not runqemu_check_taps(): self.skipTest('You must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') - result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ip tuntap show', ignore_status=True) - if result.status != 0: - result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ifconfig -a', ignore_status=True) - if result.status != 0: - self.skipTest('Failed to determine if tap devices exist with ifconfig or ip: %s' % result.output) - for line in result.output.splitlines(): - if line.startswith('tap'): - break - else: - self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri, srcrev=None): self.track_for_cleanup(self.workspacedir) diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index b60a6e6c38..5eaedd2fd9 100644 --- a/meta/lib/oeqa/utils/commands.py +++ b/meta/lib/oeqa/utils/commands.py @@ -401,6 +401,16 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, targetlogger.removeHandler(handler) qemu.stop() +def runqemu_check_taps(): + """Check if tap devices for runqemu are available""" + result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ip tuntap show', ignore_status=True) + if result.status != 0: + return False + for line in result.output.splitlines(): + if line.startswith('tap'): + return True + return False + def updateEnv(env_file): """ Source a file and update environment. -- cgit v1.2.3-54-g00ecf