expect-post: Introduce post-expect scripts to match logs post-factum
Currently LAVA cannot peform test matching on any UARTs but the main
one (UART0). However, existing expect scripts for other UARTs are
simple and just passively parse the output. So, it's possible to
just capture the UART output to a log file (what LAVA already does)
and then parse and analyze this log file. This is exactly the idea
behind post-expect scripts: where e.g. expect/tsp.exp would be run
by ArmCI (in parallel with other expect scripts), OpenCI will run
expect-lava/tsp.exp - after LAVA tests finished and logs are captured.
Currently, post-expect scripts are intended to handle all UARTs but
UART0 (UART0 is handled by lava-expect/ instead).
The directory is named `expect-post` to sort together with `expect`
and so relationship between them is clearer.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: I8659d2e4740dcd8050bf72c035bf31481bd69b16
diff --git a/script/expect-post-runner.sh b/script/expect-post-runner.sh
new file mode 100755
index 0000000..c41851e
--- /dev/null
+++ b/script/expect-post-runner.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2021, Linaro Limited
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Runner for scripts in expect-post/ directory. This script is intended
+# to be run from Jenkins build, with $WORKSPACE set and per-UART test
+# plans prepare in artefacts/debug/run/. See expect-post/README.md for
+# more info about post-expect scripts.
+
+set -e
+
+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
+
+for uartdir in $WORKSPACE/artefacts/debug/run/uart*; do
+ uart=$(basename $uartdir)
+ if [ $uart == "uart0" ]; then
+ continue
+ fi
+ expscript=$(cat $uartdir/expect)
+ if [ ! -f $WORKSPACE/tf-a-ci-scripts/expect-post/$expscript ]; then
+ echo "expect-post/$expscript: MISS"
+ continue
+ fi
+ if ! $WORKSPACE/tf-a-ci-scripts/expect-post/$expscript $WORKSPACE/lava-$uart.log; then
+ echo "expect-post/$expscript($uart): FAIL"
+ failed=$((failed + 1))
+ else
+ echo "expect-post/$expscript($uart): pass"
+ fi
+ total=$((total + 1))
+done
+
+echo "Post expect scripts: total=$total failed=$failed"
+
+if [ $failed -gt 0 ]; then
+ exit 1
+fi