[FFmpeg-devel] avutil: Improved code coverage for libavutil/random_seed.c

Submitted by Thomas Turner on Dec. 21, 2016, 12:30 a.m.

Details

Message ID 1482280256-19424-1-git-send-email-thomastdt@googlemail.com
State Superseded
Headers show

Commit Message

Thomas Turner Dec. 21, 2016, 12:30 a.m.
Signed-off-by: Thomas Turner <thomastdt@googlemail.com>
---
 libavutil/tests/random_seed.c | 36 +++++++++++++++++++++---------------
 tests/ref/fate/random_seed    |  1 +
 2 files changed, 22 insertions(+), 15 deletions(-)

Comments

Michael Niedermayer Dec. 21, 2016, 12:53 a.m.
On Tue, Dec 20, 2016 at 04:30:56PM -0800, Thomas Turner wrote:
> Signed-off-by: Thomas Turner <thomastdt@googlemail.com>
> ---
>  libavutil/tests/random_seed.c | 36 +++++++++++++++++++++---------------
>  tests/ref/fate/random_seed    |  1 +
>  2 files changed, 22 insertions(+), 15 deletions(-)
> 
> diff --git a/libavutil/tests/random_seed.c b/libavutil/tests/random_seed.c
> index ebe9b3e..ffcb74d 100644
> --- a/libavutil/tests/random_seed.c
> +++ b/libavutil/tests/random_seed.c

> @@ -1,6 +1,4 @@
>  /*
> - * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@gmail.com>
> - *
>   * This file is part of FFmpeg.
>   *
>   * FFmpeg is free software; you can redistribute it and/or

This looks like a mistake or unrelated change at least.
you cannot remove copyright statements (unless they are wrong or
the removd agrees but in these cases its best to explain in the commit
message why its removed)
You can of course add your own copyright statement to a file if you
are one of the main authors of the code in the file and want.
Some people never do some people add themselfs to every file they are
the main author of
...

[...]

Patch hide | download patch | download mbox

diff --git a/libavutil/tests/random_seed.c b/libavutil/tests/random_seed.c
index ebe9b3e..ffcb74d 100644
--- a/libavutil/tests/random_seed.c
+++ b/libavutil/tests/random_seed.c
@@ -1,6 +1,4 @@ 
 /*
- * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@gmail.com>
- *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
@@ -18,29 +16,37 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define TEST 1
+
 #include "libavutil/random_seed.c"
 
 #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;
 }
diff --git a/tests/ref/fate/random_seed b/tests/ref/fate/random_seed
index 2b5b3af..ef0eef2 100644
--- a/tests/ref/fate/random_seed
+++ b/tests/ref/fate/random_seed
@@ -1 +1,2 @@ 
 seeds OK
+seeds OK