Skip to contentSkip to conversation

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

PATCH Superseded Jordan Richards 3 participants 6 messages Jan 22 – Feb 5

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

luo_test.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.sh:
A wrapper script to discover and execute all luo_*.c tests across supported architectures, providing a summary of pass/fail/skip results.

---
Changelog since luo v7 [1]:
- Build test binaries with -nostdlib -nostdinc
- Use minimal per-arch config instead of defconfig
- Unhandled test errors now cause the test to fail instead of skip

[1] https://lore.kernel.org/all/[email protected]/

 tools/testing/selftests/liveupdate/.gitignore |   2 +
 tools/testing/selftests/liveupdate/config     |   1 +
 .../selftests/liveupdate/config.aarch64       |   2 +
 .../selftests/liveupdate/config.x86_64        |   2 +
 tools/testing/selftests/liveupdate/init.c     | 179 +++++++++++
 .../testing/selftests/liveupdate/luo_test.sh  | 303 ++++++++++++++++++
 .../selftests/liveupdate/luo_test_utils.c     |  35 +-
 tools/testing/selftests/liveupdate/run.sh     |  68 ++++
 8 files changed, 579 insertions(+), 13 deletions(-)
 create mode 100644 tools/testing/selftests/liveupdate/config.aarch64
 create mode 100644 tools/testing/selftests/liveupdate/config.x86_64
 create mode 100644 tools/testing/selftests/liveupdate/init.c
 create mode 100755 tools/testing/selftests/liveupdate/luo_test.sh
 create mode 100755 tools/testing/selftests/liveupdate/run.sh
tools/testing/selftests/liveupdate/.gitignore +2 -0
index 661827083ab6..7dc1e8aec44c 100644
@@ -6,4 +6,6 @@
 !*.sh
 !.gitignore
 !config
+!config.aarch64
+!config.x86_64
 !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.sh new file +303 -0

303 lines not on this page · raw message

tools/testing/selftests/liveupdate/luo_test_utils.c +22 -13
index 3c8721c505df..7ee80b6ed4cb 100644
@@ -13,6 +13,7 @@
 #include <getopt.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <sys.h>
 #include <sys/ioctl.h>
 #include <sys/syscall.h>
 #include <sys/mman.h>
@@ -21,8 +22,20 @@
 #include <errno.h>
 #include <stdarg.h>
 
+#include <linux/unistd.h>
+
 #include "luo_test_utils.h"
 
+int sys_ftruncate(int fd, off_t length)
+{
+	return my_syscall2(__NR_ftruncate, fd, length);
+}
+
+int ftruncate(int fd, off_t length)
+{
+	return __sysret(sys_ftruncate(fd, length));
+}
+
 int luo_open_device(void)
 {
 	return open(LUO_DEVICE, O_RDWR);
@@ -32,8 +45,8 @@ int luo_create_session(int luo_fd, const char *name)
 {
 	struct liveupdate_ioctl_create_session arg = { .size = sizeof(arg) };
 
-	snprintf((char *)arg.name, LIVEUPDATE_SESSION_NAME_LENGTH, "%.*s",
-		 LIVEUPDATE_SESSION_NAME_LENGTH - 1, name);
+	strncpy((char *)arg.name, name, LIVEUPDATE_SESSION_NAME_LENGTH);
+	arg.name[LIVEUPDATE_SESSION_NAME_LENGTH - 1] = '\0';
 
 	if (ioctl(luo_fd, LIVEUPDATE_IOCTL_CREATE_SESSION, &arg) < 0)
 		return -errno;
@@ -45,8 +58,8 @@ int luo_retrieve_session(int luo_fd, const char *name)
 {
 	struct liveupdate_ioctl_retrieve_session arg = { .size = sizeof(arg) };
 
-	snprintf((char *)arg.name, LIVEUPDATE_SESSION_NAME_LENGTH, "%.*s",
-		 LIVEUPDATE_SESSION_NAME_LENGTH - 1, name);
+	strncpy((char *)arg.name, name, LIVEUPDATE_SESSION_NAME_LENGTH);
+	arg.name[LIVEUPDATE_SESSION_NAME_LENGTH - 1] = '\0';
 
 	if (ioctl(luo_fd, LIVEUPDATE_IOCTL_RETRIEVE_SESSION, &arg) < 0)
 		return -errno;
@@ -57,7 +70,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;
 
@@ -93,7 +106,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;
 
@@ -204,16 +217,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);
@@ -224,6 +232,7 @@ static int parse_stage_args(int argc, char *argv[])
 			fail_exit("Unknown argument");
 		}
 	}
