From b3e9e584fcef49be8ca0c355d11030f0bf6231b0 Mon Sep 17 00:00:00 2001 From: Michael Roth Date: Tue, 20 Oct 2015 11:17:36 -0500 Subject: [PATCH] tests: test-qga, loosen assumptions about host filesystems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QGA skips pseudo-filesystems when querying filesystems via guest-get-fsinfo. On some hosts, such as travis-ci which uses containers with simfs filesystems, QGA might not report *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 Cc: Peter Maydell Signed-off-by: Michael Roth --- tests/test-qga.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test-qga.c b/tests/test-qga.c index 0531c9f3bc..64738465c5 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -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); }