2020-10-08 14:11:18 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -x
|
|
|
|
|
|
|
|
source $HOME/.cargo/env
|
2020-11-18 00:37:27 +00:00
|
|
|
source $(dirname "$0")/test-util.sh
|
|
|
|
|
|
|
|
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
|
|
|
|
2021-03-08 20:54:38 +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"
|
2022-01-18 10:07:01 +00:00
|
|
|
OVMF_FW_URL=$(curl --silent https://api.github.com/repos/cloud-hypervisor/edk2/releases/latest | grep "browser_download_url" | grep -o 'https://.*[^ "]')
|
|
|
|
OVMF_FW="$WORKLOADS_DIR/CLOUDHV.fd"
|
2021-12-06 17:45:17 +00:00
|
|
|
if [ ! -f "$OVMF_FW" ]; then
|
|
|
|
pushd $WORKLOADS_DIR
|
|
|
|
time wget --quiet $OVMF_FW_URL || exit 1
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2020-10-08 14:11:18 +00:00
|
|
|
CFLAGS=""
|
|
|
|
if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then
|
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
|
|
|
|
|
2023-08-04 02:33:09 +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
|