191fe48d5SPhilipp Schuster#!/usr/bin/env bash 2*2b2d0065SRuslan Mstoi# shellcheck disable=SC2048,SC2086 376c04878SRob Bradfordset -x 476c04878SRob Bradford 5*2b2d0065SRuslan Mstoi# shellcheck source=/dev/null 6*2b2d0065SRuslan Mstoisource "$HOME"/.cargo/env 7*2b2d0065SRuslan Mstoisource "$(dirname "$0")"/test-util.sh 827b5f8d7SMuminul Islam 927b5f8d7SMuminul Islamprocess_common_args "$@" 105b05e0cdSBo Chen# For now these values are default for kvm 11d83fc7f6SRob Bradfordtest_features="" 1276c04878SRob Bradford 138739f6ccSMuminul Islamif [ "$hypervisor" = "mshv" ]; then 14219716c3SBo Chen test_features="--features mshv" 158739f6ccSMuminul Islamfi 16934b20a7SAnatol BelskiWIN_IMAGE_FILE="/root/workloads/windows-server-2022-amd64-2.raw" 17eea2907dSRob Bradford 18eea2907dSRob BradfordWORKLOADS_DIR="/root/workloads" 1976dbe660SThomas Barrett 2076dbe660SThomas Barrettdownload_ovmf 21eea2907dSRob Bradford 2276c04878SRob BradfordCFLAGS="" 2376c04878SRob Bradfordif [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then 24*2b2d0065SRuslan Mstoi # shellcheck disable=SC2034 2576c04878SRob Bradford CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/" 2676c04878SRob Bradfordfi 2776c04878SRob Bradford 2829f92440SMuminul Islam# Check if the images are present 29eea2907dSRob Bradfordif [[ ! -f ${WIN_IMAGE_FILE} || ! -f ${OVMF_FW} ]]; then 3029f92440SMuminul Islam echo "Windows image/firmware not present in the host" 3129f92440SMuminul Islam exit 1 3229f92440SMuminul Islamfi 3329f92440SMuminul Islam 343b43551dSSebastien Boeuf# Use device mapper to create a snapshot of the Windows image 35282134a4SMuminul Islamimg_blk_size=$(du -b -B 512 ${WIN_IMAGE_FILE} | awk '{print $1;}') 36282134a4SMuminul Islamloop_device=$(losetup --find --show --read-only ${WIN_IMAGE_FILE}) 373b43551dSSebastien Boeufdmsetup create windows-base --table "0 $img_blk_size linear $loop_device 0" 383b43551dSSebastien Boeufdmsetup mknodes 393b43551dSSebastien Boeufdmsetup create windows-snapshot-base --table "0 $img_blk_size snapshot-origin /dev/mapper/windows-base" 403b43551dSSebastien Boeufdmsetup mknodes 413b43551dSSebastien Boeuf 42*2b2d0065SRuslan Mstoicargo build --features mshv --all --release --target "$BUILD_TARGET" 4376c04878SRob Bradford 4476c04878SRob Bradfordexport RUST_BACKTRACE=1 4576c04878SRob Bradford 462902a96aSWei Liu# Only run with 1 thread to avoid tests interfering with one another because 472902a96aSWei Liu# Windows has a static IP configured 48d83fc7f6SRob Bradfordtime cargo test $test_features "windows::$test_filter" -- ${test_binary_args[*]} 4976c04878SRob BradfordRES=$? 5076c04878SRob Bradford 513b43551dSSebastien Boeufdmsetup remove_all -f 523b43551dSSebastien Boeuflosetup -D 533b43551dSSebastien Boeuf 5476c04878SRob Bradfordexit $RES 55