From fcd69fb70707aafee97be32600bbc2ec2df4b153 Mon Sep 17 00:00:00 2001 From: Anirudh Rayabharam Date: Mon, 6 Apr 2026 14:02:59 +0000 Subject: [PATCH] tests: consolidate test config into nextest profiles Centralize test configuration (filters, retries, fail-fast, sequential/parallel scheduling) into nextest profiles, replacing scattered flags across shell scripts. This simplifies the scripts and provides a single source of truth for test behavior. Enable JUnit XML output per profile, giving CI systems structured test results for better reporting. Not all test invocations are converted to profiles yet. Just the ones that are repeated across scripts. Signed-off-by: Anirudh Rayabharam --- .config/nextest.toml | 35 ++++++++++++++++++++++++ scripts/common-aarch64.sh | 1 + scripts/run_integration_tests_aarch64.sh | 29 ++++++-------------- scripts/run_integration_tests_cvm.sh | 3 +- scripts/run_integration_tests_x86_64.sh | 16 ++++------- 5 files changed, 52 insertions(+), 32 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index a88e59909..4c5f04191 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,3 +1,38 @@ [profile.default] # Don't let one individual test run for more than 10 minutes slow-timeout = { period = "60s", terminate-after = 10 } + +[profile.integration] +fail-fast = false +retries = 3 + +[profile.common_tests] +inherits = "integration" +default-filter = 'test(common_parallel::) | test(common_sequential::) | test(aarch64_acpi::)' +junit.path = "/root/workloads/junit/common.xml" + +[[profile.common_tests.overrides]] +filter = 'test(common_sequential::)' +# use up all the available test threads for each of the sequential tests +# i.e. no other test can be running while a sequential test is running. +threads-required = 'num-test-threads' + +[profile.dbus] +inherits = "integration" +default-filter = 'test(dbus_api::)' +junit.path = "/root/workloads/junit/dbus.xml" + +[profile.fw_cfg] +inherits = "integration" +default-filter = 'test(fw_cfg::)' +junit.path = "/root/workloads/junit/fw_cfg.xml" + +[profile.ivshmem] +inherits = "integration" +default-filter = 'test(ivshmem::)' +junit.path = "/root/workloads/junit/ivshmem.xml" + +[profile.common_cvm] +inherits = "integration" +default-filter = 'test(common_cvm::)' +junit.path = "/root/workloads/junit/cvm.xml" diff --git a/scripts/common-aarch64.sh b/scripts/common-aarch64.sh index 1c0b87519..bde96f268 100644 --- a/scripts/common-aarch64.sh +++ b/scripts/common-aarch64.sh @@ -3,6 +3,7 @@ WORKLOADS_DIR="$HOME/workloads" mkdir -p "$WORKLOADS_DIR" +mkdir -p "$WORKLOADS_DIR/junit" build_edk2() { EDK2_BUILD_DIR="$WORKLOADS_DIR/edk2_build" diff --git a/scripts/run_integration_tests_aarch64.sh b/scripts/run_integration_tests_aarch64.sh index 0e728e4b5..02beb5c75 100755 --- a/scripts/run_integration_tests_aarch64.sh +++ b/scripts/run_integration_tests_aarch64.sh @@ -243,24 +243,13 @@ if ! [[ "${PARALLEL_INTEGRATION_TESTS_NUM:-}" =~ ^[1-9][0-9]*$ ]]; then PARALLEL_INTEGRATION_TESTS_NUM="${TEST_THREADS_DEFAULT}" fi echo "nproc:$(nproc), parallel_integration_tests:${PARALLEL_INTEGRATION_TESTS_NUM}" -# Run all direct kernel boot (Device Tree) test cases in mod `parallel` -time cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads="${PARALLEL_INTEGRATION_TESTS_NUM}" "common_parallel::$test_filter" -- ${test_binary_args[*]} +# Run all direct kernel boot (Device Tree) test cases in mod `parallel`, +# `sequential`, and ACPI cases. The `common_tests` profile filter covers +# all three sets, and the per-mod `threads-required = 'num-test-threads'` +# override on `common_sequential` enforces serial scheduling within the run. +time cargo nextest run -p cloud-hypervisor $test_features --profile common_tests --no-tests=pass --test-threads="${PARALLEL_INTEGRATION_TESTS_NUM}" "$test_filter" -- ${test_binary_args[*]} RES=$? - -# Run some tests in sequence since the result could be affected by other tests -# running in parallel. -if [ $RES -eq 0 ]; then - time cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads=1 "common_sequential::$test_filter" -- ${test_binary_args[*]} - RES=$? -else - exit $RES -fi - -# Run all ACPI test cases -if [ $RES -eq 0 ]; then - time cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "aarch64_acpi::$test_filter" -- ${test_binary_args[*]} - RES=$? -else +if [ $RES -ne 0 ]; then exit $RES fi @@ -269,7 +258,7 @@ if [ $RES -eq 0 ]; then cargo build --features "mshv,dbus_api" --all --release --target "$BUILD_TARGET" export RUST_BACKTRACE=1 # integration tests now do not reply on build feature "dbus_api" - time cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "dbus_api::$test_filter" -- ${test_binary_args[*]} + time cargo nextest run -p cloud-hypervisor $test_features --profile dbus --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "$test_filter" -- ${test_binary_args[*]} RES=$? fi @@ -277,14 +266,14 @@ fi if [ $RES -eq 0 ]; then cargo build --features "mshv,fw_cfg" --all --release --target "$BUILD_TARGET" export RUST_BACKTRACE=1 - time cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "fw_cfg::$test_filter" -- ${test_binary_args[*]} + time cargo nextest run -p cloud-hypervisor $test_features --profile fw_cfg --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "$test_filter" -- ${test_binary_args[*]} RES=$? fi if [ $RES -eq 0 ]; then cargo build --features "mshv,ivshmem" --all --release --target "$BUILD_TARGET" export RUST_BACKTRACE=1 - time cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "ivshmem::$test_filter" -- ${test_binary_args[*]} + time cargo nextest run -p cloud-hypervisor $test_features --profile ivshmem --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "$test_filter" -- ${test_binary_args[*]} RES=$? fi diff --git a/scripts/run_integration_tests_cvm.sh b/scripts/run_integration_tests_cvm.sh index aa4adfce3..d0022c7fa 100755 --- a/scripts/run_integration_tests_cvm.sh +++ b/scripts/run_integration_tests_cvm.sh @@ -8,6 +8,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/test-util.sh" WORKLOADS_DIR="$HOME/workloads" mkdir -p "$WORKLOADS_DIR" +mkdir -p "$WORKLOADS_DIR/junit" process_common_args "$@" @@ -27,7 +28,7 @@ popd || exit cargo build --features $build_features --all --release --target "$BUILD_TARGET" export RUST_BACKTRACE=1 -time cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads=$(($(nproc) / 4)) "common_cvm::$test_filter" -- ${test_binary_args[*]} +time cargo nextest run -p cloud-hypervisor $test_features --profile common_cvm --no-tests=pass --test-threads=$(($(nproc) / 4)) "$test_filter" -- ${test_binary_args[*]} RES=$? exit $RES diff --git a/scripts/run_integration_tests_x86_64.sh b/scripts/run_integration_tests_x86_64.sh index 99d0e54ef..de7e4bb9a 100755 --- a/scripts/run_integration_tests_x86_64.sh +++ b/scripts/run_integration_tests_x86_64.sh @@ -8,6 +8,7 @@ source "$(dirname "$0")"/test-util.sh WORKLOADS_DIR="$HOME/workloads" mkdir -p "$WORKLOADS_DIR" +mkdir -p "$WORKLOADS_DIR/junit" process_common_args "$@" @@ -225,34 +226,27 @@ if ! [[ "${PARALLEL_INTEGRATION_TESTS_NUM:-}" =~ ^[1-9][0-9]*$ ]]; then PARALLEL_INTEGRATION_TESTS_NUM="${TEST_THREADS_DEFAULT}" fi echo "nproc:$(nproc), parallel_integration_tests:${PARALLEL_INTEGRATION_TESTS_NUM}" -time cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads="${PARALLEL_INTEGRATION_TESTS_NUM}" "common_parallel::$test_filter" -- ${test_binary_args[*]} +time cargo nextest run -p cloud-hypervisor $test_features --profile common_tests --no-tests=pass --test-threads="${PARALLEL_INTEGRATION_TESTS_NUM}" "$test_filter" -- ${test_binary_args[*]} RES=$? -# Run some tests in sequence since the result could be affected by other tests -# running in parallel. -if [ $RES -eq 0 ]; then - cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads=1 "common_sequential::$test_filter" -- ${test_binary_args[*]} - RES=$? -fi - # Run tests on dbus_api if [ $RES -eq 0 ]; then cargo build --features "mshv,dbus_api" --all --release --target "$BUILD_TARGET" # integration tests now do not reply on build feature "dbus_api" - time cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "dbus_api::$test_filter" -- ${test_binary_args[*]} + time cargo nextest run -p cloud-hypervisor $test_features --profile dbus --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "$test_filter" -- ${test_binary_args[*]} RES=$? fi # Run tests on fw_cfg if [ $RES -eq 0 ]; then cargo build --features "mshv,fw_cfg" --all --release --target "$BUILD_TARGET" - time cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "fw_cfg::$test_filter" -- ${test_binary_args[*]} + time cargo nextest run -p cloud-hypervisor $test_features --profile fw_cfg --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "$test_filter" -- ${test_binary_args[*]} RES=$? fi if [ $RES -eq 0 ]; then cargo build --features "mshv,ivshmem" --all --release --target "$BUILD_TARGET" - time cargo nextest run -p cloud-hypervisor $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "ivshmem::$test_filter" -- ${test_binary_args[*]} + time cargo nextest run -p cloud-hypervisor $test_features --profile ivshmem --no-tests=pass --test-threads="$TEST_THREADS_DEFAULT" "$test_filter" -- ${test_binary_args[*]} RES=$? fi