summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Freihofer <adrian.freihofer@gmail.com>2023-09-10 17:52:36 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-09-12 12:44:47 +0100
commit843c6c2e055525af4c0c4a8f1e925a23c4280f0a (patch)
tree467718a7b8a717e24351309c24d967c6a66f5106
parentb31f99a6cbd138049d2370fa367ff55e1ec4b31d (diff)
downloadpoky-843c6c2e055525af4c0c4a8f1e925a23c4280f0a.tar.gz
oeqa/selftest/devtool: Refactor runqemu pre-requisites
Split runqemu pre-requisites into a function which can be re-used by other tests as well. (From OE-Core rev: 020a51769439f173980315f15ad64bdace8c22b2) Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/cases/devtool.py48
1 files changed, 26 insertions, 22 deletions
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index a2b77e528d..b577f6d62a 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -256,6 +256,31 @@ class DevtoolTestCase(OESelftestTestCase):
256 if remaining_removelines: 256 if remaining_removelines:
257 self.fail('Expected removed lines not found: %s' % remaining_removelines) 257 self.fail('Expected removed lines not found: %s' % remaining_removelines)
258 258
259 def _check_runqemu_prerequisites(self):
260 """Check runqemu is available
261
262 Whilst some tests would seemingly be better placed as a runtime test,
263 unfortunately the runtime tests run under bitbake and you can't run
264 devtool within bitbake (since devtool needs to run bitbake itself).
265 Additionally we are testing build-time functionality as well, so
266 really this has to be done as an oe-selftest test.
267 """
268 machine = get_bb_var('MACHINE')
269 if not machine.startswith('qemu'):
270 self.skipTest('This test only works with qemu machines')
271 if not os.path.exists('/etc/runqemu-nosudo'):
272 self.skipTest('You must set up tap devices with scripts/runqemu-gen-tapdevs before running this test')
273 result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ip tuntap show', ignore_status=True)
274 if result.status != 0:
275 result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ifconfig -a', ignore_status=True)
276 if result.status != 0:
277 self.skipTest('Failed to determine if tap devices exist with ifconfig or ip: %s' % result.output)
278 for line in result.output.splitlines():
279 if line.startswith('tap'):
280 break
281 else:
282 self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test')
283
259 def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri): 284 def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri):
260 self.track_for_cleanup(self.workspacedir) 285 self.track_for_cleanup(self.workspacedir)
261 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') 286 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
@@ -1616,28 +1641,7 @@ class DevtoolExtractTests(DevtoolBase):
1616 1641
1617 @OETestTag("runqemu") 1642 @OETestTag("runqemu")
1618 def test_devtool_deploy_target(self): 1643 def test_devtool_deploy_target(self):
1619 # NOTE: Whilst this test would seemingly be better placed as a runtime test, 1644 self._check_runqemu_prerequisites()
1620 # unfortunately the runtime tests run under bitbake and you can't run
1621 # devtool within bitbake (since devtool needs to run bitbake itself).
1622 # Additionally we are testing build-time functionality as well, so
1623 # really this has to be done as an oe-selftest test.
1624 #
1625 # Check preconditions
1626 machine = get_bb_var('MACHINE')
1627 if not machine.startswith('qemu'):
1628 self.skipTest('This test only works with qemu machines')
1629 if not os.path.exists('/etc/runqemu-nosudo'):
1630 self.skipTest('You must set up tap devices with scripts/runqemu-gen-tapdevs before running this test')
1631 result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ip tuntap show', ignore_status=True)
1632 if result.status != 0:
1633 result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ifconfig -a', ignore_status=True)
1634 if result.status != 0:
1635 self.skipTest('Failed to determine if tap devices exist with ifconfig or ip: %s' % result.output)
1636 for line in result.output.splitlines():
1637 if line.startswith('tap'):
1638 break
1639 else:
1640 self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test')
1641 self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') 1645 self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory')
1642 # Definitions 1646 # Definitions
1643 testrecipe = 'mdadm' 1647 testrecipe = 'mdadm'