On Thu, Nov 17, 2016 at 10:01:55AM -0500, robert.foss@xxxxxxxxxxxxx wrote: > From: Robert Foss <robert.foss@xxxxxxxxxxxxx> > > Add subtest test_sync_merge that tests merging fences and the validity of the > resulting merged fence. > > Signed-off-by: Robert Foss <robert.foss@xxxxxxxxxxxxx> > Reviewed-by: Eric Engestrom <eric@xxxxxxxxxxxx> > --- > tests/sw_sync.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 67 insertions(+) > > diff --git a/tests/sw_sync.c b/tests/sw_sync.c > index 9667b93..528be4d 100644 > --- a/tests/sw_sync.c > +++ b/tests/sw_sync.c > @@ -115,6 +115,70 @@ static void test_sync_busy(void) > close(timeline); > } > > +static void test_sync_merge(void) > +{ > + int in_fence[3]; > + int fence_merge; > + int timeline; > + int active, signaled; > + > + timeline = sw_sync_timeline_create(); > + in_fence[0] = sw_sync_fence_create(timeline, 1); > + in_fence[1] = sw_sync_fence_create(timeline, 2); > + in_fence[2] = sw_sync_fence_create(timeline, 3); > + > + fence_merge = sync_merge(in_fence[0], in_fence[1]); > + fence_merge = sync_merge(in_fence[2], fence_merge); Can I suggest the pattern: fence_merge = -1; for (i = 0; i < ARRAY_SIZE(in_fence); i++) { in_fence[i] = sw_sync_fence_create(timeline, i + 1); fence_merge = sync_merge(fence_merge, in_fence[i]); active = sync_fence_count_status(in_fence[i], SW_SYNC_FENCE_STATUS_ACTIVE); igt_assert_f(active == 1, "in_fence[%d] has too many active fences\n", i); igt_assert(!sync_fence_count_status(in_fence[i], SW_SYNC_FENCE_STATUS_SIGNALED)); igt_assert(!sync_fence_count_status(fence_merge, SW_SYNC_FENCE_STATUS_SIGNALED)); } > + /* confirm that fence_merge is not signaled until the max of fence 0,1,2 */ for (i = 0; i < ARRAY_SIZE(in_fence); i++) { sw_sync_timeline_inc(timeline, 1); signaled = sync_fence_count_status(in_fence[i], SW_SYNC_FENCE_STATUS_SIGNALED); igt_assert_f(signaled == 1, "in_fence[%d] did not signal\n", i); signaled = sync_fence_count_status(fence_merge, SW_SYNC_FENCE_STATUS_SIGNALED); active = sync_fence_count_status(fence_merge, SW_SYNC_FENCE_STATUS_ACTIVE); if (i + 1 == ARRAY_SIZE(in_fence)) { /* all signaled -> merge complete */ igt_assert_f(active == 0 && signaled == 1, "fence_merge did not signal\n"); } else { igt_assert_f(active == 1 && signaled == 0, "fence_merge signaled too early\n"); } close(in_fence[1]); } > + close(fence_merge); > + close(timeline); > +} > + > igt_main > { > igt_subtest("alloc_timeline") > @@ -131,5 +195,8 @@ igt_main > > igt_subtest("sync_busy") > test_sync_busy(); > + > + igt_subtest("sync_merge") > + test_sync_merge(); > } > > -- > 2.10.2 > -- Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx