On Sun, Sep 25, 2022 at 4:09 PM Bin Meng wrote:
> From: Bin Meng
>
> 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
>
Reviewed-by: Marc-André Lureau
> ---
>
> Changes in v3:
> - Split to a separate patch
>
> tests/qtest/virtio-blk-test.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/qtest/virtio-blk-test.c b/tests/qtest/virtio-blk-test.c
> index dc5eed31c8..19c01f808b 100644
> --- a/tests/qtest/virtio-blk-test.c
> +++ b/tests/qtest/virtio-blk-test.c
> @@ -49,10 +49,10 @@ static void drive_destroy(void *path)
> static char *drive_create(void)
> {
> int fd, ret;
> -char *t_path = g_strdup("/tmp/qtest.XX");
> +char *t_path;
>
> /* Create a temporary raw image */
> -fd = mkstemp(t_path);
> +fd = g_file_open_tmp("qtest.XX", _path, NULL);
> g_assert_cmpint(fd, >=, 0);
> ret = ftruncate(fd, TEST_IMAGE_SIZE);
> g_assert_cmpint(ret, ==, 0);
> --
> 2.34.1
>
>
>
--
Marc-André Lureau