1#!/bin/bash 2set -x 3 4source $HOME/.cargo/env 5source $(dirname "$0")/test-util.sh 6 7WORKLOADS_DIR="$HOME/workloads" 8mkdir -p "$WORKLOADS_DIR" 9 10process_common_args "$@" 11 12# For now these values are default for kvm 13test_features="" 14 15if [ "$hypervisor" = "mshv" ] ; then 16 test_features="--features mshv" 17fi 18 19cp scripts/sha1sums-x86_64 $WORKLOADS_DIR 20 21FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.qcow2" 22FOCAL_OS_IMAGE_URL="https://cloud-hypervisor.azureedge.net/$FOCAL_OS_IMAGE_NAME" 23FOCAL_OS_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_IMAGE_NAME" 24if [ ! -f "$FOCAL_OS_IMAGE" ]; then 25 pushd $WORKLOADS_DIR 26 time wget --quiet $FOCAL_OS_IMAGE_URL || exit 1 27 popd 28fi 29 30FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.raw" 31FOCAL_OS_RAW_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_NAME" 32if [ ! -f "$FOCAL_OS_RAW_IMAGE" ]; then 33 pushd $WORKLOADS_DIR 34 time qemu-img convert -p -f qcow2 -O raw $FOCAL_OS_IMAGE_NAME $FOCAL_OS_RAW_IMAGE_NAME || exit 1 35 popd 36fi 37 38pushd $WORKLOADS_DIR 39grep focal sha1sums-x86_64 | sha1sum --check 40if [ $? -ne 0 ]; then 41 echo "sha1sum validation of images failed, remove invalid images to fix the issue." 42 exit 1 43fi 44popd 45 46# Download Cloud Hypervisor binary from its last stable release 47LAST_RELEASE_VERSION="v36.0" 48CH_RELEASE_URL="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$LAST_RELEASE_VERSION/cloud-hypervisor-static" 49CH_RELEASE_NAME="cloud-hypervisor-static" 50pushd $WORKLOADS_DIR 51time wget --quiet $CH_RELEASE_URL -O "$CH_RELEASE_NAME" || exit 1 52chmod +x $CH_RELEASE_NAME 53popd 54 55# Build custom kernel based on virtio-pmem and virtio-fs upstream patches 56VMLINUX_IMAGE="$WORKLOADS_DIR/vmlinux" 57if [ ! -f "$VMLINUX_IMAGE" ]; then 58 build_custom_linux 59fi 60 61CFLAGS="" 62if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then 63 CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/" 64fi 65 66cargo build --features mshv --all --release --target $BUILD_TARGET 67 68# Test ovs-dpdk relies on hugepages 69HUGEPAGESIZE=`grep Hugepagesize /proc/meminfo | awk '{print $2}'` 70PAGE_NUM=`echo $((12288 * 1024 / $HUGEPAGESIZE))` 71echo $PAGE_NUM | sudo tee /proc/sys/vm/nr_hugepages 72sudo chmod a+rwX /dev/hugepages 73 74export RUST_BACKTRACE=1 75time cargo test $test_features "live_migration_parallel::$test_filter" -- ${test_binary_args[*]} 76RES=$? 77 78# Run some tests in sequence since the result could be affected by other tests 79# running in parallel. 80if [ $RES -eq 0 ]; then 81 export RUST_BACKTRACE=1 82 time cargo test $test_features "live_migration_sequential::$test_filter" -- --test-threads=1 ${test_binary_args[*]} 83 RES=$? 84fi 85 86exit $RES 87