+
 	return stage;
 }
 
@@ -251,7 +260,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.sh new file +68 -0

68 lines not on this page · raw message

base-commit: 0f61b1860cc3f52aef9036d7235ed1f017632193 --
2.52.0.457.g6b5491de43-goog

maintainer
#1 lore raw
Quoted 37 lines · Jordan Richards

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.

luo_test.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.sh:
A wrapper script to discover and execute all luo_*.c tests across supported architectures, providing a summary of pass/fail/skip results.

---
Changelog since luo v7 [1]:
- Build test binaries with -nostdlib -nostdinc
- Use minimal per-arch config instead of defconfig
- Unhandled test errors now cause the test to fail instead of skip

[1] https://lore.kernel.org/all/[email protected]/

...

tools/testing/selftests/liveupdate/.gitignore line 11

Quoted 11 lines
tools/testing/selftests/liveupdate/.gitignore +2 -0
index 661827083ab6..7dc1e8aec44c 100644
@@ -6,4 +6,6 @@
 !*.sh
 !.gitignore
 !config
+!config.aarch64
+!config.x86_64
 !Makefile

Hmm, I missed it when tools/testing/selftests/liveupdate/ was posted. I'm not a huge fun of negative logic in .gitignore.
Why can't we just exclude the patterns we don't want to track?

