blob: e429b27ac0edf2bb015c52105f45dcb672a02068 [file] [log] [blame]
Paul Sokolovsky8634f482021-11-10 17:20:59 +03001#!/usr/bin/env bash
2#
Chris Kay395d49d2022-10-17 13:31:21 +01003# Copyright (c) 2021-2022, Linaro Limited
Paul Sokolovsky8634f482021-11-10 17:20:59 +03004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7# Runner for scripts in expect-post/ directory. This script is intended
8# to be run from Jenkins build, with $WORKSPACE set and per-UART test
Chris Kayef9bf302022-11-02 17:54:38 +00009# plans prepare in artefacts-lava/run/. See expect-post/README.md for
Paul Sokolovsky8634f482021-11-10 17:20:59 +030010# more info about post-expect scripts.
11
Chris Kayfab6edc2022-11-17 19:18:32 +000012ci_root="$(readlink -f "$(dirname "$0")/..")" && \
13 . "${ci_root}/utils.sh"
Paul Sokolovsky8634f482021-11-10 17:20:59 +030014
Paul Sokolovsky993d6632024-07-29 17:38:00 +030015# utils.sh automatically enablea fail-fast backtracing, but we don't to fail
16# on first non-zero exit code, we handle them ourselves here.
17trap - ERR
18
Chris Kayfab6edc2022-11-17 19:18:32 +000019archive="${WORKSPACE}/artefacts-lava"
Paul Sokolovskyabea61d2021-12-01 20:26:12 +030020
Slava Andrianov192ee172025-06-11 15:40:43 -050021if [ $(get_run_env $archive "verify_hashes" 0) -eq 1 ]; then
22 echo "Enabling hash verification for measured boot"
23 export verify_hashes=1
24 export ci_root
25 export artefacts_dir=$archive
26 export tfa_log="${archive}/tfa_event_log"
27fi
28
Chris Kayfab6edc2022-11-17 19:18:32 +000029# Extract UART numbering from the FVP common log using the ports script
30declare -a ports=()
31
32ports_output="$(mktempfile)"
33
34awk -v "num_uarts=$(get_num_uarts "${archive}")" \
35 -f "$(get_ports_script "${archive}")" "${WORKSPACE}/lava-common.log" \
36 > "${ports_output}"
37
38. "${ports_output}" # Appends to `ports`
39
40total=0
41failed=0
42
43for uart in "${!ports[@]}"; do
Chris Kay395d49d2022-10-17 13:31:21 +010044 total=$((total + 1))
45
Chris Kayfab6edc2022-11-17 19:18:32 +000046 uart_log_file="${WORKSPACE}/lava-uart${uart}.log"
47 uart_log_expect_file="${WORKSPACE}/lava-uart${uart}-expect.log"
48
49 if [ "${uart}" = "$(get_payload_uart "${archive}")" ]; then
50 mv "${WORKSPACE}/lava-common.log" "${uart_log_file}"
51 else
52 mv "${WORKSPACE}/lava-${ports[${uart}]:?}.log" "${uart_log_file}"
53 fi
54
55 expscript_stem="$(get_uart_expect_script "${archive}" "${uart}")"
56 expscript="${WORKSPACE}/tf-a-ci-scripts/expect/${expscript_stem}"
57
58 if [ -z "${expscript_stem}" ]; then
59 continue # Some UARTs may (legitimately) not have expectations
60 fi
Chris Kay395d49d2022-10-17 13:31:21 +010061
62 if [ ! -f "${expscript}" ]; then
Chris Kayfab6edc2022-11-17 19:18:32 +000063 echo "expect/${expscript_stem}: MISS"
Chris Kay395d49d2022-10-17 13:31:21 +010064 failed=$((failed + 1))
65
66 continue
67 fi
68
Chris Kay395d49d2022-10-17 13:31:21 +010069 (
Chris Kayfab6edc2022-11-17 19:18:32 +000070 export uart_log_file # Required by the Expect script
71
72 if [ -f "$(get_uart_env_path "${archive}" "${uart}")/env" ]; then
Chris Kay395d49d2022-10-17 13:31:21 +010073 set -a
Chris Kayfab6edc2022-11-17 19:18:32 +000074
75 . "$(get_uart_env_path "${archive}" "${uart}")/env"
76
Chris Kay395d49d2022-10-17 13:31:21 +010077 set +a
78 fi
79
Chris Kayfab6edc2022-11-17 19:18:32 +000080 2>&1 expect "${expscript}" > "${uart_log_expect_file}"
Chris Kay395d49d2022-10-17 13:31:21 +010081 )
82
83 if [ $? != 0 ]; then
Chris Kayfab6edc2022-11-17 19:18:32 +000084 echo "expect/${expscript_stem}(UART${uart}): FAIL"
85
Paul Sokolovsky8634f482021-11-10 17:20:59 +030086 failed=$((failed + 1))
87 else
Chris Kayfab6edc2022-11-17 19:18:32 +000088 echo "expect/${expscript_stem}(UART${uart}): PASS"
Paul Sokolovsky8634f482021-11-10 17:20:59 +030089 fi
Paul Sokolovsky8634f482021-11-10 17:20:59 +030090done
91
Chris Kayfab6edc2022-11-17 19:18:32 +000092echo "Post-LAVA Expect scripts results: total=$total failed=$failed"
Paul Sokolovsky8634f482021-11-10 17:20:59 +030093
94if [ $failed -gt 0 ]; then
95 exit 1
96fi