| #!/usr/bin/env python3 |
| # |
| # Copyright (c) 2021, Linaro Limited |
| # Copyright (c) 2022, Arm Limited. All rights reserved. |
| # |
| # 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: |
| # Wait for the start of the event log dump. |
| for l in f: |
| if re.search("TCG_EfiSpecIDEvent:", l): |
| break |
| |
| for l in f: |
| # Look for the end of the event log dump. |
| if re.search("Booting BL31", l): |
| break |
| |
| # Capture relevant lines in between start and end strings |
| 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) |