From 5fa695529c82d5f1b5c77c83e2b46194e503987b Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Tue, 16 Oct 2012 02:41:02 +0300 Subject: [PATCH] flip_test: swap the order of check state/run test step 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 --- tests/flip_test.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/flip_test.c b/tests/flip_test.c index b30ac665..51c8b410 100644 --- a/tests/flip_test.c +++ b/tests/flip_test.c @@ -469,7 +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; struct timeval start, end; struct timeval tv_dur; @@ -480,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); @@ -493,11 +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; - do_or_die(drmHandleEvent(drm_fd, &evctx)); - return tv_dur.tv_sec * 1000 * 1000 + tv_dur.tv_usec; } @@ -551,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);