4b513a02fd
The NULL dereference tests in kunit_fault deliberately trigger a kernel BUG(), and therefore print the associated stack trace, even when the test passes. This is both annoying (as it bloats the test output), and can confuse some test harnesses, which assume any BUG() is a failure. Allow these tests to be specifically disabled (without disabling all of KUnit's other tests), by placing them behind the CONFIG_KUNIT_FAULT_TEST Kconfig option. This is enabled by default, but can be set to 'n' to disable the test. An empty 'kunit_fault' suite is left behind, which will automatically be marked 'skipped'. As the fault tests already were disabled under UML (as they weren't compatible with its fault handling), we can simply adapt those conditions, and add a dependency on !UML for our new option. Suggested-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/all/928249cc-e027-4f7f-b43f-502f99a1ea63@roeck-us.net/ Fixes: 82b0beff3497 ("kunit: Add tests for fault") Signed-off-by: David Gow <davidgow@google.com> Reviewed-by: Mickaël Salaün <mic@digikod.net> Reviewed-by: Rae Moar <rmoar@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
85 lines
3.0 KiB
Plaintext
85 lines
3.0 KiB
Plaintext
#
|
|
# KUnit base configuration
|
|
#
|
|
|
|
menuconfig KUNIT
|
|
tristate "KUnit - Enable support for unit tests"
|
|
select GLOB
|
|
help
|
|
Enables support for kernel unit tests (KUnit), a lightweight unit
|
|
testing and mocking framework for the Linux kernel. These tests are
|
|
able to be run locally on a developer's workstation without a VM or
|
|
special hardware when using UML. Can also be used on most other
|
|
architectures. For more information, please see
|
|
Documentation/dev-tools/kunit/.
|
|
|
|
if KUNIT
|
|
|
|
config KUNIT_DEBUGFS
|
|
bool "KUnit - Enable /sys/kernel/debug/kunit debugfs representation" if !KUNIT_ALL_TESTS
|
|
default KUNIT_ALL_TESTS
|
|
help
|
|
Enable debugfs representation for kunit. Currently this consists
|
|
of /sys/kernel/debug/kunit/<test_suite>/results files for each
|
|
test suite, which allow users to see results of the last test suite
|
|
run that occurred.
|
|
|
|
config KUNIT_FAULT_TEST
|
|
bool "Enable KUnit tests which print BUG stacktraces"
|
|
depends on KUNIT_TEST
|
|
depends on !UML
|
|
default y
|
|
help
|
|
Enables fault handling tests for the KUnit framework. These tests may
|
|
trigger a kernel BUG(), and the associated stack trace, even when they
|
|
pass. If this conflicts with your test infrastrcture (or is confusing
|
|
or annoying), they can be disabled by setting this to N.
|
|
|
|
config KUNIT_TEST
|
|
tristate "KUnit test for KUnit" if !KUNIT_ALL_TESTS
|
|
default KUNIT_ALL_TESTS
|
|
help
|
|
Enables the unit tests for the KUnit test framework. These tests test
|
|
the KUnit test framework itself; the tests are both written using
|
|
KUnit and test KUnit. This option should only be enabled for testing
|
|
purposes by developers interested in testing that KUnit works as
|
|
expected.
|
|
|
|
config KUNIT_EXAMPLE_TEST
|
|
tristate "Example test for KUnit" if !KUNIT_ALL_TESTS
|
|
default KUNIT_ALL_TESTS
|
|
help
|
|
Enables an example unit test that illustrates some of the basic
|
|
features of KUnit. This test only exists to help new users understand
|
|
what KUnit is and how it is used. Please refer to the example test
|
|
itself, lib/kunit/example-test.c, for more information. This option
|
|
is intended for curious hackers who would like to understand how to
|
|
use KUnit for kernel development.
|
|
|
|
config KUNIT_ALL_TESTS
|
|
tristate "All KUnit tests with satisfied dependencies"
|
|
help
|
|
Enables all KUnit tests, if they can be enabled.
|
|
KUnit tests run during boot and output the results to the debug log
|
|
in TAP format (http://testanything.org/). Only useful for kernel devs
|
|
running the KUnit test harness, and not intended for inclusion into a
|
|
production build.
|
|
|
|
For more information on KUnit and unit tests in general please refer
|
|
to the KUnit documentation in Documentation/dev-tools/kunit/.
|
|
|
|
If unsure, say N.
|
|
|
|
config KUNIT_DEFAULT_ENABLED
|
|
bool "Default value of kunit.enable"
|
|
default y
|
|
help
|
|
Sets the default value of kunit.enable. If set to N then KUnit
|
|
tests will not execute unless kunit.enable=1 is passed to the
|
|
kernel command line.
|
|
|
|
In most cases this should be left as Y. Only if additional opt-in
|
|
behavior is needed should this be set to N.
|
|
|
|
endif # KUNIT
|