blob: b695b3109b7769eb1fee55c25cf7f9cbdf42d911 [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 Kay3a968862022-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 Kay395d49d2022-10-17 13:31:21 +010015# TODO: move dependency installation to the Dockerfile
16sudo DEBIAN_FRONTEND=noninteractive apt update && \
17 sudo DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y expect ||
18 exit 1
19
Chris Kay3a968862022-11-17 19:18:32 +000020archive="${WORKSPACE}/artefacts-lava"
Paul Sokolovskyabea61d2021-12-01 20:26:12 +030021
Chris Kay3a968862022-11-17 19:18:32 +000022# Extract UART numbering from the FVP common log using the ports script
23declare -a ports=()
24
25ports_output="$(mktempfile)"
26
27awk -v "num_uarts=$(get_num_uarts "${archive}")" \
28 -f "$(get_ports_script "${archive}")" "${WORKSPACE}/lava-common.log" \
29 > "${ports_output}"
30
31. "${ports_output}" # Appends to `ports`
32
33total=0
34failed=0
35
36for uart in "${!ports[@]}"; do
Chris Kay395d49d2022-10-17 13:31:21 +010037 total=$((total + 1))
38
Chris Kay3a968862022-11-17 19:18:32 +000039 uart_log_file="${WORKSPACE}/lava-uart${uart}.log"
40 uart_log_expect_file="${WORKSPACE}/lava-uart${uart}-expect.log"
41
42 if [ "${uart}" = "$(get_payload_uart "${archive}")" ]; then
43 mv "${WORKSPACE}/lava-common.log" "${uart_log_file}"
44 else
45 mv "${WORKSPACE}/lava-${ports[${uart}]:?}.log" "${uart_log_file}"
46 fi
47
48 expscript_stem="$(get_uart_expect_script "${archive}" "${uart}")"
49 expscript="${WORKSPACE}/tf-a-ci-scripts/expect/${expscript_stem}"
50
51 if [ -z "${expscript_stem}" ]; then
52 continue # Some UARTs may (legitimately) not have expectations
53 fi
Chris Kay395d49d2022-10-17 13:31:21 +010054
55 if [ ! -f "${expscript}" ]; then
Chris Kay3a968862022-11-17 19:18:32 +000056 echo "expect/${expscript_stem}: MISS"
Chris Kay395d49d2022-10-17 13:31:21 +010057 failed=$((failed + 1))
58
59 continue
60 fi
61
Chris Kay395d49d2022-10-17 13:31:21 +010062 (
Chris Kay3a968862022-11-17 19:18:32 +000063 export uart_log_file # Required by the Expect script
64
65 if [ -f "$(get_uart_env_path "${archive}" "${uart}")/env" ]; then
Chris Kay395d49d2022-10-17 13:31:21 +010066 set -a
Chris Kay3a968862022-11-17 19:18:32 +000067
68 . "$(get_uart_env_path "${archive}" "${uart}")/env"
69
Chris Kay395d49d2022-10-17 13:31:21 +010070 set +a
71 fi
72
Chris Kay3a968862022-11-17 19:18:32 +000073 2>&1 expect "${expscript}" > "${uart_log_expect_file}"
Chris Kay395d49d2022-10-17 13:31:21 +010074 )
75
76 if [ $? != 0 ]; then
Chris Kay3a968862022-11-17 19:18:32 +000077 echo "expect/${expscript_stem}(UART${uart}): FAIL"
78
Paul Sokolovsky8634f482021-11-10 17:20:59 +030079 failed=$((failed + 1))
80 else
Chris Kay3a968862022-11-17 19:18:32 +000081 echo "expect/${expscript_stem}(UART${uart}): PASS"
Paul Sokolovsky8634f482021-11-10 17:20:59 +030082 fi
Paul Sokolovsky8634f482021-11-10 17:20:59 +030083done
84
Chris Kay3a968862022-11-17 19:18:32 +000085echo "Post-LAVA Expect scripts results: total=$total failed=$failed"
Paul Sokolovsky8634f482021-11-10 17:20:59 +030086
87if [ $failed -gt 0 ]; then
88 exit 1
89fi