avutil/tests: Improved code coverage for random_seed
authorThomas Turner <thomastdt@googlemail.com>
Fri, 23 Dec 2016 00:12:36 +0000 (16:12 -0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 23 Dec 2016 01:57:20 +0000 (02:57 +0100)
Signed-off-by: Thomas Turner <thomastdt@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavutil/tests/random_seed.c
tests/ref/fate/random_seed

index ebe9b3e..f45e198 100644 (file)
 
 #undef printf
 #define N 256
+#define F 2
 #include <stdio.h>
 
+typedef uint32_t (*random_seed_ptr_t)(void);
+
 int main(void)
 {
-    int i, j, retry;
+    int i, j, rsf, retry;
     uint32_t seeds[N];
+    random_seed_ptr_t random_seed[F] = {av_get_random_seed, get_generic_seed};
 
-    for (retry=0; retry<3; retry++){
-        for (i=0; i<N; i++){
-            seeds[i] = av_get_random_seed();
-            for (j=0; j<i; j++)
-                if (seeds[j] == seeds[i])
-                    goto retry;
+    for (rsf=0; rsf<F; ++rsf){
+        for (retry=0; retry<3; retry++){
+            for (i=0; i<N; i++){
+                seeds[i] = random_seed[rsf]();
+                for (j=0; j<i; j++)
+                    if (seeds[j] == seeds[i])
+                        goto retry;
+            }
+            printf("seeds OK\n");
+            goto next;
+            retry:;
         }
-        printf("seeds OK\n");
-        return 0;
-        retry:;
+        printf("rsf %d: FAIL at %d with %X\n", rsf, j, seeds[j]);
+        return 1;
+        next:;
     }
-    printf("FAIL at %d with %X\n", j, seeds[j]);
-    return 1;
-}
+    return 0;
+ }