From 78865847f9fae7e590960f9836f2ec8b611a190e Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Mon, 19 Aug 2013 07:23:49 +0200 Subject: [PATCH] lib/drmtest: skip fixtures after an igt_skip This way we can just enclose all igt_skip/igt_require calls into fixtures even when we have subtests, and still output correct SKIP message for all of them. Wohoo, magic! The only thing which doesn't work yet is enumerating failed subtests, but I think that should work out on top of this. Signed-off-by: Daniel Vetter --- lib/drmtest.c | 34 ++++++++++++++++++++++++++++++---- lib/drmtest.h | 7 +++++-- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index ac254ab..f08392a 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -620,6 +620,8 @@ off_t prime_get_size(int dma_buf_fd) } /* signal interrupt helpers */ +static bool igt_only_list_subtests(void); + static pid_t signal_helper = -1; long long int sig_stat; static void __attribute__((noreturn)) signal_helper_process(pid_t pid) @@ -687,9 +689,28 @@ void igt_stop_signal_helper(void) static bool list_subtests = false; static char *run_single_subtest = NULL; static const char *in_subtest = NULL; +static bool in_fixture = false; static bool test_with_subtests = false; static bool skip_subtests_henceforth = false; +bool __igt_fixture(void) +{ + if (igt_only_list_subtests()) + return false; + + if (skip_subtests_henceforth) + return false; + + in_fixture = true; + return true; +} + +void __igt_fixture_end(void) +{ + in_fixture = false; + longjmp(igt_subtest_jmpbuf, 1); +} + void igt_subtest_init(int argc, char **argv) { int c, option_index = 0; @@ -730,6 +751,7 @@ out: bool __igt_run_subtest(const char *subtest_name) { assert(!in_subtest); + assert(!in_fixture); if (list_subtests) { printf("%s\n", subtest_name); @@ -756,7 +778,7 @@ const char *igt_subtest_name(void) return in_subtest; } -bool igt_only_list_subtests(void) +static bool igt_only_list_subtests(void) { return list_subtests; } @@ -777,12 +799,16 @@ static void exit_subtest(const char *result) void igt_skip(void) { skipped_one = true; - if (in_subtest) + + if (in_subtest) { exit_subtest("SKIP"); - else if (test_with_subtests) + } else if (test_with_subtests) { skip_subtests_henceforth = true; - else + if (in_fixture) + __igt_fixture_end(); + } else { exit(77); + } } void __igt_skip_check(const char *file, const int line, diff --git a/lib/drmtest.h b/lib/drmtest.h index 7a36a48..c4e9068 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -123,7 +123,6 @@ bool __igt_run_subtest(const char *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 * @@ -176,6 +175,8 @@ void igt_exit(void) __attribute__((noreturn)); */ #define igt_require(expr) do { if (!(expr)) __igt_skip_check(__FILE__, __LINE__, __func__, #expr ); } while (0) +bool __igt_fixture(void); +void __igt_fixture_end(void) __attribute__((noreturn)); /** * igt_fixture - annote global test fixture code * @@ -184,7 +185,9 @@ void igt_exit(void) __attribute__((noreturn)); * enumeration (e.g. when enumerating on systemes without an intel gpu) such * blocks should be annotated with igt_fixture. */ -#define igt_fixture if (!igt_only_list_subtests()) +#define igt_fixture for (; __igt_fixture() && \ + (setjmp(igt_subtest_jmpbuf) == 0); \ + __igt_fixture_end()) /* check functions which auto-skip tests by calling igt_skip() */ void gem_require_caching(int fd); -- 2.7.4