On Sun, Sep 25, 2022 at 3:49 PM Bin Meng <bmeng...@gmail.com> wrote: > From: Bin Meng <bin.m...@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.m...@windriver.com> >
Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com> > --- > > 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 > > > -- Marc-André Lureau