Changelog: ========== Previous version: https://lore.kernel.org/all/[email protected]/
* Fix malformed and missing test-log when skipping kunit-suite. [David Gow] * Update kunit_init_suite() to reset the kunit-suite so that it can be re-run [David Gow] * Update kunit_suite_has_succeeded() to check for any failed test-case and update the 'status' for kunit-suite. * Added David Gow's RB to Patch-2 Summary of changes ================== This patch series introduces the ability to skip entire 'kunit_suite' based on runtime conditions, addressing a limitation where test suites could only skip individual test cases or fail when prerequisites were not met. The motivation for this feature comes from test suites that depend on specific hardware features, kernel capabilities, or runtime conditions. Currently, such suites must either: * Fail when prerequisites are missing * Skip each test case individually with redundant checks * Implement workarounds to avoid running tests An example of such a requirement came from [1] where the patch author wanted to skip the entire 'kunit_suite' but then had to resort marking all struct 'kunit_case' as skipped by accessing 'kunit_case.status' private struct member. This usecase being addressed in the patch[1] can be better implemented with the changes proposed in this patch series. Structure of the patch series ============================= PATCH 1: * Add a 'status' field to struct kunit_suite that allows 'suite_init' callbacks to mark the entire suite as KUNIT_SKIPPED. * Modify the KUnit core to check this newly introduced 'status' field and bypass all test cases when a suite is marked as skipped. * Update debugfs_print_results() to emmit correct logs for skipped 'kunit-suite' * Init 'kunit_suite.status' to KUNIT_SUCCESS so that kunit_suite can be re-run from debugfs Patch 2: * Providing an example in kunit-example-test.c demonstrating the usage pattern. The implementation is minimal and non-intrusive, adding only a status field to kunit_suite and checks in two key functions. Test suites that don't use this proposed feature should be unaffected. References ========== [1] https://lore.kernel.org/all/[email protected] Vaibhav Jain (2): kunit: Add ability to skip entire test suites kunit: Add example of test suite that can be skipped at runtime include/kunit/test.h | 1 + lib/kunit/debugfs.c | 30 +++++++++++++++++++++--------- lib/kunit/kunit-example-test.c | 29 +++++++++++++++++++++++++++++ lib/kunit/test.c | 17 ++++++++++++++++- 4 files changed, 67 insertions(+), 10 deletions(-) -- 2.54.0

