1#!/bin/bash 2set -x 3 4source $HOME/.cargo/env 5source $(dirname "$0")/test-util.sh 6source $(dirname "$0")/common-aarch64.sh 7 8process_common_args "$@" 9# For now these values are default for kvm 10features="" 11 12# aarch64 not supported for MSHV 13if [[ "$hypervisor" = "mshv" ]]; then 14 echo "AArch64 is not supported in Microsoft Hypervisor" 15 exit 1 16fi 17 18WIN_IMAGE_BASENAME="windows-11-iot-enterprise-aarch64.raw" 19WIN_IMAGE_FILE="$WORKLOADS_DIR/$WIN_IMAGE_BASENAME" 20 21# Checkout and build EDK2 22OVMF_FW="$WORKLOADS_DIR/CLOUDHV_EFI.fd" 23build_edk2 24 25BUILD_TARGET="$(uname -m)-unknown-linux-${CH_LIBC}" 26CFLAGS="" 27TARGET_CC="" 28if [[ "${BUILD_TARGET}" == "aarch64-unknown-linux-musl" ]]; then 29export TARGET_CC="musl-gcc" 30export RUSTFLAGS="-C link-arg=-lgcc -C link_arg=-specs -C link_arg=/usr/lib/aarch64-linux-musl/musl-gcc.specs" 31fi 32 33# Check if the images are present 34if [[ ! -f ${WIN_IMAGE_FILE} || ! -f ${OVMF_FW} ]]; then 35 echo "Windows image/firmware not present in the host" 36 exit 1 37fi 38 39# Use device mapper to create a snapshot of the Windows image 40img_blk_size=$(du -b -B 512 ${WIN_IMAGE_FILE} | awk '{print $1;}') 41loop_device=$(losetup --find --show --read-only ${WIN_IMAGE_FILE}) 42dmsetup create windows-base --table "0 $img_blk_size linear $loop_device 0" 43dmsetup mknodes 44dmsetup create windows-snapshot-base --table "0 $img_blk_size snapshot-origin /dev/mapper/windows-base" 45dmsetup mknodes 46 47export RUST_BACKTRACE=1 48 49cargo build --all --release $features --target $BUILD_TARGET 50strip target/$BUILD_TARGET/release/cloud-hypervisor 51 52# Only run with 1 thread to avoid tests interfering with one another because 53# Windows has a static IP configured 54time cargo test $features "windows::$test_filter" --target $BUILD_TARGET -- ${test_binary_args[*]} 55RES=$? 56 57dmsetup remove_all -f 58losetup -D 59 60exit $RES 61