blob: 22f2d498303b13d50c5a27bc2943b53e4ddd2f38 [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
RUN_QEMU_SCRIPT="$(dirname "${BASH_SOURCE[0]}")/../aarch64/run_qemu.sh"
# QEMU CPUs to use for VHE and nVHE runs
VHE_CPU="max"
NVHE_CPU="cortex-a53"
TEST_FILE=$1
LINUX_KERNEL=$2
ROOTFS=$3
QEMU=$4
VHE=$5
LOG_FILE=$6
TEST_NAME=$7
CPU=""
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
"${RUN_QEMU_SCRIPT}" \
-e "${QEMU}" \
-k "${LINUX_KERNEL}" \
-r "${ROOTFS}" \
-R "${TEST_FILE}" \
-c "${CPU}" \
-t "${TIMEOUT}" \
&> "${LOG_FILE}"
EXIT_STATUS=$?
RESULT=$(grep -E -h --color=never "[^ ](PASS|FAIL|SKIP)[^:]" "${LOG_FILE}")
if [ -z "${RESULT}" ]; then
RESULT="\e[31;1mTIMEOUT/CRASH\e[0m"
EXIT_STATUS=1
fi
echo -e "${TEST_NAME}: ${RESULT}"
exit ${EXIT_STATUS}