xref: /cloud-hypervisor/scripts/run_unit_tests.sh (revision 2571e59438597f53aa4993cd70d6462fe1364ba7)
1#!/bin/bash
2
3source $HOME/.cargo/env
4source $(dirname "$0")/test-util.sh
5
6process_common_args "$@"
7
8BUILD_TARGET=${BUILD_TARGET-x86_64-unknown-linux-gnu}
9cargo_args=("")
10
11if [[ $hypervisor = "mshv" ]]; then
12    cargo_args+=("--features $hypervisor")
13elif [[ $(uname -m) = "x86_64" ]]; then
14    cargo_args+=("--features tdx")
15fi
16
17if [[ "${BUILD_TARGET}" == "aarch64-unknown-linux-musl" ]]; then
18    export TARGET_CC="musl-gcc"
19    export RUSTFLAGS="-C link-arg=-lgcc -C link_arg=-specs -C link_arg=/usr/lib/aarch64-linux-musl/musl-gcc.specs"
20fi
21
22export RUST_BACKTRACE=1
23cargo test --lib --bins --target $BUILD_TARGET --workspace ${cargo_args[@]} || exit 1
24cargo test --doc --target $BUILD_TARGET --workspace ${cargo_args[@]} || exit 1
25