linux/tools/testing/selftests/liveupdate/run-vmtests.sh
Pasha Tatashin 89dd1421c5 selftests/liveupdate: add end to end test infrastructure and scripts
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.

Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Co-developed-by: Jordan Richards <jordanrichards@google.com>
Signed-off-by: Jordan Richards <jordanrichards@google.com>
Co-developed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Pratyush Yadav <pratyush@kernel.org>
Link: https://patch.msgid.link/20260626-luo-vmtest-v0-v4-1-e7d3111cd5b3@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
2026-07-10 11:07:54 +03:00

98 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
SCRIPT_DIR=$(dirname "$(realpath "$0")")
TEST_RUNNER="$SCRIPT_DIR/vmtest.sh"
TARGETS=("x86_64" "aarch64")
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
passed=0
failed=0
skipped=0
TEST_NAMES=(
"luo_kexec_simple"
"luo_multi_session"
"luo_stress_files"
"luo_stress_sessions"
)
function usage() {
cat <<EOF
$0 [-k] [-o output_dir] [-h]
Options:
-k) keep logs
-o) specify output directory
-h) display this help
EOF
}
function pass() {
echo -e "${GREEN}PASS${NC}"
((passed++))
}
function skip() {
echo -e "${YELLOW}SKIP${NC}"
((skipped++))
}
function fail() {
echo -e "${RED}FAIL${NC}"
((failed++))
}
function main() {
while getopts 'hko:' opt; do
case $opt in
k) keep_logs=1 ;;
o) output_dir=$OPTARG ;;
h) usage; exit 0 ;;
*) echo Unknown argument "$opt"
usage; exit 1 ;;
esac
done
if [ -n "$keep_logs" ]; then
if [ -z "$output_dir" ]; then
output_dir="$SCRIPT_DIR/results_$(date +%Y%m%d_%H%M%S)"
fi;
mkdir -p "$output_dir"
else
output_dir=$(mktemp -d /tmp/luo.XXXXXXXX)
trap 'rm -fr "$output_dir"' EXIT
fi
for arch in "${TARGETS[@]}"; do
for test_name in "${TEST_NAMES[@]}"; do
log="$output_dir/${arch}_${test_name}.log"
printf " -> %-8s %-24s ... " "$arch" "$test_name"
"$TEST_RUNNER" -t "$arch" -T "$test_name" &> "$log"
exit_code=$?
case $exit_code in
0) pass;;
4) skip;;
*) fail;;
esac
done
echo ""
done
echo "SUMMARY: PASS=$passed SKIP=$skipped FAIL=$failed"
if [ -n "$keep_logs" ]; then
echo "Logs: $output_dir"
fi
exit $((failed != 0))
}
main "$@"