1#!/usr/bin/env 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 17download_hypervisor_fw 18 19JAMMY_OS_IMAGE_NAME="jammy-server-cloudimg-amd64-custom-20230119-0.qcow2" 20JAMMY_OS_IMAGE_URL="https://cloud-hypervisor.azureedge.net/$JAMMY_OS_IMAGE_NAME" 21JAMMY_OS_IMAGE="$WORKLOADS_DIR/$JAMMY_OS_IMAGE_NAME" 22if [ ! -f "$JAMMY_OS_IMAGE" ]; then 23 pushd $WORKLOADS_DIR 24 time wget --quiet $JAMMY_OS_IMAGE_URL || exit 1 25 popd 26fi 27 28JAMMY_OS_RAW_IMAGE_NAME="jammy-server-cloudimg-amd64-custom-20230119-0.raw" 29JAMMY_OS_RAW_IMAGE="$WORKLOADS_DIR/$JAMMY_OS_RAW_IMAGE_NAME" 30if [ ! -f "$JAMMY_OS_RAW_IMAGE" ]; then 31 pushd $WORKLOADS_DIR 32 time qemu-img convert -p -f qcow2 -O raw $JAMMY_OS_IMAGE_NAME $JAMMY_OS_RAW_IMAGE_NAME || exit 1 33 popd 34fi 35 36CFLAGS="" 37if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then 38 CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/" 39fi 40 41cargo build --features mshv --all --release --target $BUILD_TARGET 42 43export RUST_BACKTRACE=1 44 45time cargo test "sgx::$test_filter" -- ${test_binary_args[*]} 46RES=$? 47 48exit $RES 49