Skip to content
Snippets Groups Projects
Commit c12fea71 authored by Bin Meng's avatar Bin Meng Committed by Thomas Huth
Browse files

tests/qtest: qmp-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: default avatarBin Meng <bin.meng@windriver.com>
Message-Id: <20220927110632.1973965-17-bmeng.cn@gmail.com>
Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
parent 8189b27d
No related branches found
No related tags found
No related merge requests found
......@@ -163,14 +163,15 @@ static void test_qmp_protocol(void)
/* Out-of-band tests */
char tmpdir[] = "/tmp/qmp-test-XXXXXX";
char *tmpdir;
char *fifo_name;
static void setup_blocking_cmd(void)
{
if (!g_mkdtemp(tmpdir)) {
g_error("g_mkdtemp: %s", strerror(errno));
}
GError *err = NULL;
tmpdir = g_dir_make_tmp("qmp-test-XXXXXX", &err);
g_assert_no_error(err);
fifo_name = g_strdup_printf("%s/fifo", tmpdir);
if (mkfifo(fifo_name, 0666)) {
g_error("mkfifo: %s", strerror(errno));
......@@ -181,6 +182,7 @@ static void cleanup_blocking_cmd(void)
{
unlink(fifo_name);
rmdir(tmpdir);
g_free(tmpdir);
}
static void send_cmd_that_blocks(QTestState *s, const char *id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment