From patchwork Wed Dec 18 13:35:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 11301011 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3E206C1 for ; Wed, 18 Dec 2019 15:17:53 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7A0D524676 for ; Wed, 18 Dec 2019 15:17:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=crudebyte.com header.i=@crudebyte.com header.b="SPxy7F0M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A0D524676 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:55632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihb5E-0006kl-K9 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Dec 2019 10:17:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59275) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <2a40095340d9536575af8fd214a7ac647b4603c9@lizzy.crudebyte.com>) id 1ihb4C-0005Xz-OK for qemu-devel@nongnu.org; Wed, 18 Dec 2019 10:16:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <2a40095340d9536575af8fd214a7ac647b4603c9@lizzy.crudebyte.com>) id 1ihb4B-000436-J6 for qemu-devel@nongnu.org; Wed, 18 Dec 2019 10:16:48 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:52497) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <2a40095340d9536575af8fd214a7ac647b4603c9@lizzy.crudebyte.com>) id 1ihb4B-0006bb-A1 for qemu-devel@nongnu.org; Wed, 18 Dec 2019 10:16:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Subject:Date:Cc:To:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=dS1iuR3dCQd46YTSHKj8EZ1+/iu1EX7LIzJnLFpbqfQ=; b=SPxy7 F0MDCIgP8kqguZzShP3LZfUxYXYPE6reJmoNy9o9Qq/fd2gGYvlCUmhtNqHd3qTm41SBtV5Pd+j4m cZydf6x8sk5TrDrStOJRalB8yecl0oqXbCvG/aO2zFgLdT855b0tRpw5aHCYRKlOc52OywdEOqgqL T6U6Ehu4qGLJD/3xKaxazZRYtDX584PJPfnsr1I/WHxtDGl/j+h6BR1pFcZ9YgxBAny2KqNONOtgf SOJ//dJ17qGGFBWA1HuGFc3wBWKLUgFzNKx1VJIuMpKEurDaGBhj3cP2M4FhYUfIdOLjk6GBb3Srf 4JKw3N3jXaouYm8wgQ8EKlUHysIzg==; Message-Id: <2a40095340d9536575af8fd214a7ac647b4603c9.1576678644.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck To: qemu-devel@nongnu.org Cc: Greg Kurz Date: Wed, 18 Dec 2019 14:35:56 +0100 Subject: [PATCH v2 5/9] tests/virtio-9p: check file names of R_readdir response 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+patchwork-qemu-devel=patchwork.kernel.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 directory entries have the expected file names (as created on 9pfs synth driver side), ignoring their precise order in result list though. Signed-off-by: Christian Schoenebeck --- tests/virtio-9p-test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c index 48c0eca292..cb5c9fb420 100644 --- a/tests/virtio-9p-test.c +++ b/tests/virtio-9p-test.c @@ -565,6 +565,16 @@ 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; @@ -599,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]); }