blob: 92fff75c473bfc4a2e3925f5709d27fc77516a15 [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
Chris Kayfab6edc2022-11-17 19:18:32 +000021# Extract UART numbering from the FVP common log using the ports script
22declare -a ports=()
23
24ports_output="$(mktempfile)"
25
26awk -v "num_uarts=$(get_num_uarts "${archive}")" \
27 -f "$(get_ports_script "${archive}")" "${WORKSPACE}/lava-common.log" \
28 > "${ports_output}"
29
30. "${ports_output}" # Appends to `ports`
31
32total=0
33failed=0
34
35for uart in "${!ports[@]}"; do
Chris Kay395d49d2022-10-17 13:31:21 +010036 total=$((total + 1))
37
Chris Kayfab6edc2022-11-17 19:18:32 +000038 uart_log_file="${WORKSPACE}/lava-uart${uart}.log"
39 uart_log_expect_file="${WORKSPACE}/lava-uart${uart}-expect.log"
40
41 if [ "${uart}" = "$(get_payload_uart "${archive}")" ]; then
42 mv "${WORKSPACE}/lava-common.log" "${uart_log_file}"
43 else
44 mv "${WORKSPACE}/lava-${ports[${uart}]:?}.log" "${uart_log_file}"
45 fi
46
47 expscript_stem="$(get_uart_expect_script "${archive}" "${uart}")"
48 expscript="${WORKSPACE}/tf-a-ci-scripts/expect/${expscript_stem}"
49
50 if [ -z "${expscript_stem}" ]; then
51 continue # Some UARTs may (legitimately) not have expectations
52 fi
Chris Kay395d49d2022-10-17 13:31:21 +010053
54 if [ ! -f "${expscript}" ]; then
Chris Kayfab6edc2022-11-17 19:18:32 +000055 echo "expect/${expscript_stem}: MISS"
Chris Kay395d49d2022-10-17 13:31:21 +010056 failed=$((failed + 1))
57
58 continue
59 fi
60
Chris Kay395d49d2022-10-17 13:31:21 +010061 (
Chris Kayfab6edc2022-11-17 19:18:32 +000062 export uart_log_file # Required by the Expect script
63
64 if [ -f "$(get_uart_env_path "${archive}" "${uart}")/env" ]; then
Chris Kay395d49d2022-10-17 13:31:21 +010065 set -a
Chris Kayfab6edc2022-11-17 19:18:32 +000066
67 . "$(get_uart_env_path "${archive}" "${uart}")/env"
68
Chris Kay395d49d2022-10-17 13:31:21 +010069 set +a
70 fi
71
Chris Kayfab6edc2022-11-17 19:18:32 +000072 2>&1 expect "${expscript}" > "${uart_log_expect_file}"
Chris Kay395d49d2022-10-17 13:31:21 +010073 )
74
75 if [ $? != 0 ]; then
Chris Kayfab6edc2022-11-17 19:18:32 +000076 echo "expect/${expscript_stem}(UART${uart}): FAIL"
77
Paul Sokolovsky8634f482021-11-10 17:20:59 +030078 failed=$((failed + 1))
79 else
Chris Kayfab6edc2022-11-17 19:18:32 +000080 echo "expect/${expscript_stem}(UART${uart}): PASS"
Paul Sokolovsky8634f482021-11-10 17:20:59 +030081 fi
Paul Sokolovsky8634f482021-11-10 17:20:59 +030082done
83
Chris Kayfab6edc2022-11-17 19:18:32 +000084echo "Post-LAVA Expect scripts results: total=$total failed=$failed"
Paul Sokolovsky8634f482021-11-10 17:20:59 +030085
86if [ $failed -gt 0 ]; then
87 exit 1
88fi