From 15c19229f404bcd04f90517925614d5716258057 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Wed, 14 Aug 2013 18:03:09 +0200 Subject: [PATCH] lib/drmtest: add igt_subtest_name and use it in kms_flip Useful when the testname is constructed with igt_subtest_f. Signed-off-by: Daniel Vetter --- lib/drmtest.c | 5 +++++ lib/drmtest.h | 1 + tests/kms_flip.c | 22 +++++++--------------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index 3cfe3e6..6e72c44 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -739,6 +739,11 @@ bool __igt_run_subtest(const char *subtest_name) } } +const char *igt_subtest_name(void) +{ + return in_subtest; +} + bool igt_only_list_subtests(void) { return list_subtests; diff --git a/lib/drmtest.h b/lib/drmtest.h index b6d6dfb..79cac57 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -121,6 +121,7 @@ bool __igt_run_subtest(const char *subtest_name); #define igt_subtest(name) for (; __igt_run_subtest((name)) && \ (setjmp(igt_subtest_jmpbuf) == 0); \ igt_success()) +const char *igt_subtest_name(void); bool igt_only_list_subtests(void); /** * igt_skip - subtest aware test skipping diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 15cf267..1d4a884 100644 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -114,7 +114,6 @@ struct event_state { }; struct test_output { - const char *test_name; uint32_t id; int mode_valid; drmModeModeInfo mode; @@ -988,7 +987,7 @@ static void run_test_on_crtc(struct test_output *o, int crtc_idx, int duration) last_connector = o->connector; fprintf(stdout, "Beginning %s on crtc %d, connector %d\n", - o->test_name, o->crtc, o->id); + igt_subtest_name(), o->crtc, o->id); o->fb_width = o->mode.hdisplay; o->fb_height = o->mode.vdisplay; @@ -1054,7 +1053,7 @@ static void run_test_on_crtc(struct test_output *o, int crtc_idx, int duration) check_final_state(o, &o->vblank_state, ellapsed); fprintf(stdout, "\n%s on crtc %d, connector %d: PASSED\n\n", - o->test_name, o->crtc, o->id); + igt_subtest_name(), o->crtc, o->id); out: kmstest_remove_fb(drm_fd, &o->fb_info[2]); @@ -1067,7 +1066,7 @@ out: drmModeFreeConnector(o->connector); } -static int run_test(int duration, int flags, const char *test_name) +static int run_test(int duration, int flags) { struct test_output o; int c; @@ -1084,7 +1083,6 @@ static int run_test(int duration, int flags, const char *test_name) for (c = 0; c < resources->count_connectors; c++) { for (crtc_idx = 0; crtc_idx < resources->count_crtcs; crtc_idx++) { memset(&o, 0, sizeof(o)); - o.test_name = test_name; o.id = resources->connectors[c]; o.flags = flags; o.flip_state.name = "flip"; @@ -1185,26 +1183,20 @@ int main(int argc, char **argv) } for (i = 0; i < sizeof(tests) / sizeof (tests[0]); i++) { - igt_subtest(tests[i].name) { - run_test(tests[i].duration, tests[i].flags, tests[i].name); - } + igt_subtest(tests[i].name) + run_test(tests[i].duration, tests[i].flags); } igt_fork_signal_helper(); for (i = 0; i < sizeof(tests) / sizeof (tests[0]); i++) { - char name[160]; - snprintf(name, sizeof(name), "%s-interruptible", tests[i].name); - /* relative blocking vblank waits that get constantly interrupt * take forver. So don't do them. */ if ((tests[i].flags & TEST_VBLANK_BLOCK) && !(tests[i].flags & TEST_VBLANK_ABSOLUTE)) continue; - igt_subtest(name) { - printf("running testcase: %s\n", name); - run_test(tests[i].duration, tests[i].flags, name); - } + igt_subtest_f( "%s-interruptible", tests[i].name) + run_test(tests[i].duration, tests[i].flags); } igt_stop_signal_helper(); -- 2.7.4