The modules are being moved from lib/livepatch to tools/testing/selftests/livepatch/test_modules. This code moving will allow writing more complex tests, like for example an userspace C code that will call a livepatched kernel function. The modules are now built as out-of-tree modules, but being part of the kernel source means they will be maintained. Another advantage of the code moving is to be able to easily change, debug and rebuild the tests by running make on the selftests/livepatch directory, which is not currently possible since the modules on lib/livepatch are build and installed using the "modules" target. The current approach also keeps the ability to execute the tests manually by executing the scripts inside selftests/livepatch directory, as it's currently supported. If the modules are modified, they needed to be rebuilt before running the scripts though. The modules are built before running the selftests when using the kselftest invocations: make kselftest TARGETS=livepatch or make -C tools/testing/selftests/livepatch run_tests Having the modules being built as out-of-modules requires changing the currently used 'modprobe' by 'insmod' and adapt the test scripts that check for the kernel message buffer. Now it is possible to only compile the modules by running: make -C tools/testing/selftests/livepatch/ This way the test modules and other test program can be built in order to be packaged if so desired. As there aren't any modules being built on lib/livepatch, remove the TEST_LIVEPATCH Kconfig and it's references. Note: "make gen_tar" packages the pre-built binaries into the tarball. It means that it will store the test modules pre-built for the kernel running on the build host. Note that these modules need not binary compatible with the kernel built from the same sources. But the same is true for other packaged selftest binaries. The entire kernel sources are needed for rebuilding the selftests on another system. Reviewed-by: Joe Lawrence <joe.lawrence@redhat.com> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
56 lines
1.8 KiB
Text
56 lines
1.8 KiB
Text
====================
|
|
Livepatch Self Tests
|
|
====================
|
|
|
|
This is a small set of sanity tests for the kernel livepatching.
|
|
|
|
The test suite loads and unloads several test kernel modules to verify
|
|
livepatch behavior. Debug information is logged to the kernel's message
|
|
buffer and parsed for expected messages. (Note: the tests will compare
|
|
the message buffer for only the duration of each individual test.)
|
|
|
|
|
|
Config
|
|
------
|
|
|
|
Set CONFIG_LIVEPATCH=y option and it's prerequisites.
|
|
|
|
|
|
Building the tests
|
|
------------------
|
|
|
|
To only build the tests without running them, run:
|
|
|
|
% make -C tools/testing/selftests/livepatch
|
|
|
|
The command above will compile all test modules and test programs, making them
|
|
ready to be packaged if so desired.
|
|
|
|
Running the tests
|
|
-----------------
|
|
|
|
Test kernel modules are built before running the livepatch selftests. The
|
|
modules are located under test_modules directory, and are built as out-of-tree
|
|
modules. This is specially useful since the same sources can be built and
|
|
tested on systems with different kABI, ensuring they the tests are backwards
|
|
compatible. The modules will be loaded by the test scripts using insmod.
|
|
|
|
To run the livepatch selftests, from the top of the kernel source tree:
|
|
|
|
% make -C tools/testing/selftests TARGETS=livepatch run_tests
|
|
|
|
or
|
|
|
|
% make kselftest TARGETS=livepatch
|
|
|
|
|
|
Adding tests
|
|
------------
|
|
|
|
See the common functions.sh file for the existing collection of utility
|
|
functions, most importantly setup_config(), start_test() and
|
|
check_result(). The latter function greps the kernel's ring buffer for
|
|
"livepatch:" and "test_klp" strings, so tests be sure to include one of
|
|
those strings for result comparison. Other utility functions include
|
|
general module loading and livepatch loading helpers (waiting for patch
|
|
transitions, sysfs entries, etc.)
|