[oe-commits] [openembedded-core] 08/28: selftest/runqemu.py: add it to test runqemu

git at git.openembedded.org git at git.openembedded.org
Sat Mar 25 11:03:59 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit da014d3aba7f16af2396252050d1e7e93a2cadb2
Author: Robert Yang <liezhi.yang at windriver.com>
AuthorDate: Fri Mar 24 01:45:01 2017 -0700

    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]
    
    Signed-off-by: Robert Yang <liezhi.yang at windriver.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/lib/oeqa/selftest/runqemu.py | 136 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 136 insertions(+)

diff --git a/meta/lib/oeqa/selftest/runqemu.py b/meta/lib/oeqa/selftest/runqemu.py
new file mode 100644
index 0000000..c1d5c16
--- /dev/null
+++ b/meta/lib/oeqa/selftest/runqemu.py
@@ -0,0 +1,136 @@
+#
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+
+import re
+import logging
+
+from oeqa.selftest.base import oeSelfTest
+from oeqa.utils.commands import bitbake, runqemu, get_bb_var
+from oeqa.utils.decorators import testcase
+
+class RunqemuTests(oeSelfTest):
+    """Runqemu test class"""
+
+    image_is_ready = False
+    deploy_dir_image = ''
+
+    def setUpLocal(self):
+        self.recipe = 'core-image-minimal'
+        self.machine =  'qemux86-64'
+        self.fstypes = "ext4 iso hddimg vmdk qcow2 vdi"
+        self.cmd_common = "runqemu nographic"
+
+        self.write_config(
+"""
+MACHINE = "%s"
+IMAGE_FSTYPES = "%s"
+# 10 means 1 second
+SYSLINUX_TIMEOUT = "10"
+"""
+% (self.machine, self.fstypes)
+        )
+
+        if not RunqemuTests.image_is_ready:
+            RunqemuTests.deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
+            bitbake(self.recipe)
+            RunqemuTests.image_is_ready = True
+
+    @testcase(2001)
+    def test_boot_machine(self):
+        """Test runqemu machine"""
+        cmd = "%s %s" % (self.cmd_common, self.machine)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
+
+    @testcase(2002)
+    def test_boot_machine_ext4(self):
+        """Test runqemu machine ext4"""
+        cmd = "%s %s ext4" % (self.cmd_common, self.machine)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue('rootfs.ext4' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2003)
+    def test_boot_machine_iso(self):
+        """Test runqemu machine iso"""
+        cmd = "%s %s iso" % (self.cmd_common, self.machine)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue(' -cdrom ' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2004)
+    def test_boot_recipe_image(self):
+        """Test runqemu recipe-image"""
+        cmd = "%s %s" % (self.cmd_common, self.recipe)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
+
+    @testcase(2005)
+    def test_boot_recipe_image_vmdk(self):
+        """Test runqemu recipe-image vmdk"""
+        cmd = "%s %s vmdk" % (self.cmd_common, self.recipe)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue('format=vmdk' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2006)
+    def test_boot_recipe_image_vdi(self):
+        """Test runqemu recipe-image vdi"""
+        cmd = "%s %s vdi" % (self.cmd_common, self.recipe)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue('format=vdi' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2007)
+    def test_boot_deploy(self):
+        """Test runqemu deploy_dir_image"""
+        cmd = "%s %s" % (self.cmd_common, self.deploy_dir_image)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
+
+    @testcase(2008)
+    def test_boot_deploy_hddimg(self):
+        """Test runqemu deploy_dir_image hddimg"""
+        cmd = "%s %s hddimg" % (self.cmd_common, self.deploy_dir_image)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue(re.search('file=.*.hddimg', f.read()), "Failed: %s" % cmd)
+
+    @testcase(2009)
+    def test_boot_machine_slirp(self):
+        """Test runqemu machine slirp"""
+        cmd = "%s slirp %s" % (self.cmd_common, self.machine)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue(' -netdev user' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2009)
+    def test_boot_machine_slirp_qcow2(self):
+        """Test runqemu machine slirp qcow2"""
+        cmd = "%s slirp qcow2 %s" % (self.cmd_common, self.machine)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            with open(qemu.qemurunnerlog) as f:
+                self.assertTrue('format=qcow2' in f.read(), "Failed: %s" % cmd)
+
+    @testcase(2010)
+    def test_boot_qemu_boot(self):
+        """Test runqemu /path/to/image.qemuboot.conf"""
+        qemuboot_conf = "%s-%s.qemuboot.conf" % (self.recipe, self.machine)
+        qemuboot_conf = os.path.join(self.deploy_dir_image, qemuboot_conf)
+        if not os.path.exists(qemuboot_conf):
+            self.skipTest("%s not found" % qemuboot_conf)
+        cmd = "%s %s" % (self.cmd_common, qemuboot_conf)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
+
+    @testcase(2011)
+    def test_boot_rootfs(self):
+        """Test runqemu /path/to/rootfs.ext4"""
+        rootfs = "%s-%s.ext4" % (self.recipe, self.machine)
+        rootfs = os.path.join(self.deploy_dir_image, rootfs)
+        if not os.path.exists(rootfs):
+            self.skipTest("%s not found" % rootfs)
+        cmd = "%s %s" % (self.cmd_common, rootfs)
+        with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
+            self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list