[FFmpeg-cvslog] random_seed: add selftest

Michael Niedermayer git at videolan.org
Fri Feb 24 00:01:31 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Feb 22 22:25:01 2012 +0100| [946de27d25645a2daa43ed3aa264fcead3c39379] | committer: Michael Niedermayer

random_seed: add selftest

Reviewed-by: Nicolas George <nicolas.george at normalesup.org>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=946de27d25645a2daa43ed3aa264fcead3c39379
---

 libavutil/Makefile      |    2 +-
 libavutil/random_seed.c |   26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 6d78bd5..23049f6 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -83,7 +83,7 @@ OBJS-$(ARCH_X86) += x86/cpu.o
 
 
 TESTPROGS = adler32 aes avstring base64 cpu crc des eval file fifo lfg lls \
-            md5 opt pca parseutils rational sha tree
+            md5 opt pca parseutils random_seed rational sha tree
 TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo
 
 TOOLS = ffeval
diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c
index 235028b..6a8666c 100644
--- a/libavutil/random_seed.c
+++ b/libavutil/random_seed.c
@@ -80,3 +80,29 @@ uint32_t av_get_random_seed(void)
         return seed;
     return get_generic_seed();
 }
+
+#ifdef TEST
+#undef printf
+#define N 256
+#include <stdio.h>
+
+int main(void)
+{
+    int i, j, retry;
+    uint32_t seeds[N];
+
+    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;
+        }
+        printf("seeds OK\n");
+        return 0;
+        retry:;
+    }
+    printf("FAIL at %d with %X\n", j, seeds[j]);
+    return 1;
+}
+#endif



More information about the ffmpeg-cvslog mailing list