Re: [kvm-unit-tests PATCH v2 3/8] s390x: css: simplify skipping tests on no device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 3/29/21 10:19 AM, Thomas Huth wrote:
On 25/03/2021 10.39, Pierre Morel wrote:
We will lhave to test if a device is present for every tests
in the future.
Let's provide a macro to check if the device is present and
to skip the tests if it is not.

Signed-off-by: Pierre Morel <pmorel@xxxxxxxxxxxxx>
---
  s390x/css.c | 27 +++++++++++----------------
  1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/s390x/css.c b/s390x/css.c
index c340c53..16723f6 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -27,6 +27,13 @@ static int test_device_sid;
  static struct senseid *senseid;
  struct ccw1 *ccw;
+#define NODEV_SKIP(dev) do {                        \
+                if (!(dev)) {                \
+                    report_skip("No device");    \
+                    return;                \
+                }                    \
+            } while (0)
+
  static void test_enumerate(void)
  {
      test_device_sid = css_enumerate();
@@ -41,10 +48,7 @@ static void test_enable(void)
  {
      int cc;
-    if (!test_device_sid) {
-        report_skip("No device");
-        return;
-    }
+    NODEV_SKIP(test_device_sid);
      cc = css_enable(test_device_sid, IO_SCH_ISC);
@@ -62,10 +66,7 @@ static void test_sense(void)
      int ret;
      int len;
-    if (!test_device_sid) {
-        report_skip("No device");
-        return;
-    }
+    NODEV_SKIP(test_device_sid);
      ret = css_enable(test_device_sid, IO_SCH_ISC);
      if (ret) {
@@ -218,10 +219,7 @@ static void test_schm_fmt0(void)
      struct measurement_block_format0 *mb0;
      int shared_mb_size = 2 * sizeof(struct measurement_block_format0);
-    if (!test_device_sid) {
-        report_skip("No device");
-        return;
-    }
+    NODEV_SKIP(test_device_sid);
      /* Allocate zeroed Measurement block */
      mb0 = alloc_io_mem(shared_mb_size, 0);
@@ -289,10 +287,7 @@ static void test_schm_fmt1(void)
  {
      struct measurement_block_format1 *mb1;
-    if (!test_device_sid) {
-        report_skip("No device");
-        return;
-    }
+    NODEV_SKIP(test_device_sid);
      if (!css_test_general_feature(CSSC_EXTENDED_MEASUREMENT_BLOCK)) {
          report_skip("Extended measurement block not available");


I wonder whether it would be easier to simply skip all tests in main() if the test device is not available, instead of checking it again and again and again...?

  Thomas


I will silently skip the remaining tests when the enumeration fails or do you want that we see other information?
It seems obvious enough that finding no device we do not continue testing.

--
Pierre Morel
IBM Lab Boeblingen



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux