1a2818ee4SJoe Lawrence==================== 2a2818ee4SJoe LawrenceLivepatch Self Tests 3a2818ee4SJoe Lawrence==================== 4a2818ee4SJoe Lawrence 5a2818ee4SJoe LawrenceThis is a small set of sanity tests for the kernel livepatching. 6a2818ee4SJoe Lawrence 7a2818ee4SJoe LawrenceThe test suite loads and unloads several test kernel modules to verify 8a2818ee4SJoe Lawrencelivepatch behavior. Debug information is logged to the kernel's message 92eeb0d45SJoe Lawrencebuffer and parsed for expected messages. (Note: the tests will compare 102eeb0d45SJoe Lawrencethe message buffer for only the duration of each individual test.) 11a2818ee4SJoe Lawrence 12a2818ee4SJoe Lawrence 13a2818ee4SJoe LawrenceConfig 14a2818ee4SJoe Lawrence------ 15a2818ee4SJoe Lawrence 16*c4bbe83dSMarcos Paulo de SouzaSet CONFIG_LIVEPATCH=y option and it's prerequisites. 17a2818ee4SJoe Lawrence 18a2818ee4SJoe Lawrence 19*c4bbe83dSMarcos Paulo de SouzaBuilding the tests 20*c4bbe83dSMarcos Paulo de Souza------------------ 21*c4bbe83dSMarcos Paulo de Souza 22*c4bbe83dSMarcos Paulo de SouzaTo only build the tests without running them, run: 23*c4bbe83dSMarcos Paulo de Souza 24*c4bbe83dSMarcos Paulo de Souza % make -C tools/testing/selftests/livepatch 25*c4bbe83dSMarcos Paulo de Souza 26*c4bbe83dSMarcos Paulo de SouzaThe command above will compile all test modules and test programs, making them 27*c4bbe83dSMarcos Paulo de Souzaready to be packaged if so desired. 28a2818ee4SJoe Lawrence 29a2818ee4SJoe LawrenceRunning the tests 30a2818ee4SJoe Lawrence----------------- 31a2818ee4SJoe Lawrence 32*c4bbe83dSMarcos Paulo de SouzaTest kernel modules are built before running the livepatch selftests. The 33*c4bbe83dSMarcos Paulo de Souzamodules are located under test_modules directory, and are built as out-of-tree 34*c4bbe83dSMarcos Paulo de Souzamodules. This is specially useful since the same sources can be built and 35*c4bbe83dSMarcos Paulo de Souzatested on systems with different kABI, ensuring they the tests are backwards 36*c4bbe83dSMarcos Paulo de Souzacompatible. The modules will be loaded by the test scripts using insmod. 37a2818ee4SJoe Lawrence 38a2818ee4SJoe LawrenceTo run the livepatch selftests, from the top of the kernel source tree: 39a2818ee4SJoe Lawrence 40a2818ee4SJoe Lawrence % make -C tools/testing/selftests TARGETS=livepatch run_tests 41a2818ee4SJoe Lawrence 42*c4bbe83dSMarcos Paulo de Souzaor 43*c4bbe83dSMarcos Paulo de Souza 44*c4bbe83dSMarcos Paulo de Souza % make kselftest TARGETS=livepatch 45*c4bbe83dSMarcos Paulo de Souza 46a2818ee4SJoe Lawrence 47a2818ee4SJoe LawrenceAdding tests 48a2818ee4SJoe Lawrence------------ 49a2818ee4SJoe Lawrence 50a2818ee4SJoe LawrenceSee the common functions.sh file for the existing collection of utility 512eeb0d45SJoe Lawrencefunctions, most importantly setup_config(), start_test() and 522eeb0d45SJoe Lawrencecheck_result(). The latter function greps the kernel's ring buffer for 532eeb0d45SJoe Lawrence"livepatch:" and "test_klp" strings, so tests be sure to include one of 542eeb0d45SJoe Lawrencethose strings for result comparison. Other utility functions include 552eeb0d45SJoe Lawrencegeneral module loading and livepatch loading helpers (waiting for patch 562eeb0d45SJoe Lawrencetransitions, sysfs entries, etc.) 57