lib/kunit: Fix illegal igt_fail() calls inside subtest body
In a body of a subtest with dynamic sub-subtests, it is illegal to call igt_fail() and its variants from outside of a dynamic sub-subtest body. On the other hand, it is perfectly legal to call either igt_skip() and friends or __igt_abort() or its variant from there. In the current implementation of igt_kunit(), there are several places where igt_fail() is called despite being illegal. Moreover, it is called with IGT_EXIT_ABORT as an argument with no good reason for using such aggressive method that forces CI to trigger system reboot (in most cases igt_runner can decide if abort is required). Follow igt_kselftests() pattern more closely, where similar setup and cleanup operations are performed but their potential errors are processed in a more friendly way. Move common cleanup and their corresponding setup steps out of the subtest body. Place the latter as requirements in a preceding igt_fixture section. Replace remaining illegal igt_fail() calls with more friendly skips. Let igt_runner decide if abort is needed. v2: Also call igt_skip() on igt_ktest_init() failure (Mauro), but then, initialize local tst structure when declaring it to avoid freeing a random pointer from igt_ktest_fini() when only listing subtests, - call igt_ktest_end() from igt_fixture so it is not unnecessarily called when only listing subtests. Signed-off-by:Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> Acked-by:
Mauro Carvalho Chehab <mchehab@kernel.org>
Please register or sign in to comment