1#!/bin/bash
2#
3# Copyright 2023 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# Default log level
10HFTEST_LOG_LEVEL="INFO"
11
12# Parse script arguments
13while test $# -gt 0
14do
15  case "$1" in
16    --debug)
17      HFTEST_LOG_LEVEL="DEBUG"
18      ;;
19    -h|--help)
20      echo "Usage: $0 [debug|info]"
21      exit 0
22      ;;
23    *)
24      echo "Unexpected argument $1"
25      echo "Run with -h or --help for usage."
26      exit 1
27      ;;
28  esac
29  shift
30done
31
32# TIMEOUT, PROJECT, OUT, LOG_DIR_BASE set in:
33KOKORO_DIR="$(dirname "$0")"
34source $KOKORO_DIR/test_common.sh
35
36DRIVER="fvp"
37
38HFTEST=(${TIMEOUT[@]} 1000s ./test/hftest/drivers/hftest.py $DRIVER)
39
40HYPERVISOR_PATH="$OUT/aem_v8a_fvp_vhe_ffa_v1_1_clang"
41
42HFTEST+=(--log "$LOG_DIR_BASE/el3_spmc")
43HFTEST+=(--el3_spmc)
44
45# Add hftest loglevel argument
46HFTEST+=(--log-level "$HFTEST_LOG_LEVEL")
47
48# Test Hafnium primary VM with EL3 SPMC and services SP
49${HFTEST[@]} --hypervisor "$HYPERVISOR_PATH/hafnium.bin" --out_partitions "$OUT/secure_aem_v8a_fvp_vhe_vm_clang" \
50             --partitions_json test/vmapi/ffa_both_worlds_el3_spmc/ffa_both_world_partitions_test.json
51
52#Test Hafnium primary_only_test with EL3 SPMC and TSP SP
53${HFTEST[@]}  --out_initrd "$OUT/aem_v8a_fvp_vhe_ffa_v1_1_vm_clang" --hypervisor "$HYPERVISOR_PATH/hafnium.bin" \
54                    --initrd test/vmapi/primary_only/primary_only_test
55
56#Test EL3 SPMC with S-EL1 SP based on Hafnium standalone secure SP
57${HFTEST[@]} --out_partitions "$OUT/secure_aem_v8a_fvp_vhe_vm_clang" --partitions_json \
58	test/vmapi/ffa_secure_partition_el3_spmc/ffa_secure_partition_only_test.json
59