09 Feb, 2021

1 commit

  • E.g. specifying this would run suites with "list" in their name.
    kunit.filter_glob=list*

    Note: the executor prints out a TAP header that includes the number of
    suites we intend to run.
    So unless we want to report empty results for filtered-out suites, we
    need to do the filtering here in the executor.
    It's also probably better in the executor since we most likely don't
    want any filtering to apply to tests built as modules.

    This code does add a CONFIG_GLOB=y dependency for CONFIG_KUNIT=y.
    But the code seems light enough that it shouldn't be an issue.

    For now, we only filter on suite names so we don't have to create copies
    of the suites themselves, just the array (of arrays) holding them.

    The name is rather generic since in the future, we could consider
    extending it to a syntax like:
    kunit.filter_glob=.
    E.g. to run all the del list tests
    kunit.filter_glob=list-kunit-test.*del*

    But at the moment, it's far easier to manually comment out test cases in
    test files as opposed to messing with sets of Kconfig entries to select
    specific suites.
    So even just doing this makes using kunit far less annoying.

    Signed-off-by: Daniel Latypov
    Reviewed-by: Brendan Higgins
    Signed-off-by: Shuah Khan

    Daniel Latypov
     

02 Jun, 2020

2 commits

  • This makes it easier to enable all KUnit fragments.

    Adding 'if !KUNIT_ALL_TESTS' so individual tests can not be turned off.
    Therefore if KUNIT_ALL_TESTS is enabled that will hide the prompt in
    menuconfig.

    Reviewed-by: David Gow
    Signed-off-by: Anders Roxell
    Signed-off-by: Shuah Khan

    Anders Roxell
     
  • Make it easier to enable all KUnit fragments. This is useful for kernel
    devs or testers, so its easy to get all KUnit tests enabled and if new
    gets added they will be enabled as well. Fragments that has to be
    builtin will be missed if CONFIG_KUNIT_ALL_TESTS is set as a module.

    Signed-off-by: Anders Roxell
    Reviewed-by: Brendan Higgins
    Signed-off-by: Shuah Khan

    Anders Roxell
     

27 Mar, 2020

1 commit

  • add debugfs support for displaying kunit test suite results; this is
    especially useful for module-loaded tests to allow disentangling of
    test result display from other dmesg events. debugfs support is
    provided if CONFIG_KUNIT_DEBUGFS=y.

    As well as printk()ing messages, we append them to a per-test log.

    Signed-off-by: Alan Maguire
    Reviewed-by: Brendan Higgins
    Reviewed-by: Frank Rowand
    Signed-off-by: Shuah Khan

    Alan Maguire
     

10 Jan, 2020

2 commits

  • Making kunit itself buildable as a module allows for "always-on"
    kunit configuration; specifying CONFIG_KUNIT=m means the module
    is built but only used when loaded. Kunit test modules will load
    kunit.ko as an implicit dependency, so simply running
    "modprobe my-kunit-tests" will load the tests along with the kunit
    module and run them.

    Co-developed-by: Knut Omang
    Signed-off-by: Knut Omang
    Signed-off-by: Alan Maguire
    Reviewed-by: Brendan Higgins
    Signed-off-by: Shuah Khan

    Alan Maguire
     
  • 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

    Alan Maguire
     

01 Oct, 2019

2 commits

  • 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

    Brendan Higgins
     
  • Add core facilities for defining unit tests; this provides a common way
    to define test cases, functions that execute code which is under test
    and determine whether the code under test behaves as expected; this also
    provides a way to group together related test cases in test suites (here
    we call them test_modules).

    Just define test cases and how to execute them for now; setting
    expectations on code will be defined later.

    Signed-off-by: Brendan Higgins
    Reviewed-by: Greg Kroah-Hartman
    Reviewed-by: Logan Gunthorpe
    Reviewed-by: Luis Chamberlain
    Reviewed-by: Stephen Boyd
    Signed-off-by: Shuah Khan

    Brendan Higgins