From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: Greg Kurz <groug@kaod.org>
Subject: [PULL v2 2/5] tests/9pfs: fix mkdir() being called twice
Date: Thu, 17 Feb 2022 17:19:44 +0100 [thread overview]
Message-ID: <68c66a96c8393d482599bf56f1c13c7ae3e13ec1.1645114783.git.qemu_oss@crudebyte.com> (raw)
In-Reply-To: <cover.1645114783.git.qemu_oss@crudebyte.com>
The 9p test cases use mkdtemp() to create a temporary directory for
running the 'local' 9p tests with real files/dirs. Unlike mktemp()
which only generates a unique file name, mkdtemp() also creates the
directory, therefore the subsequent mkdir() was wrong and caused
errors on some systems.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Fixes: 136b7af2 (tests/9pfs: fix test dir for parallel tests)
Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/832
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Greg Kurz <Greg Kurz <groug@kaod.org>
Message-Id: <f6602123c6f7d0d593466231b04fba087817abbd.1642879848.git.qemu_oss@crudebyte.com>
---
tests/qtest/libqos/virtio-9p.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index b4e1143288..ef96ef006a 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -37,31 +37,19 @@ static char *concat_path(const char* a, const char* b)
return g_build_filename(a, b, NULL);
}
-static void init_local_test_path(void)
+void virtio_9p_create_local_test_dir(void)
{
+ struct stat st;
char *pwd = g_get_current_dir();
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);
-}
-
-void virtio_9p_create_local_test_dir(void)
-{
- struct stat st;
- int res;
-
- init_local_test_path();
g_assert(local_test_path != NULL);
- res = mkdir(local_test_path, 0777);
- if (res < 0) {
- g_test_message("mkdir('%s') failed: %s", local_test_path,
- strerror(errno));
- }
/* ensure test directory exists now ... */
g_assert(stat(local_test_path, &st) == 0);
--
2.20.1
next prev parent reply other threads:[~2022-02-17 17:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 16:19 [PULL v2 0/5] 9p queue (previous 2022-02-10) Christian Schoenebeck
2022-02-17 16:19 ` [PULL v2 3/5] tests/9pfs: Fix leak of local_test_path Christian Schoenebeck
2022-02-17 16:19 ` [PULL v2 1/5] tests/9pfs: use g_autofree where possible Christian Schoenebeck
2022-02-17 16:19 ` [PULL v2 5/5] 9pfs: Fix segfault in do_readdir_many caused by struct dirent overread Christian Schoenebeck
2022-02-22 13:21 ` Peter Maydell
2022-02-22 13:54 ` Christian Schoenebeck
2022-02-22 15:35 ` Greg Kurz
2022-02-17 16:19 ` Christian Schoenebeck [this message]
2022-02-17 16:19 ` [PULL v2 4/5] tests/9pfs: Use g_autofree and g_autoptr where possible Christian Schoenebeck
2022-02-19 15:21 ` [PULL v2 0/5] 9p queue (previous 2022-02-10) Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=68c66a96c8393d482599bf56f1c13c7ae3e13ec1.1645114783.git.qemu_oss@crudebyte.com \
--to=qemu_oss@crudebyte.com \
--cc=groug@kaod.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).