Commit 946de27d authored by Michael Niedermayer's avatar Michael Niedermayer

random_seed: add selftest

Reviewed-by: 's avatarNicolas George <nicolas.george@normalesup.org>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 1b932443
......@@ -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
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment