diff options
| author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-03-13 18:27:06 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-03-20 11:27:48 +0000 |
| commit | a976d63ae5ccf0d27b8dd9a332a9406794c093cc (patch) | |
| tree | 356648a19322012d8de23876174da5e6af2b6a0d | |
| parent | a0b774e43ff5d952647fdcf412c9639d4e484ce1 (diff) | |
| download | poky-a976d63ae5ccf0d27b8dd9a332a9406794c093cc.tar.gz | |
oe-selftest: add a test for devtool deploy-target
Whilst this test would seemingly be better placed as a runtime test,
unfortunately the runtime tests run under bitbake and you can't run
devtool within bitbake (since devtool needs to run bitbake itself).
Additionally we are testing build-time functionality as well, so
really this has to be done as an oe-selftest test.
This test does have a few perhaps unusual requirements in order to run:
* pexpect is installed
* MACHINE is set to one of the qemu machines
* runqemu tap devices have been set up
(From OE-Core rev: 9dc16a8a87bef5dc408aefb256c01e2a4fe3563c)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta-selftest/recipes-test/images/oe-selftest-image.bb | 9 | ||||
| -rw-r--r-- | meta/lib/oeqa/selftest/devtool.py | 56 |
2 files changed, 65 insertions, 0 deletions
diff --git a/meta-selftest/recipes-test/images/oe-selftest-image.bb b/meta-selftest/recipes-test/images/oe-selftest-image.bb new file mode 100644 index 0000000000..f17094c5d0 --- /dev/null +++ b/meta-selftest/recipes-test/images/oe-selftest-image.bb | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | SUMMARY = "An image used during oe-selftest tests" | ||
| 2 | |||
| 3 | IMAGE_INSTALL = "packagegroup-core-boot ${ROOTFS_PKGMANAGE_BOOTSTRAP} dropbear" | ||
| 4 | IMAGE_FEATURES = "debug-tweaks" | ||
| 5 | |||
| 6 | IMAGE_LINGUAS = " " | ||
| 7 | |||
| 8 | inherit core-image | ||
| 9 | |||
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 2574e4bbf4..1caf0f098a 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py | |||
| @@ -437,3 +437,59 @@ class DevtoolTests(oeSelfTest): | |||
| 437 | self.assertFalse(matches1, 'Stamp files exist for recipe %s that should have been cleaned' % testrecipe1) | 437 | self.assertFalse(matches1, 'Stamp files exist for recipe %s that should have been cleaned' % testrecipe1) |
| 438 | matches2 = glob.glob(stampprefix2 + '*') | 438 | matches2 = glob.glob(stampprefix2 + '*') |
| 439 | self.assertFalse(matches2, 'Stamp files exist for recipe %s that should have been cleaned' % testrecipe2) | 439 | self.assertFalse(matches2, 'Stamp files exist for recipe %s that should have been cleaned' % testrecipe2) |
| 440 | |||
| 441 | def test_devtool_deploy_target(self): | ||
| 442 | # NOTE: Whilst this test would seemingly be better placed as a runtime test, | ||
| 443 | # unfortunately the runtime tests run under bitbake and you can't run | ||
| 444 | # devtool within bitbake (since devtool needs to run bitbake itself). | ||
| 445 | # Additionally we are testing build-time functionality as well, so | ||
| 446 | # really this has to be done as an oe-selftest test. | ||
| 447 | # | ||
| 448 | # Check preconditions | ||
| 449 | machine = get_bb_var('MACHINE') | ||
| 450 | if not machine.startswith('qemu'): | ||
| 451 | self.skipTest('This test only works with qemu machines') | ||
| 452 | if not os.path.exists('/etc/runqemu-nosudo'): | ||
| 453 | self.skipTest('You must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') | ||
| 454 | workspacedir = os.path.join(self.builddir, 'workspace') | ||
| 455 | self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory') | ||
| 456 | import pexpect | ||
| 457 | # Definitions | ||
| 458 | testrecipe = 'mdadm' | ||
| 459 | testfile = '/sbin/mdadm' | ||
| 460 | testimage = 'oe-selftest-image' | ||
| 461 | testhost = '192.168.7.2' | ||
| 462 | testcommand = '/sbin/mdadm --help' | ||
| 463 | # Build an image to run | ||
| 464 | bitbake("%s qemu-native qemu-helper-native" % testimage) | ||
| 465 | deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') | ||
| 466 | self.add_command_to_tearDown('bitbake -c clean %s' % testimage) | ||
| 467 | self.add_command_to_tearDown('rm -f %s/%s*' % (deploy_dir_image, testimage)) | ||
| 468 | # Clean recipe so the first deploy will fail | ||
| 469 | bitbake("%s -c clean" % testrecipe) | ||
| 470 | # Try devtool modify | ||
| 471 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | ||
| 472 | self.track_for_cleanup(tempdir) | ||
| 473 | self.track_for_cleanup(workspacedir) | ||
| 474 | self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') | ||
| 475 | self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) | ||
| 476 | result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) | ||
| 477 | # Test that deploy-target at this point fails (properly) | ||
| 478 | result = runCmd('devtool deploy-target -n %s root@%s' % (testrecipe, testhost), ignore_status=True) | ||
| 479 | self.assertNotEqual(result.output, 0, 'devtool deploy-target should have failed, output: %s' % result.output) | ||
| 480 | self.assertNotIn(result.output, 'Traceback', 'devtool deploy-target should have failed with a proper error not a traceback, output: %s' % result.output) | ||
| 481 | result = runCmd('devtool build %s' % testrecipe) | ||
| 482 | # First try a dry-run of deploy-target | ||
| 483 | result = runCmd('devtool deploy-target -n %s root@%s' % (testrecipe, testhost)) | ||
| 484 | self.assertIn(' %s' % testfile, result.output) | ||
| 485 | # Boot the image | ||
| 486 | console = pexpect.spawn('runqemu %s %s qemuparams="-snapshot" nographic' % (machine, testimage)) | ||
| 487 | console.expect("login:", timeout=120) | ||
| 488 | # Now really test deploy-target | ||
| 489 | result = runCmd('devtool deploy-target -c %s root@%s' % (testrecipe, testhost)) | ||
| 490 | result = runCmd('ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s %s' % (testhost, testcommand)) | ||
| 491 | # Test undeploy-target | ||
| 492 | result = runCmd('devtool undeploy-target -c %s root@%s' % (testrecipe, testhost)) | ||
| 493 | result = runCmd('ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s %s' % (testhost, testcommand), ignore_status=True) | ||
| 494 | self.assertNotEqual(result, 0, 'undeploy-target did not remove command as it should have') | ||
| 495 | console.close() | ||
