[FFmpeg-devel] [PATCH] avutil/tests: Improved code coverage for random_seed

Michael Niedermayer michael at niedermayer.cc
Wed Dec 28 20:57:10 EET 2016


On Wed, Dec 28, 2016 at 07:12:25PM +0100, Hendrik Leppkes wrote:
> On Wed, Dec 28, 2016 at 7:08 PM, Hendrik Leppkes <h.leppkes at gmail.com> wrote:
> > On Fri, Dec 23, 2016 at 1:12 AM, Thomas Turner <thomastdt at googlemail.com> wrote:
> >> Signed-off-by: Thomas Turner <thomastdt at googlemail.com>
> >> ---
> >>  libavutil/tests/random_seed.c | 34 +++++++++++++++++++++-------------
> >>  tests/ref/fate/random_seed    |  1 +
> >>  2 files changed, 22 insertions(+), 13 deletions(-)
> >>
> >> diff --git a/libavutil/tests/random_seed.c b/libavutil/tests/random_seed.c
> >> index ebe9b3e..fcd68bc 100644
> >> --- a/libavutil/tests/random_seed.c
> >> +++ b/libavutil/tests/random_seed.c
> >> @@ -23,24 +23,32 @@
> >>
> >>  #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;
> >> + }
> >> \ 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
> >
> > The new test sporadically fails on msvc x86_64 for some reason. What
> > does it actually mean when it fails, ie. what does this thing test?
> >
> 
> Specifically, it always fails with rsf 1, which seems to be
> get_generic_seed  - but windows has a special crypto seed provider,
> get_generic_seed is never used. Making fate fail for some inaccuracy
> in the clock in code thats never used is a bit annoying.

Thats like saying that as long as asm works it doesnt matter if the C
code doesnt work.

get_generic_seed() should work on any platform, ideally.
why does it fail on windows ?
can you take a look, its probably not very hard to improve it, the
function is also quite short.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161228/b5e86dab/attachment.sig>


More information about the ffmpeg-devel mailing list