blob: 3b38e6509da90ce976f5f8b67970bfbd6578082d [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
Chris Kayfab6edc2022-11-17 19:18:32 +000015archive="${WORKSPACE}/artefacts-lava"
Paul Sokolovskyabea61d2021-12-01 20:26:12 +030016
Chris Kayfab6edc2022-11-17 19:18:32 +000017# Extract UART numbering from the FVP common log using the ports script
18declare -a ports=()
19
20ports_output="$(mktempfile)"
21
22awk -v "num_uarts=$(get_num_uarts "${archive}")" \
23 -f "$(get_ports_script "${archive}")" "${WORKSPACE}/lava-common.log" \
24 > "${ports_output}"
25
26. "${ports_output}" # Appends to `ports`
27
28total=0
29failed=0
30
31for uart in "${!ports[@]}"; do
Chris Kay395d49d2022-10-17 13:31:21 +010032 total=$((total + 1))
33
Chris Kayfab6edc2022-11-17 19:18:32 +000034 uart_log_file="${WORKSPACE}/lava-uart${uart}.log"
35 uart_log_expect_file="${WORKSPACE}/lava-uart${uart}-expect.log"
36
37 if [ "${uart}" = "$(get_payload_uart "${archive}")" ]; then
38 mv "${WORKSPACE}/lava-common.log" "${uart_log_file}"
39 else
40 mv "${WORKSPACE}/lava-${ports[${uart}]:?}.log" "${uart_log_file}"
41 fi
42
43 expscript_stem="$(get_uart_expect_script "${archive}" "${uart}")"
44 expscript="${WORKSPACE}/tf-a-ci-scripts/expect/${expscript_stem}"
45
46 if [ -z "${expscript_stem}" ]; then
47 continue # Some UARTs may (legitimately) not have expectations
48 fi
Chris Kay395d49d2022-10-17 13:31:21 +010049
50 if [ ! -f "${expscript}" ]; then
Chris Kayfab6edc2022-11-17 19:18:32 +000051 echo "expect/${expscript_stem}: MISS"
Chris Kay395d49d2022-10-17 13:31:21 +010052 failed=$((failed + 1))
53
54 continue
55 fi
56
Chris Kay395d49d2022-10-17 13:31:21 +010057 (
Chris Kayfab6edc2022-11-17 19:18:32 +000058 export uart_log_file # Required by the Expect script
59
60 if [ -f "$(get_uart_env_path "${archive}" "${uart}")/env" ]; then
Chris Kay395d49d2022-10-17 13:31:21 +010061 set -a
Chris Kayfab6edc2022-11-17 19:18:32 +000062
63 . "$(get_uart_env_path "${archive}" "${uart}")/env"
64
Chris Kay395d49d2022-10-17 13:31:21 +010065 set +a
66 fi
67
Chris Kayfab6edc2022-11-17 19:18:32 +000068 2>&1 expect "${expscript}" > "${uart_log_expect_file}"
Chris Kay395d49d2022-10-17 13:31:21 +010069 )
70
71 if [ $? != 0 ]; then
Chris Kayfab6edc2022-11-17 19:18:32 +000072 echo "expect/${expscript_stem}(UART${uart}): FAIL"
73
Paul Sokolovsky8634f482021-11-10 17:20:59 +030074 failed=$((failed + 1))
75 else
Chris Kayfab6edc2022-11-17 19:18:32 +000076 echo "expect/${expscript_stem}(UART${uart}): PASS"
Paul Sokolovsky8634f482021-11-10 17:20:59 +030077 fi
Paul Sokolovsky8634f482021-11-10 17:20:59 +030078done
79
Chris Kayfab6edc2022-11-17 19:18:32 +000080echo "Post-LAVA Expect scripts results: total=$total failed=$failed"
Paul Sokolovsky8634f482021-11-10 17:20:59 +030081
82if [ $failed -gt 0 ]; then
83 exit 1
84fi