path: root/lib/list-test.c
Commit message (Collapse)AuthorAgeFilesLines
* list: test: Add a test for list_entry_is_head()David Gow2022-02-251-0/+21
| | | | | | | | | | | | | The list_entry_is_head() macro was added[1] after the list KUnit tests, so wasn't tested. Add a new KUnit test to complete the set. [1]: Signed-off-by: David Gow <> Acked-by: Daniel Latypov <> Acked-by: Brendan Higgins <> Reviewed-by: Andy Shevchenko <> Signed-off-by: Shuah Khan <>
* list: test: Add a test for list_is_head()David Gow2022-02-251-0/+19
| | | | | | | | | | | | | | list_is_head() was added recently[1], and didn't have a KUnit test. The implementation is trivial, so it's not a particularly exciting test, but it'd be nice to get back to full coverage of the list functions. [1]: Signed-off-by: David Gow <> Acked-by: Daniel Latypov <> Acked-by: Brendan Higgins <> Reviewed-by: Andy Shevchenko <> Signed-off-by: Shuah Khan <>
* list: test: Add test for list_del_init_careful()David Gow2022-02-251-0/+21
| | | | | | | | | | | | | | | The list_del_init_careful() function was added[1] after the list KUnit test. Add a very basic test to cover it. Note that this test only covers the single-threaded behaviour (which matches list_del_init()), as is already the case with the test for list_empty_careful(). [1]: Signed-off-by: David Gow <> Reviewed-by: Andy Shevchenko <> Signed-off-by: Shuah Khan <>
* Fix linked-list KUnit test when run multiple timesDavid Gow2020-03-251-2/+2
| | | | | | | | | | | | | | | | | | A few of the lists used in the linked-list KUnit tests (the for_each_entry{,_reverse} tests) are declared 'static', and so are not-reinitialised if the test runs multiple times. This was not a problem when KUnit tests were run once on startup, but when tests are able to be run manually (e.g. from debugfs[1]), this is no longer the case. Making these lists no longer 'static' causes the lists to be reinitialised, and the test passes each time it is run. While there may be some value in testing that initialising static lists works, the for_each_entry_* tests are unlikely to be the right place for it. Signed-off-by: David Gow <> Reviewed-by: Brendan Higgins <> Signed-off-by: Shuah Khan <>
* kunit: allow kunit tests to be loaded as a moduleAlan Maguire2020-01-091-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <>
* lib/list-test: add a test for the 'list' doubly linked listDavid Gow2019-11-011-0/+746
Add a KUnit test for the kernel doubly linked list implementation in include/linux/list.h Each test case (list_test_x) is focused on testing the behaviour of the list function/macro 'x'. None of the tests pass invalid lists to these macros, and so should behave identically with DEBUG_LIST enabled and disabled. Note that, at present, it only tests the list_ types (not the singly-linked hlist_), and does not yet test all of the list_for_each_entry* macros (and some related things like list_prepare_entry). Ignoring spurious errors related to its handling of for_each and other list macros. expects anything with for_each in its name to be a loop and expects that the open brace is placed on the same line as for a for loop. In this case, test case naming scheme includes name of the macro it is testing, which results in the spurious errors. Commit message updated by Shuah Khan <> Signed-off-by: David Gow <> Reviewed-by: Brendan Higgins <> Tested-by: Brendan Higgins <> Signed-off-by: Shuah Khan <>