aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-22 22:25:01 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-02-23 23:44:38 +0100
commit946de27d25645a2daa43ed3aa264fcead3c39379 (patch)
tree4879b27d7e1297598bf3c18a9f2e35abea29b7c3
parent1b93244381af895c481d9de967a278d17262ecd0 (diff)
downloadffmpeg-946de27d25645a2daa43ed3aa264fcead3c39379.tar.gz
random_seed: add selftest
Reviewed-by: Nicolas George <nicolas.george@normalesup.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavutil/Makefile2
-rw-r--r--libavutil/random_seed.c26
2 files changed, 27 insertions, 1 deletions
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 6d78bd5528..23049f600f 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 235028b5c5..6a8666cca6 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