diff options
author | Adrian Freihofer <adrian.freihofer@siemens.com> | 2025-07-07 22:34:18 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-07-10 23:26:46 +0100 |
commit | 7ba23b1c1189978655c3eddf44b91dee2aa2ef0d (patch) | |
tree | 999adf56e3ddf3ff8a9c38faf01d1d6b6d70d632 | |
parent | 934856dd03528d3b33eda1a8b11841abb29aa1b9 (diff) | |
download | poky-master-next.tar.gz |
oe-selftest: devtool: split tap detection into functionmaster-next
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 <adrian.freihofer@siemens.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/selftest/cases/devtool.py | 14 | ||||
-rw-r--r-- | 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 | |||
16 | 16 | ||
17 | from oeqa.selftest.case import OESelftestTestCase | 17 | from oeqa.selftest.case import OESelftestTestCase |
18 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer | 18 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer |
19 | from oeqa.utils.commands import get_bb_vars, runqemu, get_test_layer | 19 | from oeqa.utils.commands import get_bb_vars, runqemu, runqemu_check_taps, get_test_layer |
20 | from oeqa.core.decorator import OETestTag | 20 | from oeqa.core.decorator import OETestTag |
21 | 21 | ||
22 | oldmetapath = None | 22 | oldmetapath = None |
@@ -277,18 +277,8 @@ class DevtoolTestCase(OESelftestTestCase): | |||
277 | machine = get_bb_var('MACHINE') | 277 | machine = get_bb_var('MACHINE') |
278 | if not machine.startswith('qemu'): | 278 | if not machine.startswith('qemu'): |
279 | self.skipTest('This test only works with qemu machines') | 279 | self.skipTest('This test only works with qemu machines') |
280 | if not os.path.exists('/etc/runqemu-nosudo'): | 280 | if not runqemu_check_taps(): |
281 | self.skipTest('You must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') | 281 | self.skipTest('You must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') |
282 | result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ip tuntap show', ignore_status=True) | ||
283 | if result.status != 0: | ||
284 | result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ifconfig -a', ignore_status=True) | ||
285 | if result.status != 0: | ||
286 | self.skipTest('Failed to determine if tap devices exist with ifconfig or ip: %s' % result.output) | ||
287 | for line in result.output.splitlines(): | ||
288 | if line.startswith('tap'): | ||
289 | break | ||
290 | else: | ||
291 | self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') | ||
292 | 282 | ||
293 | def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri, srcrev=None): | 283 | def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri, srcrev=None): |
294 | self.track_for_cleanup(self.workspacedir) | 284 | 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, | |||
401 | targetlogger.removeHandler(handler) | 401 | targetlogger.removeHandler(handler) |
402 | qemu.stop() | 402 | qemu.stop() |
403 | 403 | ||
404 | def runqemu_check_taps(): | ||
405 | """Check if tap devices for runqemu are available""" | ||
406 | result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ip tuntap show', ignore_status=True) | ||
407 | if result.status != 0: | ||
408 | return False | ||
409 | for line in result.output.splitlines(): | ||
410 | if line.startswith('tap'): | ||
411 | return True | ||
412 | return False | ||
413 | |||
404 | def updateEnv(env_file): | 414 | def updateEnv(env_file): |
405 | """ | 415 | """ |
406 | Source a file and update environment. | 416 | Source a file and update environment. |