summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2017-03-24 01:45:01 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-27 08:15:06 +0100
commitb6f5a8ab6b69fea9c6ae71b5eb73f2c32d05b0fa (patch)
tree0c78620ad62f79bb87504ecfc5a35a230a0aefdf /meta/lib
parenta5a1d4f4319ec164abf904aeae0753c9bfefcb09 (diff)
downloadpoky-b6f5a8ab6b69fea9c6ae71b5eb73f2c32d05b0fa.tar.gz
selftest/runqemu.py: add it to test runqemu
Usage: $ oe-selftest -r runqemu Current test cases: $ runqemu nographic qemux86-64 $ runqemu nographic qemux86-64 ext4 $ runqemu nographic qemux86-64 iso $ runqemu nographic core-image-minimal $ runqemu nographic core-image-minimal vmdk $ runqemu nographic core-image-minimal vdi $ runqemu nographic tmp/deploy/images/qemux86-64 $ runqemu nographic tmp/deploy/images/qemux86-64 hddimg $ runqemu nographic qemux86-64 slirp $ runqemu nographic qemux86-64 slirp qcow2 $ runqemu nographic tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.qemuboot.conf $ runqemu nographic tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.ext4 Need more later: - Test initramfs - Test nfs - Test when set DEPLOY_DIR_IMAGE and OECORE_NATIVE_SYSROOT - And others which similate runqemu runs on SDK and eSDK. [YOCTO #10249] (From OE-Core rev: e7073cb4786411bb71645e7d7cbc1c510910c4cc) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/runqemu.py136
1 files changed, 136 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/runqemu.py b/meta/lib/oeqa/selftest/runqemu.py
new file mode 100644
index 0000000000..c1d5c16e81
--- /dev/null
+++ b/meta/lib/oeqa/selftest/runqemu.py
@@ -0,0 +1,136 @@
1#
2# Copyright (c) 2017 Wind River Systems, Inc.
3#
4
5import re
6import logging
7
8from oeqa.selftest.base import oeSelfTest
9from oeqa.utils.commands import bitbake, runqemu, get_bb_var
10from oeqa.utils.decorators import testcase
11
12class RunqemuTests(oeSelfTest):
13 """Runqemu test class"""
14
15 image_is_ready = False
16 deploy_dir_image = ''
17
18 def setUpLocal(self):
19 self.recipe = 'core-image-minimal'
20 self.machine = 'qemux86-64'
21 self.fstypes = "ext4 iso hddimg vmdk qcow2 vdi"
22 self.cmd_common = "runqemu nographic"
23
24 self.write_config(
25"""
26MACHINE = "%s"
27IMAGE_FSTYPES = "%s"
28# 10 means 1 second
29SYSLINUX_TIMEOUT = "10"
30"""
31% (self.machine, self.fstypes)
32 )
33
34 if not RunqemuTests.image_is_ready:
35 RunqemuTests.deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
36 bitbake(self.recipe)
37 RunqemuTests.image_is_ready = True
38
39 @testcase(2001)
40 def test_boot_machine(self):
41 """Test runqemu machine"""
42 cmd = "%s %s" % (self.cmd_common, self.machine)
43 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
44 self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
45
46 @testcase(2002)
47 def test_boot_machine_ext4(self):
48 """Test runqemu machine ext4"""
49 cmd = "%s %s ext4" % (self.cmd_common, self.machine)
50 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
51 with open(qemu.qemurunnerlog) as f:
52 self.assertTrue('rootfs.ext4' in f.read(), "Failed: %s" % cmd)
53
54 @testcase(2003)
55 def test_boot_machine_iso(self):
56 """Test runqemu machine iso"""
57 cmd = "%s %s iso" % (self.cmd_common, self.machine)
58 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
59 with open(qemu.qemurunnerlog) as f:
60 self.assertTrue(' -cdrom ' in f.read(), "Failed: %s" % cmd)
61
62 @testcase(2004)
63 def test_boot_recipe_image(self):
64 """Test runqemu recipe-image"""
65 cmd = "%s %s" % (self.cmd_common, self.recipe)
66 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
67 self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
68
69 @testcase(2005)
70 def test_boot_recipe_image_vmdk(self):
71 """Test runqemu recipe-image vmdk"""
72 cmd = "%s %s vmdk" % (self.cmd_common, self.recipe)
73 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
74 with open(qemu.qemurunnerlog) as f:
75 self.assertTrue('format=vmdk' in f.read(), "Failed: %s" % cmd)
76
77 @testcase(2006)
78 def test_boot_recipe_image_vdi(self):
79 """Test runqemu recipe-image vdi"""
80 cmd = "%s %s vdi" % (self.cmd_common, self.recipe)
81 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
82 with open(qemu.qemurunnerlog) as f:
83 self.assertTrue('format=vdi' in f.read(), "Failed: %s" % cmd)
84
85 @testcase(2007)
86 def test_boot_deploy(self):
87 """Test runqemu deploy_dir_image"""
88 cmd = "%s %s" % (self.cmd_common, self.deploy_dir_image)
89 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
90 self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
91
92 @testcase(2008)
93 def test_boot_deploy_hddimg(self):
94 """Test runqemu deploy_dir_image hddimg"""
95 cmd = "%s %s hddimg" % (self.cmd_common, self.deploy_dir_image)
96 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
97 with open(qemu.qemurunnerlog) as f:
98 self.assertTrue(re.search('file=.*.hddimg', f.read()), "Failed: %s" % cmd)
99
100 @testcase(2009)
101 def test_boot_machine_slirp(self):
102 """Test runqemu machine slirp"""
103 cmd = "%s slirp %s" % (self.cmd_common, self.machine)
104 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
105 with open(qemu.qemurunnerlog) as f:
106 self.assertTrue(' -netdev user' in f.read(), "Failed: %s" % cmd)
107
108 @testcase(2009)
109 def test_boot_machine_slirp_qcow2(self):
110 """Test runqemu machine slirp qcow2"""
111 cmd = "%s slirp qcow2 %s" % (self.cmd_common, self.machine)
112 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
113 with open(qemu.qemurunnerlog) as f:
114 self.assertTrue('format=qcow2' in f.read(), "Failed: %s" % cmd)
115
116 @testcase(2010)
117 def test_boot_qemu_boot(self):
118 """Test runqemu /path/to/image.qemuboot.conf"""
119 qemuboot_conf = "%s-%s.qemuboot.conf" % (self.recipe, self.machine)
120 qemuboot_conf = os.path.join(self.deploy_dir_image, qemuboot_conf)
121 if not os.path.exists(qemuboot_conf):
122 self.skipTest("%s not found" % qemuboot_conf)
123 cmd = "%s %s" % (self.cmd_common, qemuboot_conf)
124 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
125 self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
126
127 @testcase(2011)
128 def test_boot_rootfs(self):
129 """Test runqemu /path/to/rootfs.ext4"""
130 rootfs = "%s-%s.ext4" % (self.recipe, self.machine)
131 rootfs = os.path.join(self.deploy_dir_image, rootfs)
132 if not os.path.exists(rootfs):
133 self.skipTest("%s not found" % rootfs)
134 cmd = "%s %s" % (self.cmd_common, rootfs)
135 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
136 self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)