From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org,
Richard Henderson <richard.henderson@linaro.org>,
Peter Maydell <peter.maydell@linaro.org>
Cc: Bin Meng <bin.meng@windriver.com>
Subject: [PULL 02/23] tests/qtest: Use g_mkdtemp()
Date: Tue, 30 Aug 2022 20:39:51 +0200 [thread overview]
Message-ID: <20220830184012.77978-3-thuth@redhat.com> (raw)
In-Reply-To: <20220830184012.77978-1-thuth@redhat.com>
From: Bin Meng <bin.meng@windriver.com>
Windows does not provide a mkdtemp() API, but glib does.
Replace mkdtemp() call with the glib version.
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20220824094029.1634519-3-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/fuzz/generic_fuzz_configs.h | 2 +-
tests/qtest/cdrom-test.c | 2 +-
tests/qtest/cxl-test.c | 6 +++---
tests/qtest/ivshmem-test.c | 4 ++--
tests/qtest/libqos/virtio-9p.c | 4 ++--
tests/qtest/libqtest.c | 2 +-
tests/qtest/migration-test.c | 4 ++--
tests/qtest/qmp-test.c | 4 ++--
tests/qtest/vhost-user-test.c | 4 ++--
tests/unit/test-qga.c | 2 +-
10 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/tests/qtest/fuzz/generic_fuzz_configs.h b/tests/qtest/fuzz/generic_fuzz_configs.h
index 004c701915..0775e6702b 100644
--- a/tests/qtest/fuzz/generic_fuzz_configs.h
+++ b/tests/qtest/fuzz/generic_fuzz_configs.h
@@ -21,7 +21,7 @@ typedef struct generic_fuzz_config {
static inline gchar *generic_fuzzer_virtio_9p_args(void){
char tmpdir[] = "/tmp/qemu-fuzz.XXXXXX";
- g_assert_nonnull(mkdtemp(tmpdir));
+ g_assert_nonnull(g_mkdtemp(tmpdir));
return g_strdup_printf("-machine q35 -nodefaults "
"-device virtio-9p,fsdev=hshare,mount_tag=hshare "
diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c
index a7766a9e65..26a2400181 100644
--- a/tests/qtest/cdrom-test.c
+++ b/tests/qtest/cdrom-test.c
@@ -52,7 +52,7 @@ static int prepare_image(const char *arch, char *isoimage)
perror("Error creating temporary iso image file");
return -1;
}
- if (!mkdtemp(srcdir)) {
+ if (!g_mkdtemp(srcdir)) {
perror("Error creating temporary directory");
goto cleanup;
}
diff --git a/tests/qtest/cxl-test.c b/tests/qtest/cxl-test.c
index 2133e973f4..4e6d285061 100644
--- a/tests/qtest/cxl-test.c
+++ b/tests/qtest/cxl-test.c
@@ -95,7 +95,7 @@ static void cxl_t3d(void)
char template[] = "/tmp/cxl-test-XXXXXX";
const char *tmpfs;
- tmpfs = mkdtemp(template);
+ tmpfs = g_mkdtemp(template);
g_string_printf(cmdline, QEMU_PXB_CMD QEMU_RP QEMU_T3D, tmpfs, tmpfs);
@@ -109,7 +109,7 @@ static void cxl_1pxb_2rp_2t3d(void)
char template[] = "/tmp/cxl-test-XXXXXX";
const char *tmpfs;
- tmpfs = mkdtemp(template);
+ tmpfs = g_mkdtemp(template);
g_string_printf(cmdline, QEMU_PXB_CMD QEMU_2RP QEMU_2T3D,
tmpfs, tmpfs, tmpfs, tmpfs);
@@ -124,7 +124,7 @@ static void cxl_2pxb_4rp_4t3d(void)
char template[] = "/tmp/cxl-test-XXXXXX";
const char *tmpfs;
- tmpfs = mkdtemp(template);
+ tmpfs = g_mkdtemp(template);
g_string_printf(cmdline, QEMU_2PXB_CMD QEMU_4RP QEMU_4T3D,
tmpfs, tmpfs, tmpfs, tmpfs, tmpfs, tmpfs,
diff --git a/tests/qtest/ivshmem-test.c b/tests/qtest/ivshmem-test.c
index e23a97fa8e..9611d05eb5 100644
--- a/tests/qtest/ivshmem-test.c
+++ b/tests/qtest/ivshmem-test.c
@@ -481,8 +481,8 @@ int main(int argc, char **argv)
tmpshmem = mmap(0, TMPSHMSIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
g_assert(tmpshmem != MAP_FAILED);
/* server */
- if (mkdtemp(dir) == NULL) {
- g_error("mkdtemp: %s", g_strerror(errno));
+ if (g_mkdtemp(dir) == NULL) {
+ g_error("g_mkdtemp: %s", g_strerror(errno));
}
tmpdir = dir;
tmpserver = g_strconcat(tmpdir, "/server", NULL);
diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index 70aea8bf62..ae9b0a20e2 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -48,9 +48,9 @@ void virtio_9p_create_local_test_dir(void)
*/
char *template = concat_path(pwd, "qtest-9p-local-XXXXXX");
- local_test_path = mkdtemp(template);
+ local_test_path = g_mkdtemp(template);
if (!local_test_path) {
- g_test_message("mkdtemp('%s') failed: %s", template, strerror(errno));
+ g_test_message("g_mkdtemp('%s') failed: %s", template, strerror(errno));
}
g_assert(local_test_path != NULL);
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index ad6860d774..7c9fc07de4 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -393,7 +393,7 @@ QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd)
char *sock_path, sock_dir[] = "/tmp/qtest-serial-XXXXXX";
QTestState *qts;
- g_assert_true(mkdtemp(sock_dir) != NULL);
+ g_assert_true(g_mkdtemp(sock_dir) != NULL);
sock_path = g_strdup_printf("%s/sock", sock_dir);
sock_fd_init = init_socket(sock_path);
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index f63edd0bc8..60f3d4e9d2 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -2452,9 +2452,9 @@ int main(int argc, char **argv)
return g_test_run();
}
- tmpfs = mkdtemp(template);
+ tmpfs = g_mkdtemp(template);
if (!tmpfs) {
- g_test_message("mkdtemp on path (%s): %s", template, strerror(errno));
+ g_test_message("g_mkdtemp on path (%s): %s", template, strerror(errno));
}
g_assert(tmpfs);
diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c
index 9a42480cef..bf7304c7dc 100644
--- a/tests/qtest/qmp-test.c
+++ b/tests/qtest/qmp-test.c
@@ -166,8 +166,8 @@ char *fifo_name;
static void setup_blocking_cmd(void)
{
- if (!mkdtemp(tmpdir)) {
- g_error("mkdtemp: %s", strerror(errno));
+ if (!g_mkdtemp(tmpdir)) {
+ g_error("g_mkdtemp: %s", strerror(errno));
}
fifo_name = g_strdup_printf("%s/fifo", tmpdir);
if (mkfifo(fifo_name, 0666)) {
diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
index 8bf390be20..d7d6cfc9bd 100644
--- a/tests/qtest/vhost-user-test.c
+++ b/tests/qtest/vhost-user-test.c
@@ -491,9 +491,9 @@ static TestServer *test_server_new(const gchar *name,
/* run the main loop thread so the chardev may operate */
server->thread = g_thread_new(NULL, thread_function, server->loop);
- tmpfs = mkdtemp(template);
+ tmpfs = g_mkdtemp(template);
if (!tmpfs) {
- g_test_message("mkdtemp on path (%s): %s", template, strerror(errno));
+ g_test_message("g_mkdtemp on path (%s): %s", template, strerror(errno));
}
g_assert(tmpfs);
diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
index b27c77a695..a05a4628ed 100644
--- a/tests/unit/test-qga.c
+++ b/tests/unit/test-qga.c
@@ -60,7 +60,7 @@ fixture_setup(TestFixture *fixture, gconstpointer data, gchar **envp)
fixture->loop = g_main_loop_new(NULL, FALSE);
fixture->test_dir = g_strdup("/tmp/qgatest.XXXXXX");
- g_assert_nonnull(mkdtemp(fixture->test_dir));
+ g_assert_nonnull(g_mkdtemp(fixture->test_dir));
path = g_build_filename(fixture->test_dir, "sock", NULL);
cwd = g_get_current_dir();
--
2.31.1
next prev parent reply other threads:[~2022-08-30 18:43 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 18:39 [PULL 00/23] First testing patches for QEMU 7.2 Thomas Huth
2022-08-30 18:39 ` [PULL 01/23] tests/qtest: Use g_setenv() Thomas Huth
2022-08-30 18:39 ` Thomas Huth [this message]
2022-08-30 18:39 ` [PULL 03/23] tests: Use g_mkdir_with_parents() Thomas Huth
2022-08-30 18:39 ` [PULL 04/23] tests/qtest: migration-test: Handle link() for win32 Thomas Huth
2022-08-30 18:39 ` [PULL 05/23] backends/tpm: Exclude headers and macros that don't exist on win32 Thomas Huth
2022-08-30 18:39 ` [PULL 06/23] tests/qtest: Adapt {m48t59,rtc}-test cases for win32 Thomas Huth
2022-08-30 18:39 ` [PULL 07/23] tests/qtest: Build e1000e-test for posix only Thomas Huth
2022-08-30 18:39 ` [PULL 08/23] tests/qtest: Build cases that use memory-backend-file " Thomas Huth
2022-08-30 18:39 ` [PULL 09/23] tests/qtest: i440fx-test: Skip running request_{bios, pflash} for win32 Thomas Huth
2022-08-30 18:39 ` [PULL 10/23] tests/qtest: migration-test: Skip running test_migrate_fd_proto on win32 Thomas Huth
2022-08-30 18:40 ` [PULL 11/23] tests/qtest: libqos: Drop inclusion of <sys/wait.h> Thomas Huth
2022-08-30 18:40 ` [PULL 12/23] tests/qtest: libqos: Rename malloc.h to libqos-malloc.h Thomas Huth
2022-08-30 18:40 ` [PULL 13/23] tests/qtest: device-plug-test: Reverse the usage of double/single quotes Thomas Huth
2022-08-30 18:40 ` [PULL 14/23] tests/qtest: machine-none-test: Use double quotes to pass the cpu option Thomas Huth
2022-08-30 18:40 ` [PULL 15/23] tests/qtest: npcm7xx_emc-test: Skip running test_{tx, rx} on win32 Thomas Huth
2022-08-30 18:40 ` [PULL 16/23] tests/qtest: prom-env-test: Use double quotes to pass the prom-env option Thomas Huth
2022-08-30 18:40 ` [PULL 17/23] tests/vm: Add libslirp to the VM tests Thomas Huth
2022-08-30 18:40 ` [PULL 18/23] tests/avocado: Do not run tests that require libslirp if it is not available Thomas Huth
2022-08-30 18:40 ` [PULL 19/23] tests/avocado: Fix trivial typo Thomas Huth
2022-08-30 18:40 ` [PULL 20/23] docs/devel/testing: fix minor typo Thomas Huth
2022-08-30 18:40 ` [PULL 21/23] gitlab-ci: Only use one process in Windows jobs for compilation Thomas Huth
2022-08-30 18:40 ` [PULL 22/23] tests/qtest/ac97-test: Correct reference to driver Thomas Huth
2022-08-30 18:40 ` [PULL 23/23] tests/avocado/migration: Get find_free_port() from the ports Thomas Huth
2022-08-31 23:54 ` [PULL 00/23] First testing patches for QEMU 7.2 Stefan Hajnoczi
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=20220830184012.77978-3-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=bin.meng@windriver.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).