1#!/bin/bash 2# 3# Copyright 2018 The Hafnium Authors. 4# 5# Use of this source code is governed by a BSD-style 6# license that can be found in the LICENSE file or at 7# https://opensource.org/licenses/BSD-3-Clause. 8 9# Note: this assumes that the images have all been built and the current working 10# directory is the root of the repo. 11 12USE_FVP=false 13USE_TFA=false 14EL0_TEST_ONLY=false 15SKIP_LONG_RUNNING_TESTS=false 16SKIP_UNIT_TESTS=false 17ASSERT_DISABLED_BUILD=false 18DEFAULT_HFTEST_TIMEOUT="600s" 19HFTEST_LOG_LEVEL="INFO" # Default log level 20 21while test $# -gt 0 22do 23 case "$1" in 24 --fvp) USE_FVP=true 25 ;; 26 --tfa) USE_TFA=true 27 ;; 28 --el0) EL0_TEST_ONLY=true 29 ;; 30 --skip-unit-tests) SKIP_UNIT_TESTS=true 31 ;; 32 --skip-long-running-tests) SKIP_LONG_RUNNING_TESTS=true 33 ;; 34 --assert-disabled-build) ASSERT_DISABLED_BUILD=true 35 ;; 36 --debug) HFTEST_LOG_LEVEL="DEBUG" 37 ;; 38 *) echo "Unexpected argument $1" 39 exit 1 40 ;; 41 esac 42 shift 43done 44 45# TIMEOUT, PROJECT, OUT, LOG_DIR_BASE set in: 46KOKORO_DIR="$(dirname "$0")" 47source $KOKORO_DIR/test_common.sh 48 49if [ $USE_FVP == true ] 50then 51 DRIVER="fvp" 52else 53 DRIVER="qemu" 54fi 55 56# Run the tests with a timeout so they can't loop forever. 57HFTEST=(${TIMEOUT[@]} $DEFAULT_HFTEST_TIMEOUT ./test/hftest/drivers/hftest.py $DRIVER) 58 59# Add hftest loglevel argument 60HFTEST+=(--log-level "$HFTEST_LOG_LEVEL") 61 62HYPERVISOR_PATH="$OUT/" 63if [ $USE_FVP == true ] 64then 65 HYPERVISOR_PATH+="aem_v8a_fvp_vhe_clang" 66 HFTEST+=(--out_initrd "$OUT/aem_v8a_fvp_vhe_vm_clang") 67 HFTEST+=(--out_partitions "$OUT/aem_v8a_fvp_vhe_vm_clang") 68else 69 HYPERVISOR_PATH+="qemu_aarch64_vhe_clang" 70 HFTEST+=(--out_initrd "$OUT/qemu_aarch64_vhe_vm_clang") 71fi 72if [ $USE_TFA == true ] 73then 74 HFTEST+=(--tfa) 75fi 76if [ $SKIP_LONG_RUNNING_TESTS == true ] 77then 78 HFTEST+=(--skip-long-running-tests) 79fi 80 81if [ $SKIP_UNIT_TESTS == false ] 82then 83# Run the host unit tests. 84mkdir -p "${LOG_DIR_BASE}/unit_tests" 85 ${TIMEOUT[@]} 30s "$OUT/host_fake_clang/unit_tests" \ 86 --gtest_output="xml:${LOG_DIR_BASE}/unit_tests/sponge_log.xml" \ 87 | tee "${LOG_DIR_BASE}/unit_tests/sponge_log.log" 88fi 89 90if [ $USE_FVP == false ] 91then 92 HFTEST+=(--cpu "max") 93fi 94 95HFTEST+=(--log "$LOG_DIR_BASE") 96 97if [ $EL0_TEST_ONLY == false ] 98then 99 "${HFTEST[@]}" --hypervisor "$HYPERVISOR_PATH/arch_test.bin" 100 if [ $USE_TFA == true -o $USE_FVP == true ] 101 then 102 "${HFTEST[@]}" --hypervisor "$HYPERVISOR_PATH/aarch64_test.bin" 103 fi 104 105 "${HFTEST[@]}" --hypervisor "$HYPERVISOR_PATH/hafnium.bin" \ 106 --initrd test/vmapi/arch/aarch64/aarch64_test 107 108 "${HFTEST[@]}" --hypervisor "$HYPERVISOR_PATH/hafnium.bin" \ 109 --initrd test/vmapi/arch/aarch64/gicv3/gicv3_test 110 111 "${HFTEST[@]}" --hypervisor "$HYPERVISOR_PATH/hafnium.bin" \ 112 --initrd test/vmapi/primary_only/primary_only_test 113 114 "${HFTEST[@]}" --hypervisor "$HYPERVISOR_PATH/hafnium.bin" \ 115 --initrd test/vmapi/primary_with_secondaries/primary_with_secondaries_test 116 117 "${HFTEST[@]}" --hypervisor "$HYPERVISOR_PATH/hafnium.bin" \ 118 --initrd test/vmapi/primary_with_secondaries/primary_with_secondaries_no_fdt 119fi 120 121 "${HFTEST[@]}" --hypervisor "$HYPERVISOR_PATH/hafnium.bin" \ 122 --initrd test/vmapi/primary_with_secondaries/primary_with_secondaries_el0_test 123 124if [ $USE_TFA == true ] && [ $USE_FVP == true ] 125then 126 "${HFTEST[@]}" --hypervisor "$HYPERVISOR_PATH/hafnium.bin" \ 127 --partitions_json test/vmapi/primary_only_ffa/primary_only_ffa_test.json 128fi 129