Skip to contentSkip to conversation

tests: test-qga, loosen assumptions about host filesystems

PATCH In review Michael Roth 1 participant 2 messages Oct 20, 2015 – Oct 21, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests: test-qga, loosen assumptions about host filesystems

QGA skips pseudo-filesystems when querying filesystems via guest-get-fsinfo. On some hosts, such as travis-ci which uses containers which simfs filesystems, QGA might not reports *any* filesystems. Our test case assumes there would be at least one, leading to false error messages in these situations.

Instead, sanity-check values iff we get at least one filesystem.

Cc Marc-André Lureau <[email protected]>
Cc Peter Maydell <[email protected]>
---
 tests/test-qga.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
tests/test-qga.c +7 -5
index 0531c9f..6473846 100644
@@ -273,13 +273,15 @@ static void test_qga_get_fsinfo(gconstpointer fix)
     g_assert_nonnull(ret);
     qmp_assert_no_error(ret);
 
-    /* check there is at least a fs */
+    /* sanity-check the response if there are any filesystems */
     list = qdict_get_qlist(ret, "return");
     entry = qlist_first(list);
-    g_assert(qdict_haskey(qobject_to_qdict(entry->value), "name"));
-    g_assert(qdict_haskey(qobject_to_qdict(entry->value), "mountpoint"));
-    g_assert(qdict_haskey(qobject_to_qdict(entry->value), "type"));
-    g_assert(qdict_haskey(qobject_to_qdict(entry->value), "disk"));
+    if (entry) {
+        g_assert(qdict_haskey(qobject_to_qdict(entry->value), "name"));
+        g_assert(qdict_haskey(qobject_to_qdict(entry->value), "mountpoint"));
+        g_assert(qdict_haskey(qobject_to_qdict(entry->value), "type"));
+        g_assert(qdict_haskey(qobject_to_qdict(entry->value), "disk"));
+    }
 
     QDECREF(ret);
 }
Signature · 1 line
1.9.1
#1 lore raw

Quoting Michael Roth (2015-10-20 11:49:19)

Quoted 11 lines

QGA skips pseudo-filesystems when querying filesystems via guest-get-fsinfo. On some hosts, such as travis-ci which uses containers which simfs filesystems, QGA might not reports *any* filesystems. Our test case assumes there would be at least one, leading to false error messages in these situations.

Instead, sanity-check values iff we get at least one filesystem.

Cc Marc-André Lureau <[email protected]>
Cc Peter Maydell <[email protected]>

Applied with some spelling fixes:

https://github.com/mdroth/qemu/commits/qga

Quoted 32 lines
---
 tests/test-qga.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
tests/test-qga.c +7 -5
index 0531c9f..6473846 100644
@@ -273,13 +273,15 @@ static void test_qga_get_fsinfo(gconstpointer fix)
     g_assert_nonnull(ret);
     qmp_assert_no_error(ret);
 
-    /* check there is at least a fs */
+    /* sanity-check the response if there are any filesystems */
     list = qdict_get_qlist(ret, "return");
     entry = qlist_first(list);
-    g_assert(qdict_haskey(qobject_to_qdict(entry->value), "name"));
-    g_assert(qdict_haskey(qobject_to_qdict(entry->value), "mountpoint"));
-    g_assert(qdict_haskey(qobject_to_qdict(entry->value), "type"));
-    g_assert(qdict_haskey(qobject_to_qdict(entry->value), "disk"));
+    if (entry) {
+        g_assert(qdict_haskey(qobject_to_qdict(entry->value), "name"));
+        g_assert(qdict_haskey(qobject_to_qdict(entry->value), "mountpoint"));
+        g_assert(qdict_haskey(qobject_to_qdict(entry->value), "type"));
+        g_assert(qdict_haskey(qobject_to_qdict(entry->value), "disk"));
+    }
 
     QDECREF(ret);
 }
Signature · 1 line
1.9.1