diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2017-08-14 11:32:04 +0200 |
---|---|---|
committer | Petri Latvala <petri.latvala@intel.com> | 2017-08-14 12:51:40 +0300 |
commit | 2459b80b8da75f78baa681d4a878492715dd71f9 (patch) | |
tree | c0192ea34865e10b8e4295d02db3083b9f64d814 /lib/igt_core.c | |
parent | 0c514b0cb876fb578afb2bb0297579bc896251d8 (diff) |
lib: Add igt_can_fail()
Useful to make sure folks use library helpers correctly.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'lib/igt_core.c')
-rw-r--r-- | lib/igt_core.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c index c0488e94..9eb99eda 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -1170,7 +1170,7 @@ void igt_fail(int exitcode) else exit_subtest("FAIL"); } else { - assert(!test_with_subtests || in_fixture); + assert(igt_can_fail()); if (in_fixture) { skip_subtests_henceforth = FAIL; @@ -1181,6 +1181,22 @@ void igt_fail(int exitcode) } } +/** + * igt_can_fail: + * + * Returns true if called from either an #igt_fixture, #igt_subtest or a + * testcase without subtests, i.e. #igt_simple_main. Returns false otherwise. In + * other words, it checks whether it's legal to call igt_fail(), igt_skip_on() + * and all the convenience macros build around those. + * + * This is useful to make sure that library code is called from the right + * places. + */ +bool igt_can_fail(void) +{ + return !test_with_subtests || in_fixture || in_subtest; +} + static bool run_under_gdb(void) { char buf[1024]; @@ -2015,7 +2031,7 @@ void igt_skip_on_simulation(void) if (igt_only_list_subtests()) return; - if (!in_fixture && !in_subtest) { + if (!igt_can_fail()) { igt_fixture igt_require(!igt_run_in_simulation()); } else |