xref: /cloud-hypervisor/scripts/run_unit_tests.sh (revision eea9bcea38e0c5649f444c829f3a4f9c22aa486c)
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+=("--no-default-features")
13    cargo_args+=("--features $hypervisor")
14elif [[ $(uname -m) = "x86_64" ]]; then
15    cargo_args+=("--features tdx")
16fi
17
18if [[ "${BUILD_TARGET}" == "aarch64-unknown-linux-musl" ]]; then
19    export TARGET_CC="musl-gcc"
20    export RUSTFLAGS="-C link-arg=-lgcc -C link_arg=-specs -C link_arg=/usr/lib/aarch64-linux-musl/musl-gcc.specs"
21fi
22
23export RUST_BACKTRACE=1
24cargo test --lib --bins --target $BUILD_TARGET --workspace ${cargo_args[@]} || exit 1
25