refactor(expect): introduce timeout Expect script fragment
This change introduces an Expect script fragment for handling timeouts
sanely on both the on-premises CI and the OpenCI.
The two CI systems need a different mechanism for dealing with timeouts
because they both read from the UARTs in different ways. In the OpenCI,
an Expect script cannot "time out" in the conventional sense because
UART logs are generated by LAVA and merely read from the log file by
Expect. This differs from the on-premises CI, which spawns a telnet
terminal to read UART output live.
Timeouts must therefore look for both a real timeout and the stream EOF.
If either of these are encountered then the script exits with success,
otherwise it exits with failure.
Additionally, the fragment looks for common failure cases - "hung" UARTs
should neither include a crash dump nor reach the end of TFTF.
Signed-off-by: Chris Kay <chris.kay@arm.com>
Change-Id: Ic15df36fc563458734a64e61420f29bcf09ea566
diff --git a/expect/timeout.exp b/expect/timeout.exp
index 276244c..4a57fd9 100644
--- a/expect/timeout.exp
+++ b/expect/timeout.exp
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -7,12 +7,4 @@
#
source [file join [file dirname [info script]] handle-arguments.inc]
-
-expect {
- timeout {
- puts "<<Timeout expected - Success>>"
- exit_uart 0
- }
-}
-
-exit_uart -1
+source [file join [file dirname [info script]] timeout.inc]