fvp_utils.sh: support Monitor LAVA Test actions

Monitor test actions [1] are useful to define multiple expect matches
through regular expressions and can work together with the current
interactive test actions [2], the latter commonly used for single
expect matches and interaction with the booted model.

The change implied a complete refactor of current defined expect
strings, where now these must define whether is a interactive or
monitor test action through a leading char: 'i' for interactive or 'm'
for monitor.

To provide an short example, if we define the following lava expect script

    expect_string+=('m;Booting Trusted Firmware;\
                       Booting BL31;\
                       Digest(\s|\w)*:\s(\w{2}\s){16}@: (\w{2}\s){16}@Event(\s|\w)*:\s\w+\s')

    expect_string+=('i;buildroot login:')

The CI processes it and converts it into the LAVA job definition [3]:

    .
    .
    - test:
       timeout:
        minutes: 15
       monitors:
       - name: tests
         start: 'Booting Trusted Firmware'
         end: 'Booting BL31'
         pattern: 'Digest(\s|\w)*:\s(\w{2}\s){16}'
         pattern: ': (\w{2}\s){16}'
         pattern: 'Event(\s|\w)*:\s\w+\s'
         fixupdict:
          PASS: pass
          FAIL: fail
    - test:
       timeout:
        minutes: 15
       interactive:
       - name: uart0_0
         prompts: ['buildroot login:']
         script:
         - name: result
           command:

Note that boht type of actions are defined. The lava-expects/README.md
has more information about the details implied on this change.

[1] https://validation.linaro.org/static/docs/v2/monitors.html
[2] https://validation.linaro.org/static/docs/v2/actions-test.html#interactive-test-action
[3] https://tf.validation.linaro.org/scheduler/job/312768

Signed-off-by: Leonardo Sandoval <leonardo.sandoval@linaro.org>
Change-Id: Icc05403abf59f30ded60565b8c942d53a91d3990
diff --git a/lava-expect/linux-tpm.exp b/lava-expect/linux-tpm.exp
index f0755da..27adf92 100644
--- a/lava-expect/linux-tpm.exp
+++ b/lava-expect/linux-tpm.exp
@@ -6,4 +6,23 @@
 # Expect script for Linux/Buildroot using Measured Boot & fTPM
 #
 
-# TODO
+non_zero_pcr='(?!(\s00){16})((\s([0-9a-f]){2}){16}\s)'
+
+# Parse the event log from the debug logs and store the digests
+# so they can be matched later with what the fTPM read.
+
+expect_string+=('m;Booting Trusted Firmware;Booting BL31;Digest(\s|\w)*:\s(\w{2}\s){16}@: (\w{2}\s){16}@Event(\s|\w)*:\s\w+\s')
+
+# Wait for the login prompt
+expect_string+=('i;buildroot login:')
+
+# Load the fTPM driver and retrieves PCR0
+# Pass condition: PCR0 must not be all zeros.
+expect_string+=("i;#;${non_zero_pcr};;root@ftpm")
+
+# Iterate over the rest of PCRs and check that they all are zeros.
+zero_pcr="(\s00){16}\s+(00\s){16}"
+for i in $(seq 1 11); do
+    expect_string+=("i;#;${zero_pcr};;pcrread -ha $i")
+done
+