[FFmpeg-devel] [PATCH] avutil: Improved code coverage for libavutil/random_seed.c
Thomas Turner
thomastdt at googlemail.com
Wed Dec 21 03:07:29 EET 2016
Signed-off-by: Thomas Turner <thomastdt at googlemail.com>
---
libavutil/tests/random_seed.c | 40 ++++++++++++++++++++++++----------------
tests/ref/fate/random_seed | 1 +
2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/libavutil/tests/random_seed.c b/libavutil/tests/random_seed.c
index ebe9b3e..f00b962 100644
--- a/libavutil/tests/random_seed.c
+++ b/libavutil/tests/random_seed.c
@@ -18,29 +18,37 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define TEST 1
-#include "libavutil/random_seed.c"
+ #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];
-
- 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;
+ random_seed_ptr_t random_seed[F] = {av_get_random_seed, get_generic_seed};
+
+ 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;
+ }
\ No newline at end of file
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
--
1.9.1
More information about the ffmpeg-devel
mailing list