Re: [PATCH 02/51] tests/qtest: Use g_mkdtemp()

2022-08-24 Thread Thomas Huth

On 24/08/2022 11.39, Bin Meng wrote:

From: Bin Meng 

Windows does not provide a mkdtemp() API, but glib does.
Replace mkdtemp() call with the glib version.

Signed-off-by: Bin Meng 
---

  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(-)


Reviewed-by: Thomas Huth 




[PATCH 02/51] tests/qtest: Use g_mkdtemp()

2022-08-24 Thread Bin Meng
From: Bin Meng 

Windows does not provide a mkdtemp() API, but glib does.
Replace mkdtemp() call with the glib version.

Signed-off-by: Bin Meng 
---

 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.XX";
-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-XX";
 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-XX";
 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-XX";
 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-XX");
 
-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-XX";
 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 520a5f917c..52988b86eb 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -2450,9 +2450,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