mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-16 14:41:55 -06:00
tests/qtest: ide-test: Avoid using hardcoded /tmp
This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_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: <20220925113032.1949844-14-bmeng.cn@gmail.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
3ff220a0ac
commit
354aeeabec
1 changed files with 6 additions and 4 deletions
|
@ -121,8 +121,8 @@ enum {
|
||||||
static QPCIBus *pcibus = NULL;
|
static QPCIBus *pcibus = NULL;
|
||||||
static QGuestAllocator guest_malloc;
|
static QGuestAllocator guest_malloc;
|
||||||
|
|
||||||
static char tmp_path[] = "/tmp/qtest.XXXXXX";
|
static char *tmp_path;
|
||||||
static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX";
|
static char *debug_path;
|
||||||
|
|
||||||
static QTestState *ide_test_start(const char *cmdline_fmt, ...)
|
static QTestState *ide_test_start(const char *cmdline_fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -1015,12 +1015,12 @@ int main(int argc, char **argv)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Create temporary blkdebug instructions */
|
/* Create temporary blkdebug instructions */
|
||||||
fd = mkstemp(debug_path);
|
fd = g_file_open_tmp("qtest-blkdebug.XXXXXX", &debug_path, NULL);
|
||||||
g_assert(fd >= 0);
|
g_assert(fd >= 0);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
/* Create a temporary raw image */
|
/* Create a temporary raw image */
|
||||||
fd = mkstemp(tmp_path);
|
fd = g_file_open_tmp("qtest.XXXXXX", &tmp_path, NULL);
|
||||||
g_assert(fd >= 0);
|
g_assert(fd >= 0);
|
||||||
ret = ftruncate(fd, TEST_IMAGE_SIZE);
|
ret = ftruncate(fd, TEST_IMAGE_SIZE);
|
||||||
g_assert(ret == 0);
|
g_assert(ret == 0);
|
||||||
|
@ -1049,7 +1049,9 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
unlink(tmp_path);
|
unlink(tmp_path);
|
||||||
|
g_free(tmp_path);
|
||||||
unlink(debug_path);
|
unlink(debug_path);
|
||||||
|
g_free(debug_path);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue