fix: fix FTPM test expectations on OpenCI
The expectations for the FTPM tests need to run in an explicit order
because of an implicit dependency between two UART expectations. This
change reorders the port numbering to enforce that order.
Signed-off-by: Chris Kay <chris.kay@arm.com>
Change-Id: Idc264bcc19ea71e23622979b3750ed334a3f1004
(cherry picked from commit 07756bc04502128d9d933860b999f87cdeada8b9)
diff --git a/expect-lava/linux-tpm-384.exp b/expect-lava/linux-tpm-384.exp
index fd92838..5a44c5e 100644
--- a/expect-lava/linux-tpm-384.exp
+++ b/expect-lava/linux-tpm-384.exp
@@ -26,3 +26,5 @@
expect_string+=("i;#")
expect_string+=("i;${zero_pcr};;;pcrread -ha $i")
done
+
+expect_string+=("i;#;;;@") # Flush newline after final prompt
diff --git a/expect-lava/linux-tpm.exp b/expect-lava/linux-tpm.exp
index fb02652..f305198 100644
--- a/expect-lava/linux-tpm.exp
+++ b/expect-lava/linux-tpm.exp
@@ -29,3 +29,5 @@
expect_string+=("i;#")
expect_string+=("i;${zero_pcr};;;pcrread -ha $i")
done
+
+expect_string+=("i;#;;;@") # Flush newline after final prompt
diff --git a/expect/linux-tpm-384.exp b/expect/linux-tpm-384.exp
index 57674ff..262cf4c 100644
--- a/expect/linux-tpm-384.exp
+++ b/expect/linux-tpm-384.exp
@@ -70,19 +70,14 @@
}
}
+expect_string "#" "finished reading PCRs"
+
# Match the previously stored digest with the one generated by the
# fTPM service. The pass criteria is that both digests must match,
# meaning that TF-A successfully passed the event log to the TPM service.
-expect {
- "#" {
- spawn diff -s $TFA_DIGEST ftpm_event_log
- }
+if {[catch {exec diff -s $TFA_DIGEST ftpm_event_log} result options] == 0} {
+ message "tests succeeded, digests matched"
+} else {
+ message "tests failed, digests did not match"
+ exit_uart -1
}
-
-expect {
- -exact "are identical" {
- exit_uart 0
- }
-}
-
-exit_uart -1
diff --git a/expect/linux-tpm.exp b/expect/linux-tpm.exp
index 6783503..8aff8ce 100644
--- a/expect/linux-tpm.exp
+++ b/expect/linux-tpm.exp
@@ -88,19 +88,14 @@
}
}
+expect_string "#" "finished reading PCRs"
+
# Match the previously stored digest with the one generated by the
# fTPM service. The pass criteria is that both digests must match,
# meaning that TF-A successfully passed the event log to the TPM service.
-expect {
- "#" {
- spawn diff -s $TFA_DIGEST ftpm_event_log
- }
+if {[catch {exec diff -s $TFA_DIGEST ftpm_event_log} result options] == 0} {
+ message "tests succeeded, digests matched"
+} else {
+ message "tests failed, digests did not match"
+ exit_uart -1
}
-
-expect {
- -exact "are identical" {
- exit_uart 0
- }
-}
-
-exit_uart -1
diff --git a/model/ftpm-ports.awk b/model/ftpm-ports.awk
index 515258f..4793421 100644
--- a/model/ftpm-ports.awk
+++ b/model/ftpm-ports.awk
@@ -4,8 +4,8 @@
# SPDX-License-Identifier: BSD-3-Clause
#
-/terminal_0/ { ports[0] = $NF }
-/terminal_1/ { ports[1] = $NF }
+/terminal_0/ { ports[1] = $NF }
+/terminal_1/ { ports[0] = $NF }
END {
for (i = 0; i < num_uarts; i++) {
if (ports[i] != "")
diff --git a/run_config/fvp-linux.rootfs+ftpm b/run_config/fvp-linux.rootfs+ftpm
index 6e7c207..bba9024 100644
--- a/run_config/fvp-linux.rootfs+ftpm
+++ b/run_config/fvp-linux.rootfs+ftpm
@@ -14,9 +14,10 @@
}
generate_lava_job_template() {
- # Configure the uarts for tracking.
- uart="0" timeout="600" file="linux-tpm.exp" track_expect
- uart="1" timeout="600" file="tpm-logs.exp" track_expect
+ # These UARTs are swapped because of an Expect script order requirement
+ uart="1" port="5000" timeout="600" file="linux-tpm.exp" set_primary="1" \
+ track_expect
+ uart="0" port="5001" timeout="600" file="tpm-logs.exp" track_expect
set_run_env "ports_script" "$ci_root/model/ftpm-ports.awk"
set_run_env "num_uarts" "2"
diff --git a/run_config/fvp-linux.rootfs+ftpm_384 b/run_config/fvp-linux.rootfs+ftpm_384
index c8fefe1..aa0e02a 100644
--- a/run_config/fvp-linux.rootfs+ftpm_384
+++ b/run_config/fvp-linux.rootfs+ftpm_384
@@ -17,8 +17,10 @@
}
generate_lava_job_template() {
- uart="0" timeout="600" file="linux-tpm-384.exp" track_expect
- uart="1" timeout="600" file="tpm-logs.exp" track_expect
+ # These UARTs are swapped because of an Expect script order requirement
+ uart="1" port="5000" timeout="600" file="linux-tpm-384.exp" \
+ set_primary="1" track_expect
+ uart="0" port="5001" timeout="600" file="tpm-logs.exp" track_expect
set_run_env "ports_script" "$ci_root/model/ftpm-ports.awk"
set_run_env "num_uarts" "2"