public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Ross Burton <ross.burton@arm.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 17/23] oeqa: rationalise skipifqemu decorators
Date: Thu, 31 Mar 2022 19:29:09 +0100	[thread overview]
Message-ID: <20220331182915.22128-17-ross.burton@arm.com> (raw)
In-Reply-To: <20220331182915.22128-1-ross.burton@arm.com>

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/lib/oeqa/core/decorator/data.py          | 44 ++++---------------
 meta/lib/oeqa/runtime/cases/boot.py           |  2 +-
 .../oeqa/runtime/cases/ethernet_ip_connman.py |  3 +-
 meta/lib/oeqa/runtime/cases/ltp_stress.py     |  3 +-
 meta/lib/oeqa/runtime/cases/storage.py        | 16 +++----
 meta/lib/oeqa/runtime/cases/suspend.py        |  2 +-
 meta/lib/oeqa/runtime/cases/usb_hid.py        |  2 +-
 meta/lib/oeqa/selftest/cases/runtime_test.py  |  4 +-
 8 files changed, 25 insertions(+), 51 deletions(-)

diff --git a/meta/lib/oeqa/core/decorator/data.py b/meta/lib/oeqa/core/decorator/data.py
index 12197be246e..3ce10e54999 100644
--- a/meta/lib/oeqa/core/decorator/data.py
+++ b/meta/lib/oeqa/core/decorator/data.py
@@ -27,17 +27,6 @@ def has_machine(td, machine):
         return True
     return False
 
-def is_qemu(td, qemu):
-    """
-        Checks if MACHINE is qemu.
-    """
-
-    machine = td.get('MACHINE', '')
-    if (qemu in td.get('MACHINE', '') or
-    machine.startswith('qemu')):
-        return True
-    return False
-
 @registerDecorator
 class skipIfDataVar(OETestDecorator):
     """
@@ -189,34 +178,19 @@ class skipIfMachine(OETestDecorator):
 @registerDecorator
 class skipIfNotQemu(OETestDecorator):
     """
-        Skip test based on MACHINE.
-
-        value must be a qemu MACHINE or it will skip the test
-        with msg as the reason.
+    Skip test if MACHINE is not qemu*
     """
-
-    attrs = ('value', 'msg')
-
     def setUpDecorator(self):
-        msg = ('Checking if %s is not this MACHINE' % self.value)
-        self.logger.debug(msg)
-        if not is_qemu(self.case.td, self.value):
-            self.case.skipTest(self.msg)
+        self.logger.debug("Checking if not qemu MACHINE")
+        if not self.case.td.get('MACHINE', '').startswith('qemu'):
+            self.case.skipTest('Test only runs on qemu machines')
 
 @registerDecorator
 class skipIfQemu(OETestDecorator):
     """
-        Skip test based on Qemu Machine.
-
-        value must not be a qemu machine or it will skip the test
-        with msg as the reason.
-   """
-
-    attrs = ('value', 'msg')
-
+    Skip test if MACHINE is qemu*
+    """
     def setUpDecorator(self):
-        msg = ('Checking if %s is this MACHINE' % self.value)
-        self.logger.debug(msg)
-        if is_qemu(self.case.td, self.value):
-             self.case.skipTest(self.msg)
-
+        self.logger.debug("Checking if qemu MACHINE")
+        if self.case.td.get('MACHINE', '').startswith('qemu'):
+             self.case.skipTest('Test only runs on real hardware')
diff --git a/meta/lib/oeqa/runtime/cases/boot.py b/meta/lib/oeqa/runtime/cases/boot.py
index 2142f400a05..e1ad88a1744 100644
--- a/meta/lib/oeqa/runtime/cases/boot.py
+++ b/meta/lib/oeqa/runtime/cases/boot.py
@@ -13,7 +13,7 @@ from oeqa.core.decorator.data import skipIfQemu
 class BootTest(OERuntimeTestCase):
 
     @OETimeout(120)
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @skipIfQemu()
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     def test_reboot(self):
         output = ''
diff --git a/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py b/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py
index e0106128389..b93ee299415 100644
--- a/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py
+++ b/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py
@@ -11,7 +11,7 @@ class Ethernet_Test(OERuntimeTestCase):
         x = '.'.join(x)
         return x
     
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')    
+    @skipIfQemu()
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     def test_set_virtual_ip(self):
         (status, output) = self.target.run("ifconfig eth0 | grep 'inet ' | awk '{print $2}'")
@@ -22,6 +22,7 @@ class Ethernet_Test(OERuntimeTestCase):
         (status, output) = self.target.run("ifconfig eth0:1 %s netmask 255.255.255.0 && sleep 2 && ping -c 5 %s && ifconfig eth0:1 down" % (virtual_ip,virtual_ip))
         self.assertEqual(status, 0, msg='Failed to create virtual ip address, output: %s' % output)
         
+    @skipIfQemu()
     @OETestDepends(['ethernet_ip_connman.Ethernet_Test.test_set_virtual_ip'])  
     def test_get_ip_from_dhcp(self): 
         (status, output) = self.target.run("connmanctl services | grep -E '*AO Wired|*AR Wired' | awk '{print $3}'")
diff --git a/meta/lib/oeqa/runtime/cases/ltp_stress.py b/meta/lib/oeqa/runtime/cases/ltp_stress.py
index 2445ffbc939..ce6f4bf59d3 100644
--- a/meta/lib/oeqa/runtime/cases/ltp_stress.py
+++ b/meta/lib/oeqa/runtime/cases/ltp_stress.py
@@ -89,8 +89,7 @@ class LtpStressTest(LtpStressBase):
 
     # LTP stress runtime tests
     #
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
-
+    @skipIfQemu()
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     @OEHasPackage(["ltp"])
     def test_ltp_stress(self):
diff --git a/meta/lib/oeqa/runtime/cases/storage.py b/meta/lib/oeqa/runtime/cases/storage.py
index 166d26b252b..972ef8210c0 100644
--- a/meta/lib/oeqa/runtime/cases/storage.py
+++ b/meta/lib/oeqa/runtime/cases/storage.py
@@ -91,24 +91,24 @@ class UsbTest(StorageBase):
         self.test_file = "usb.tst"
         self.test_dir = os.path.join(self.mount_point, "oeqa")
 
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @skipIfQemu()
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     def test_usb_mount(self):
         self.storage_umount(2)
         self.storage_mount(5)
 
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @skipIfQemu()
     @OETestDepends(['storage.UsbTest.test_usb_mount'])
     def test_usb_basic_operations(self):
         self.storage_basic()
 
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @skipIfQemu()
     @OETestDepends(['storage.UsbTest.test_usb_basic_operations'])
     def test_usb_basic_rw(self):
         self.storage_write()
         self.storage_read()
 
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @skipIfQemu()
     @OETestDepends(['storage.UsbTest.test_usb_mount'])
     def test_usb_umount(self):
         self.storage_umount(2)
@@ -126,24 +126,24 @@ class MMCTest(StorageBase):
         self.test_file = "mmc.tst"
         self.test_dir = os.path.join(self.mount_point, "oeqa")
 
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @skipIfQemu()
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     def test_mmc_mount(self):
         self.storage_umount(2)
         self.storage_mount()
 
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @skipIfQemu()
     @OETestDepends(['storage.MMCTest.test_mmc_mount'])
     def test_mmc_basic_operations(self):
         self.storage_basic()
 
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @skipIfQemu()
     @OETestDepends(['storage.MMCTest.test_mmc_basic_operations'])
     def test_mmc_basic_rw(self):
         self.storage_write()
         self.storage_read()
 
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @skipIfQemu()
     @OETestDepends(['storage.MMCTest.test_mmc_mount'])
     def test_mmc_umount(self):
         self.storage_umount(2)
diff --git a/meta/lib/oeqa/runtime/cases/suspend.py b/meta/lib/oeqa/runtime/cases/suspend.py
index 67b6f7e56fa..0382d48f458 100644
--- a/meta/lib/oeqa/runtime/cases/suspend.py
+++ b/meta/lib/oeqa/runtime/cases/suspend.py
@@ -23,7 +23,7 @@ class Suspend_Test(OERuntimeTestCase):
         (status, output) = self.target.run('sudo rtcwake -m mem -s 10')
         self.assertEqual(status, 0,  msg = 'Failed to suspends your system to RAM, output : %s' % output)
     
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @skipIfQemu()
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     def test_suspend(self):
         self.test_date()
diff --git a/meta/lib/oeqa/runtime/cases/usb_hid.py b/meta/lib/oeqa/runtime/cases/usb_hid.py
index 3c292cf661c..8743174370d 100644
--- a/meta/lib/oeqa/runtime/cases/usb_hid.py
+++ b/meta/lib/oeqa/runtime/cases/usb_hid.py
@@ -14,7 +14,7 @@ class USB_HID_Test(OERuntimeTestCase):
         return self.assertEqual(status, 0,  msg = 'Failed to suspends your system to RAM, output : %s' % output)
     
     @OEHasPackage(['xdotool'])
-    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @skipIfQemu()
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     def test_USB_Hid_input(self):
         self.keyboard_mouse_simulation()
diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py
index 7b7371b6e07..2ad89490fcf 100644
--- a/meta/lib/oeqa/selftest/cases/runtime_test.py
+++ b/meta/lib/oeqa/selftest/cases/runtime_test.py
@@ -281,7 +281,7 @@ class Postinst(OESelftestTestCase):
 
 
 
-    @skipIfNotQemu('qemuall', 'Test only runs in qemu')
+    @skipIfNotQemu()
     def test_postinst_rootfs_and_boot_sysvinit(self):
         """
         Summary:        The purpose of this test case is to verify Post-installation
@@ -302,7 +302,7 @@ class Postinst(OESelftestTestCase):
         self.init_manager_loop("sysvinit")
 
 
-    @skipIfNotQemu('qemuall', 'Test only runs in qemu')
+    @skipIfNotQemu()
     def test_postinst_rootfs_and_boot_systemd(self):
         """
         Summary:        The purpose of this test case is to verify Post-installation
-- 
2.25.1



  parent reply	other threads:[~2022-03-31 18:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31 18:28 [PATCH 01/23] buildtools-tarball: include nativesdk-python3-pyyaml Ross Burton
2022-03-31 18:28 ` [PATCH 02/23] image_types: hddimg and iso only work on x86 Ross Burton
2022-03-31 18:28 ` [PATCH 03/23] oeqa/selftest/devtool: ensure Git username is set before upgrade tests Ross Burton
2022-03-31 18:28 ` [PATCH 04/23] oeqa/selftest/wic: use os.rename instead of bb.utils.rename Ross Burton
2022-03-31 18:28 ` [PATCH 05/23] oeqa/selftest/wic: remove redundant asserts Ross Burton
2022-03-31 18:28 ` [PATCH 06/23] oeqa/selftest/wic: clean up only_for_arch decorator Ross Burton
2022-03-31 18:28 ` [PATCH 07/23] oeqa/selftest/wic: don't hardcode kernel image type in test_wic_rm Ross Burton
2022-03-31 18:29 ` [PATCH 08/23] oeqa/selftest/wic: add more arch-specific annotations Ross Burton
2022-03-31 18:29 ` [PATCH 09/23] oeqa/selftest/buildoptions: set PACKAGE_CLASSES in test_arch_work_dir_and_export_source Ross Burton
2022-03-31 18:29 ` [PATCH 10/23] oeqa/runtime/decorator/package.py: remove use of strToSet Ross Burton
2022-03-31 18:29 ` [PATCH 11/23] oeqa/core/decorator: remove redundant code Ross Burton
2022-03-31 18:29 ` [PATCH 12/23] testimage: inline updateTestData() Ross Burton
2022-03-31 18:29 ` [PATCH 13/23] oeqa/core/utils/misc: remove redundant file Ross Burton
2022-03-31 18:29 ` [PATCH 14/23] oeqa/selftest: remove unused imports Ross Burton
2022-03-31 18:29 ` [PATCH 15/23] oeqa/core/decorators/data: improve has_* logic Ross Burton
2022-03-31 18:29 ` [PATCH 16/23] oeqa/selftest: tag tests that use runqemu Ross Burton
2022-03-31 18:29 ` Ross Burton [this message]
2022-03-31 18:29 ` [PATCH 18/23] oeqa/selftest/oescripts: refactor skipping logic Ross Burton
2022-03-31 18:29 ` [PATCH 19/23] oeqa/selftest/wic: cleanup WicTestCase.setUpLocal Ross Burton
2022-03-31 18:29 ` [PATCH 20/23] oeqa/selftest/wic: rearrange tests Ross Burton
2022-03-31 18:29 ` [PATCH 21/23] oeqa/selftest/wic: use os.path.join to join paths Ross Burton
2022-03-31 18:29 ` [PATCH 22/23] oeqa/selftest/wic: use self.td instead of get_bb_var to save on bitbake calls Ross Burton
2022-03-31 18:29 ` [PATCH 23/23] oeqa/selftest: generalise test_devtool_virtual_kernel_modify Ross Burton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220331182915.22128-17-ross.burton@arm.com \
    --to=ross.burton@arm.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox