From nobody Fri May 17 23:12:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604063259; cv=none; d=zohomail.com; s=zohoarc; b=KT17V3q3sj4rSuyqKDsgbHz4f9CFNrHEE7g2sOSOX2vCc4yYUVNT26j0ki77GEHvK6pNzxOWkojwqon7YFhZ/NF0nNai6s1ifUBqFj5RkocFKyxfgwxLNDqspVpf/yBh41yKzI2TdZ1WYI+mnALxaR70QsNq2B+ggwkAXxY/Hf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604063259; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Ld7D9oh7N3BYknwG5EaWpmySWIkgoTSxmXWvwmQbqDc=; b=hDgkDR9r0owWyJ5QmnroBuMZZ49FvOZwmNaTAWP4S9Vh2hzoT2kpNcGUuNzczWu2507kp9JE0WiWDi0lsZKjZw/aGBszPCMZW3h91qcb3p8SR7nILSx5574FVLjjyB29ofuCd804bmP8AdjQs2rlyv8X3E70hEzu6XlJt8w81us= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604063259699870.3904227404616; Fri, 30 Oct 2020 06:07:39 -0700 (PDT) Received: from localhost ([::1]:33914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYU82-0004FR-UU for importer@patchew.org; Fri, 30 Oct 2020 09:07:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTwG-0003wU-2o for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:55:28 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:44555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTwA-0003k2-Ls for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:55:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=Ld7D9oh7N3BYknwG5EaWpmySWIkgoTSxmXWvwmQbqDc=; b=eUW+E 2rifWqS9wkZ5MjRnsS3oSR8TCeG3SkdoDYMI3Cd7rVbKCq96weWHIEuwnIIFq4TlMgMe0w5AgwyuW 1guk9RlHka2bhBRRowaewxt5r5bHoU47uf32yr55rlgQgpGshUCeuw7duNzhy/KTIC5/feRZPGetU fhx+NFJXpUK7VdWUcNq5e7CI3QgfvtIw9lAAxJjCR3WxAZAcgFdgK9ctuIDv1QuvFiii9cIFZ8+wa /3RldAejKs4m3zbStDXjnER0xLVFe7kjeAKyl6EyzMcbOgMj91pVEBYY8w1wgefbY/W3F1ax9pGFZ M6IwRlQy0AixnqOPQky6nYgzfDILw==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 30 Oct 2020 13:07:03 +0100 Subject: [PATCH v2 1/2] tests/9pfs: fix test dir for parallel tests To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=a37fbc713614f7615b11d0a3cb8d9adc3b8fba4b@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 07:59:50 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use mkdtemp() to generate a unique directory for the 9p 'local' tests. This fixes occasional 9p test failures when running 'make check -jN' if QEMU was compiled for multiple target architectures, because the individual architecture's test suites would run in parallel and interfere with each other's data as the test directory was previously hard coded and hence the same directory was used by all of them simultaniously. This also requires a change how the test directory is created and deleted: As the test path is now randomized and virtio_9p_register_nodes() being called in a somewhat undeterministic way, that's no longer an appropriate place to create and remove the test directory. Use a constructor and destructor function for creating and removing the test directory instead. Unfortunately libqos currently does not support setup/teardown callbacks to handle this more cleanly. Signed-off-by: Christian Schoenebeck Tested-by: Greg Kurz Reviewed-by: Greg Kurz --- tests/qtest/libqos/virtio-9p.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index d43647b3b7..6b22fa0e9a 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -35,7 +35,12 @@ static char *concat_path(const char* a, const char* b) static void init_local_test_path(void) { char *pwd =3D g_get_current_dir(); - local_test_path =3D concat_path(pwd, "qtest-9p-local"); + char *template =3D concat_path(pwd, "qtest-9p-local-XXXXXX"); + local_test_path =3D mkdtemp(template); + if (!local_test_path) { + g_test_message("mkdtemp('%s') failed: %s", template, strerror(errn= o)); + } + g_assert(local_test_path); g_free(pwd); } =20 @@ -246,11 +251,6 @@ static void virtio_9p_register_nodes(void) const char *str_simple =3D "fsdev=3Dfsdev0,mount_tag=3D" MOUNT_TAG; const char *str_addr =3D "fsdev=3Dfsdev0,addr=3D04.0,mount_tag=3D" MOU= NT_TAG; =20 - /* make sure test dir for the 'local' tests exists and is clean */ - init_local_test_path(); - remove_local_test_dir(); - create_local_test_dir(); - QPCIAddress addr =3D { .devfn =3D QPCI_DEVFN(4, 0), }; @@ -278,3 +278,16 @@ static void virtio_9p_register_nodes(void) } =20 libqos_init(virtio_9p_register_nodes); + +static void __attribute__((constructor)) construct_virtio_9p(void) +{ + /* make sure test dir for the 'local' tests exists */ + init_local_test_path(); + create_local_test_dir(); +} + +static void __attribute__((destructor)) destruct_virtio_9p(void) +{ + /* remove previously created test dir when test suite completed */ + remove_local_test_dir(); +} --=20 2.20.1 From nobody Fri May 17 23:12:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604062642; cv=none; d=zohomail.com; s=zohoarc; b=hRcwlKJp3H5h4QWiXag7Z4AeRa0CaoCbNE1OvLXSmWRkXoQpgVfESIBXKMYp8KJIM9DRlCSUYM6thYVHUSVS1tTSrlWbT1XAo1YK3d/QVUOkt7X6jyeuYPkIdNv+jJIszb1I9O2+7LNP0Rey7mfRVTIIRc7Cm8ZUQnuJGQlWDaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604062642; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=9s02O/KYcd7A7lc/0kRbCK6nYi9tDPfa0S4ictjN0vw=; b=T9PMKo+ovq15XDTDIv8StHs0vHZDQ2JhMTgo/Eu23W3jJWHJUfOQI9rbwPIOzdOTD+yT+wnwquKHHYdgs9l0Z646XNZRgGKJMhLH01sLU+h4t/ttizmjXaKs5htb0y5bek8q2PFDiD2a5LxI7GE+N0OHFbFpaBxSYX2cvv7QbyM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604062642837380.6438166869634; Fri, 30 Oct 2020 05:57:22 -0700 (PDT) Received: from localhost ([::1]:45462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTy5-0005Bl-F0 for importer@patchew.org; Fri, 30 Oct 2020 08:57:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <03f68c7ec08064e20f43797f4eb4305ad21e1e8e@lizzy.crudebyte.com>) id 1kYTwI-0003xM-3K for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:55:30 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:33871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <03f68c7ec08064e20f43797f4eb4305ad21e1e8e@lizzy.crudebyte.com>) id 1kYTwF-0003lo-Fy for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:55:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=9s02O/KYcd7A7lc/0kRbCK6nYi9tDPfa0S4ictjN0vw=; b=YT1tj RC5+bOA3w0oqYHkaeIn4abX1BKAUWzEswOakZFJYTIL8ZgdK8ZydioFzkiB/iib2iavbnt4YPSFqH B8T68N6/XVadkdHcwM3BSOBOMWu7ui02M/82ENeVUY+znJTNVgnyRWayjKw6WvRy8zd+GsMhKrPpV PymnTrIC4/nhsGqngu++L9dcfAdzLAo9onvKHUkwSa088+NnHmN8Vo011iOx9FbAKsNZwTmMlu/j7 Q1L8q5EFKeIb5Kkf+saDABEUGs1zCdmab1uxXy3+dtUdaGbby6yadGDQvgnqM3JmLsCU/0GUkiW7c 2jNkmVoSDsE+jE3ZqXHuTIgbVbjlw==; Message-Id: <03f68c7ec08064e20f43797f4eb4305ad21e1e8e.1604061839.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 30 Oct 2020 13:07:03 +0100 Subject: [PATCH v2 2/2] tests/9pfs: fix coverity error in create_local_test_dir() To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=03f68c7ec08064e20f43797f4eb4305ad21e1e8e@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 07:59:50 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Coverity wants the return value of mkdir() to be checked: /qemu/tests/qtest/libqos/virtio-9p.c: 48 in create_local_test_dir() 42 /* Creates the directory for the 9pfs 'local' filesystem driver to access. */ 43 static void create_local_test_dir(void) 44 { 45 struct stat st; 46 47 g_assert(local_test_path !=3D NULL); >>> CID 1435963: Error handling issues (CHECKED_RETURN) >>> Calling "mkdir(local_test_path, 511U)" without checking return value. This library function may fail and return an error code. 48 mkdir(local_test_path, 0777); 49 50 /* ensure test directory exists now ... */ 51 g_assert(stat(local_test_path, &st) =3D=3D 0); 52 /* ... and is actually a directory */ 53 g_assert((st.st_mode & S_IFMT) =3D=3D S_IFDIR); So let's just do that and log an info-level message at least, because we actually only care if the required directory exists and we do have an existence check for that in place already. Reported-by: Coverity (CID 1435963) Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/libqos/virtio-9p.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index 6b22fa0e9a..8459a3ee58 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -48,9 +48,14 @@ static void init_local_test_path(void) static void create_local_test_dir(void) { struct stat st; + int res; =20 g_assert(local_test_path !=3D NULL); - mkdir(local_test_path, 0777); + res =3D mkdir(local_test_path, 0777); + if (res < 0) { + g_test_message("mkdir('%s') failed: %s", local_test_path, + strerror(errno)); + } =20 /* ensure test directory exists now ... */ g_assert(stat(local_test_path, &st) =3D=3D 0); --=20 2.20.1