[vlc-devel] [PATCH v2 6/13] tests: make use of config_GetTempPath()
Steve Lhomme
robux4 at ycbcr.xyz
Tue Oct 6 09:07:18 CEST 2020
On 2020-10-06 7:59, Lyndon Brown wrote:
> diff --git a/test/src/input/stream.c b/test/src/input/stream.c
> index 3b7ef19fc5..f9ffe933c6 100644
> --- a/test/src/input/stream.c
> +++ b/test/src/input/stream.c
> @@ -26,6 +26,7 @@
> #include <vlc_stream.h>
> #include <vlc_rand.h>
> #include <vlc_fs.h>
> +#include <vlc_configuration.h>
>
> #include <inttypes.h>
> #include <limits.h>
> @@ -368,13 +369,23 @@ main( void )
> test_init();
>
> #ifndef TEST_NET
> - char psz_tmp_path[] = "/tmp/libvlc_XXXXXX";
> char *psz_url;
> - int i_tmp_fd;
>
> test_log( "Generating random file...\n" );
> - i_tmp_fd = vlc_mkstemp( psz_tmp_path );
> +
> + 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);
nit picking: For better readability of the patch it's cleaner to keep
lines from the original when possible. In this case the 'i_tmp_fd'
declaration and setting the value also don't have to change.
Then the patch will clearly show that the modified line is the one
setting psz_tmp_path.
> + assert(i_tmp_fd != -1);
> +
> fill_rand( i_tmp_fd, RAND_FILE_SIZE );
> +
> test_log( "Testing random file with libc, and stream...\n" );
> assert( i_tmp_fd != -1 );
> assert( asprintf( &psz_url, "file://%s", psz_tmp_path ) != -1 );
> @@ -382,6 +393,8 @@ main( void )
> assert( ( pp_readers[0] = libc_open( psz_tmp_path ) ) );
> assert( ( pp_readers[1] = stream_open( psz_url ) ) );
>
> + free(psz_tmp_path);
> +
> test( pp_readers, 2, NULL );
> for( unsigned int i = 0; i < 2; ++i )
> pp_readers[i]->pf_close( pp_readers[i] );
> diff --git a/test/src/misc/keystore.c b/test/src/misc/keystore.c
> index d510b5d1cf..caf882f1f3 100644
> --- a/test/src/misc/keystore.c
> +++ b/test/src/misc/keystore.c
> @@ -33,6 +33,7 @@
> #include <vlc_dialog.h>
> #include <vlc_url.h>
> #include <vlc_fs.h>
> +#include <vlc_configuration.h>
>
> #include <assert.h>
>
> @@ -339,9 +340,16 @@ main(void)
> test_init();
>
> printf("creating tmp plaintext keystore file\n");
> - char psz_tmp_path[] = "/tmp/libvlc_XXXXXX";
> - int i_tmp_fd = -1;
> - i_tmp_fd = vlc_mkstemp(psz_tmp_path);
> +
> + 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);
Ditto.
> assert(i_tmp_fd != -1);
>
> int i_vlc_argc = 4;
> @@ -367,6 +375,7 @@ main(void)
>
> libvlc_release(p_libvlc);
> vlc_close(i_tmp_fd);
> + free(psz_tmp_path);
>
> return 0;
> }
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list