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