From nobody Fri May 17 09:18:35 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=1604244329; cv=none; d=zohomail.com; s=zohoarc; b=kbF37eCJesMwnw3VVxENHlNTZLLDyOBNweTWOmbj3PP3iz1230x1vVlJbbscMNFi4V5QJWNGU+UslteBSS335jPwhbnS7EVwVgLocZ44ZAh0bC4K2CnfmCuhUkRp0WMFOPVk58jRXCFzCpno7Aoz0xlilz4t2dunG2AT5oqUlUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604244329; 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=M4F3q8KaK+NXBeqlbOxwURsCLbUnH74xNhiohvqEx/4=; b=Y0eMVVTnNSkll78324zmBXVy4sA+A995g7rD/4CB97v0JnuvtEhYiqSitcsB86E0pqUjzUHxPrQ0l8wZdrUjcOLlfa63gdG9QbP2tcIbzErZQmZ+5U47ih+PX56M5EFfckGwTJBarFq6lWr2iX2uN2f4fCeIwzmklwk4dZ8qcao= 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 1604244328836401.7165206786249; Sun, 1 Nov 2020 07:25:28 -0800 (PST) Received: from localhost ([::1]:50596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZFES-0004VK-WF for importer@patchew.org; Sun, 01 Nov 2020 10:25:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZFCZ-0003Fx-6l for qemu-devel@nongnu.org; Sun, 01 Nov 2020 10:23:27 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:36899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZFCW-0006k0-S3 for qemu-devel@nongnu.org; Sun, 01 Nov 2020 10:23:26 -0500 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=M4F3q8KaK+NXBeqlbOxwURsCLbUnH74xNhiohvqEx/4=; b=ULDeq 4obX2L2KJPTUDISmyYF/sKDlJOAZwkI+JTzjc3EBCI9aH8vjlutzDIx52MMcJiIJNs0D4ZwOwVpZN CITFnR4LFi+2VACbPHPysOsDfVgFyI3c8T4sfp0MMsQfIjFYjjDVtZAXTdH0rU9zelmwLFXihAE4K w/81e8vIWm5oAkRW9PhASGfYPOAkOI/UnfAjiodoZOYJI0tAAToroD5YmULoD+Nz7OGqsm3TXsnae YiGvlcT7WqnxqunkzvViAghQ2lRfKh6whLNavI6eb80kGCbR8JVJN2poSjS8bnnpCvc14VQvnNKL2 qSSJ+nyaWQN7eWX7xN7tlKdkvjxVg==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 1 Nov 2020 15:25:14 +0100 Subject: [PATCH v3 1/2] tests/9pfs: make create/remove test dir public 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=ec90703cbc23d6b612b3672f946d7741f4a16080@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/01 10:22:17 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" Make functions create_local_test_dir() and remove_local_test_dir() public. They're going to be used in the next patch. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/libqos/virtio-9p.c | 10 ++++------ tests/qtest/libqos/virtio-9p.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index d43647b3b7..2736e9ae2a 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -39,8 +39,7 @@ static void init_local_test_path(void) g_free(pwd); } =20 -/* Creates the directory for the 9pfs 'local' filesystem driver to access.= */ -static void create_local_test_dir(void) +void virtio_9p_create_local_test_dir(void) { struct stat st; =20 @@ -53,8 +52,7 @@ static void create_local_test_dir(void) g_assert((st.st_mode & S_IFMT) =3D=3D S_IFDIR); } =20 -/* Deletes directory previously created by create_local_test_dir(). */ -static void remove_local_test_dir(void) +void virtio_9p_remove_local_test_dir(void) { g_assert(local_test_path !=3D NULL); char *cmd =3D g_strdup_printf("rm -r '%s'\n", local_test_path); @@ -248,8 +246,8 @@ static void virtio_9p_register_nodes(void) =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(); + virtio_9p_remove_local_test_dir(); + virtio_9p_create_local_test_dir(); =20 QPCIAddress addr =3D { .devfn =3D QPCI_DEVFN(4, 0), diff --git a/tests/qtest/libqos/virtio-9p.h b/tests/qtest/libqos/virtio-9p.h index 19a4d97454..480727120e 100644 --- a/tests/qtest/libqos/virtio-9p.h +++ b/tests/qtest/libqos/virtio-9p.h @@ -44,6 +44,16 @@ struct QVirtio9PDevice { QVirtio9P v9p; }; =20 +/** + * Creates the directory for the 9pfs 'local' filesystem driver to access. + */ +void virtio_9p_create_local_test_dir(void); + +/** + * Deletes directory previously created by virtio_9p_create_local_test_dir= (). + */ +void virtio_9p_remove_local_test_dir(void); + /** * Prepares QEMU command line for 9pfs tests using the 'local' fs driver. */ --=20 2.20.1 From nobody Fri May 17 09:18:35 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=1604244407; cv=none; d=zohomail.com; s=zohoarc; b=c6sa2/tA+nVvCq0NEj47KDQ/BazGvfwTEX6dX9GmFbFmDtPu0Eisi3BDV2prZ4qNEM51VL7WX/ccOgvtqmFx4hbsY11iLruMcAwHZFTGBB9DnBWRHvJamW+N6L45rvn6BLxBlNbv0/Zon+FYfMvqPOsnH5trjqcachur6iqOOTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604244407; 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=tgAD6D3APZHppVajKkzG3/l4JDgMPHhecmwfxqWqFbA=; b=LQvq1VG6f4ELBrePo8qxGbpiGV04O3/mDmgC6ZKWx2r8oJTm5VGHvWUujcIKNafDcBegjCWykK70/BxgwfHwGtQG5tC4any6u0dprKOgij8vQ6PU4IkXIDZmHFtpyaTG2E+uW/Zz/z8prEXivvIvu3XmyEv+X7AyysAyyZJNUBM= 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 1604244407749588.3937413104759; Sun, 1 Nov 2020 07:26:47 -0800 (PST) Received: from localhost ([::1]:54996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZFFm-0006ZB-EV for importer@patchew.org; Sun, 01 Nov 2020 10:26:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <7746f42d8f557593898d3d9d8e57c46e872dfb4f@lizzy.crudebyte.com>) id 1kZFCf-0003No-Hs for qemu-devel@nongnu.org; Sun, 01 Nov 2020 10:23:33 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:51771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <7746f42d8f557593898d3d9d8e57c46e872dfb4f@lizzy.crudebyte.com>) id 1kZFCd-0006kh-PH for qemu-devel@nongnu.org; Sun, 01 Nov 2020 10:23:33 -0500 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=tgAD6D3APZHppVajKkzG3/l4JDgMPHhecmwfxqWqFbA=; b=cte5y 5XGQW5J70IeTFzv1Ld7/7JPQK0K5Js1EWjTz9E0DaKN3/dWgT2L3y1BooeUyro73NEG2FY97ic/rg nt2bZb6b+5of25Be+zsSfhtMtIw0Qf8sBr6RMss+4/TKzQoUbM45Z1ev8xL+4nrntZlGyam0ehZxg 8J50sD57/thev5EZuto43Bgkx20cWd92fkiM8KlyvCdO52aVoFD3nlBHcrDsDw++htt2srIGuC3S2 QstNWetsMWx4ujerqfIpJcBIFLWbeAdvsO1krllXHmEEP6BdayATGEQkfa7pECSyOoSOEWbksR7Kr pXxjR+jmcWWbwhHVLDzV8d8TNFM7w==; Message-Id: <7746f42d8f557593898d3d9d8e57c46e872dfb4f.1604243521.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 1 Nov 2020 15:37:12 +0100 Subject: [PATCH v3 2/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=7746f42d8f557593898d3d9d8e57c46e872dfb4f@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/01 10:22:17 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. The constructor functions needs to be in virtio-9p-test.c, not in virtio-9p.c, because in the latter location it would cause all apps that link to libqos (i.e. entirely unrelated test suites) to create a 9pfs test directory as well, which would even break other test suites. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Tested-by: Greg Kurz --- tests/qtest/libqos/virtio-9p.c | 14 ++++++++------ tests/qtest/virtio-9p-test.c | 12 ++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index 2736e9ae2a..586e700b24 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 @@ -43,6 +48,8 @@ void virtio_9p_create_local_test_dir(void) { struct stat st; =20 + init_local_test_path(); + g_assert(local_test_path !=3D NULL); mkdir(local_test_path, 0777); =20 @@ -244,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(); - virtio_9p_remove_local_test_dir(); - virtio_9p_create_local_test_dir(); - QPCIAddress addr =3D { .devfn =3D QPCI_DEVFN(4, 0), }; diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index c15908f27b..6401d4f564 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1076,3 +1076,15 @@ static void register_virtio_9p_test(void) } =20 libqos_init(register_virtio_9p_test); + +static void __attribute__((constructor)) construct_9p_test(void) +{ + /* make sure test dir for the 'local' tests exists */ + virtio_9p_create_local_test_dir(); +} + +static void __attribute__((destructor)) destruct_9p_test(void) +{ + /* remove previously created test dir when test suite completed */ + virtio_9p_remove_local_test_dir(); +} --=20 2.20.1