xref: /cloud-hypervisor/scripts/run_integration_tests_sgx.sh (revision 6f8bd27cf7629733582d930519e98d19e90afb16)
1#!/bin/bash
2set -x
3
4source $HOME/.cargo/env
5source $(dirname "$0")/test-util.sh
6
7process_common_args "$@"
8
9if [[ "$hypervisor" = "mshv" ]]; then
10    echo "Unsupported SGX test for MSHV"
11    exit 1
12fi
13
14WORKLOADS_DIR="$HOME/workloads"
15mkdir -p "$WORKLOADS_DIR"
16
17FW_URL=$(curl --silent https://api.github.com/repos/cloud-hypervisor/rust-hypervisor-firmware/releases/latest | grep "browser_download_url" | grep -o 'https://.*[^ "]')
18FW="$WORKLOADS_DIR/hypervisor-fw"
19pushd $WORKLOADS_DIR
20rm -f $FW
21time wget --quiet $FW_URL || exit 1
22popd
23
24JAMMY_OS_IMAGE_NAME="jammy-server-cloudimg-amd64-custom-20221118-1.qcow2"
25JAMMY_OS_IMAGE_URL="https://cloud-hypervisor.azureedge.net/$JAMMY_OS_IMAGE_NAME"
26JAMMY_OS_IMAGE="$WORKLOADS_DIR/$JAMMY_OS_IMAGE_NAME"
27if [ ! -f "$JAMMY_OS_IMAGE" ]; then
28    pushd $WORKLOADS_DIR
29    time wget --quiet $JAMMY_OS_IMAGE_URL || exit 1
30    popd
31fi
32
33JAMMY_OS_RAW_IMAGE_NAME="jammy-server-cloudimg-amd64-custom-20221118-1.raw"
34JAMMY_OS_RAW_IMAGE="$WORKLOADS_DIR/$JAMMY_OS_RAW_IMAGE_NAME"
35if [ ! -f "$JAMMY_OS_RAW_IMAGE" ]; then
36    pushd $WORKLOADS_DIR
37    time qemu-img convert -p -f qcow2 -O raw $JAMMY_OS_IMAGE_NAME $JAMMY_OS_RAW_IMAGE_NAME || exit 1
38    popd
39fi
40
41BUILD_TARGET="$(uname -m)-unknown-linux-${CH_LIBC}"
42CFLAGS=""
43TARGET_CC=""
44if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then
45TARGET_CC="musl-gcc"
46CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/"
47fi
48
49cargo build --no-default-features --features "kvm,mshv" --all --release --target $BUILD_TARGET
50
51export RUST_BACKTRACE=1
52
53time cargo test "sgx::$test_filter" -- ${test_binary_args[*]}
54RES=$?
55
56exit $RES
57