summaryrefslogtreecommitdiffstats
path: root/tests/qtest/migration-test.c
diff options
context:
space:
mode:
authorBin Meng2022-10-06 17:19:13 +0200
committerThomas Huth2022-10-12 08:43:40 +0200
commite5553c1b8d28fde6b69dc9e6ac148515d361a86c (patch)
tree155a4e6c44e2109cdb30450a844ee48350e2bd19 /tests/qtest/migration-test.c
parentqtest: start a VNC test (diff)
downloadqemu-e5553c1b8d28fde6b69dc9e6ac148515d361a86c.tar.gz
qemu-e5553c1b8d28fde6b69dc9e6ac148515d361a86c.tar.xz
qemu-e5553c1b8d28fde6b69dc9e6ac148515d361a86c.zip
tests/qtest: migration-test: Avoid using hardcoded /tmp
This case was written to use hardcoded /tmp directory for temporary files. Update to use g_dir_make_tmp() for a portable implementation. Signed-off-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20221006151927.2079583-5-bmeng.cn@gmail.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/qtest/migration-test.c')
-rw-r--r--tests/qtest/migration-test.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 0d153d6b5e..ef4427ff4d 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -102,7 +102,7 @@ static bool ufd_version_check(void)
#endif
-static const char *tmpfs;
+static char *tmpfs;
/* The boot file modifies memory area in [start_address, end_address)
* repeatedly. It outputs a 'B' at a fixed rate while it's still running.
@@ -2451,10 +2451,10 @@ static bool kvm_dirty_ring_supported(void)
int main(int argc, char **argv)
{
- char template[] = "/tmp/migration-test-XXXXXX";
const bool has_kvm = qtest_has_accel("kvm");
const bool has_uffd = ufd_version_check();
const char *arch = qtest_get_arch();
+ g_autoptr(GError) err = NULL;
int ret;
g_test_init(&argc, &argv, NULL);
@@ -2479,9 +2479,10 @@ int main(int argc, char **argv)
return g_test_run();
}
- tmpfs = g_mkdtemp(template);
+ tmpfs = g_dir_make_tmp("migration-test-XXXXXX", &err);
if (!tmpfs) {
- g_test_message("g_mkdtemp on path (%s): %s", template, strerror(errno));
+ g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs,
+ err->message);
}
g_assert(tmpfs);
@@ -2612,6 +2613,7 @@ int main(int argc, char **argv)
g_test_message("unable to rmdir: path (%s): %s",
tmpfs, strerror(errno));
}
+ g_free(tmpfs);
return ret;
}