blob: e44a0cdc173d9b01d7d07afc1103602e1ac0f8e6 [file] [log] [blame]
#!/usr/bin/env bash
# Copyright 2020 The Android KVM Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TIMEOUT=180s
# QEMU CPUs to use for VHE and nVHE runs
VHE_CPU="max,sve=off"
NVHE_CPU="cortex-a53"
TEST_FILE=$1
LINUX_KERNEL=$2
ROOTFS=$3
QEMU=$4
VHE=$5
CPU=""
# Assume that the roms are located with the disk image.
ROM_PATH=$(dirname ${ROOTFS})
echo $ROM_PATH
if [ ! -f ${TEST_FILE} ]; then
echo "Standalone kvmunittest file not found"
echo "Run make standalone first to generate the standalone test files."
exit 1
fi
if [ ! -f ${LINUX_KERNEL} ]; then
echo "Linux kernel image file not found."
exit 1
fi
if [ ! -f ${ROOTFS} ]; then
echo "Root filesystem image file not found."
exit 1
fi
if [ ! -x ${QEMU} ]; then
echo "QEMU executable not found."
exit 1
fi
if [ ${VHE} = 1 ]; then
CPU=${VHE_CPU}
else
CPU=${NVHE_CPU}
fi
timeout -k 1s --foreground ${TIMEOUT} ${QEMU} \
-M virt \
-machine virtualization=true -machine virt,gic-version=3 \
-cpu "${CPU}" \
-nographic \
-smp 2 \
-m 512 \
-kernel "${LINUX_KERNEL}" \
-L ${ROM_PATH} \
-append "rootwait root=/dev/vda" \
-drive file="${ROOTFS}",readonly,if=virtio,format=raw \
-drive file="${TEST_FILE}",readonly,if=virtio,format=raw \
-object rng-random,filename=/dev/urandom,id=rng0 \
-device virtio-rng-pci,rng=rng0