tests/qtest: Use g_mkdtemp()
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>
This commit is contained in:
parent
a47ea61de5
commit
3c239aa77e
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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 "
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user