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
(cherry picked from commit 38c68965ceafedb36cdf3eb0b64a5160db1486c0)
diff --git a/expect/timeout_test.exp b/expect/timeout_test.exp
index 7e2b758..11fb0c5 100644
--- a/expect/timeout_test.exp
+++ b/expect/timeout_test.exp
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
+# Copyright (c) 2019-2022 Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -9,11 +9,5 @@
 source [file join [file dirname [info script]] handle-arguments.inc]
 
 expect_string "Booting trusted firmware test framework" "Starting TFTF"
-expect {
-        timeout {
-		puts "<<Timeout expected - Success>>"
-                exit_uart 0
-        }
-}
 
-exit_uart -1
+source [file join [file dirname [info script]] timeout.inc]