selftests/liveupdate: add end to end test infrastructure and scripts
Subsystems (3)
Mike Rapoport
maintainerPATCH v4 1/1 selftests/liveupdate: add end to end test infrastructure and scripts
From: Pasha Tatashin <[email protected]>
Add the end to end testing infrastructure required to verify the liveupdate feature. This includes a custom init process, a test orchestration script, and a batch runner.
The framework consists of:
init.c:
A lightweight init process that manages the kexec lifecycle. It mounts necessary filesystems, determines the current execution stage (1 or 2) via the kernel command line, and handles the kexec_file_load() sequence to transition between kernels.
vmtest.sh:
The primary KTAP-compliant test driver. It handles:
- Kernel configuration merging and building.
- Cross-compilation detection for x86_64 and arm64.
- Generation of the initrd containing the test binary and init.
- QEMU execution with automatic accelerator detection (KVM, HVF, or TCG).
run-vmtests.sh:
A wrapper that runs vmtest.sh for each LUO test across supported architectures, providing a summary of pass/fail/skip results.
---
v4 changes:
* drop addition of ftruncate to nolibc, it is already merged
* rename a single test runner to vmtest.sh and the wrapper to run-vmtests.sh
* revamp run-vmtests.sh:
- add luo_stress_files and luo_stress_files tests
- only keep result logs if explicitly requested
- replace chatty and colorful summary with use a single line print
v3: https://lore.kernel.org/all/[email protected]
--- tools/testing/selftests/liveupdate/.gitignore | 1 + tools/testing/selftests/liveupdate/config | 1 + tools/testing/selftests/liveupdate/config.aarch64 | 2 + tools/testing/selftests/liveupdate/config.x86_64 | 2 + tools/testing/selftests/liveupdate/init.c | 179 ++++++++++++++ .../testing/selftests/liveupdate/luo_test_utils.c | 15 +- tools/testing/selftests/liveupdate/run-vmtests.sh | 97 ++++++++ tools/testing/selftests/liveupdate/vmtest.sh | 263 +++++++++++++++++++++ 8 files changed, 551 insertions(+), 9 deletions(-)
tools/testing/selftests/liveupdate/.gitignore +1 -0
@@ -6,4 +6,5 @@ !*.sh !.gitignore !config +!config.* !Makefile
tools/testing/selftests/liveupdate/config +1 -0
@@ -1,4 +1,5 @@ CONFIG_BLK_DEV_INITRD=y +CONFIG_DEVTMPFS=y CONFIG_KEXEC_FILE=y CONFIG_KEXEC_HANDOVER=y CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y
tools/testing/selftests/liveupdate/config.aarch64 new file +2 -0
@@ -0,0 +1,2 @@ +CONFIG_SERIAL_AMBA_PL011=y +CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
tools/testing/selftests/liveupdate/config.x86_64 new file +2 -0
@@ -0,0 +1,2 @@ +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y
tools/testing/selftests/liveupdate/init.c new file +179 -0
179 lines not on this page · raw message
tools/testing/selftests/liveupdate/luo_test_utils.c +6 -9
@@ -21,6 +21,7 @@#include <sys/stat.h> #include <errno.h> #include <stdarg.h> +#include <linux/unistd.h> #include "luo_test_utils.h"
@@ -81,7 +82,7 @@ int luo_retrieve_session(int luo_fd, const char *name)int create_and_preserve_memfd (int session_fd,int token,const char *data) {struct liveupdate_session_preserve_fd arg = { .size =sizeof (arg) }; -long page_size =sysconf (_SC_PAGE_SIZE); +long page_size =getpagesize ();void *map =MAP_FAILED ;int mfd =-1 , ret =-1 ;
@@ -117,7 +118,7 @@ int restore_and_verify_memfd(int session_fd, int token, const char *expected_data) {struct liveupdate_session_retrieve_fd arg = { .size =sizeof (arg) }; -long page_size =sysconf (_SC_PAGE_SIZE); +long page_size =getpagesize ();void *map =MAP_FAILED ;int mfd =-1 , ret =-1 ;
@@ -228,16 +229,11 @@ void daemonize_and_wait(void)static int parse_stage_args (int argc,char *argv[]) { -static struct option long_options[] = { - {"stage" , required_argument,0 ,'s' }, - {0 ,0 ,0 ,0 } - }; -int option_index =0 ;int stage =1 ;int opt; optind =1 ; -while ((opt =getopt_long (argc, argv,"s:" , long_options, &option_index)) !=-1 ) { +while ((opt =getopt (argc, argv,"s:" )) !=-1 ) {switch (opt) {case 's' : stage =atoi (optarg);
@@ -248,6 +244,7 @@ static int parse_stage_args(int argc, char *argv[])fail_exit ("Unknown argument" ); } } +return stage; }
@@ -275,7 +272,7 @@ int luo_test(int argc, char *argv[],fail_exit ("Failed to check for state session" );if (target_stage != detected_stage) { -ksft_exit_fail_msg ("Stage mismatch Requested --stage %d, but system is in stage %d.\n" +ksft_exit_fail_msg ("Stage mismatch Requested stage %d, but system is in stage %d.\n" "(State session %s: %s)\n" , target_stage, detected_stage, state_session_name, (detected_stage ==2 ) ?"EXISTS" :"MISSING" );
tools/testing/selftests/liveupdate/run-vmtests.sh new file +97 -0
97 lines not on this page · raw message
tools/testing/selftests/liveupdate/vmtest.sh new file +263 -0
263 lines not on this page · raw message
---
base-commit: 962528fef90253aeded29cee20a9b6ff3595fed4
change-id: 20260626-luo-vmtest-v0-56849797a008
Best regards,
Signature · 2 lines
Sincerely yours, Mike.
Quoted 26 lines · Mike Rapoport
From: Pasha Tatashin <[email protected]>
Add the end to end testing infrastructure required to verify the liveupdate feature. This includes a custom init process, a test orchestration script, and a batch runner.
The framework consists of:
init.c:
A lightweight init process that manages the kexec lifecycle. It mounts necessary filesystems, determines the current execution stage (1 or 2) via the kernel command line, and handles thekexec_file_load()sequence to transition between kernels.
vmtest.sh:
The primary KTAP-compliant test driver. It handles:
- Kernel configuration merging and building.
- Cross-compilation detection forx86_64and arm64.
- Generation of the initrd containing the test binary and init.
- QEMU execution with automatic accelerator detection (KVM, HVF, or TCG).
run-vmtests.sh:
A wrapper that runsvmtest.shfor each LUO test across supported architectures, providing a summary of pass/fail/skip results.
Quoted 5 lines
Signed-off-by Pasha Tatashin <[email protected]>Co-developed-by Jordan Richards <[email protected]>Signed-off-by Jordan Richards <[email protected]>Co-developed-by Mike Rapoport (Microsoft) <[email protected]>Signed-off-by Mike Rapoport (Microsoft) <[email protected]>
[...]
Signature · 2 lines
Regards, Pratyush Yadav
Quoted 1 line · Mike Rapoport
selftests/liveupdate: add end to end test infrastructure and scripts
Applied to misc branch of liveupdate/linux.git tree, thanks!
[1/1] selftests/liveupdate: add end to end test infrastructure and scripts
commit: 89dd1421c554515e0f562ec67d976e6309f2710b
tree: https://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux
branch: misc
--
Sincerely yours,
Mike.