linux-stable/tools/testing/selftests/livepatch
Linus Torvalds d451b075f7 linux_kselftest-next-6.9-rc1
This kselftest next update for Linux 6.9-rc1 consists of:
 
 -- livepatch restructuring to move the module out of lib to be
    built as a out-of-tree modules during kselftest build. This
    change makes it easier 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 main makefile modules target.
 
 -- livepatch restructuring fixes for problems found by kernel test
    robot. The change skips the test if kernel-devel isn't installed
    (default value of KDIR), or if KDIR variable passed doesn't exists.
 
 -- resctrl test restructuring and new non-contiguous CBMs CAT test
 
 -- new ktap_helpers to print diagnostic messages, pass/fail tests
    based on exit code, abort test, and finish the test.
 
 -- a new test verify power supply properties.
 
 -- a new ftrace to exercise function tracer across cpu hotplug.
 
 -- timeout increase for mqueue test to allow the test to run on
    i3.metal AWS instances.
 
 -- minor spelling corrections in several tests.
 
 -- missing gitignore files and changes to existing gitignore files.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEPZKym/RZuOCGeA/kCwJExA0NQxwFAmXo/kUACgkQCwJExA0N
 Qxy0aBAAk0SLA1ZIAdlNjo5B13C7GC7rFRrtaai9ReXSvU/X5TX9sD5T9DIULKdj
 Mcqi+oaP88GPSUZS+bn7DyVxKyuvHg/f4jWQwqZ34WxK4K1K+yt+3YhTnHZx7ezU
 6WIbUsD1Zs7tXXI2v76riHFbD3pfxZ+AXQaf/1cXDi4SpIpLkiqyeYWoWN5Z2rtJ
 BwMzrI2RBiLMox4g8F3Ey4BX+bOIYiiJq5bdl7gJVKcp74VdU3S7IyOuXFbSdcFR
 xxmFMxWGFOgRzexW0fmDWLudD2dII0XQAExSsl5xMnR/lmSh+lHWheoNgphQl050
 VcLmrPugWVJSioe0fHEgmDQXe3lPqDtepUg921tIlWvCmtR3Ur6+GpILTbSvQ4qp
 SK+2pt7nGSAT2UkRO/6/TYFG3mELADvj6tglj0b1SkIXmNiF+7OZ+hJ2XqyM7peo
 Z7gtmSmpbAotxp64Jj8HsNZLpCX0xdaxoTMEWPoG09fwTXY7Hy03yoWDKBKB4MZ9
 jBtNXDolhpEQ/ppSGFnRPzXuNVapYX28UY0cwBBVgke5jwB8SUnBEr2dbNnVU1q0
 y5uxtj/EFQzxSynB3eM1us2OuXvr5TfAWmKVpyE/cNC3WreHeA+Y2kN1dzv8hgpw
 o4NbltdF8F+a9qQF9B1XvjVhqa5By1esS1jOg96cJgGseAVWiQs=
 =G+DO
 -----END PGP SIGNATURE-----

Merge tag 'linux_kselftest-next-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest update from Shuah Khan:

 - livepatch restructuring to move the module out of lib to be built as
   a out-of-tree modules during kselftest build. This makes it easier
   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 main
   makefile modules target.

 - livepatch restructuring fixes for problems found by kernel test
   robot. The change skips the test if kernel-devel isn't installed
   (default value of KDIR), or if KDIR variable passed doesn't exists.

 - resctrl test restructuring and new non-contiguous CBMs CAT test

 - new ktap_helpers to print diagnostic messages, pass/fail tests based
   on exit code, abort test, and finish the test.

 - a new test verify power supply properties.

 - a new ftrace to exercise function tracer across cpu hotplug.

 - timeout increase for mqueue test to allow the test to run on i3.metal
   AWS instances.

 - minor spelling corrections in several tests.

 - missing gitignore files and changes to existing gitignore files.

* tag 'linux_kselftest-next-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (57 commits)
  kselftest: Add basic test for probing the rust sample modules
  selftests: lib.mk: Do not process TEST_GEN_MODS_DIR
  selftests: livepatch: Avoid running the tests if kernel-devel is missing
  selftests: livepatch: Add initial .gitignore
  selftests/resctrl: Add non-contiguous CBMs CAT test
  selftests/resctrl: Add resource_info_file_exists()
  selftests/resctrl: Split validate_resctrl_feature_request()
  selftests/resctrl: Add a helper for the non-contiguous test
  selftests/resctrl: Add test groups and name L3 CAT test L3_CAT
  selftests: sched: Fix spelling mistake "hiearchy" -> "hierarchy"
  selftests/mqueue: Set timeout to 180 seconds
  selftests/ftrace: Add test to exercize function tracer across cpu hotplug
  selftest: ftrace: fix minor typo in log
  selftests: thermal: intel: workload_hint: add missing gitignore
  selftests: thermal: intel: power_floor: add missing gitignore
  selftests: uevent: add missing gitignore
  selftests: Add test to verify power supply properties
  selftests: ktap_helpers: Add a helper to finish the test
  selftests: ktap_helpers: Add a helper to abort the test
  selftests: ktap_helpers: Add helper to pass/fail test based on exit code
  ...
2024-03-11 09:25:33 -07:00
..
test_modules selftests: livepatch: Avoid running the tests if kernel-devel is missing 2024-02-27 17:03:35 -07:00
.gitignore selftests: livepatch: Add initial .gitignore 2024-02-27 17:03:28 -07:00
config livepatch: Move tests from lib/livepatch to selftests/livepatch 2024-01-22 10:29:47 -07:00
functions.sh linux_kselftest-next-6.9-rc1 2024-03-11 09:25:33 -07:00
Makefile selftests: livepatch: Test livepatching a heavily called syscall 2024-01-22 10:29:53 -07:00
README livepatch: Move tests from lib/livepatch to selftests/livepatch 2024-01-22 10:29:47 -07:00
settings selftests/livepatch: Disable the timeout 2019-10-25 19:59:12 +02:00
test-callbacks.sh livepatch: Move tests from lib/livepatch to selftests/livepatch 2024-01-22 10:29:47 -07:00
test-ftrace.sh livepatch: Move tests from lib/livepatch to selftests/livepatch 2024-01-22 10:29:47 -07:00
test-livepatch.sh livepatch: Move tests from lib/livepatch to selftests/livepatch 2024-01-22 10:29:47 -07:00
test-shadow-vars.sh livepatch: Move tests from lib/livepatch to selftests/livepatch 2024-01-22 10:29:47 -07:00
test-state.sh livepatch: Move tests from lib/livepatch to selftests/livepatch 2024-01-22 10:29:47 -07:00
test-syscall.sh selftests: livepatch: Test livepatching a heavily called syscall 2024-01-22 10:29:53 -07:00
test-sysfs.sh livepatch: Move tests from lib/livepatch to selftests/livepatch 2024-01-22 10:29:47 -07:00
test_klp-call_getpid.c selftests: livepatch: Test livepatching a heavily called syscall 2024-01-22 10:29:53 -07:00

====================
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.)