From patchwork Fri Oct 30 08:19:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 11868779 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 C756E14B2 for ; Fri, 30 Oct 2020 08:42:00 +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 30E312076D for ; Fri, 30 Oct 2020 08:41:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=crudebyte.com header.i=@crudebyte.com header.b="dbXpZ34j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30E312076D 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]:44182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYPyv-0007B3-34 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 30 Oct 2020 04:41:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <73a2acc5ca29f95d6d2e5ce60ec69c62bd55f637@lizzy.crudebyte.com>) id 1kYPyO-0006J6-5e for qemu-devel@nongnu.org; Fri, 30 Oct 2020 04:41:24 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:52601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <73a2acc5ca29f95d6d2e5ce60ec69c62bd55f637@lizzy.crudebyte.com>) id 1kYPyM-000432-57 for qemu-devel@nongnu.org; Fri, 30 Oct 2020 04:41:23 -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=FZEBSYePsIFOW2CmW0yoFTgrrrEQwM44sA87p65ipA8=; b=dbXpZ 34jgapHQihclKMWs9JdtFKg2YEEiUSUnQ3YaKj/+ysBEBR21N6OHMWWg1Iy0XJo0PdgsYtpaWWCoP ndC3xNeBFQDZFK8e7POSPBUJACu7P7XKXzQmMJUkMNHfz1yEDRseeF7tyH9P16LLvmKB25nEFqKcb J8MieD2v1aC7PApDJJ47IrjLnw8NHqQNdiBzTJbzFesqNnQSv8ARLzMtqapjelTNcx1+4NOEOskxO qADOzG8r+HFQ5DBB7aCt+15y3TT8bs8C/DLprFH8hhtChjxXILo4CxCNj5micoPXWwF3qHC5Y3T0M aUauyDekJJA8tsLCl7UV+BfDl9ZVQ==; Message-Id: <73a2acc5ca29f95d6d2e5ce60ec69c62bd55f637.1604046404.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 30 Oct 2020 09:19:46 +0100 Subject: [PATCH 1/2] tests/9pfs: fix test dir for parallel tests To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=73a2acc5ca29f95d6d2e5ce60ec69c62bd55f637@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 04:40:14 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 = g_get_current_dir(); - local_test_path = concat_path(pwd, "qtest-9p-local"); + char *template = concat_path(pwd, "qtest-9p-local-XXXXXX"); + local_test_path = mkdtemp(template); + if (!local_test_path) { + g_test_message("mkdtemp('%s') failed: %s", template, strerror(errno)); + } + g_assert(local_test_path); g_free(pwd); } @@ -246,11 +251,6 @@ static void virtio_9p_register_nodes(void) const char *str_simple = "fsdev=fsdev0,mount_tag=" MOUNT_TAG; const char *str_addr = "fsdev=fsdev0,addr=04.0,mount_tag=" MOUNT_TAG; - /* 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 = { .devfn = QPCI_DEVFN(4, 0), }; @@ -278,3 +278,16 @@ static void virtio_9p_register_nodes(void) } 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(); +} From patchwork Fri Oct 30 08:19:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 11868781 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 6DC8014B2 for ; Fri, 30 Oct 2020 08:43:32 +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 C3B9F2075E for ; Fri, 30 Oct 2020 08:43:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=crudebyte.com header.i=@crudebyte.com header.b="i9T8I2gU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3B9F2075E 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]:47360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYQ0Q-0008Uh-Lr for patchwork-qemu-devel@patchwork.kernel.org; Fri, 30 Oct 2020 04:43:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYPyV-0006Ur-H5 for qemu-devel@nongnu.org; Fri, 30 Oct 2020 04:41:31 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:34439) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYPyT-000487-S6 for qemu-devel@nongnu.org; Fri, 30 Oct 2020 04:41:31 -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=TYpAqY+nQKdFSjfR6Uv42nfzjmKSdH0n8xLRASXaJqA=; b=i9T8I 2gUqFsAMQZEou/Y89t/yiDnOHgCaUeP0eMauuUKt0QKoHIXkOyLuYw6G2yhLneJN+6+7ua3QRYT8f r2kDcUNS2T88DMqNyaV2B/RLoCZpAilpOXj0Vcr6dZXjqMnoCmXiapxwtb0ggwBOCm611TmktOmNk 97l0mUVQNJNx4R/r4nXaXbfA23/uS9ZZXa7vsxvSgJio6ODxob8ona5POfqvyNde+4gofK/IyxiAS 0ObxlY9uOnR8E2nWZNRzWP6JJYc/GC8YcC/bmKhwLShpJ9fZKpPjA0E3F7Q1wlzuw8aRu54cjKHO+ 23BbAis7VwXDxumAFGIN03oXTLMqQ==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 30 Oct 2020 09:19:46 +0100 Subject: [PATCH 2/2] tests/9pfs: fix coverity error in create_local_test_dir() To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=b111895492f8fb79bcca1c3e9586c0615f46cc97@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 04:40:14 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Coverity wants the return value of mkdir() to be checked, so let's pretend to do that. We're actually just making a dummy check and ignore the result, because we actually only care if the required directory exists and we have an existence check for that in place already. Reported-by: Greg Kurz Signed-off-by: Christian Schoenebeck Reported-by: Coverity (CID 1435963) --- tests/qtest/libqos/virtio-9p.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index 6b22fa0e9a..0a7c0ee5d8 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -48,9 +48,13 @@ static void init_local_test_path(void) static void create_local_test_dir(void) { struct stat st; + int res; g_assert(local_test_path != NULL); - mkdir(local_test_path, 0777); + res = mkdir(local_test_path, 0777); + if (res < 0) { + /* ignore error, dummy check to prevent error by coverity */ + } /* ensure test directory exists now ... */ g_assert(stat(local_test_path, &st) == 0);