devtool: Add test-image plugin for testing packages via devtool via images.
PATCH v2 1/1 devtool: Add test-image plugin for testing packages via devtool via images.
Based of a feature of AUH this is a plugin to run a testimage directly with packages installed that you are working on via devtool.
Inputs would be a:
- target image
- target packages
The tool will take care to make sure it also installs the minimal necessary dependencies to be able to run ptest on the target image. Logs will be captured and stored in the devtool workspace for easy access.
An oe-selftest is added to test the plugin.
V2: Dropped the hard dependency on using ext4 as a filesystem for the test image, now it can be used with any filesystem supported by the testimage plugin. Furthermore now the correct test suite is installed.
--- meta/lib/oeqa/selftest/cases/devtool.py | 61 +++++++++++ scripts/lib/devtool/test_image.py | 130 ++++++++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 scripts/lib/devtool/test_image.py
meta/lib/oeqa/selftest/cases/devtool.py +61 -0
@@ -1932,6 +1932,67 @@ class DevtoolBuildImageTests(DevtoolBase): if reqpkgs: self.fail('The following packages were not present in the image as expected: %s' % ', '.join(reqpkgs)) + +class DevtoolTestImageTests(DevtoolBase): + + @OETestTag("runqemu") + def test_devtool_test_image(self): + """Test devtool test-image plugin.""" + + machine = get_bb_var('MACHINE') + if not machine or not machine.startswith('qemu'): + self.skipTest('This test only works with qemu machines') + + self.assertTrue(not os.path.exists(self.workspacedir), + 'This test cannot be run with a workspace directory under the build directory') + + image = 'oe-selftest-image' + recipe = 'python3-atomicwrites' + + # Ensure selected test package is ptest-capable. + ptest_path = get_bb_var('PTEST_PATH', recipe) + self.assertTrue(ptest_path, + 'Selected package %s does not appear to inherit ptest' % recipe) + + self.track_for_cleanup(self.workspacedir) + # self.add_command_to_tearDown('bitbake -c clean %s' % image) + self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') + + # Ensure we're starting from a clean state + bitbake('%s -c clean' % image) + + result = runCmd('devtool test-image %s -p %s' % (image, recipe), ignore_status=True) + if result.status != 0 and 'runqemu - ERROR - Unknown path arg' in result.output: + self.skipTest('runqemu in this environment does not accept testimage rootfs path args') + self.assertEqual(result.status, 0, + 'devtool test-image failed unexpectedly:\n%s' % result.output) + + # Check that requested package and its ptest package were installed + deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') + self.assertTrue(deploy_dir_image, 'Unable to get DEPLOY_DIR_IMAGE') + + manifests = sorted(glob.glob(os.path.join(deploy_dir_image, '%s*.manifest' % image))) + self.assertTrue(manifests, 'Image manifest not found for %s in %s' % (image, deploy_dir_image)) + manifest = manifests[-1] + self.assertExists(manifest, 'Image manifest not found: %s' % manifest) + + pkgs = set() + with open(manifest, 'r') as f: + for line in f: + splitval = line.split() + if splitval: + pkgs.add(splitval[0]) + + self.assertIn(recipe, pkgs) + self.assertIn(recipe + '-ptest', pkgs) + + match = re.search(r'Logs are in (\S+)', result.output) + if match: + logdir = match.group(1) + else: + logdir = os.path.join(self.workspacedir, 'testimage-logs') + self.assertTrue(os.path.isdir(logdir), 'Expected logs directory not found: %s' % logdir) + class DevtoolUpgradeTests(DevtoolBase): def setUp(self):
scripts/lib/devtool/test_image.py new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
2.43.0