seL4test is an seL4 testing framework that runs test suites on seL4. It is used to test both kernel and user code.
Even though seL4 is a verified microkernel we still require a comprehensive set of tests that can be used as a way to easily check if the kernel is working. Here are some reasons:
In order to achieve the above, each test added to sel4test should have the following properties in roughly the following priority ordering:
Additionally a universal goal is that there are at least as many tests present to validate that the systems under test are functioning correctly.
This project has the following components/features:
sel4test-driver is an executable that runs as an seL4 root task. It expects to be given the initial set of seL4 capabilities (seL4_Bootinfo_t) and it uses them to bootstrap its own system environment and create testing environments for then running all of the tests. It has basic operating system functionality for creating and destroying multiple test runs and supporting different testing environments.
A test environment defines what resources a test has access to when it runs. An environment may have start-up and shut-down procedures that are run before and after the test is run. A test definition has a test environment attribute that is used to link a test with the environment it requires.
Each test environment runs the test in a separate “process” from the root task. This is to isolate tests from each other. However there is a bootstrap test environment that runs tests within the root task. This environment is for running tests that test the functionality for creating and communicating with different environment “processes”.
A test is a function that is invoked with a reference to its environment. Each test performs a set of actions that produce a result. The result is compared to an expected value to determine success or failure. A test is expected to terminate with a success or failure result and isn't allowed to run forever.
A reference to the test is added to a special linker section and the roottask uses this to select and run the tests at runtime. The tests run are selected based on whether a test is enabled and whether the test name matches a regex that the roottask is configured with. Tests are expected to automatically select whether they are enabled based on the build configuration at build time. The regex is used for further filtering which tests are run. The default regex is .* for selecting all enabled tests.
Tests are run sequentially and their test environments are reset between each test run. The roottask can be configured whether to stop or continue running on test failure conditions. A test failure shouldn‘t result in the entire application crashing. This isn’t enforced by most test environments as many of the tests are testing kernel mechanisms and may require permissions that allow them to crash the system. A test needs to be written such that this outcome is minimized.
Test results are reported via functions that the test calls which are defined by a common testing API. The roottask can choose how to report the results of a test based on its configuration. Some reporting formats should be machine-parsable to support test running automation. Human readable formats should also be available.
seL4bench is another application similar to seL4test that is used for running benchmarks on seL4.