[vlc-devel] [PATCH v3 9/14] tests: make use of vlc_MakeTmpFile()
Lyndon Brown
jnqnfe at gmail.com
Wed Oct 14 04:55:09 CEST 2020
From: Lyndon Brown <jnqnfe at gmail.com>
Date: Tue, 6 Oct 2020 01:44:10 +0100
Subject: tests: make use of vlc_MakeTmpFile()
diff --git a/test/modules/keystore/test.c b/test/modules/keystore/test.c
index 1ca13cac54..67644a5a3e 100644
--- a/test/modules/keystore/test.c
+++ b/test/modules/keystore/test.c
@@ -30,7 +30,6 @@
#include <vlc_modules.h>
#include <vlc_interrupt.h>
#include <vlc_fs.h>
-#include <vlc_configuration.h>
#include <vlc_keystore.h>
#undef NDEBUG
@@ -327,13 +326,8 @@ main(int i_argc, char *ppsz_argv[])
if (strcmp(psz_module, "file") == 0)
{
- char *psz_tmp_dir = config_GetTempPath();
- assert(psz_tmp_dir != NULL);
-
- assert(asprintf(&psz_tmp_path, "%s" DIR_SEP "libvlc_XXXXXX", psz_tmp_dir) >= 0);
- free(psz_tmp_dir);
-
- assert((i_tmp_fd = vlc_mkstemp(psz_tmp_path)) != -1);
+ i_tmp_fd = vlc_MakeTmpFile(&psz_tmp_path, "libvlc_");
+ assert(i_tmp_fd != -1);
printf("plaintext tmp file: '%s'\n", psz_tmp_path);
assert(asprintf(&ppsz_vlc_argv[1],
"--keystore-file=%s", psz_tmp_path) != -1);
diff --git a/test/src/input/stream.c b/test/src/input/stream.c
index 2aac35530c..83633e6744 100644
--- a/test/src/input/stream.c
+++ b/test/src/input/stream.c
@@ -26,7 +26,6 @@
#include <vlc_stream.h>
#include <vlc_rand.h>
#include <vlc_fs.h>
-#include <vlc_configuration.h>
#include <inttypes.h>
#include <limits.h>
@@ -370,20 +369,11 @@ main( void )
#ifndef TEST_NET
char *psz_url;
- int i_tmp_fd;
test_log( "Generating random file...\n" );
-
- char *psz_tmp_dir = config_GetTempPath();
- assert(psz_tmp_dir != NULL);
-
char *psz_tmp_path;
- assert(asprintf(&psz_tmp_path, "%s" DIR_SEP "libvlc_XXXXXX", psz_tmp_dir) >= 0);
- free(psz_tmp_dir);
-
- i_tmp_fd = vlc_mkstemp( psz_tmp_path );
+ int i_tmp_fd = vlc_MakeTmpFile(&psz_tmp_path, "libvlc_");
assert(i_tmp_fd != -1);
-
fill_rand( i_tmp_fd, RAND_FILE_SIZE );
test_log( "Testing random file with libc, and stream...\n" );
diff --git a/test/src/misc/keystore.c b/test/src/misc/keystore.c
index f30b913616..ece9ad7eee 100644
--- a/test/src/misc/keystore.c
+++ b/test/src/misc/keystore.c
@@ -33,7 +33,6 @@
#include <vlc_dialog.h>
#include <vlc_url.h>
#include <vlc_fs.h>
-#include <vlc_configuration.h>
#include <assert.h>
@@ -340,16 +339,8 @@ main(void)
test_init();
printf("creating tmp plaintext keystore file\n");
-
- char *psz_tmp_dir = config_GetTempPath();
- assert(psz_tmp_dir != NULL);
-
char *psz_tmp_path;
- assert(asprintf(&psz_tmp_path, "%s" DIR_SEP "libvlc_XXXXXX", psz_tmp_dir) >= 0);
- free(psz_tmp_dir);
-
- int i_tmp_fd = -1;
- i_tmp_fd = vlc_mkstemp(psz_tmp_path);
+ int i_tmp_fd = vlc_MakeTmpFile(&psz_tmp_path, "libvlc_");
assert(i_tmp_fd != -1);
int i_vlc_argc = 4;
More information about the vlc-devel
mailing list