From patchwork Mon Dec 16 15:34:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 1211827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=crudebyte.com header.i=@crudebyte.com header.b="DOwwp1xF"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47cwzP4rhgz9sRc for ; Wed, 18 Dec 2019 11:35:59 +1100 (AEDT) Received: from localhost ([::1]:47710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihNJk-0003AD-C6 for incoming@patchwork.ozlabs.org; Tue, 17 Dec 2019 19:35:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43995) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihNHN-0001nv-Ux for qemu-devel@nongnu.org; Tue, 17 Dec 2019 19:33:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihNHM-0001dI-ED for qemu-devel@nongnu.org; Tue, 17 Dec 2019 19:33:29 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:44093) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihNHM-0008Ou-6x for qemu-devel@nongnu.org; Tue, 17 Dec 2019 19:33:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Message-Id:Subject:Date:Cc:To:From:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Content-ID: Content-Description; bh=Of3kdSNGm1c+zy/bfBvYPY10KOTunHycAP/quTGcvK4=; b=DOwwp 1xFX2Pbl3pylqHR+PjM5cOywxNj8/JsLt6FPdWrHLGCFjW58Tkjmk4S4/n+R+hSo0JKLrry85HVIG c73iAMHqgNZ384s028tsGYC01MZVD+U6umrRjjvDzR6xTkMxXBp8F9+NKDn/ISjcRv+5+GPCmE63d aHIIfZXAbIeyAITadV6evWD7ZzswTbz+mzh3Ocs4oykSU/aqQqFxCer2mCl4ZD3drJhtk82/xagWa zgYZ/jOIMLiav/cEj53VkNXbnrysaPeQKwQh/0oHCiyjXGQZsk0KqycVP6EqJ4i9HaQlZ+8intxtB eOQRR20klocaL0h/AtDtFQSmVuW6Q==; From: Christian Schoenebeck To: qemu-devel@nongnu.org Cc: Greg Kurz Date: Mon, 16 Dec 2019 16:34:04 +0100 Subject: [PATCH 5/9] tests/virtio-9p: check file names of READDIR response Message-Id: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 91.194.90.13 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Additionally to the already existing check for expected amount of directory entries returned by R_readdir response, also check whether all entries have the expected file names, ignoring their precise order in result list though. Signed-off-by: Christian Schoenebeck --- tests/virtio-9p-test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c index ab5926527a..dafea1ae61 100644 --- a/tests/virtio-9p-test.c +++ b/tests/virtio-9p-test.c @@ -563,6 +563,15 @@ static void fs_walk(void *obj, void *data, QGuestAllocator *t_alloc) g_free(wqid); } +static bool fs_dirents_contain_name(struct v9fs_dirent *e, const char* name) { + for (; e; e = e->next) { + if (!strcmp(e->name, name)) { + return true; + } + } + return false; +} + static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtio9P *v9p = obj; @@ -600,6 +609,18 @@ static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc) QTEST_V9FS_SYNTH_READDIR_NFILES + 2 /* "." and ".." */ ); + /* + * Check all file names exist in returned entries, ignore their order + * though. + */ + g_assert_cmpint(fs_dirents_contain_name(entries, "."), ==, true); + g_assert_cmpint(fs_dirents_contain_name(entries, ".."), ==, true); + for (int i = 0; i < QTEST_V9FS_SYNTH_READDIR_NFILES; ++i) { + char *name = g_strdup_printf(QTEST_V9FS_SYNTH_READDIR_FILE, i); + g_assert_cmpint(fs_dirents_contain_name(entries, name), ==, true); + g_free(name); + } + v9fs_free_dirents(entries); g_free(wnames[0]); }