livepatch: Move tests from lib/livepatch to selftests/livepatch
authorMarcos Paulo de Souza <mpdesouza@suse.com>
Fri, 12 Jan 2024 17:43:51 +0000 (14:43 -0300)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 22 Jan 2024 17:29:47 +0000 (10:29 -0700)
commitc4bbe83d27c2446a033cc0381c3fb6be5e8c41c7
tree8c8baef6b1936c8f890b640c5524220fd57137c1
parent6727980b67852dae6b82a97e24fbadbdd218c033
livepatch: Move tests from lib/livepatch to selftests/livepatch

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>
37 files changed:
MAINTAINERS
arch/s390/configs/debug_defconfig
arch/s390/configs/defconfig
lib/Kconfig.debug
lib/Makefile
lib/livepatch/Makefile [deleted file]
lib/livepatch/test_klp_atomic_replace.c [deleted file]
lib/livepatch/test_klp_callbacks_busy.c [deleted file]
lib/livepatch/test_klp_callbacks_demo.c [deleted file]
lib/livepatch/test_klp_callbacks_demo2.c [deleted file]
lib/livepatch/test_klp_callbacks_mod.c [deleted file]
lib/livepatch/test_klp_livepatch.c [deleted file]
lib/livepatch/test_klp_shadow_vars.c [deleted file]
lib/livepatch/test_klp_state.c [deleted file]
lib/livepatch/test_klp_state2.c [deleted file]
lib/livepatch/test_klp_state3.c [deleted file]
tools/testing/selftests/livepatch/Makefile
tools/testing/selftests/livepatch/README
tools/testing/selftests/livepatch/config
tools/testing/selftests/livepatch/functions.sh
tools/testing/selftests/livepatch/test-callbacks.sh
tools/testing/selftests/livepatch/test-ftrace.sh
tools/testing/selftests/livepatch/test-livepatch.sh
tools/testing/selftests/livepatch/test-shadow-vars.sh
tools/testing/selftests/livepatch/test-state.sh
tools/testing/selftests/livepatch/test-sysfs.sh
tools/testing/selftests/livepatch/test_modules/Makefile [new file with mode: 0644]
tools/testing/selftests/livepatch/test_modules/test_klp_atomic_replace.c [new file with mode: 0644]
tools/testing/selftests/livepatch/test_modules/test_klp_callbacks_busy.c [new file with mode: 0644]
tools/testing/selftests/livepatch/test_modules/test_klp_callbacks_demo.c [new file with mode: 0644]
tools/testing/selftests/livepatch/test_modules/test_klp_callbacks_demo2.c [new file with mode: 0644]
tools/testing/selftests/livepatch/test_modules/test_klp_callbacks_mod.c [new file with mode: 0644]
tools/testing/selftests/livepatch/test_modules/test_klp_livepatch.c [new file with mode: 0644]
tools/testing/selftests/livepatch/test_modules/test_klp_shadow_vars.c [new file with mode: 0644]
tools/testing/selftests/livepatch/test_modules/test_klp_state.c [new file with mode: 0644]
tools/testing/selftests/livepatch/test_modules/test_klp_state2.c [new file with mode: 0644]
tools/testing/selftests/livepatch/test_modules/test_klp_state3.c [new file with mode: 0644]