feat: use original Expect scripts for UART validation
To avoid having to implement custom Python post-expect scripts for every
payload that might use a non-primary UART, and to make use of as much
prior art as possible, this change replaces the OpenCI-only post-expect
scripts with the same one uses used by both the local and on-premises CI.
The original Expect scripts have been amended to identify whether they're
being run in the postprocessing step and, if so, load the UART log from a
file rather than connecting to the FVP over Telnet.
Change-Id: I61a5859de4f3f62b50deaffe84580206ec411c99
Signed-off-by: Chris Kay <chris.kay@arm.com>
diff --git a/expect/handle-arguments.inc b/expect/handle-arguments.inc
index f475302..6a730a5 100644
--- a/expect/handle-arguments.inc
+++ b/expect/handle-arguments.inc
@@ -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
#
@@ -10,8 +10,14 @@
source [file join [file dirname [info script]] utils.inc]
# Store environment variables into local variables
-set uart_port [get_param uart_port]
-set timeout [get_param timeout]
+set timeout [get_param timeout 30]
-# Open a telnet connection on the required UART port
-set telnet_pid [spawn telnet localhost $uart_port]
+if { [postprocessing] != 1 } {
+ # Open a Telnet connection to the required UART port
+ set uart_port [get_param uart_port]
+ set telnet_pid [spawn telnet localhost $uart_port]
+} else {
+ # Read directly from the UART log file
+ set uart_log_file [get_param uart_log_file]
+ set telnet_pid [spawn cat $uart_log_file]
+}
diff --git a/expect/spm-optee-sp-uart1.exp b/expect/spm-optee-sp-uart1.exp
index c874551..6908609 100644
--- a/expect/spm-optee-sp-uart1.exp
+++ b/expect/spm-optee-sp-uart1.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,7 +7,7 @@
source [file join [file dirname [info script]] handle-arguments.inc]
expect {
- "OP-TEE version: 3.3" {
+ "OP-TEE version: " {
puts "<<OP-TEE version>>"
}
timeout {
diff --git a/expect/utils.inc b/expect/utils.inc
index 0100534..3d5a7f5 100644
--- a/expect/utils.inc
+++ b/expect/utils.inc
@@ -1,8 +1,19 @@
#
-# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
+# Copyright (c) 2019-2022, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
+
+# Determine whether the script is being run on a live FVP UART terminal or
+# postprocessing a UART log file (probably dumped by LAVA).
+proc postprocessing {} {
+ if { [info exists ::env(uart_log_file)] } {
+ return 1
+ } else {
+ return 0
+ }
+}
+
# Retrieve script parameters from environment variables. If they don't exist,
# return empty string
proc get_param {name {default ""}} {
@@ -14,10 +25,13 @@
}
proc exit_uart {status} {
- # Allow UART output to flush
- sleep 1
- send "\x1b"
- send "close\r"
+ if { [postprocessing] != 1 } {
+ # Allow UART output to flush
+ sleep 1
+ send "\x1b"
+ send "close\r"
+ }
+
exit $status
}