From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zoa6b-00078U-O5 for qemu-devel@nongnu.org; Tue, 20 Oct 2015 12:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zoa6X-0001cK-K7 for qemu-devel@nongnu.org; Tue, 20 Oct 2015 12:49:45 -0400 Received: from e17.ny.us.ibm.com ([129.33.205.207]:53635) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zoa6X-0001bl-Fa for qemu-devel@nongnu.org; Tue, 20 Oct 2015 12:49:41 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Oct 2015 12:49:40 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 76190C9005C for ; Tue, 20 Oct 2015 12:37:48 -0400 (EDT) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9KGnbZM64159872 for ; Tue, 20 Oct 2015 16:49:37 GMT Received: from d01av02.pok.ibm.com (localhost [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9KGnaoV001356 for ; Tue, 20 Oct 2015 12:49:36 -0400 From: Michael Roth Date: Tue, 20 Oct 2015 11:49:19 -0500 Message-Id: <1445359759-7575-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH] tests: test-qga, loosen assumptions about host filesystems List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Michael Roth , Peter Maydell 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 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 0531c9f..6473846 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); } -- 1.9.1