[vlc-devel] [PATCH v2 11/13] tests: make use of vlc_MakeTmpFile()
Lyndon Brown
jnqnfe at gmail.com
Tue Oct 6 08:01:18 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 1412d57b43..6426176cb9 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,14 +326,9 @@ main(int i_argc, char *ppsz_argv[])
if (strcmp(psz_module, "file") == 0)
{
- char *psz_tmp_dir = config_GetTempPath();
- assert(psz_tmp_dir != NULL);
-
const char *psz_tmp_filetemplate = "libvlc_XXXXXX";
- assert(asprintf(&psz_tmp_path, "%s"DIR_SEP"%s", psz_tmp_dir, psz_tmp_filetemplate) >= 0);
- free(psz_tmp_dir);
-
- assert((i_tmp_fd = vlc_mkstemp(psz_tmp_path)) != -1);
+ i_tmp_fd = vlc_MakeTmpFile(&psz_tmp_path, psz_tmp_filetemplate, NULL);
+ 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 f9ffe933c6..915abad7b2 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>
@@ -372,18 +371,10 @@ main( void )
char *psz_url;
test_log( "Generating random file...\n" );
-
- char *psz_tmp_dir = config_GetTempPath();
- assert(psz_tmp_dir != NULL);
-
char *psz_tmp_path;
const char *psz_tmp_filetemplate = "libvlc_XXXXXX";
- assert(asprintf(&psz_tmp_path, "%s"DIR_SEP"%s", psz_tmp_dir, psz_tmp_filetemplate) >= 0);
- free(psz_tmp_dir);
-
- int i_tmp_fd = vlc_mkstemp(psz_tmp_path);
+ int i_tmp_fd = vlc_MakeTmpFile(&psz_tmp_path, psz_tmp_filetemplate, NULL);
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 caf882f1f3..7bbe47ccef 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,9 @@ 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;
const char *psz_tmp_filetemplate = "libvlc_XXXXXX";
- assert(asprintf(&psz_tmp_path, "%s"DIR_SEP"%s", psz_tmp_dir, psz_tmp_filetemplate) >= 0);
- free(psz_tmp_dir);
-
- int i_tmp_fd = vlc_mkstemp(psz_tmp_path);
+ int i_tmp_fd = vlc_MakeTmpFile(&psz_tmp_path, psz_tmp_filetemplate, NULL);
assert(i_tmp_fd != -1);
int i_vlc_argc = 4;
More information about the vlc-devel
mailing list