10 Jan, 2020
2 commits
-
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; specifyingCONFIG_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 -
string-stream interfaces are not intended for external use;
move them from include/kunit to lib/kunit accordingly.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
01 Oct, 2019
2 commits
-
Add support for assertions which are like expectations except the test
terminates if the assertion is not satisfied.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. It is not used universally in x-unit style test
frameworks, but I really like it as a convention. You could still
express the idea of a premise using the above idiom, but I think
KUNIT_ASSERT_* states the intended idea perfectly.Signed-off-by: Brendan Higgins
Reviewed-by: Greg Kroah-Hartman
Reviewed-by: Logan Gunthorpe
Reviewed-by: Stephen Boyd
Signed-off-by: Shuah Khan -
Add a test for string stream along with a simpler example.
Signed-off-by: Brendan Higgins
Reviewed-by: Greg Kroah-Hartman
Reviewed-by: Logan Gunthorpe
Reviewed-by: Stephen Boyd
Signed-off-by: Shuah Khan