191fe48d5SPhilipp Schuster#!/usr/bin/env bash 22b2d0065SRuslan Mstoi# shellcheck disable=SC2048,SC2086 356b0c855SSebastien Boeufset -x 456b0c855SSebastien Boeuf 52b2d0065SRuslan Mstoi# shellcheck source=/dev/null 62b2d0065SRuslan Mstoisource "$HOME"/.cargo/env 72b2d0065SRuslan Mstoisource "$(dirname "$0")"/test-util.sh 827b5f8d7SMuminul Islam 927b5f8d7SMuminul Islamprocess_common_args "$@" 10ca4857b5SMuminul Islam 11ca4857b5SMuminul Islamif [[ "$hypervisor" = "mshv" ]]; then 12ca4857b5SMuminul Islam echo "Unsupported SGX test for MSHV" 13ca4857b5SMuminul Islam exit 1 14ca4857b5SMuminul Islamfi 15ca4857b5SMuminul Islam 161a2185eaSRob BradfordWORKLOADS_DIR="$HOME/workloads" 171a2185eaSRob Bradfordmkdir -p "$WORKLOADS_DIR" 181a2185eaSRob Bradford 1972e213ebSRob Bradforddownload_hypervisor_fw 201a2185eaSRob Bradford 21*b1547c4cSRob BradfordJAMMY_OS_IMAGE_NAME="jammy-server-cloudimg-amd64-custom-20241017-0.qcow2" 2205ec6190SRavi kumar VeeramallyJAMMY_OS_IMAGE_URL="https://ch-images.azureedge.net/$JAMMY_OS_IMAGE_NAME" 231a2185eaSRob BradfordJAMMY_OS_IMAGE="$WORKLOADS_DIR/$JAMMY_OS_IMAGE_NAME" 241a2185eaSRob Bradfordif [ ! -f "$JAMMY_OS_IMAGE" ]; then 252b2d0065SRuslan Mstoi pushd "$WORKLOADS_DIR" || exit 261a2185eaSRob Bradford time wget --quiet $JAMMY_OS_IMAGE_URL || exit 1 272b2d0065SRuslan Mstoi popd || exit 281a2185eaSRob Bradfordfi 291a2185eaSRob Bradford 30*b1547c4cSRob BradfordJAMMY_OS_RAW_IMAGE_NAME="jammy-server-cloudimg-amd64-custom-20241017-0.raw" 311a2185eaSRob BradfordJAMMY_OS_RAW_IMAGE="$WORKLOADS_DIR/$JAMMY_OS_RAW_IMAGE_NAME" 321a2185eaSRob Bradfordif [ ! -f "$JAMMY_OS_RAW_IMAGE" ]; then 332b2d0065SRuslan Mstoi pushd "$WORKLOADS_DIR" || exit 341a2185eaSRob Bradford time qemu-img convert -p -f qcow2 -O raw $JAMMY_OS_IMAGE_NAME $JAMMY_OS_RAW_IMAGE_NAME || exit 1 352b2d0065SRuslan Mstoi popd || exit 361a2185eaSRob Bradfordfi 371a2185eaSRob Bradford 3856b0c855SSebastien BoeufCFLAGS="" 3956b0c855SSebastien Boeufif [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then 402b2d0065SRuslan Mstoi # shellcheck disable=SC2034 4156b0c855SSebastien Boeuf CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/" 4256b0c855SSebastien Boeuffi 4356b0c855SSebastien Boeuf 442b2d0065SRuslan Mstoicargo build --features mshv --all --release --target "$BUILD_TARGET" 4556b0c855SSebastien Boeuf 4656b0c855SSebastien Boeufexport RUST_BACKTRACE=1 4756b0c855SSebastien Boeuf 48d83fc7f6SRob Bradfordtime cargo test "sgx::$test_filter" -- ${test_binary_args[*]} 4956b0c855SSebastien BoeufRES=$? 5056b0c855SSebastien Boeuf 5156b0c855SSebastien Boeufexit $RES 52