aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBin Meng <bin.meng@windriver.com>2022-09-25 19:29:44 +0800
committerThomas Huth <thuth@redhat.com>2022-09-27 20:51:20 +0200
commit39df79e4ed89cd835784ede8563ee41aa1f8265d (patch)
tree8ee55d06f930c08736d12bed625d6d86bfcd5213 /tests
parentd9eefd35b678d6c1fa8c523de6441ef722f5321a (diff)
downloadqemu-39df79e4ed89cd835784ede8563ee41aa1f8265d.zip
qemu-39df79e4ed89cd835784ede8563ee41aa1f8265d.tar.gz
qemu-39df79e4ed89cd835784ede8563ee41aa1f8265d.tar.bz2
tests/qtest: aspeed_smc-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: Thomas Huth <thuth@redhat.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> Message-Id: <20220925113032.1949844-7-bmeng.cn@gmail.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qtest/aspeed_smc-test.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c
index 05ce941..c713a37 100644
--- a/tests/qtest/aspeed_smc-test.c
+++ b/tests/qtest/aspeed_smc-test.c
@@ -608,16 +608,15 @@ static void test_write_block_protect_bottom_bit(void)
flash_reset();
}
-static char tmp_path[] = "/tmp/qtest.m25p80.XXXXXX";
-
int main(int argc, char **argv)
{
+ g_autofree char *tmp_path = NULL;
int ret;
int fd;
g_test_init(&argc, &argv, NULL);
- fd = mkstemp(tmp_path);
+ fd = g_file_open_tmp("qtest.m25p80.XXXXXX", &tmp_path, NULL);
g_assert(fd >= 0);
ret = ftruncate(fd, FLASH_SIZE);
g_assert(ret == 0);