qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 07/12] tests/qtest: drive_del-test: Skip tests that require m


From: Thomas Huth
Subject: Re: [PATCH 07/12] tests/qtest: drive_del-test: Skip tests that require missing devices
Date: Tue, 7 Feb 2023 15:20:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0

On 06/02/2023 16.04, Fabiano Rosas wrote:
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
  tests/qtest/drive_del-test.c | 70 ++++++++++++++++++++++++++++++++++++
  1 file changed, 70 insertions(+)

diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
index 9a750395a9..6fa96fa94a 100644
--- a/tests/qtest/drive_del-test.c
+++ b/tests/qtest/drive_del-test.c
@@ -16,6 +16,21 @@
  #include "qapi/qmp/qdict.h"
  #include "qapi/qmp/qlist.h"
+static const char *qvirtio_get_dev_type(void);
+
+/*
+ * This covers the possible absence of a device due to QEMU build
+ * options.
+ */
+static bool look_for_device_builtin(const char *prefix, const char *suffix)
+{
+    gchar *device = g_strdup_printf("%s-%s", prefix, suffix);
+    bool rc = qtest_has_device(device);
+
+    g_free(device);
+    return rc;
+}

I think I'd rather merge the above code into the has_device_builtin() function below ... or is there a reason for keeping this separate?

  static bool look_for_drive0(QTestState *qts, const char *command, const char 
*key)
  {
      QDict *response;
@@ -40,6 +55,11 @@ static bool look_for_drive0(QTestState *qts, const char 
*command, const char *ke
      return found;
  }
+static bool has_device_builtin(const char *dev)
+{
+    return look_for_device_builtin(dev, qvirtio_get_dev_type());
+}
+
  static bool has_drive(QTestState *qts)
  {
      return look_for_drive0(qts, "query-block", "device");
@@ -208,6 +228,11 @@ static void test_drive_del_device_del(void)
  {
      QTestState *qts;
+ if (!has_device_builtin("virtio-scsi")) {
+        g_test_skip(NULL);

Having a short message for the skip would be nice.

+        return;
+    }

 Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]