All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] oe-selftest: qemutest: add tests for qemu boot and shutdown
@ 2018-04-05  0:35 Yeoh Ee Peng
  2018-04-05  8:09 ` Yeoh, Ee Peng
  0 siblings, 1 reply; 4+ messages in thread
From: Yeoh Ee Peng @ 2018-04-05  0:35 UTC (permalink / raw)
  To: openembedded-core

QA team were testing qemu boot image and shutdown on each qemu
architecture manually. Add automated test to test qemu boot on
ext4 and nfs, finally it can shutdown properly.

This tests was not included into existing runqemu.py as runqemu
was dedicated for qemux86-64 where it test various live image
(iso and hddimg) can boot but this live image was not supported
on other qemu architechture.

Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
---
 meta/lib/oeqa/selftest/cases/qemutest.py | 44 ++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/qemutest.py

diff --git a/meta/lib/oeqa/selftest/cases/qemutest.py b/meta/lib/oeqa/selftest/cases/qemutest.py
new file mode 100644
index 0000000..f06e3fd
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/qemutest.py
@@ -0,0 +1,44 @@
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_var, runCmd, runqemu
+import os
+import tempfile
+
+class QemuTest(OESelftestTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        super(QemuTest, cls).setUpClass()
+        cls.recipe = 'core-image-minimal'
+        cls.machine =  get_bb_var('MACHINE')
+        cls.deploy_dir_image =  get_bb_var('DEPLOY_DIR_IMAGE')
+        cls.cmd_common = "runqemu nographic"
+        cls.qemuboot_conf = "%s-%s.qemuboot.conf" % (cls.recipe, cls.machine)
+        cls.qemuboot_conf = os.path.join(cls.deploy_dir_image, cls.qemuboot_conf)
+        result = bitbake(cls.recipe)
+
+    def test_qemu_can_shutdown(self):
+        if not os.path.exists(self.qemuboot_conf):
+            self.skipTest("%s not found" % self.qemuboot_conf)
+        cmd = "%s %s" % (self.cmd_common, self.qemuboot_conf)
+        with runqemu(self.recipe, ssh=True, launch_cmd=cmd) as qemu:
+            status, output = qemu.run("shutdown -h now")
+        self.assertEqual(status, 0, 'Failed: qemu shutdown')
+
+    def test_qemu_can_boot_nfs_and_shutdown(self):
+        bitbake('meta-ide-support')
+        rootfs_tar = "%s-%s.tar.bz2" % (self.recipe, self.machine)
+        rootfs_tar = os.path.join(self.deploy_dir_image, rootfs_tar)
+        if not os.path.exists(rootfs_tar):
+            self.skipTest("%s not found" % rootfs_tar)
+        tmpdir = tempfile.mkdtemp(prefix='qemu_nfs')
+        tmpdir_nfs = os.path.join(tmpdir, 'nfs')
+        cmd_extract_nfs = 'runqemu-extract-sdk %s %s' % (rootfs_tar, tmpdir_nfs)
+        runCmd(cmd_extract_nfs)
+        if not os.path.exists(self.qemuboot_conf):
+            self.skipTest("%s not found" % self.qemuboot_conf)
+        cmd = "%s nfs %s %s" % (self.cmd_common, self.qemuboot_conf, tmpdir_nfs)
+        with runqemu(self.recipe, ssh=True, launch_cmd=cmd) as qemu:
+            status, output = qemu.run("shutdown -h now")
+        self.assertEqual(status, 0, 'Failed: qemu shutdown')
+        runCmd('rm -rf %s' % tmpdir)
+
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] oe-selftest: qemutest: add tests for qemu boot and shutdown
  2018-04-05  0:35 [PATCH] oe-selftest: qemutest: add tests for qemu boot and shutdown Yeoh Ee Peng
@ 2018-04-05  8:09 ` Yeoh, Ee Peng
  2018-04-05  9:55   ` Alexander Kanavin
  0 siblings, 1 reply; 4+ messages in thread
From: Yeoh, Ee Peng @ 2018-04-05  8:09 UTC (permalink / raw)
  To: Yeoh, Ee Peng, openembedded-core; +Cc: Eggleton, Paul

Hi Alex & Paul,

I had developed this selftest testcase to test qemu can boot nfs & ext4 and finally shutdown for various qemu architecture. 

Initially, I was thinking to develop this automated test as part of testimage but as this test involve shutting down qemu, testimage testcases executed after this will face lost connection to qemu.  Furthermore, when I tried to add this test to selftest runqemu.py, I realized runqemu was dedicated for MACHINE=qemux86-64 and it was testing various live image (iso and hddimg) but live image was not supported by other qemu architecture. Therefore, this test was developed as independent selftest testcase. 

Please let me know your inputs and feedback.

Thanks,
Yeoh Ee Peng 

-----Original Message-----
From: openembedded-core-bounces@lists.openembedded.org [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of Yeoh Ee Peng
Sent: Thursday, April 5, 2018 8:36 AM
To: openembedded-core@lists.openembedded.org
Subject: [OE-core] [PATCH] oe-selftest: qemutest: add tests for qemu boot and shutdown

QA team were testing qemu boot image and shutdown on each qemu architecture manually. Add automated test to test qemu boot on
ext4 and nfs, finally it can shutdown properly.

This tests was not included into existing runqemu.py as runqemu was dedicated for qemux86-64 where it test various live image (iso and hddimg) can boot but this live image was not supported on other qemu architechture.

Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
---
 meta/lib/oeqa/selftest/cases/qemutest.py | 44 ++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/qemutest.py

diff --git a/meta/lib/oeqa/selftest/cases/qemutest.py b/meta/lib/oeqa/selftest/cases/qemutest.py
new file mode 100644
index 0000000..f06e3fd
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/qemutest.py
@@ -0,0 +1,44 @@
+from oeqa.selftest.case import OESelftestTestCase from 
+oeqa.utils.commands import bitbake, get_bb_var, runCmd, runqemu import 
+os import tempfile
+
+class QemuTest(OESelftestTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        super(QemuTest, cls).setUpClass()
+        cls.recipe = 'core-image-minimal'
+        cls.machine =  get_bb_var('MACHINE')
+        cls.deploy_dir_image =  get_bb_var('DEPLOY_DIR_IMAGE')
+        cls.cmd_common = "runqemu nographic"
+        cls.qemuboot_conf = "%s-%s.qemuboot.conf" % (cls.recipe, cls.machine)
+        cls.qemuboot_conf = os.path.join(cls.deploy_dir_image, cls.qemuboot_conf)
+        result = bitbake(cls.recipe)
+
+    def test_qemu_can_shutdown(self):
+        if not os.path.exists(self.qemuboot_conf):
+            self.skipTest("%s not found" % self.qemuboot_conf)
+        cmd = "%s %s" % (self.cmd_common, self.qemuboot_conf)
+        with runqemu(self.recipe, ssh=True, launch_cmd=cmd) as qemu:
+            status, output = qemu.run("shutdown -h now")
+        self.assertEqual(status, 0, 'Failed: qemu shutdown')
+
+    def test_qemu_can_boot_nfs_and_shutdown(self):
+        bitbake('meta-ide-support')
+        rootfs_tar = "%s-%s.tar.bz2" % (self.recipe, self.machine)
+        rootfs_tar = os.path.join(self.deploy_dir_image, rootfs_tar)
+        if not os.path.exists(rootfs_tar):
+            self.skipTest("%s not found" % rootfs_tar)
+        tmpdir = tempfile.mkdtemp(prefix='qemu_nfs')
+        tmpdir_nfs = os.path.join(tmpdir, 'nfs')
+        cmd_extract_nfs = 'runqemu-extract-sdk %s %s' % (rootfs_tar, tmpdir_nfs)
+        runCmd(cmd_extract_nfs)
+        if not os.path.exists(self.qemuboot_conf):
+            self.skipTest("%s not found" % self.qemuboot_conf)
+        cmd = "%s nfs %s %s" % (self.cmd_common, self.qemuboot_conf, tmpdir_nfs)
+        with runqemu(self.recipe, ssh=True, launch_cmd=cmd) as qemu:
+            status, output = qemu.run("shutdown -h now")
+        self.assertEqual(status, 0, 'Failed: qemu shutdown')
+        runCmd('rm -rf %s' % tmpdir)
+
--
2.7.4

--
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] oe-selftest: qemutest: add tests for qemu boot and shutdown
  2018-04-05  8:09 ` Yeoh, Ee Peng
@ 2018-04-05  9:55   ` Alexander Kanavin
  2018-04-06  0:46     ` Yeoh, Ee Peng
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Kanavin @ 2018-04-05  9:55 UTC (permalink / raw)
  To: Yeoh, Ee Peng, openembedded-core; +Cc: Eggleton, Paul

On 04/05/2018 11:09 AM, Yeoh, Ee Peng wrote:
> I had developed this selftest testcase to test qemu can boot nfs &
> ext4 and finally shutdown for various qemu architecture.
> 
> Initially, I was thinking to develop this automated test as part of
> testimage but as this test involve shutting down qemu, testimage
> testcases executed after this will face lost connection to qemu.
> Furthermore, when I tried to add this test to selftest runqemu.py, I
> realized runqemu was dedicated for MACHINE=qemux86-64 and it was
> testing various live image (iso and hddimg) but live image was not
> supported by other qemu architecture. Therefore, this test was
> developed as independent selftest testcase.
> 
> Please let me know your inputs and feedback.
It's totally okay to have several test classes in a single .py file (see 
for example signing.py). I think this should go to runqemu.py, as 
otherwise there would be two different files doing roughly same thing 
and named very similarly (runqemu and qemutest?), which is confusing.

You can add comments to both classes to explain what they do and why, 
and how they are different. (generally, be generous with comments every 
time there is possibility for confusion, or the code does unusual things 
etc.)