Quoted 35 lines
tools/testing/selftests/liveupdate/.gitignore +35 -0
+static int kexec_load(void)
+{
+	char cmdline[COMMAND_LINE_SIZE];
+	int kernel_fd, initrd_fd, err;
+	ssize_t len;
+	int fd;
+
+	fd = open("/proc/cmdline", O_RDONLY);
+	if (fd < 0) {
+		fprintf(stderr, "INIT: Failed to read /proc/cmdline\n");
+
+		return -1;
+	}
+
+	len = read(fd, cmdline, sizeof(cmdline) - 1);
+	close(fd);
+	if (len < 0)
+		return -1;
+
+	cmdline[len] = 0;
+	if (len > 0 && cmdline[len - 1] == '\n')
+		cmdline[len - 1] = 0;
+
+	strncat(cmdline, " luo_stage=2", sizeof(cmdline) - strlen(cmdline) - 1);
+
+	kernel_fd = open(KERNEL_IMAGE, O_RDONLY);
+	if (kernel_fd < 0) {
+		fprintf(stderr, "INIT: Failed to open kernel image\n");
+		return -1;
+	}
+
+	initrd_fd = open(INITRD_IMAGE, O_RDONLY);
+	if (initrd_fd < 0) {
+		fprintf(stderr, "INIT: Failed to open initrd image\n");
+		close(kernel_fd);

tools/testing/selftests/liveupdate/.gitignore

Quoted 10 lines
tools/testing/selftests/liveupdate/.gitignore +10 -0
+		return -1;
+	}
+
+	err = kexec_file_load(kernel_fd, initrd_fd, strlen(cmdline) + 1,
+			      cmdline, 0);
+
+	close(initrd_fd);
+	close(kernel_fd);
+
+	return err ? : 0;

Just return err?

Quoted 5 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +0 -0
new file mode 100755
index 000000000000..90ecb16e87bb

...

tools/testing/selftests/liveupdate/luo_test.sh line 85

Quoted 4 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +4 -0
+function detect_cross_compile() {
+	local target=$1
+	local host=$(uname -m)
+

This function works fine if you run luo_test.sh directly or have cross compilers named the way it expects in $PATH.

But if I run CROSS_COMPILE=~/cross/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux- ./run.sh on x86, x86 tests fail

Quoted 37 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +37 -0
+	if [ -n "$CROSS_COMPILE" ]; then
+		return
+	fi
+
+	[[ "$host" == "arm64" ]] && host="aarch64"
+	[[ "$target" == "arm64" ]] && target="aarch64"
+
+	if [[ "$host" == "$target" ]]; then
+		CROSS_COMPILE=""
+		return
+	fi
+
+	local candidate=""
+	case "$target" in
+		aarch64) candidate="aarch64-linux-gnu-" ;;
+		x86_64)  candidate="x86_64-linux-gnu-" ;;
+		*)       skip "Auto-detection for target '$target' not supported. Please set CROSS_COMPILE manually." ;;
+	esac
+
+	if command -v "${candidate}gcc" &> /dev/null; then
+		CROSS_COMPILE="$candidate"
+	else
+		skip "Compiler '${candidate}gcc' not found. Please install it (e.g., 'apt install gcc-aarch64-linux-gnu') or set CROSS_COMPILE."
+	fi
+}
+
+function build_kernel() {
+	local build_dir=$1
+	local make_cmd=$2
+	local kimage=$3
+	local target_arch=$4
+
+	local kconfig="$build_dir/.config"
+	local common_conf="$test_dir/config"
+	local arch_conf="$test_dir/config.$target_arch"
+
+	echo "# Building kernel in: $build_dir"

tools/testing/selftests/liveupdate/luo_test.sh line 132

Quoted 10 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +10 -0
+
+	local fragments=()
+
+	if [[ -f "$common_conf" ]]; then
+		fragments+=("$common_conf")
+	fi
+
+	if [[ -f "$arch_conf" ]]; then
+		fragments+=("$arch_conf")
+	fi

I think the common and arch config fragments are required and we can just assign fragments directly and run merge_config.sh.

Quoted 14 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +14 -0
+
+	if [[ ${#fragments[@]} > 1 ]]; then
+		echo $fragments
+		"$kernel_dir/scripts/kconfig/merge_config.sh" \
+			-Q -m -O "$build_dir" "${fragments[@]}" >> /dev/null
+	else
+		cp ${fragments[0]} $kconfig
+	fi
+	cat $kconfig
+
+	$make_cmd olddefconfig
+	$make_cmd "$kimage"
+	$make_cmd headers_install INSTALL_HDR_PATH="$headers_dir"
+}

...

Quoted 7 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +7 -0
+function run_qemu() {
+	local qemu_cmd=$1
+	local cmdline=$2
+	local kernel_path=$3
+	local serial="$workspace_dir/qemu.serial"
+
+	local accel="-accel tcg"

tools/testing/selftests/liveupdate/luo_test.sh line 212

Quoted 10 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +10 -0
+	local host_machine=$(uname -m)
+
+	[[ "$host_machine" == "arm64" ]] && host_machine="aarch64"
+	[[ "$host_machine" == "x86_64" ]] && host_machine="x86_64"
+
+	if [[ "$qemu_cmd" == *"$host_machine"* ]]; then
+		if [ -w /dev/kvm ]; then
+			accel="-accel kvm"
+		fi
+	fi

Do we care that much about qemu warnings about invalid accelerator to have this logic here?

-accel kvm -accel hvf -accel tcg

seems to cover all bases.

Quoted 3 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +3 -0
+
+	cmdline="$cmdline liveupdate=on panic=-1"
+

...

tools/testing/selftests/liveupdate/luo_test_utils.c line 16

Quoted 9 lines
tools/testing/selftests/liveupdate/luo_test_utils.c +1 -0
index 3c8721c505df..7ee80b6ed4cb 100644
@@ -13,6 +13,7 @@
 #include <getopt.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <sys.h>

This breaks running normal make:

luo_test_utils.c:16:10: fatal error: sys.h: No such file or directory
16 | #include <sys.h>

      |          ^~~~~~~

NOLIBC specific includes and calls should be guarded with #ifdef NOLIBC

Quoted 10 lines
tools/testing/selftests/liveupdate/luo_test_utils.c +2 -0
 #include <sys/ioctl.h>
 #include <sys/syscall.h>
 #include <sys/mman.h>
@@ -21,8 +22,20 @@
 #include <errno.h>
 #include <stdarg.h>
 
+#include <linux/unistd.h>
+
 #include "luo_test_utils.h"

tools/testing/selftests/liveupdate/luo_test_utils.c line 37

Quoted 10 lines
tools/testing/selftests/liveupdate/luo_test_utils.c +9 -0
 
+int sys_ftruncate(int fd, off_t length)
+{
+	return my_syscall2(__NR_ftruncate, fd, length);
+}
+
+int ftruncate(int fd, off_t length)
+{
+	return __sysret(sys_ftruncate(fd, length));
+}

These should be added to nolibc I suppose.

tools/testing/selftests/liveupdate/luo_test_utils.c line 38

Quoted 1 line
tools/testing/selftests/liveupdate/luo_test_utils.c +1 -0
+

,,,

tools/testing/selftests/liveupdate/run.sh line 4

Quoted 10 lines
tools/testing/selftests/liveupdate/run.sh new file +4 -0
new file mode 100755
index 000000000000..3f6b29a26648
@@ -0,0 +1,68 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+OUTPUT_DIR="results_$(date +%Y%m%d_%H%M%S)"

I don't think that putting the results in the current directory rather than in SCRIPT_DIR or in an explicitly named directory is a good idea.

Quoted 10 lines
tools/testing/selftests/liveupdate/run.sh new file +10 -0
+SCRIPT_DIR=$(dirname "$(realpath "$0")")
+TEST_RUNNER="$SCRIPT_DIR/luo_test.sh"
+
+TARGETS=("x86_64" "aarch64")
+
+GREEN='\033[0;32m'
+RED='\033[0;31m'
+YELLOW='\033[1;33m'
+NC='\033[0m'
+

tools/testing/selftests/liveupdate/run.sh line 24

Quoted 10 lines
tools/testing/selftests/liveupdate/run.sh new file +10 -0
+PASSED=()
+FAILED=()
+SKIPPED=()
+
+mkdir -p "$OUTPUT_DIR"
+
+TEST_NAMES=()
+while IFS= read -r file; do
+    TEST_NAMES+=("$(basename "$file" .c)")
+done < <(find "$SCRIPT_DIR" -maxdepth 1 -name "luo_*.c" ! -name "luo_test_utils.c")

I don't like name based detection of tests. Listing them explicitly seems a viable option.

Quoted 6 lines
tools/testing/selftests/liveupdate/run.sh new file +6 -0
+
+if [ ${#TEST_NAMES[@]} -eq 0 ]; then
+    echo "No tests found in $SCRIPT_DIR"
+    exit 1
+fi
+
Signature · 2 lines
Sincerely yours,
Mike.
#2 lore raw
Quoted 12 lines · Mike Rapoport

tools/testing/selftests/liveupdate/.gitignore line 10

Quoted 10 lines · Jordan Richards
tools/testing/selftests/liveupdate/.gitignore +2 -0
index 661827083ab6..7dc1e8aec44c 100644
@@ -6,4 +6,6 @@
 !*.sh
 !.gitignore
 !config
+!config.aarch64
+!config.x86_64

This could be:

!config.*

Quoted 5 lines

tools/testing/selftests/liveupdate/.gitignore line 11

Quoted 1 line
tools/testing/selftests/liveupdate/.gitignore +0 -0
 !Makefile

Hmm, I missed it when tools/testing/selftests/liveupdate/ was posted. I'm not a huge fun of negative logic in .gitignore.
Why can't we just exclude the patterns we don't want to track?

I'm pretty sure this came from me. It's the pattern we use for VFIO and KVM selftests .gitignore.

Positive logic requires updating .gitignore for every new executable (every new selftest). Negative logic requires updating .gitignore for every new one-off files that don't match the existing negative logic. In my experience with selftests, the former happens more frequently than the latter, so the negative logic is easier to maintain.

#3 lore raw
In reply to Mike Rapoport

Hi Mike,

Thanks for the feedback.

Quoted 11 lines

tools/testing/selftests/liveupdate/luo_test_utils.c line 37

Quoted 9 lines
tools/testing/selftests/liveupdate/luo_test_utils.c +9 -0
+int sys_ftruncate(int fd, off_t length)
+{
+     return my_syscall2(__NR_ftruncate, fd, length);
+}
+
+int ftruncate(int fd, off_t length)
+{
+     return __sysret(sys_ftruncate(fd, length));
+}

These should be added to nolibc I suppose.

I notice that nolibc has its own tree. If I patch nolibc/sys.h, will those changes make their way there? Or should I avoid modifying nolibc/sys.h and keep this local copy for now, to be removed if/when ftruncate is added to nolibc?

maintainer
#4 lore raw
Quoted 16 lines · Jordan Richards

Hi Mike,

Thanks for the feedback.

Quoted 11 lines

tools/testing/selftests/liveupdate/luo_test_utils.c line 37

Quoted 9 lines
tools/testing/selftests/liveupdate/luo_test_utils.c +9 -0
+int sys_ftruncate(int fd, off_t length)
+{
+     return my_syscall2(__NR_ftruncate, fd, length);
+}
+
+int ftruncate(int fd, off_t length)
+{
+     return __sysret(sys_ftruncate(fd, length));
+}

These should be added to nolibc I suppose.

Quoted 4 lines

I notice that nolibc has its own tree. If I patch nolibc/sys.h, will those changes make their way there? Or should I avoid modifying nolibc/sys.h and keep this local copy for now, to be removed if/when ftruncate is added to nolibc?

I think you can make this a set of two patches: the first that adds ftruncate to nolibc and the second with LUO test.

Then with an Ack from nolibc maintainer both can be merged via Andrew's tree.

Signature · 2 lines
Sincerely yours,
Mike.
#5 lore raw
In reply to Mike Rapoport

Sending v2 addressing this feedback soon:

Quoted 9 lines

tools/testing/selftests/liveupdate/init.c line 95

Quoted 7 lines
tools/testing/selftests/liveupdate/init.c new file +7 -0
+	err = kexec_file_load(kernel_fd, initrd_fd, strlen(cmdline) + 1,
+			      cmdline, 0);
+
+	close(initrd_fd);
+	close(kernel_fd);
+
+	return err ? : 0;

Just return err?

Good point, fixed.

Quoted 20 lines
Quoted 5 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +0 -0
new file mode 100755
index 000000000000..90ecb16e87bb

...

tools/testing/selftests/liveupdate/luo_test.sh line 85

Quoted 4 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +4 -0
+function detect_cross_compile() {
+	local target=$1
+	local host=$(uname -m)
+

This function works fine if you run luo_test.sh directly or have cross compilers named the way it expects in $PATH.

But if I run CROSS_COMPILE=~/cross/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux- ./run.sh on x86, x86 tests fail

Quoted 11 lines

tools/testing/selftests/liveupdate/luo_test.sh line 96

Quoted 11 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +11 -0
+	if [ -n "$CROSS_COMPILE" ]; then
+		return
+	fi
+
+	[[ "$host" == "arm64" ]] && host="aarch64"
+	[[ "$target" == "arm64" ]] && target="aarch64"
+
+	if [[ "$host" == "$target" ]]; then
+		CROSS_COMPILE=""
+		return
+	fi

The host==target test needed to be first, fixed.

Quoted 4 lines
Quoted 4 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +4 -0
+	local fragments=()
+
+	if [[ -f "$common_conf" ]]; then
+		fragments+=("$common_conf")
Quoted 8 lines

tools/testing/selftests/liveupdate/luo_test.sh line 132

Quoted 5 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +5 -0
+	fi
+
+	if [[ -f "$arch_conf" ]]; then
+		fragments+=("$arch_conf")
+	fi

I think the common and arch config fragments are required and we can just assign fragments directly and run merge_config.sh.

Done.

I wasn't sure if arch_conf would be necessary for all architectures, but it is kind of needless complexity.

Quoted 6 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +5 -0
+	if [[ "$qemu_cmd" == *"$host_machine"* ]]; then
+		if [ -w /dev/kvm ]; then
+			accel="-accel kvm"
+		fi
+	fi
Quoted 6 lines

Do we care that much about qemu warnings about invalid accelerator to have this logic here?

-accel kvm -accel hvf -accel tcg

seems to cover all bases.

The warning doesn't break the tests, so it should be fine.

Quoted 9 lines
Quoted 1 line

+#include <sys.h>

This breaks running normal make:

luo_test_utils.c:16:10: fatal error: sys.h: No such file or directory
16 | #include <sys.h>

     |          ^~~~~~~

NOLIBC specific includes and calls should be guarded with #ifdef NOLIBC

Done.

Quoted 11 lines
tools/testing/selftests/liveupdate/run.sh new file +3 -0
new file mode 100755
index 000000000000..3f6b29a26648
@@ -0,0 +1,68 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
Quoted 1 line

+OUTPUT_DIR="results_$(date +%Y%m%d_%H%M%S)"

Quoted 2 lines

I don't think that putting the results in the current directory rather than in SCRIPT_DIR or in an explicitly named directory is a good idea.

Changed to "$SCRIPT_DIR/results_*".

Quoted 6 lines

tools/testing/selftests/liveupdate/luo_test.sh

Quoted 4 lines
tools/testing/selftests/liveupdate/luo_test.sh new file +4 -0
+TEST_NAMES=()
+while IFS= read -r file; do
+    TEST_NAMES+=("$(basename "$file" .c)")
+done < <(find "$SCRIPT_DIR" -maxdepth 1 -name "luo_*.c" ! -name "luo_test_utils.c")

I don't like name based detection of tests. Listing them explicitly seems a

viable option.

Agreed, changed to a fixed array.