The current kunit execution model is to provide base kunit functionality and tests built-in to the kernel. The aim of this series is to allow building kunit itself and tests as modules. This in turn allows a simple form of selective execution; load the module you wish to test. In doing so, kunit itself (if also built as a module) will be loaded as an implicit dependency. Because this requires a core API modification - if a module delivers multiple suites, they must be declared with the kunit_test_suites() macro - we're proposing this patch set as a candidate to be applied to the test tree before too many kunit consumers appear. We attempt to deal with existing consumers in patch 4. Changes since v2: - moved string-stream.h header to lib/kunit/string-stream-impl.h (Brendan) (patch 1) - split out non-exported interfaces in try-catch-impl.h (Brendan) (patch 2) - added kunit_find_symbol() and KUNIT_INIT_*SYMBOL to lookup non-exported symbols. KUNIT_INIT_*SYMBOL() is defined so that a mismatch between local symbol definition and definition of symbol in target will trigger a compilation error when the object is compiled built-in (Brendan) (patches 3, 4) - removed #ifdef MODULE around module licenses (Randy, Brendan, Andy) (patch 4) - replaced kunit_test_suite() with kunit_test_suites() rather than supporting both (Brendan) (patch 4) - lookup sysctl_hung_task_timeout_secs as kunit may be built as a module and the symbol may not be available (patch 5) - fixed whitespace issues in doc (patch 6) Alan Maguire (6): kunit: move string-stream.h to lib/kunit/string-stream-impl.h kunit: hide unexported try-catch interface in try-catch-impl.h kunit: add kunit_find_symbol() function for symbol lookup kunit: allow kunit tests to be loaded as a module kunit: allow kunit to be loaded as a module kunit: update documentation to describe module-based build Documentation/dev-tools/kunit/faq.rst | 3 +- Documentation/dev-tools/kunit/index.rst | 3 + Documentation/dev-tools/kunit/usage.rst | 16 +++++ include/kunit/assert.h | 3 +- include/kunit/string-stream.h | 51 ------------- include/kunit/test.h | 123 +++++++++++++++++++++++++++++--- include/kunit/try-catch.h | 10 --- kernel/sysctl-test.c | 4 +- lib/Kconfig.debug | 2 +- lib/kunit/Kconfig | 6 +- lib/kunit/Makefile | 4 +- lib/kunit/assert.c | 9 +++ lib/kunit/example-test.c | 4 +- lib/kunit/string-stream-impl.h | 51 +++++++++++++ lib/kunit/string-stream-test.c | 46 ++++++++---- lib/kunit/string-stream.c | 3 +- lib/kunit/test-test.c | 50 ++++++++++--- lib/kunit/test.c | 49 +++++++++++++ lib/kunit/try-catch-impl.h | 23 ++++++ lib/kunit/try-catch.c | 6 ++ 20 files changed, 363 insertions(+), 103 deletions(-) delete mode 100644 include/kunit/string-stream.h create mode 100644 lib/kunit/string-stream-impl.h create mode 100644 lib/kunit/try-catch-impl.h -- 1.8.3.1