The test harness which runs on our bots (called “runtests”) picks up all executables in the “/boot/test” and “/system/test” directories and runs them. If you provide a command-line argument, such as
runtests -S -m widget_test, runtests will only run the single test requested -- in this case,
“runtests” takes command-line arguments to toggle classes of tests to execute.
These classes are the following:
Since runtests doesn't really know what “class” is executing when it launches a test, it encodes this information in the environment variable
RUNTESTS_TEST_CLASS, which is detailed in the unittest header , and lets the executable itself decide what to run / not run. This environment variable is a bitmask indicating which tests to run.
For example, if a a test executable is run with “small” and “medium” tests, it will be executed ONCE with
RUNTESTS_TEST_CLASS set to 00000003 (the hex bitwise OR of “TEST_SMALL” and “TEST_MEDIUM” -- though this information should be parsed using the unittest header, as it may be updated in the future).
The following macros can be used to filter tests into these categories:
RUN_TEST_SMALL(widget_tiny_test) RUN_TEST_MEDIUM(widget_test) RUN_TEST_LARGE(widget_big_test) RUN_TEST_PERFORMANCE(widget_benchmark)
RUN_TEST(widget_test) is aliased to mean the same thing as
For tests compiled into the kernel itself you can call them from the shell with
k ut all will run all tests or you can use
k ut $TEST_NAME to run a specific test.
The output from these tests will only be shown on the serial console.
The environment variable
RUNTESTS_TEST_CLASS will still be available to all executables launched by runtests. The unittest header can be used to parse different categories of tests which the runtests harness attempted to run.
By default, runtests will run both small and medium tests.
To determine how to run a custom set of test categories, run
runtests -h, which includes usage information.