refactor: use updated LAVA log names in post-LAVA Expect scripts
The log splitting script (part of the CI jobs repository) now directs
LAVA terminal output to files of the form `lava-${NAME}.log`, where
`NAME` is the name of the terminal captured by the `NAME` regular
expression groups specified by the feedbacks in the LAVA job definition.
A recent edge-case showed that platforms with duplicate terminal names
may exist, which means we must now make several adjustments to how we
enumerate the terminals and name our feedbacks.
The most prominent change is that feedback terminals in the LAVA job
definitions now use the port as the feedback name. The port is the only
mechanism we have for uniquely identifying a UART so given its FVP
terminal printout so, while it isn't pretty, it is at least resilient.
Signed-off-by: Chris Kay <chris.kay@arm.com>
Change-Id: Ib6222e6342e7d795ea1f3f603ba1fed9405cb81b
diff --git a/script/build_package.sh b/script/build_package.sh
index c2a7058..15131bb 100755
--- a/script/build_package.sh
+++ b/script/build_package.sh
@@ -259,6 +259,10 @@
echo "UART$uart to be tracked with $file; timeout ${timeout}s"
+ if [ ! -z "${port}" ]; then
+ echo "${port}" > "$uart_dir/port"
+ fi
+
# The run script assumes UART0 to be primary. If we're asked to set any
# other UART to be primary, set a run environment variable to signal
# that to the run script
diff --git a/script/expect-post-runner.sh b/script/expect-post-runner.sh
index 4f3ab68..b695b31 100755
--- a/script/expect-post-runner.sh
+++ b/script/expect-post-runner.sh
@@ -9,60 +9,80 @@
# plans prepare in artefacts-lava/run/. See expect-post/README.md for
# more info about post-expect scripts.
-if [ -z "$WORKSPACE" ]; then
- echo "Error: WORKSPACE is not set. This script is intended to be run from Jenkins build. (Or suitably set up local env)."
- exit 1
-fi
-
-total=0
-failed=0
+ci_root="$(readlink -f "$(dirname "$0")/..")" && \
+ . "${ci_root}/utils.sh"
# TODO: move dependency installation to the Dockerfile
sudo DEBIAN_FRONTEND=noninteractive apt update && \
sudo DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y expect ||
exit 1
-for uartdir in $WORKSPACE/artefacts-lava/run/uart*; do
- # In case no dirs exist and the glob above isn't expanded at all.
- if [ ! -d "$uartdir" ]; then
- break
- fi
+archive="${WORKSPACE}/artefacts-lava"
+# Extract UART numbering from the FVP common log using the ports script
+declare -a ports=()
+
+ports_output="$(mktempfile)"
+
+awk -v "num_uarts=$(get_num_uarts "${archive}")" \
+ -f "$(get_ports_script "${archive}")" "${WORKSPACE}/lava-common.log" \
+ > "${ports_output}"
+
+. "${ports_output}" # Appends to `ports`
+
+total=0
+failed=0
+
+for uart in "${!ports[@]}"; do
total=$((total + 1))
- expscript_fragment=$(cat ${uartdir}/expect)
- expscript=${WORKSPACE}/tf-a-ci-scripts/expect/${expscript_fragment}
+ uart_log_file="${WORKSPACE}/lava-uart${uart}.log"
+ uart_log_expect_file="${WORKSPACE}/lava-uart${uart}-expect.log"
+
+ if [ "${uart}" = "$(get_payload_uart "${archive}")" ]; then
+ mv "${WORKSPACE}/lava-common.log" "${uart_log_file}"
+ else
+ mv "${WORKSPACE}/lava-${ports[${uart}]:?}.log" "${uart_log_file}"
+ fi
+
+ expscript_stem="$(get_uart_expect_script "${archive}" "${uart}")"
+ expscript="${WORKSPACE}/tf-a-ci-scripts/expect/${expscript_stem}"
+
+ if [ -z "${expscript_stem}" ]; then
+ continue # Some UARTs may (legitimately) not have expectations
+ fi
if [ ! -f "${expscript}" ]; then
- echo "expect/${expscript_fragment}: MISS"
+ echo "expect/${expscript_stem}: MISS"
failed=$((failed + 1))
continue
fi
- uart=$(basename $uartdir)
-
(
- if [ -f "${uartdir}/env" ]; then
+ export uart_log_file # Required by the Expect script
+
+ if [ -f "$(get_uart_env_path "${archive}" "${uart}")/env" ]; then
set -a
- source "${uartdir}/env"
+
+ . "$(get_uart_env_path "${archive}" "${uart}")/env"
+
set +a
fi
- export uart_log_file="${WORKSPACE}/lava-${uart}.log"
-
- 2>&1 expect "${expscript}" > "${WORKSPACE}/lava-${uart}-expect.log"
+ 2>&1 expect "${expscript}" > "${uart_log_expect_file}"
)
if [ $? != 0 ]; then
- echo "expect/${expscript_fragment}(${uart}): FAIL"
+ echo "expect/${expscript_stem}(UART${uart}): FAIL"
+
failed=$((failed + 1))
else
- echo "expect/${expscript_fragment}(${uart}): pass"
+ echo "expect/${expscript_stem}(UART${uart}): PASS"
fi
done
-echo "Post expect scripts: total=$total failed=$failed"
+echo "Post-LAVA Expect scripts results: total=$total failed=$failed"
if [ $failed -gt 0 ]; then
exit 1
diff --git a/script/lava-templates/fvp-linux.yaml b/script/lava-templates/fvp-linux.yaml
index f512690..6187e14 100644
--- a/script/lava-templates/fvp-linux.yaml
+++ b/script/lava-templates/fvp-linux.yaml
@@ -62,16 +62,16 @@
local: true
image: ${model_dir}/${model_bin}
version_string: ${version_string}
- console_string: '${ports[$(get_payload_uart "${archive}")]:?}: Listening for serial connection on port (?P<PORT>\d+)'
+ console_string: 'terminal_\w+: Listening for serial connection on port (?P<PORT>$(get_uart_port "${archive:?}" "$(get_payload_uart "${archive:?}")"))'
feedbacks:
-$(for port in "${ports[@]}"; do
- if [ "${port}" = "${ports[$(get_payload_uart "${archive}")]}" ]; then
+$(for uart in $(seq 0 $(( $(get_num_uarts "${archive:?}") - 1 ))); do
+ if [ "${uart}" = "$(get_payload_uart "${archive:?}")" ]; then
continue
fi
cat <<-YAML
- - '(?P<NAME>${port}): Listening for serial connection on port (?P<PORT>\d+)'
+ - 'terminal_\w+: Listening for serial connection on port (?P<NAME>(?P<PORT>$(get_uart_port "${archive:?}" "${uart}")))'
YAML
done)
diff --git a/script/lava-templates/fvp-tftf.yaml b/script/lava-templates/fvp-tftf.yaml
index 73d0a2e..0e49171 100644
--- a/script/lava-templates/fvp-tftf.yaml
+++ b/script/lava-templates/fvp-tftf.yaml
@@ -75,16 +75,16 @@
local: true
image: ${model_dir}/${model_bin}
version_string: ${version_string}
- console_string: '${ports[$(get_payload_uart "${archive}")]:?}: Listening for serial connection on port (?P<PORT>\d+)'
+ console_string: 'terminal_\w+: Listening for serial connection on port (?P<PORT>$(get_uart_port "${archive:?}" "$(get_payload_uart "${archive:?}")"))'
feedbacks:
-$(for port in "${ports[@]}"; do
- if [ "${port}" = "${ports[$(get_payload_uart "${archive}")]}" ]; then
+$(for uart in $(seq 0 $(( $(get_num_uarts "${archive:?}") - 1 ))); do
+ if [ "${uart}" = "$(get_payload_uart "${archive:?}")" ]; then
continue
fi
cat <<-YAML
- - '(?P<NAME>${port}): Listening for serial connection on port (?P<PORT>\d+)'
+ - 'terminal_\w+: Listening for serial connection on port (?P<NAME>(?P<PORT>$(get_uart_port "${archive:?}" "${uart}")))'
YAML
done)