From d83fc7f663098c8e81bee3e45f25779f34056f42 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 24 Nov 2022 13:06:53 +0000 Subject: [PATCH] scripts: Make --hypervisor=mshv only affect features used by tests This uncouples it from the features used for building the binary under test allowing it to use the default build features. This change also removes the feature control from the test scripts where it was never used (e.g. run_integration_tests_sgx.sh) This allows the combined binary to be used for all testing but allows the disabling of tests known not to work under mshv. Fixes: #4915 Signed-off-by: Rob Bradford --- scripts/run_integration_tests_aarch64.sh | 15 ++++++--------- scripts/run_integration_tests_live_migration.sh | 10 +++++----- scripts/run_integration_tests_rate_limiter.sh | 8 ++++---- scripts/run_integration_tests_sgx.sh | 7 ++----- scripts/run_integration_tests_vfio.sh | 8 +++----- scripts/run_integration_tests_windows_aarch64.sh | 6 ++---- scripts/run_integration_tests_windows_x86_64.sh | 8 ++++---- scripts/run_integration_tests_x86_64.sh | 10 +++++----- scripts/run_metrics.sh | 9 +-------- 9 files changed, 32 insertions(+), 49 deletions(-) diff --git a/scripts/run_integration_tests_aarch64.sh b/scripts/run_integration_tests_aarch64.sh index 412c666d4..2171501db 100755 --- a/scripts/run_integration_tests_aarch64.sh +++ b/scripts/run_integration_tests_aarch64.sh @@ -208,8 +208,6 @@ if [[ "$hypervisor" = "mshv" ]]; then exit 1 fi -# For now these values are deafult for kvm -features="" # lock the workloads folder to avoid parallel updating by different containers ( @@ -233,8 +231,7 @@ fi export RUST_BACKTRACE=1 -# Test without ACPI -cargo build --all --release $features --target $BUILD_TARGET +cargo build --all --release --target $BUILD_TARGET # Enable KSM with some reasonable parameters so that it won't take too long # for the memory to be merged between two processes. @@ -247,13 +244,13 @@ echo 6144 | 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 $features "common_parallel::$test_filter" --target $BUILD_TARGET -- ${test_binary_args[*]} +time cargo test "common_parallel::$test_filter" --target $BUILD_TARGET -- ${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 $features "common_sequential::$test_filter" --target $BUILD_TARGET -- --test-threads=1 ${test_binary_args[*]} + time cargo test "common_sequential::$test_filter" --target $BUILD_TARGET -- --test-threads=1 ${test_binary_args[*]} RES=$? else exit $RES @@ -261,7 +258,7 @@ fi # Run all ACPI test cases if [ $RES -eq 0 ]; then - time cargo test $features "aarch64_acpi::$test_filter" --target $BUILD_TARGET -- ${test_binary_args[*]} + time cargo test "aarch64_acpi::$test_filter" --target $BUILD_TARGET -- ${test_binary_args[*]} RES=$? else exit $RES @@ -269,14 +266,14 @@ fi # Run all test cases related to live migration if [ $RES -eq 0 ]; then - time cargo test $features "live_migration_parallel::$test_filter" --target $BUILD_TARGET -- ${test_binary_args[*]} + time cargo test "live_migration_parallel::$test_filter" --target $BUILD_TARGET -- ${test_binary_args[*]} RES=$? else exit $RES fi if [ $RES -eq 0 ]; then - time cargo test $features "live_migration_sequential::$test_filter" --target $BUILD_TARGET -- --test-threads=1 ${test_binary_args[*]} + time cargo test "live_migration_sequential::$test_filter" --target $BUILD_TARGET -- --test-threads=1 ${test_binary_args[*]} RES=$? else exit $RES diff --git a/scripts/run_integration_tests_live_migration.sh b/scripts/run_integration_tests_live_migration.sh index dc9490319..a0eb5e9c8 100755 --- a/scripts/run_integration_tests_live_migration.sh +++ b/scripts/run_integration_tests_live_migration.sh @@ -12,10 +12,10 @@ mkdir -p "$WORKLOADS_DIR" process_common_args "$@" # For now these values are default for kvm -features="" +test_features="" if [ "$hypervisor" = "mshv" ] ; then - features="--no-default-features --features mshv" + test_features="--no-default-features --features mshv" fi cp scripts/sha1sums-x86_64 $WORKLOADS_DIR @@ -86,21 +86,21 @@ if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/" fi -cargo build --all --release $features --target $BUILD_TARGET +cargo build --all --release --target $BUILD_TARGET # Test ovs-dpdk relies on hugepages echo 6144 | sudo tee /proc/sys/vm/nr_hugepages sudo chmod a+rwX /dev/hugepages export RUST_BACKTRACE=1 -time cargo test $features "live_migration_parallel::$test_filter" -- ${test_binary_args[*]} +time cargo test $test_features "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 $features "live_migration_sequential::$test_filter" -- --test-threads=1 ${test_binary_args[*]} + time cargo test $test_features "live_migration_sequential::$test_filter" -- --test-threads=1 ${test_binary_args[*]} RES=$? fi diff --git a/scripts/run_integration_tests_rate_limiter.sh b/scripts/run_integration_tests_rate_limiter.sh index 95286f03c..c20103587 100755 --- a/scripts/run_integration_tests_rate_limiter.sh +++ b/scripts/run_integration_tests_rate_limiter.sh @@ -12,10 +12,10 @@ mkdir -p "$WORKLOADS_DIR" process_common_args "$@" # For now these values are default for kvm -features="" +test_features="" if [ "$hypervisor" = "mshv" ] ; then - features="--no-default-features --features mshv" + test_features="--no-default-features --features mshv" fi cp scripts/sha1sums-x86_64 $WORKLOADS_DIR @@ -77,10 +77,10 @@ if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/" fi -cargo build --all --release $features --target $BUILD_TARGET +cargo build --all --release --target $BUILD_TARGET export RUST_BACKTRACE=1 -time cargo test $features "rate_limiter::$test_filter" -- --test-threads=1 ${test_binary_args[*]} +time cargo test $test_features "rate_limiter::$test_filter" -- --test-threads=1 ${test_binary_args[*]} RES=$? exit $RES diff --git a/scripts/run_integration_tests_sgx.sh b/scripts/run_integration_tests_sgx.sh index 7d9cea31f..f1318e304 100755 --- a/scripts/run_integration_tests_sgx.sh +++ b/scripts/run_integration_tests_sgx.sh @@ -38,9 +38,6 @@ if [ ! -f "$JAMMY_OS_RAW_IMAGE" ]; then popd fi -# For now these values are default for kvm -features="" - BUILD_TARGET="$(uname -m)-unknown-linux-${CH_LIBC}" CFLAGS="" TARGET_CC="" @@ -49,11 +46,11 @@ TARGET_CC="musl-gcc" CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/" fi -cargo build --all --release $features --target $BUILD_TARGET +cargo build --all --release --target $BUILD_TARGET export RUST_BACKTRACE=1 -time cargo test $features "sgx::$test_filter" -- ${test_binary_args[*]} +time cargo test "sgx::$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 62a59080c..05da2d537 100755 --- a/scripts/run_integration_tests_vfio.sh +++ b/scripts/run_integration_tests_vfio.sh @@ -5,8 +5,6 @@ source $HOME/.cargo/env source $(dirname "$0")/test-util.sh process_common_args "$@" -# For now these values are default for kvm -features="" WORKLOADS_DIR="$HOME/workloads" FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.raw" @@ -43,7 +41,7 @@ TARGET_CC="musl-gcc" CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/" fi -cargo build --all --release $features --target $BUILD_TARGET +cargo build --all --release --target $BUILD_TARGET # We always copy a fresh version of our binary for our L2 guest. cp target/$BUILD_TARGET/release/cloud-hypervisor $VFIO_DIR @@ -54,11 +52,11 @@ echo 6144 | sudo tee /proc/sys/vm/nr_hugepages sudo chmod a+rwX /dev/hugepages export RUST_BACKTRACE=1 -time cargo test $features "vfio::test_vfio" -- ${test_binary_args[*]} +time cargo test "vfio::test_vfio" -- ${test_binary_args[*]} RES=$? if [ $RES -eq 0 ]; then - time cargo test $features "vfio::test_nvidia" -- --test-threads=1 ${test_binary_args[*]} + time cargo test "vfio::test_nvidia" -- --test-threads=1 ${test_binary_args[*]} RES=$? fi diff --git a/scripts/run_integration_tests_windows_aarch64.sh b/scripts/run_integration_tests_windows_aarch64.sh index a7198c228..be721fbfe 100755 --- a/scripts/run_integration_tests_windows_aarch64.sh +++ b/scripts/run_integration_tests_windows_aarch64.sh @@ -6,8 +6,6 @@ source $(dirname "$0")/test-util.sh source $(dirname "$0")/common-aarch64.sh process_common_args "$@" -# For now these values are default for kvm -features="" # aarch64 not supported for MSHV if [[ "$hypervisor" = "mshv" ]]; then @@ -46,11 +44,11 @@ dmsetup mknodes export RUST_BACKTRACE=1 -cargo build --all --release $features --target $BUILD_TARGET +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 $features "windows::$test_filter" --target $BUILD_TARGET -- ${test_binary_args[*]} +time cargo test "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 61724d3c1..6974db96c 100755 --- a/scripts/run_integration_tests_windows_x86_64.sh +++ b/scripts/run_integration_tests_windows_x86_64.sh @@ -6,10 +6,10 @@ source $(dirname "$0")/test-util.sh process_common_args "$@" # For now these values are default for kvm -features="" +test_features="" if [ "$hypervisor" = "mshv" ] ; then - features="--no-default-features --features mshv" + test_features="--no-default-features --features mshv" fi WIN_IMAGE_FILE="/root/workloads/windows-server-2019.raw" @@ -44,13 +44,13 @@ dmsetup mknodes dmsetup create windows-snapshot-base --table "0 $img_blk_size snapshot-origin /dev/mapper/windows-base" dmsetup mknodes -cargo build --all --release $features --target $BUILD_TARGET +cargo build --all --release --target $BUILD_TARGET 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 $features "windows::$test_filter" -- ${test_binary_args[*]} +time cargo test $test_features "windows::$test_filter" -- ${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 b8d9f3126..f1027a3dd 100755 --- a/scripts/run_integration_tests_x86_64.sh +++ b/scripts/run_integration_tests_x86_64.sh @@ -12,10 +12,10 @@ mkdir -p "$WORKLOADS_DIR" process_common_args "$@" # For now these values are default for kvm -features="" +test_features="" if [ "$hypervisor" = "mshv" ] ; then - features="--no-default-features --features mshv" + test_features="--no-default-features --features mshv" fi cp scripts/sha1sums-x86_64 $WORKLOADS_DIR @@ -174,7 +174,7 @@ cp $VMLINUX_IMAGE $VFIO_DIR || exit 1 BUILD_TARGET="$(uname -m)-unknown-linux-${CH_LIBC}" -cargo build --all --release $features --target $BUILD_TARGET +cargo build --all --release --target $BUILD_TARGET # We always copy a fresh version of our binary for our L2 guest. cp target/$BUILD_TARGET/release/cloud-hypervisor $VFIO_DIR @@ -194,14 +194,14 @@ sudo chmod a+rwX /dev/hugepages ulimit -l unlimited export RUST_BACKTRACE=1 -time cargo test $features "common_parallel::$test_filter" -- ${test_binary_args[*]} +time cargo test $test_features "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 $features "common_sequential::$test_filter" -- --test-threads=1 ${test_binary_args[*]} + time cargo test $test_features "common_sequential::$test_filter" -- --test-threads=1 ${test_binary_args[*]} RES=$? fi diff --git a/scripts/run_metrics.sh b/scripts/run_metrics.sh index d28b5c1dd..ad7fdd2f6 100755 --- a/scripts/run_metrics.sh +++ b/scripts/run_metrics.sh @@ -28,13 +28,6 @@ build_fio() { process_common_args "$@" -# For now these values are default for kvm -features="" - -if [ "$hypervisor" = "mshv" ]; then - features="--no-default-features --features mshv" -fi - cp scripts/sha1sums-${TEST_ARCH} $WORKLOADS_DIR if [ ${TEST_ARCH} == "aarch64" ]; then @@ -99,7 +92,7 @@ if [[ "${BUILD_TARGET}" == "${TEST_ARCH}-unknown-linux-musl" ]]; then CFLAGS="-I /usr/include/${TEST_ARCH}-linux-musl/ -idirafter /usr/include/" fi -cargo build --all --release $features --target $BUILD_TARGET +cargo build --all --release --target $BUILD_TARGET # setup hugepages echo 6144 | sudo tee /proc/sys/vm/nr_hugepages