Skip to content
Snippets Groups Projects
Commit aa5a6aad authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

test: use reproducible input

vlc_stream_NewURL() can spawn stream filters which may alter the content
or even the nature of the stream, which is not suitable here.

vlc_access_NewMRL() would avoid loading stream filters at all. But it
would also skip testing the cache filter, thus missing much of the point
of the test case.

So use a reproducible pseudorandom input using a constant seed, which
is known not to trigger any stream filter.

Fixes #26569.
parent ce7cc9dd
No related branches found
No related tags found
1 merge request!1334test: use reproducible input
Pipeline #186572 passed with stage
in 51 minutes and 38 seconds
......@@ -24,11 +24,12 @@
#include <vlc_strings.h>
#include <vlc_hash.h>
#include <vlc_stream.h>
#include <vlc_rand.h>
#include <vlc_fs.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
......@@ -345,18 +346,25 @@ test( struct reader **pp_readers, unsigned int i_readers, const char *psz_md5 )
static void
fill_rand( int i_fd, size_t i_size )
{
uint8_t p_buf[4096];
size_t i_written = 0;
while( i_written < i_size )
unsigned int seed = 12345;
while( i_size > 0 )
{
size_t i_tocopy = __MIN( i_size - i_written, 4096 );
uint8_t p_buf[4096];
size_t i_tocopy = __MIN( i_size, sizeof (p_buf) );
for (size_t i = 0; i < i_tocopy; i++)
p_buf[i] = rand_r(&seed);
vlc_rand_bytes(p_buf, i_tocopy);
ssize_t i_ret = write( i_fd, p_buf, i_tocopy );
assert( i_ret > 0 );
i_written += i_ret;
if( i_ret < (ssize_t)i_tocopy ) {
if( i_ret >= 0 )
errno = ENOSPC;
perror("write error");
abort();
}
i_size -= i_ret;
}
assert( i_written == i_size );
}
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment