xref: /cloud-hypervisor/scripts/run_integration_tests_windows_x86_64.sh (revision 3ce0fef7fd546467398c914dbc74d8542e45cf6f)
1#!/usr/bin/env bash
2set -x
3
4source $HOME/.cargo/env
5source $(dirname "$0")/test-util.sh
6
7process_common_args "$@"
8# For now these values are default for kvm
9test_features=""
10
11if [ "$hypervisor" = "mshv" ] ;  then
12    test_features="--features mshv"
13fi
14WIN_IMAGE_FILE="/root/workloads/windows-server-2022-amd64-2.raw"
15
16WORKLOADS_DIR="/root/workloads"
17
18download_ovmf
19
20CFLAGS=""
21if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then
22    CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/"
23fi
24
25# Check if the images are present
26if [[ ! -f ${WIN_IMAGE_FILE} || ! -f ${OVMF_FW} ]]; then
27    echo "Windows image/firmware not present in the host"
28    exit 1
29fi
30
31# Use device mapper to create a snapshot of the Windows image
32img_blk_size=$(du -b -B 512 ${WIN_IMAGE_FILE} | awk '{print $1;}')
33loop_device=$(losetup --find --show --read-only ${WIN_IMAGE_FILE})
34dmsetup create windows-base --table "0 $img_blk_size linear $loop_device 0"
35dmsetup mknodes
36dmsetup create windows-snapshot-base --table "0 $img_blk_size snapshot-origin /dev/mapper/windows-base"
37dmsetup mknodes
38
39cargo build --features mshv --all --release --target $BUILD_TARGET
40
41export RUST_BACKTRACE=1
42
43# Only run with 1 thread to avoid tests interfering with one another because
44# Windows has a static IP configured
45time cargo test $test_features "windows::$test_filter" -- ${test_binary_args[*]}
46RES=$?
47
48dmsetup remove_all -f
49losetup -D
50
51exit $RES
52