diff options
author | Bin Meng <bin.meng@windriver.com> | 2022-09-25 19:29:45 +0800 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2022-09-27 20:51:20 +0200 |
commit | 4bcea44b9af7981e2074c74298e89ea3f97a3174 (patch) | |
tree | 71089ce744296b2e0fcf5f00653813852c0c1a65 /tests | |
parent | 39df79e4ed89cd835784ede8563ee41aa1f8265d (diff) | |
download | qemu-4bcea44b9af7981e2074c74298e89ea3f97a3174.zip qemu-4bcea44b9af7981e2074c74298e89ea3f97a3174.tar.gz qemu-4bcea44b9af7981e2074c74298e89ea3f97a3174.tar.bz2 |
tests/qtest: boot-serial-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>
Message-Id: <20220925113032.1949844-8-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qtest/boot-serial-test.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c index 2f99d71..72310ba 100644 --- a/tests/qtest/boot-serial-test.c +++ b/tests/qtest/boot-serial-test.c @@ -224,14 +224,14 @@ static bool check_guest_output(QTestState *qts, const testdef_t *test, int fd) static void test_machine(const void *data) { const testdef_t *test = data; - char serialtmp[] = "/tmp/qtest-boot-serial-sXXXXXX"; - char codetmp[] = "/tmp/qtest-boot-serial-cXXXXXX"; + g_autofree char *serialtmp = NULL; + g_autofree char *codetmp = NULL; const char *codeparam = ""; const uint8_t *code = NULL; QTestState *qts; int ser_fd; - ser_fd = mkstemp(serialtmp); + ser_fd = g_file_open_tmp("qtest-boot-serial-sXXXXXX", &serialtmp, NULL); g_assert(ser_fd != -1); if (test->kernel) { @@ -246,7 +246,7 @@ static void test_machine(const void *data) ssize_t wlen; int code_fd; - code_fd = mkstemp(codetmp); + code_fd = g_file_open_tmp("qtest-boot-serial-cXXXXXX", &codetmp, NULL); g_assert(code_fd != -1); wlen = write(code_fd, code, test->codesize); g_assert(wlen == test->codesize); |