Skip to contentSkip to conversation

tests/qtest: Unify the test for the xenfv and xenpv machines

PATCH In review Thomas Huth 2 participants 2 messages Jun 22, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/qtest: Unify the test for the xenfv and xenpv machines

We have the same check in three places. Let's unify it in a central place instead.

---
 tests/qtest/device-introspect-test.c | 5 -----
 tests/qtest/libqtest.c               | 4 ++++
 tests/qtest/qom-test.c               | 5 -----
 tests/qtest/test-hmp.c               | 5 -----
 4 files changed, 4 insertions(+), 15 deletions(-)
tests/qtest/device-introspect-test.c +0 -5
index f2c1576cae..9abb5ec889 100644
@@ -287,11 +287,6 @@ static void add_machine_test_case(const char *mname)
 {
     char *path, *args;
 
-    /* Ignore blacklisted machines */
-    if (!memcmp("xenfv", mname, 5) || g_str_equal("xenpv", mname)) {
-        return;
-    }
-
     path = g_strdup_printf("device/introspect/concrete/defaults/%s", mname);
     args = g_strdup_printf("-M %s", mname);
     qtest_add_data_func(path, args, test_device_intro_concrete);
tests/qtest/libqtest.c +4 -0
index 49075b55a1..fd4680590d 100644
@@ -1232,6 +1232,10 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine),
         qstr = qobject_to(QString, qobj);
         g_assert(qstr);
         mname = qstring_get_str(qstr);
+        /* Ignore machines that cannot be used for qtests */
+        if (!memcmp("xenfv", mname, 5) || g_str_equal("xenpv", mname)) {
+            continue;
+        }
         if (!skip_old_versioned || !qtest_is_old_versioned_machine(mname)) {
             cb(mname);
         }
tests/qtest/qom-test.c +0 -5
index e338a41194..1acf0d7369 100644
@@ -81,11 +81,6 @@ static void add_machine_test_case(const char *mname)
 {
     char *path;
 
-    /* Ignore blacklisted machines that have known problems */
-    if (!memcmp("xenfv", mname, 5) || g_str_equal("xenpv", mname)) {
-        return;
-    }
-
     path = g_strdup_printf("qom/%s", mname);
     qtest_add_data_func(path, g_strdup(mname), test_machine);
     g_free(path);
tests/qtest/test-hmp.c +0 -5
index b8b1271b9e..d5e7ebd176 100644
@@ -143,11 +143,6 @@ static void add_machine_test_case(const char *mname)
 {
     char *path;
 
-    /* Ignore blacklisted machines that have known problems */
-    if (!memcmp("xenfv", mname, 5) || g_str_equal("xenpv", mname)) {
-        return;
-    }
-
     path = g_strdup_printf("hmp/%s", mname);
     qtest_add_data_func(path, g_strdup(mname), test_machine);
     g_free(path);
Signature · 1 line
2.18.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 32 lines · Thomas Huth

We have the same check in three places. Let's unify it in a central place instead.

---
 tests/qtest/device-introspect-test.c | 5 -----
 tests/qtest/libqtest.c               | 4 ++++
 tests/qtest/qom-test.c               | 5 -----
 tests/qtest/test-hmp.c               | 5 -----
 4 files changed, 4 insertions(+), 15 deletions(-)
tests/qtest/device-introspect-test.c +0 -5
index f2c1576cae..9abb5ec889 100644
@@ -287,11 +287,6 @@ static void add_machine_test_case(const char *mname)
 {
     char *path, *args;
 
-    /* Ignore blacklisted machines */
-    if (!memcmp("xenfv", mname, 5) || g_str_equal("xenpv", mname)) {
-        return;
-    }
-
     path = g_strdup_printf("device/introspect/concrete/defaults/%s", mname);
     args = g_strdup_printf("-M %s", mname);
     qtest_add_data_func(path, args, test_device_intro_concrete);
tests/qtest/libqtest.c +0 -0
index 49075b55a1..fd4680590d 100644

tests/qtest/libqtest.c void qtest_cb_for_every_machine(void (*cb)(const char *machine), · line 1238

Quoted 7 lines
tests/qtest/libqtest.c +4 -0
@@ -1232,6 +1232,10 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine),
         qstr = qobject_to(QString, qobj);
         g_assert(qstr);
         mname = qstring_get_str(qstr);
+        /* Ignore machines that cannot be used for qtests */
+        if (!memcmp("xenfv", mname, 5) || g_str_equal("xenpv", mname)) {
+            continue;
+        }

The patch is correct.

Since qtest uses QMP introspection, it would be cleaner to have a MachineClass::qtest_allowed property (default to true), set it to false in the xenfv/pv machines, and either check the property here or have a query-qtest-machines QMP command.
Just thinking loudly.

Quoted 36 lines
tests/qtest/libqtest.c +0 -0
         if (!skip_old_versioned || !qtest_is_old_versioned_machine(mname)) {
             cb(mname);
         }
tests/qtest/qom-test.c +0 -5
index e338a41194..1acf0d7369 100644
@@ -81,11 +81,6 @@ static void add_machine_test_case(const char *mname)
 {
     char *path;
 
-    /* Ignore blacklisted machines that have known problems */
-    if (!memcmp("xenfv", mname, 5) || g_str_equal("xenpv", mname)) {
-        return;
-    }
-
     path = g_strdup_printf("qom/%s", mname);
     qtest_add_data_func(path, g_strdup(mname), test_machine);
     g_free(path);
tests/qtest/test-hmp.c +0 -5
index b8b1271b9e..d5e7ebd176 100644
@@ -143,11 +143,6 @@ static void add_machine_test_case(const char *mname)
 {
     char *path;
 
-    /* Ignore blacklisted machines that have known problems */
-    if (!memcmp("xenfv", mname, 5) || g_str_equal("xenpv", mname)) {
-        return;
-    }
-
     path = g_strdup_printf("hmp/%s", mname);
     qtest_add_data_func(path, g_strdup(mname), test_machine);
     g_free(path);