xref: /cloud-hypervisor/scripts/run_integration_tests_rate_limiter.sh (revision eeae63b4595fbf0cc69f62b6e9d9a79c543c4ac7)
1#!/usr/bin/env bash
2# shellcheck disable=SC2048,SC2086
3set -x
4
5# shellcheck source=/dev/null
6source "$HOME"/.cargo/env
7source "$(dirname "$0")"/test-util.sh
8
9WORKLOADS_DIR="$HOME/workloads"
10mkdir -p "$WORKLOADS_DIR"
11
12process_common_args "$@"
13
14# For now these values are default for kvm
15test_features=""
16
17if [ "$hypervisor" = "mshv" ]; then
18    test_features="--features mshv"
19fi
20
21cp scripts/sha1sums-x86_64 "$WORKLOADS_DIR"
22
23FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.qcow2"
24FOCAL_OS_IMAGE_URL="https://ch-images.azureedge.net/$FOCAL_OS_IMAGE_NAME"
25FOCAL_OS_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_IMAGE_NAME"
26if [ ! -f "$FOCAL_OS_IMAGE" ]; then
27    pushd "$WORKLOADS_DIR" || exit
28    time wget --quiet $FOCAL_OS_IMAGE_URL || exit 1
29    popd || exit
30fi
31
32FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.raw"
33FOCAL_OS_RAW_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_NAME"
34if [ ! -f "$FOCAL_OS_RAW_IMAGE" ]; then
35    pushd "$WORKLOADS_DIR" || exit
36    time qemu-img convert -p -f qcow2 -O raw $FOCAL_OS_IMAGE_NAME $FOCAL_OS_RAW_IMAGE_NAME || exit 1
37    popd || exit
38fi
39
40pushd "$WORKLOADS_DIR" || exit
41if ! grep focal sha1sums-x86_64 | sha1sum --check; then
42    echo "sha1sum validation of images failed, remove invalid images to fix the issue."
43    exit 1
44fi
45popd || exit
46
47# Prepare linux image (build from source or download pre-built)
48prepare_linux
49
50CFLAGS=""
51if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then
52    # shellcheck disable=SC2034
53    CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/"
54fi
55
56cargo build --features mshv --all --release --target "$BUILD_TARGET"
57
58export RUST_BACKTRACE=1
59time cargo test $test_features "rate_limiter::$test_filter" -- --test-threads=1 ${test_binary_args[*]}
60RES=$?
61
62exit $RES
63