[Intel-gfx] [PATCH i-g-t] tests/kms_flip: Adjust tolerance when counting frames
Chris Wilson
chris at chris-wilson.co.uk
Tue May 17 07:41:31 UTC 2016
On Tue, May 17, 2016 at 09:30:59AM +0200, Daniel Vetter wrote:
> On Tue, May 10, 2016 at 05:15:37PM +0300, Gabriel Feceoru wrote:
> >
> >
> > On 10.05.2016 16:52, Jani Nikula wrote:
> > >On Tue, 10 May 2016, Gabriel Feceoru <gabriel.feceoru at intel.com> wrote:
> > >>Comparing 2 numbers with 1% accuracy depends on which one is the
> > >>reference. If count == 100 and expected == 99 this condition fails,
> > >>although it should pass.
> > >
> > >Well, the expectation should be the reference. If you expect 50 at 50%
> > >tolerance, 25..75 is okay. 100 is clearly out of tolerance, but your
> > >method would accept it too.
> > >
> > >Would it help to round the lower limit down and upper limit up? I think
> > >that would be more acceptable.
> >
> > Yes, you are right. I'll adjust it to 98/100 and 102/100.
>
> Maybe also extract the computation for lower/upper limit into local
> variables, to make the code less dense and easier to understand.
Just because I have this lying around (untested):
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index eda2fcc..22b9c9d 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1182,14 +1182,14 @@ static void check_final_state(struct test_output *o, struct event_state *es,
/* Verify we drop no frames, but only if it's not a TV encoder, since
* those use some funny fake timings behind userspace's back. */
if (o->flags & TEST_CHECK_TS && !analog_tv_connector(o)) {
- int expected;
- int count = es->count;
+ int count = es->count * o->seq_step;
+ unsigned int min = frame_time(o) * (count - 1);
+ unsigned int max = frame_time(o) * (count + 1);
- count *= o->seq_step;
- expected = elapsed / frame_time(o);
- igt_assert_f(count >= expected * 99/100 && count <= expected * 101/100,
+ igt_assert_f(elapsed > min && elapsed < max,
"dropped frames, expected %d, counted %d, encoder type %d\n",
- expected, count, o->kencoder[0]->encoder_type);
+ elapsed / frame_time(o), count,
+ o->kencoder[0]->encoder_type);
}
}
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list