Skip to contentSkip to conversation

selftests/liveupdate: add end to end test infrastructure and scripts

PATCH Applied Mike Rapoport 2 participants 3 messages Jun 26 – Jul 10

Subsystems (3)
lore
Share & tools
lore

Mike Rapoport

author maintainer
#0 lore raw

PATCH 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
index 661827083ab6..cb08ddb0dfee 100644
@@ -6,4 +6,5 @@
 !*.sh
 !.gitignore
 !config
+!config.*
 !Makefile
tools/testing/selftests/liveupdate/config +1 -0
index 91d03f9a6a39..016d009dba13 100644
@@ -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
new file mode 100644
index 000000000000..445716403925
@@ -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
new file mode 100644
index 000000000000..810d9c9d213e
@@ -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
index 333a3530051b..1439b2b48ed0 100644
@@ -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.
maintainer Acked-by on v4 1/1
#1 lore raw
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 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.

Quoted 5 lines

[...]

Signature · 2 lines
Regards,
Pratyush Yadav