[vlc-commits] [Git][videolan/vlc][master] test: use reproducible input

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Thu Feb 3 11:17:48 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
aa5a6aad by Rémi Denis-Courmont at 2022-02-03T10:56:29+00:00
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.

- - - - -


1 changed file:

- test/src/input/stream.c


Changes:

=====================================
test/src/input/stream.c
=====================================
@@ -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
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/aa5a6aad699ab83d3eb00903a7ff46d3ca3b7822

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/aa5a6aad699ab83d3eb00903a7ff46d3ca3b7822
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list