At the moment we first check the state then run the test step in our test loop. Swapping the order makes the starting state of each iteration better defined, allowing an easier extension of these steps in the future. Since now it's guaranteed that we exit the event loop with no pending flips, we can also get rid of the final flushing of events. We don't want the first initializing flip to affect the test loop other than setting an initial FB, so before starting the test loop wait for it to complete by calling wait_for_events() and leave the flip event counter at zero. Signed-off-by: Imre Deak <imre.deak at intel.com> --- tests/flip_test.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/flip_test.c b/tests/flip_test.c index 790463c..6cfc0ec 100644 --- a/tests/flip_test.c +++ b/tests/flip_test.c @@ -469,8 +469,6 @@ static void wait_for_events(struct test_output *o) /* Returned the ellapsed time in us */ static unsigned event_loop(struct test_output *o, unsigned duration_sec) { - drmEventContext evctx; - int ret; struct timeval start, end; struct timeval tv_dur; @@ -481,9 +479,9 @@ static unsigned event_loop(struct test_output *o, unsigned duration_sec) while (1) { struct timeval now; + run_test_step(o); wait_for_events(o); check_all_state(o); - run_test_step(o); update_all_state(o); gettimeofday(&now, NULL); @@ -494,12 +492,6 @@ static unsigned event_loop(struct test_output *o, unsigned duration_sec) gettimeofday(&end, NULL); timersub(&end, &start, &tv_dur); - /* and drain the event queue */ - memset(&evctx, 0, sizeof evctx); - evctx.page_flip_handler = NULL; - ret = drmHandleEvent(drm_fd, &evctx); - assert(ret == 0); - return tv_dur.tv_sec * 1000 * 1000 + tv_dur.tv_usec; } @@ -553,8 +545,9 @@ static void flip_mode(struct test_output *o, int crtc, int duration) fprintf(stderr, "failed to page flip: %s\n", strerror(errno)); exit(4); } + wait_for_events(o); + o->current_fb_id = 1; - o->count = 1; /* for the uncounted tail */ ellapsed = event_loop(o, duration); -- 1.7.9.5