expect-post/tpm-logs.exp: Conversion of the TCL expect script.

Just as the original, it doesn't really check anything, just extracts
bits of information into a separate log file, ftpm_event_log. Effort
was taken to produce exact output as the original script (based
on tf-l1-boot-tests-misc/fvp-mb-256-optee-romlib:fvp-optee.mb-linux.rootfs+ftpm-romlib-fip.ftpm-aemv8a
output), even though that output isn't exactly pretty (double
newlines, etc.).

expect-post/tpm-logs.exp: Compare output with TF side.

Also extract pertinent log lines from the TF side of execution, and
then compare output from TPM and TF. In ArmCI, these latter actions
are performed in linux-tpm.exp, but in OpenCI that script runs in
LAVA, which can't execute arbitrary actions, it makes sense to
move that to post-expect script, i.e. tpm-logs.exp.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: Ia9133a9b8f4090a78080a987776ada3fb66ec1ac
diff --git a/expect-post/tpm-logs.exp b/expect-post/tpm-logs.exp
new file mode 100755
index 0000000..fb10b80
--- /dev/null
+++ b/expect-post/tpm-logs.exp
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2021, Linaro Limited
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+import re
+import sys
+from subprocess import check_call
+
+
+PATTERN = "\
+Digest(\\s|\\w)*:\\s(\\w{2}\\s){16}|\
+ : (\\w{2}\\s){16}|\
+ Event\\w*\\s*:\\s\\w+\\s"
+
+
+# Extract pertinent information from TPM side.
+with open(sys.argv[1]) as f, open("ftpm_event_log", "w") as out:
+    for l in f:
+        m = re.search(PATTERN, l)
+        if m:
+            print(m.group(), file=out)
+
+# Extract pertinent information from TF side.
+with open(sys.argv[1].replace("uart1", "uart0")) as f, open("tfa_event_log", "w") as out:
+    for l in f:
+        m = re.search(PATTERN, l)
+        if m:
+            print(m.group(), file=out)
+
+# Compare it to match.
+check_call("diff -s -u tfa_event_log ftpm_event_log", shell=True)