path: root/lib/kunit/try-catch.c
Commit message (Collapse)AuthorAgeFilesLines
* kunit: remove timeout dependence on sysctl_hung_task_timeout_secondsAlan Maguire2020-01-091-18/+4
| | | | | | | | | | | | | | | | | | In discussion of how to handle timeouts, it was noted that if sysctl_hung_task_timeout_seconds is exceeded for a kunit test, the test task will be killed and an oops generated. This should suffice as a means of debugging such timeout issues for now. Hence remove use of sysctl_hung_task_timeout_secs, which has the added benefit of avoiding the need to export that symbol from the core kernel. Co-developed-by: Knut Omang <> Signed-off-by: Knut Omang <> Signed-off-by: Alan Maguire <> Reviewed-by: Stephen Boyd <> Acked-by: Brendan Higgins <> Signed-off-by: Shuah Khan <>
* kunit: allow kunit tests to be loaded as a moduleAlan Maguire2020-01-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As tests are added to kunit, it will become less feasible to execute all built tests together. By supporting modular tests we provide a simple way to do selective execution on a running system; specifying CONFIG_KUNIT=y CONFIG_KUNIT_EXAMPLE_TEST=m ...means we can simply "insmod example-test.ko" to run the tests. To achieve this we need to do the following: o export the required symbols in kunit o string-stream tests utilize non-exported symbols so for now we skip building them when CONFIG_KUNIT_TEST=m. o drivers/base/power/qos-test.c contains a few unexported interface references, namely freq_qos_read_value() and freq_constraints_init(). Both of these could be potentially defined as static inline functions in include/linux/pm_qos.h, but for now we simply avoid supporting module build for that test suite. o support a new way of declaring test suites. Because a module cannot do multiple late_initcall()s, we provide a kunit_test_suites() macro to declare multiple suites within the same module at once. o some test module names would have been too general ("test-test" and "example-test" for kunit tests, "inode-test" for ext4 tests); rename these as appropriate ("kunit-test", "kunit-example-test" and "ext4-inode-test" respectively). Also define kunit_test_suite() via kunit_test_suites() as callers in other trees may need the old definition. Co-developed-by: Knut Omang <> Signed-off-by: Knut Omang <> Signed-off-by: Alan Maguire <> Reviewed-by: Brendan Higgins <> Acked-by: Theodore Ts'o <> # for ext4 bits Acked-by: David Gow <> # For list-test Reported-by: kbuild test robot <> Signed-off-by: Shuah Khan <>
* kunit: hide unexported try-catch interface in try-catch-impl.hAlan Maguire2020-01-091-11/+2
| | | | | | | | | | | | | Define function as static inline in try-catch-impl.h to allow it to be used in kunit itself and tests. Also remove unused kunit_generic_try_catch Co-developed-by: Knut Omang <> Signed-off-by: Knut Omang <> Signed-off-by: Alan Maguire <> Reviewed-by: Brendan Higgins <> Tested-by: Brendan Higgins <> Signed-off-by: Shuah Khan <>
* kunit: test: add support for test abortBrendan Higgins2019-09-301-0/+118
Add support for aborting/bailing out of test cases, which is needed for implementing assertions. An assertion is like an expectation, but bails out of the test case early if the assertion is not met. The idea with assertions is that you use them to state all the preconditions for your test. Logically speaking, these are the premises of the test case, so if a premise isn't true, there is no point in continuing the test case because there are no conclusions that can be drawn without the premises. Whereas, the expectation is the thing you are trying to prove. Signed-off-by: Brendan Higgins <> Reviewed-by: Greg Kroah-Hartman <> Reviewed-by: Logan Gunthorpe <> Reviewed-by: Stephen Boyd <> Signed-off-by: Shuah Khan <>