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