Alex


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] oe-selftest: qemutest: add tests for qemu boot and shutdown
  2018-04-05  9:55   ` Alexander Kanavin
@ 2018-04-06  0:46     ` Yeoh, Ee Peng
  0 siblings, 0 replies; 4+ messages in thread
From: Yeoh, Ee Peng @ 2018-04-06  0:46 UTC (permalink / raw)
  To: Alexander Kanavin, openembedded-core; +Cc: Eggleton, Paul

Noted, let me rework on this. Thank you for your feedback! 

-----Original Message-----
From: Alexander Kanavin [mailto:alexander.kanavin@linux.intel.com] 
Sent: Thursday, April 5, 2018 5:56 PM
To: Yeoh, Ee Peng <ee.peng.yeoh@intel.com>; openembedded-core@lists.openembedded.org
Cc: Eggleton, Paul <paul.eggleton@intel.com>
Subject: Re: [OE-core] [PATCH] oe-selftest: qemutest: add tests for qemu boot and shutdown

On 04/05/2018 11:09 AM, Yeoh, Ee Peng wrote:
> I had developed this selftest testcase to test qemu can boot nfs &
> ext4 and finally shutdown for various qemu architecture.
> 
> Initially, I was thinking to develop this automated test as part of 
> testimage but as this test involve shutting down qemu, testimage 
> testcases executed after this will face lost connection to qemu.
> Furthermore, when I tried to add this test to selftest runqemu.py, I 
> realized runqemu was dedicated for MACHINE=qemux86-64 and it was 
> testing various live image (iso and hddimg) but live image was not 
> supported by other qemu architecture. Therefore, this test was 
> developed as independent selftest testcase.
> 
> Please let me know your inputs and feedback.
It's totally okay to have several test classes in a single .py file (see for example signing.py). I think this should go to runqemu.py, as otherwise there would be two different files doing roughly same thing and named very similarly (runqemu and qemutest?), which is confusing.

You can add comments to both classes to explain what they do and why, and how they are different. (generally, be generous with comments every time there is possibility for confusion, or the code does unusual things
etc.)

Alex

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-06  0:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-05  0:35 [PATCH] oe-selftest: qemutest: add tests for qemu boot and shutdown Yeoh Ee Peng
2018-04-05  8:09 ` Yeoh, Ee Peng
2018-04-05  9:55   ` Alexander Kanavin
2018-04-06  0:46     ` Yeoh, Ee Peng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.