blob: ea9a3ca7ec86b8070a095b4e94c6e28e595f7f7d [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
9# plans prepare in artefacts/debug/run/. See expect-post/README.md for
10# more info about post-expect scripts.
11
Paul Sokolovsky8634f482021-11-10 17:20:59 +030012if [ -z "$WORKSPACE" ]; then
13 echo "Error: WORKSPACE is not set. This script is intended to be run from Jenkins build. (Or suitably set up local env)."
14 exit 1
15fi
16
17total=0
18failed=0
19
Chris Kay395d49d2022-10-17 13:31:21 +010020# TODO: move dependency installation to the Dockerfile
21sudo DEBIAN_FRONTEND=noninteractive apt update && \
22 sudo DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y expect ||
23 exit 1
24
Paul Sokolovsky8634f482021-11-10 17:20:59 +030025for uartdir in $WORKSPACE/artefacts/debug/run/uart*; do
Paul Sokolovskyabea61d2021-12-01 20:26:12 +030026 # In case no dirs exist and the glob above isn't expanded at all.
27 if [ ! -d "$uartdir" ]; then
28 break
29 fi
30
Chris Kay395d49d2022-10-17 13:31:21 +010031 total=$((total + 1))
32
33 expscript_fragment=$(cat ${uartdir}/expect)
34 expscript=${WORKSPACE}/tf-a-ci-scripts/expect/${expscript_fragment}
35
36 if [ ! -f "${expscript}" ]; then
37 echo "expect/${expscript_fragment}: MISS"
38 failed=$((failed + 1))
39
40 continue
41 fi
42
Paul Sokolovsky8634f482021-11-10 17:20:59 +030043 uart=$(basename $uartdir)
Chris Kay395d49d2022-10-17 13:31:21 +010044
45 (
46 if [ -f "${uartdir}/env" ]; then
47 set -a
48 source "${uartdir}/env"
49 set +a
50 fi
51
52 export uart_log_file="${WORKSPACE}/lava-${uart}.log"
53
54 expect "${expscript}"
55 )
56
57 if [ $? != 0 ]; then
58 echo "expect/${expscript_fragment}(${uart}): FAIL"
Paul Sokolovsky8634f482021-11-10 17:20:59 +030059 failed=$((failed + 1))
60 else
Chris Kay395d49d2022-10-17 13:31:21 +010061 echo "expect/${expscript_fragment}(${uart}): pass"
Paul Sokolovsky8634f482021-11-10 17:20:59 +030062 fi
Paul Sokolovsky8634f482021-11-10 17:20:59 +030063done
64
65echo "Post expect scripts: total=$total failed=$failed"
66
67if [ $failed -gt 0 ]; then
68 exit 1
69fi