xref: /cloud-hypervisor/scripts/run_integration_tests_sgx.sh (revision 80b2c98a68d4c68f372f849e8d26f7cae5867000)
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
11if [[ "$hypervisor" = "mshv" ]]; then
12    echo "Unsupported SGX test for MSHV"
13    exit 1
14fi
15
16WORKLOADS_DIR="$HOME/workloads"
17mkdir -p "$WORKLOADS_DIR"
18
19download_hypervisor_fw
20
21JAMMY_OS_IMAGE_NAME="jammy-server-cloudimg-amd64-custom-20241017-0.qcow2"
22JAMMY_OS_IMAGE_URL="https://ch-images.azureedge.net/$JAMMY_OS_IMAGE_NAME"
23JAMMY_OS_IMAGE="$WORKLOADS_DIR/$JAMMY_OS_IMAGE_NAME"
24if [ ! -f "$JAMMY_OS_IMAGE" ]; then
25    pushd "$WORKLOADS_DIR" || exit
26    time wget --quiet $JAMMY_OS_IMAGE_URL || exit 1
27    popd || exit
28fi
29
30JAMMY_OS_RAW_IMAGE_NAME="jammy-server-cloudimg-amd64-custom-20241017-0.raw"
31JAMMY_OS_RAW_IMAGE="$WORKLOADS_DIR/$JAMMY_OS_RAW_IMAGE_NAME"
32if [ ! -f "$JAMMY_OS_RAW_IMAGE" ]; then
33    pushd "$WORKLOADS_DIR" || exit
34    time qemu-img convert -p -f qcow2 -O raw $JAMMY_OS_IMAGE_NAME $JAMMY_OS_RAW_IMAGE_NAME || exit 1
35    popd || exit
36fi
37
38CFLAGS=""
39if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then
40    # shellcheck disable=SC2034
41    CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/"
42fi
43
44cargo build --features mshv --all --release --target "$BUILD_TARGET"
45
46export RUST_BACKTRACE=1
47
48time cargo test "sgx::$test_filter" -- ${test_binary_args[*]}
49RES=$?
50
51exit $RES
52