2023-12-15 20:33:46 +00:00
|
|
|
#!/usr/bin/env bash
|
2024-01-29 15:38:44 +00:00
|
|
|
# shellcheck disable=SC2048,SC2086
|
2020-10-08 14:11:18 +00:00
|
|
|
set -x
|
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
# shellcheck source=/dev/null
|
|
|
|
source "$HOME"/.cargo/env
|
|
|
|
source "$(dirname "$0")"/test-util.sh
|
2020-11-18 00:37:27 +00:00
|
|
|
|
|
|
|
process_common_args "$@"
|
2022-01-06 22:36:24 +00:00
|
|
|
# For now these values are default for kvm
|
2022-11-24 13:06:53 +00:00
|
|
|
test_features=""
|
2020-10-08 14:11:18 +00:00
|
|
|
|
2024-01-26 15:30:32 +00:00
|
|
|
if [ "$hypervisor" = "mshv" ]; then
|
2023-08-04 02:33:09 +00:00
|
|
|
test_features="--features mshv"
|
2021-03-08 20:54:38 +00:00
|
|
|
fi
|
2023-02-10 15:51:42 +00:00
|
|
|
WIN_IMAGE_FILE="/root/workloads/windows-server-2022-amd64-2.raw"
|
2021-12-06 17:45:17 +00:00
|
|
|
|
|
|
|
WORKLOADS_DIR="/root/workloads"
|
2024-01-18 18:50:11 +00:00
|
|
|
|
|
|
|
download_ovmf
|
2021-12-06 17:45:17 +00:00
|
|
|
|
2020-10-08 14:11:18 +00:00
|
|
|
CFLAGS=""
|
|
|
|
if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
# shellcheck disable=SC2034
|
2023-04-20 15:26:41 +00:00
|
|
|
CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/"
|
2020-10-08 14:11:18 +00:00
|
|
|
fi
|
|
|
|
|
2021-02-18 18:55:11 +00:00
|
|
|
# Check if the images are present
|
2021-12-06 17:45:17 +00:00
|
|
|
if [[ ! -f ${WIN_IMAGE_FILE} || ! -f ${OVMF_FW} ]]; then
|
2021-02-18 18:55:11 +00:00
|
|
|
echo "Windows image/firmware not present in the host"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-01-12 10:03:28 +00:00
|
|
|
# Use device mapper to create a snapshot of the Windows image
|
2021-02-18 18:51:29 +00:00
|
|
|
img_blk_size=$(du -b -B 512 ${WIN_IMAGE_FILE} | awk '{print $1;}')
|
|
|
|
loop_device=$(losetup --find --show --read-only ${WIN_IMAGE_FILE})
|
2021-01-12 10:03:28 +00:00
|
|
|
dmsetup create windows-base --table "0 $img_blk_size linear $loop_device 0"
|
|
|
|
dmsetup mknodes
|
|
|
|
dmsetup create windows-snapshot-base --table "0 $img_blk_size snapshot-origin /dev/mapper/windows-base"
|
|
|
|
dmsetup mknodes
|
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
cargo build --features mshv --all --release --target "$BUILD_TARGET"
|
2020-10-08 14:11:18 +00:00
|
|
|
|
|
|
|
export RUST_BACKTRACE=1
|
|
|
|
|
2020-10-21 22:31:01 +00:00
|
|
|
# Only run with 1 thread to avoid tests interfering with one another because
|
|
|
|
# Windows has a static IP configured
|
2022-11-24 13:06:53 +00:00
|
|
|
time cargo test $test_features "windows::$test_filter" -- ${test_binary_args[*]}
|
2020-10-08 14:11:18 +00:00
|
|
|
RES=$?
|
|
|
|
|
2021-01-12 10:03:28 +00:00
|
|
|
dmsetup remove_all -f
|
|
|
|
losetup -D
|
|
|
|
|
2020-10-08 14:11:18 +00:00
|
|
|
exit $RES
|