From 3734a13cbf306ed098f94bbe3641c9a155cef6fe Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 14 Nov 2025 15:04:59 +0000 Subject: [PATCH] tests: Use cargo nextest for integration tests This alternative test runner supports retries and also reports how long each test takes to run. Signed-off-by: Rob Bradford --- scripts/run_integration_tests_aarch64.sh | 20 ++++++++++--------- .../run_integration_tests_live_migration.sh | 5 +++-- scripts/run_integration_tests_rate_limiter.sh | 2 +- scripts/run_integration_tests_vfio.sh | 2 +- .../run_integration_tests_windows_aarch64.sh | 2 +- .../run_integration_tests_windows_x86_64.sh | 2 +- scripts/run_integration_tests_x86_64.sh | 10 +++++----- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/scripts/run_integration_tests_aarch64.sh b/scripts/run_integration_tests_aarch64.sh index 483c9e8d3..af6b4773c 100755 --- a/scripts/run_integration_tests_aarch64.sh +++ b/scripts/run_integration_tests_aarch64.sh @@ -208,13 +208,13 @@ echo "$PAGE_NUM" | sudo tee /proc/sys/vm/nr_hugepages sudo chmod a+rwX /dev/hugepages # Run all direct kernel boot (Device Tree) test cases in mod `parallel` -time cargo test "common_parallel::$test_filter" --target "$BUILD_TARGET" $test_features -- --test-threads=$(($(nproc) / 8)) ${test_binary_args[*]} +time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=$(($(nproc) / 4)) "common_parallel::$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 test "common_sequential::$test_filter" --target "$BUILD_TARGET" $test_features -- --test-threads=1 ${test_binary_args[*]} + time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=1 "common_sequential::$test_filter" -- ${test_binary_args[*]} RES=$? else exit $RES @@ -222,7 +222,7 @@ fi # Run all ACPI test cases if [ $RES -eq 0 ]; then - time cargo test "aarch64_acpi::$test_filter" --target "$BUILD_TARGET" $test_features -- ${test_binary_args[*]} + time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=$(($(nproc) / 4)) "aarch64_acpi::$test_filter" -- ${test_binary_args[*]} RES=$? else exit $RES @@ -230,14 +230,14 @@ fi # Run all test cases related to live migration if [ $RES -eq 0 ]; then - time cargo test "live_migration_parallel::$test_filter" --target "$BUILD_TARGET" $test_features -- ${test_binary_args[*]} + time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=$(($(nproc) / 4)) "live_migration_parallel::$test_filter" -- ${test_binary_args[*]} RES=$? else exit $RES fi if [ $RES -eq 0 ]; then - time cargo test "live_migration_sequential::$test_filter" --target "$BUILD_TARGET" $test_features -- --test-threads=1 ${test_binary_args[*]} + time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=1 "live_migration_sequential::$test_filter" -- ${test_binary_args[*]} RES=$? else exit $RES @@ -247,7 +247,8 @@ fi if [ $RES -eq 0 ]; then cargo build --features "dbus_api" --all --release --target "$BUILD_TARGET" export RUST_BACKTRACE=1 - time cargo test "dbus_api::$test_filter" --target "$BUILD_TARGET" -- ${test_binary_args[*]} + # integration tests now do not reply on build feature "dbus_api" + time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=$(($(nproc) / 4)) "dbus_api::$test_filter" -- ${test_binary_args[*]} RES=$? fi @@ -255,14 +256,15 @@ fi if [ $RES -eq 0 ]; then cargo build --features "fw_cfg" --all --release --target "$BUILD_TARGET" export RUST_BACKTRACE=1 - time cargo test "fw_cfg::$test_filter" --target "$BUILD_TARGET" -- ${test_binary_args[*]} + time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=$(($(nproc) / 4)) "fw_cfg::$test_filter" -- ${test_binary_args[*]} RES=$? fi if [ $RES -eq 0 ]; then - cargo build --features ivshmem --all --release --target "$BUILD_TARGET" + cargo build --features "ivshmem" --all --release --target "$BUILD_TARGET" export RUST_BACKTRACE=1 - time cargo test "ivshmem::$test_filter" --target "$BUILD_TARGET" -- ${test_binary_args[*]} + time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=$(($(nproc) / 4)) "ivshmem::$test_filter" -- ${test_binary_args[*]} + RES=$? fi diff --git a/scripts/run_integration_tests_live_migration.sh b/scripts/run_integration_tests_live_migration.sh index fa0b3dcf4..38ddd9e38 100755 --- a/scripts/run_integration_tests_live_migration.sh +++ b/scripts/run_integration_tests_live_migration.sh @@ -84,14 +84,15 @@ echo "$PAGE_NUM" | sudo tee /proc/sys/vm/nr_hugepages sudo chmod a+rwX /dev/hugepages export RUST_BACKTRACE=1 -time cargo test $test_features "live_migration_parallel::$test_filter" -- ${test_binary_args[*]} +time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=$(($(nproc) / 4)) "live_migration_parallel::$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 export RUST_BACKTRACE=1 - time cargo test $test_features "live_migration_sequential::$test_filter" -- --test-threads=1 ${test_binary_args[*]} + time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=1 "live_migration_sequential::$test_filter" -- ${test_binary_args[*]} RES=$? fi diff --git a/scripts/run_integration_tests_rate_limiter.sh b/scripts/run_integration_tests_rate_limiter.sh index fd9f689a3..1ae897594 100755 --- a/scripts/run_integration_tests_rate_limiter.sh +++ b/scripts/run_integration_tests_rate_limiter.sh @@ -56,7 +56,7 @@ fi cargo build --features mshv --all --release --target "$BUILD_TARGET" export RUST_BACKTRACE=1 -time cargo test $test_features "rate_limiter::$test_filter" -- --test-threads=1 ${test_binary_args[*]} +time cargo nextest run $test_features --test-threads=1 "rate_limiter::$test_filter" -- ${test_binary_args[*]} RES=$? exit $RES diff --git a/scripts/run_integration_tests_vfio.sh b/scripts/run_integration_tests_vfio.sh index 4d7bac60a..1f36f9580 100755 --- a/scripts/run_integration_tests_vfio.sh +++ b/scripts/run_integration_tests_vfio.sh @@ -27,7 +27,7 @@ fi cargo build --features mshv --all --release --target "$BUILD_TARGET" export RUST_BACKTRACE=1 -time cargo test "vfio::test_nvidia" -- --test-threads=1 ${test_binary_args[*]} +time cargo nextest run --test-threads=1 "vfio::test_nvidia" -- ${test_binary_args[*]} RES=$? exit $RES diff --git a/scripts/run_integration_tests_windows_aarch64.sh b/scripts/run_integration_tests_windows_aarch64.sh index 92d66f805..a4dcda7a6 100755 --- a/scripts/run_integration_tests_windows_aarch64.sh +++ b/scripts/run_integration_tests_windows_aarch64.sh @@ -42,7 +42,7 @@ cargo build --all --release --target "$BUILD_TARGET" # Only run with 1 thread to avoid tests interfering with one another because # Windows has a static IP configured -time cargo test "windows::$test_filter" --target "$BUILD_TARGET" -- ${test_binary_args[*]} +time cargo nextest run "windows::$test_filter" --target "$BUILD_TARGET" -- ${test_binary_args[*]} RES=$? dmsetup remove_all -f diff --git a/scripts/run_integration_tests_windows_x86_64.sh b/scripts/run_integration_tests_windows_x86_64.sh index 2b11a6e68..970803829 100755 --- a/scripts/run_integration_tests_windows_x86_64.sh +++ b/scripts/run_integration_tests_windows_x86_64.sh @@ -45,7 +45,7 @@ export RUST_BACKTRACE=1 # Only run with 1 thread to avoid tests interfering with one another because # Windows has a static IP configured -time cargo test $test_features "windows::$test_filter" -- ${test_binary_args[*]} +time cargo nextest run $test_features "windows::$test_filter" --target "$BUILD_TARGET" -- ${test_binary_args[*]} RES=$? dmsetup remove_all -f diff --git a/scripts/run_integration_tests_x86_64.sh b/scripts/run_integration_tests_x86_64.sh index 1d9c56be7..1b2990a66 100755 --- a/scripts/run_integration_tests_x86_64.sh +++ b/scripts/run_integration_tests_x86_64.sh @@ -178,14 +178,14 @@ ulimit -l unlimited ulimit -n 4096 export RUST_BACKTRACE=1 -time cargo test --release --target "$BUILD_TARGET" $test_features "common_parallel::$test_filter" -- ${test_binary_args[*]} --test-threads=$((($(nproc) * 3) / 4)) +time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=$(($(nproc) / 4)) "common_parallel::$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 export RUST_BACKTRACE=1 - time cargo test --release --target "$BUILD_TARGET" $test_features "common_sequential::$test_filter" -- --test-threads=1 ${test_binary_args[*]} + cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=1 "common_sequential::$test_filter" -- ${test_binary_args[*]} RES=$? fi @@ -194,7 +194,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 test $test_features "dbus_api::$test_filter" -- ${test_binary_args[*]} + time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=$(($(nproc) / 4)) "dbus_api::$test_filter" -- ${test_binary_args[*]} RES=$? fi @@ -202,14 +202,14 @@ fi if [ $RES -eq 0 ]; then cargo build --features "mshv,fw_cfg" --all --release --target "$BUILD_TARGET" export RUST_BACKTRACE=1 - time cargo test $test_features "fw_cfg::$test_filter" --target "$BUILD_TARGET" -- ${test_binary_args[*]} + time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=$(($(nproc) / 4)) "fw_cfg::$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 test $test_features "ivshmem::$test_filter" --target "$BUILD_TARGET" -- ${test_binary_args[*]} + time cargo nextest run $test_features --retries 3 --no-fail-fast --test-threads=$(($(nproc) / 4)) "ivshmem::$test_filter" -- ${test_binary_args[*]} RES=$? fi