[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 09/54] tests/qtest: fdc-test: Avoid using hardcoded /tmp
From: |
Bin Meng |
Subject: |
[PATCH v4 09/54] tests/qtest: fdc-test: Avoid using hardcoded /tmp |
Date: |
Tue, 27 Sep 2022 19:05:47 +0800 |
From: Bin Meng <bin.meng@windriver.com>
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>
---
(no changes since v3)
Changes in v3:
- Split to a separate patch
tests/qtest/fdc-test.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tests/qtest/fdc-test.c b/tests/qtest/fdc-test.c
index 52ade90a7d..1f9b99ad6d 100644
--- a/tests/qtest/fdc-test.c
+++ b/tests/qtest/fdc-test.c
@@ -68,7 +68,7 @@ enum {
DSKCHG = 0x80,
};
-static char test_image[] = "/tmp/qtest.XXXXXX";
+static char *test_image;
#define assert_bit_set(data, mask) g_assert_cmphex((data) & (mask), ==, (mask))
#define assert_bit_clear(data, mask) g_assert_cmphex((data) & (mask), ==, 0)
@@ -608,7 +608,7 @@ int main(int argc, char **argv)
int ret;
/* Create a temporary raw image */
- fd = mkstemp(test_image);
+ fd = g_file_open_tmp("qtest.XXXXXX", &test_image, NULL);
g_assert(fd >= 0);
ret = ftruncate(fd, TEST_IMAGE_SIZE);
g_assert(ret == 0);
@@ -640,6 +640,7 @@ int main(int argc, char **argv)
/* Cleanup */
qtest_end();
unlink(test_image);
+ g_free(test_image);
return ret;
}
--
2.34.1
- [PATCH v4 00/54] tests/qtest: Enable running qtest on Windows, Bin Meng, 2022/09/27
- [PATCH v4 01/54] tests/qtest: i440fx-test: Rewrite create_blob_file() to be portable, Bin Meng, 2022/09/27
- [PATCH v4 03/54] tcg: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 02/54] semihosting/arm-compat-semi: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 07/54] tests/qtest: boot-serial-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 09/54] tests/qtest: fdc-test: Avoid using hardcoded /tmp,
Bin Meng <=
- [PATCH v4 08/54] tests/qtest: cxl-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 10/54] tests/qtest: generic_fuzz: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 06/54] tests/qtest: aspeed_smc-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 04/54] util/qemu-sockets: Use g_get_tmp_dir() to get the directory for temporary files, Bin Meng, 2022/09/27
- [PATCH v4 05/54] tests/qtest: ahci-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 12/54] tests/qtest: hd-geo-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27
- [PATCH v4 14/54] tests/qtest: migration-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/27