xref: /cloud-hypervisor/scripts/run_integration_tests_windows_x86_64.sh (revision 4d7a4c598ac247aaf770b00dfb057cdac891f67d)
1#!/bin/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"
17OVMF_FW_URL=$(curl --silent https://api.github.com/repos/cloud-hypervisor/edk2/releases/latest | grep "browser_download_url" | grep -o 'https://.*[^ "]')
18OVMF_FW="$WORKLOADS_DIR/CLOUDHV.fd"
19if [ ! -f "$OVMF_FW" ]; then
20    pushd $WORKLOADS_DIR
21    time wget --quiet $OVMF_FW_URL || exit 1
22    popd
23fi
24
25CFLAGS=""
26if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then
27    CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/"
28fi
29
30# Check if the images are present
31if [[ ! -f ${WIN_IMAGE_FILE} || ! -f ${OVMF_FW} ]]; then
32    echo "Windows image/firmware not present in the host"
33    exit 1
34fi
35
36# Use device mapper to create a snapshot of the Windows image
37img_blk_size=$(du -b -B 512 ${WIN_IMAGE_FILE} | awk '{print $1;}')
38loop_device=$(losetup --find --show --read-only ${WIN_IMAGE_FILE})
39dmsetup create windows-base --table "0 $img_blk_size linear $loop_device 0"
40dmsetup mknodes
41dmsetup create windows-snapshot-base --table "0 $img_blk_size snapshot-origin /dev/mapper/windows-base"
42dmsetup mknodes
43
44cargo build --features mshv --all --release --target $BUILD_TARGET
45
46export RUST_BACKTRACE=1
47
48# Only run with 1 thread to avoid tests interfering with one another because
49# Windows has a static IP configured
50time cargo test $test_features "windows::$test_filter" -- ${test_binary_args[*]}
51RES=$?
52
53dmsetup remove_all -f
54losetup -D
55
56exit $RES
57