mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
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: Bin Meng <bin.meng@windriver.com> Message-Id: <20220927110632.1973965-17-bmeng.cn@gmail.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
8189b27d3b
commit
c12fea71a0
1 changed files with 6 additions and 4 deletions
|
@ -163,14 +163,15 @@ static void test_qmp_protocol(void)
|
||||||
|
|
||||||
/* Out-of-band tests */
|
/* Out-of-band tests */
|
||||||
|
|
||||||
char tmpdir[] = "/tmp/qmp-test-XXXXXX";
|
char *tmpdir;
|
||||||
char *fifo_name;
|
char *fifo_name;
|
||||||
|
|
||||||
static void setup_blocking_cmd(void)
|
static void setup_blocking_cmd(void)
|
||||||
{
|
{
|
||||||
if (!g_mkdtemp(tmpdir)) {
|
GError *err = NULL;
|
||||||
g_error("g_mkdtemp: %s", strerror(errno));
|
tmpdir = g_dir_make_tmp("qmp-test-XXXXXX", &err);
|
||||||
}
|
g_assert_no_error(err);
|
||||||
|
|
||||||
fifo_name = g_strdup_printf("%s/fifo", tmpdir);
|
fifo_name = g_strdup_printf("%s/fifo", tmpdir);
|
||||||
if (mkfifo(fifo_name, 0666)) {
|
if (mkfifo(fifo_name, 0666)) {
|
||||||
g_error("mkfifo: %s", strerror(errno));
|
g_error("mkfifo: %s", strerror(errno));
|
||||||
|
@ -181,6 +182,7 @@ static void cleanup_blocking_cmd(void)
|
||||||
{
|
{
|
||||||
unlink(fifo_name);
|
unlink(fifo_name);
|
||||||
rmdir(tmpdir);
|
rmdir(tmpdir);
|
||||||
|
g_free(tmpdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_cmd_that_blocks(QTestState *s, const char *id)
|
static void send_cmd_that_blocks(QTestState *s, const char *id)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue