diff options
| author | Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | 2017-05-12 14:40:21 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-06 19:02:43 +0100 |
| commit | 157c3be2ca93f076033f725ec1ee912df91f7488 (patch) | |
| tree | 8ef896ff7adf78d63b34059cd5b017a4f0a3419a /meta/lib/oeqa/selftest/cases/runqemu.py | |
| parent | 10c512b60d1167122b5fe778b93838dca3def717 (diff) | |
| download | poky-157c3be2ca93f076033f725ec1ee912df91f7488.tar.gz | |
oeqa/selftest/cases: Migrate test cases into the new oe-qa framework
New framework has different classes/decorators so adapt current test cases to
support these. Changes include changes on base classes and decorators.
Also include paths in selftest/__init__.py isn't needed because the
loader is the standard unittest one.
(From OE-Core rev: ddbbefdd124604d10bd47dd0266b55a764fcc0ab)
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/runqemu.py')
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/runqemu.py | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/runqemu.py b/meta/lib/oeqa/selftest/cases/runqemu.py new file mode 100644 index 0000000000..4050a4123b --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/runqemu.py | |||
| @@ -0,0 +1,141 @@ | |||
| 1 | # | ||
| 2 | # Copyright (c) 2017 Wind River Systems, Inc. | ||
| 3 | # | ||
| 4 | |||
| 5 | import re | ||
| 6 | import logging | ||
| 7 | |||
| 8 | from oeqa.selftest.case import OESelftestTestCase | ||
| 9 | from oeqa.utils.commands import bitbake, runqemu, get_bb_var | ||
| 10 | from oeqa.core.decorator.oeid import OETestID | ||
| 11 | |||
| 12 | class RunqemuTests(OESelftestTestCase): | ||
| 13 | """Runqemu test class""" | ||
| 14 | |||
| 15 | image_is_ready = False | ||
| 16 | deploy_dir_image = '' | ||
| 17 | |||
| 18 | def setUpLocal(self): | ||
| 19 | super(RunqemuTests, self).setUpLocal() | ||
| 20 | self.recipe = 'core-image-minimal' | ||
| 21 | self.machine = 'qemux86-64' | ||
| 22 | self.fstypes = "ext4 iso hddimg vmdk qcow2 vdi" | ||
| 23 | self.cmd_common = "runqemu nographic" | ||
| 24 | |||
| 25 | # Avoid emit the same record multiple times. | ||
| 26 | mainlogger = logging.getLogger("BitBake.Main") | ||
| 27 | mainlogger.propagate = False | ||
| 28 | |||
| 29 | self.write_config( | ||
| 30 | """ | ||
| 31 | MACHINE = "%s" | ||
| 32 | IMAGE_FSTYPES = "%s" | ||
| 33 | # 10 means 1 second | ||
| 34 | SYSLINUX_TIMEOUT = "10" | ||
| 35 | """ | ||
| 36 | % (self.machine, self.fstypes) | ||
| 37 | ) | ||
| 38 | |||
| 39 | if not RunqemuTests.image_is_ready: | ||
| 40 | RunqemuTests.deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') | ||
| 41 | bitbake(self.recipe) | ||
| 42 | RunqemuTests.image_is_ready = True | ||
| 43 | |||
| 44 | @OETestID(2001) | ||
| 45 | def test_boot_machine(self): | ||
| 46 | """Test runqemu machine""" | ||
| 47 | cmd = "%s %s" % (self.cmd_common, self.machine) | ||
| 48 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 49 | self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd) | ||
| 50 | |||
| 51 | @OETestID(2002) | ||
| 52 | def test_boot_machine_ext4(self): | ||
| 53 | """Test runqemu machine ext4""" | ||
| 54 | cmd = "%s %s ext4" % (self.cmd_common, self.machine) | ||
| 55 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 56 | with open(qemu.qemurunnerlog) as f: | ||
| 57 | self.assertTrue('rootfs.ext4' in f.read(), "Failed: %s" % cmd) | ||
| 58 | |||
| 59 | @OETestID(2003) | ||
| 60 | def test_boot_machine_iso(self): | ||
| 61 | """Test runqemu machine iso""" | ||
| 62 | cmd = "%s %s iso" % (self.cmd_common, self.machine) | ||
| 63 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 64 | with open(qemu.qemurunnerlog) as f: | ||
| 65 | self.assertTrue(' -cdrom ' in f.read(), "Failed: %s" % cmd) | ||
| 66 | |||
| 67 | @OETestID(2004) | ||
| 68 | def test_boot_recipe_image(self): | ||
| 69 | """Test runqemu recipe-image""" | ||
| 70 | cmd = "%s %s" % (self.cmd_common, self.recipe) | ||
| 71 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 72 | self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd) | ||
| 73 | |||
| 74 | @OETestID(2005) | ||
| 75 | def test_boot_recipe_image_vmdk(self): | ||
| 76 | """Test runqemu recipe-image vmdk""" | ||
| 77 | cmd = "%s %s vmdk" % (self.cmd_common, self.recipe) | ||
| 78 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 79 | with open(qemu.qemurunnerlog) as f: | ||
| 80 | self.assertTrue('format=vmdk' in f.read(), "Failed: %s" % cmd) | ||
| 81 | |||
| 82 | @OETestID(2006) | ||
| 83 | def test_boot_recipe_image_vdi(self): | ||
| 84 | """Test runqemu recipe-image vdi""" | ||
| 85 | cmd = "%s %s vdi" % (self.cmd_common, self.recipe) | ||
| 86 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 87 | with open(qemu.qemurunnerlog) as f: | ||
| 88 | self.assertTrue('format=vdi' in f.read(), "Failed: %s" % cmd) | ||
| 89 | |||
| 90 | @OETestID(2007) | ||
| 91 | def test_boot_deploy(self): | ||
| 92 | """Test runqemu deploy_dir_image""" | ||
| 93 | cmd = "%s %s" % (self.cmd_common, self.deploy_dir_image) | ||
| 94 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 95 | self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd) | ||
| 96 | |||
| 97 | @OETestID(2008) | ||
| 98 | def test_boot_deploy_hddimg(self): | ||
| 99 | """Test runqemu deploy_dir_image hddimg""" | ||
| 100 | cmd = "%s %s hddimg" % (self.cmd_common, self.deploy_dir_image) | ||
| 101 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 102 | with open(qemu.qemurunnerlog) as f: | ||
| 103 | self.assertTrue(re.search('file=.*.hddimg', f.read()), "Failed: %s" % cmd) | ||
| 104 | |||
| 105 | @OETestID(2009) | ||
| 106 | def test_boot_machine_slirp(self): | ||
| 107 | """Test runqemu machine slirp""" | ||
| 108 | cmd = "%s slirp %s" % (self.cmd_common, self.machine) | ||
| 109 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 110 | with open(qemu.qemurunnerlog) as f: | ||
| 111 | self.assertTrue(' -netdev user' in f.read(), "Failed: %s" % cmd) | ||
| 112 | |||
| 113 | @OETestID(2009) | ||
| 114 | def test_boot_machine_slirp_qcow2(self): | ||
| 115 | """Test runqemu machine slirp qcow2""" | ||
| 116 | cmd = "%s slirp qcow2 %s" % (self.cmd_common, self.machine) | ||
| 117 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 118 | with open(qemu.qemurunnerlog) as f: | ||
| 119 | self.assertTrue('format=qcow2' in f.read(), "Failed: %s" % cmd) | ||
| 120 | |||
| 121 | @OETestID(2010) | ||
| 122 | def test_boot_qemu_boot(self): | ||
| 123 | """Test runqemu /path/to/image.qemuboot.conf""" | ||
| 124 | qemuboot_conf = "%s-%s.qemuboot.conf" % (self.recipe, self.machine) | ||
| 125 | qemuboot_conf = os.path.join(self.deploy_dir_image, qemuboot_conf) | ||
| 126 | if not os.path.exists(qemuboot_conf): | ||
| 127 | self.skipTest("%s not found" % qemuboot_conf) | ||
| 128 | cmd = "%s %s" % (self.cmd_common, qemuboot_conf) | ||
| 129 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 130 | self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd) | ||
| 131 | |||
| 132 | @OETestID(2011) | ||
| 133 | def test_boot_rootfs(self): | ||
| 134 | """Test runqemu /path/to/rootfs.ext4""" | ||
| 135 | rootfs = "%s-%s.ext4" % (self.recipe, self.machine) | ||
| 136 | rootfs = os.path.join(self.deploy_dir_image, rootfs) | ||
| 137 | if not os.path.exists(rootfs): | ||
| 138 | self.skipTest("%s not found" % rootfs) | ||
| 139 | cmd = "%s %s" % (self.cmd_common, rootfs) | ||
| 140 | with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: | ||
| 141 | self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd) | ||
