summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/devtool.py56
1 files changed, 56 insertions, 0 deletions
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()