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/fvp_utils.sh b/fvp_utils.sh
index 109d3fe..c159c8b 100644
--- a/fvp_utils.sh
+++ b/fvp_utils.sh
@@ -622,8 +622,10 @@
}
gen_fvp_yaml_expect() {
- # Loop through all uarts expect files
+
run_root="$archive/run"
+
+ # Loop through all uarts expect files
for expect_file in $(find $run_root -name expect); do
# TODO: currently, only handle UART 0
@@ -636,10 +638,21 @@
;;
esac
- # Array containing expect strings and populated during run config execution
+ # Array containing "interactive" or "monitor" expect strings and populated during run config execution.
+ # Interactive expect scripts are converted into LAVA Interactive Test Actions (see
+ # https://tf.validation.linaro.org/static/docs/v2/interactive.html#writing-tests-interactive) and
+ # monitor expect scripts are converted into LAVA Monitor Test Actions (see
+ # https://validation.linaro.org/static/docs/v2/actions-test.html#monitor)
+ #
+ # Interactive Expect strings have the format 'i;<prompt>;<succeses>;<failures>;<commands>'
+ # where multiple successes or failures or commands are separated by @
+ #
+ # Monitor Expect strings have the format 'm;<start>;<end>;<patterns>'
+ # where multiple patterns are separated by @
+ #
expect_string=()
- # Get the real name of the expect file
+ # Get the real name of the expect file
expect_file=$(cat $expect_file)
# Source the run_config enviroment variables
@@ -652,100 +665,178 @@
expect_file=$ci_root/lava-expect/${expect_file}
source $expect_file
- # Append the corresponding test-interactive commands
+
if [ ${#expect_string[@]} -gt 0 ]; then
- cat << EOF
-- test:
- timeout:
- minutes: 15
- interactive:
-EOF
+ # expect loop
for key in "${!expect_string[@]}"; do
- # Expect strings have the format '<prompt>;<successes>;<failures>', so use these
- # arrays to store them separately
- prompts=()
- successes=()
- failures=()
- commands=()
+ # single raw expect string
+ es="${expect_string[${key}]}"
- # Parse expect string values and split into the arrays
- for es in "${expect_string[@]}"; do
- prompts+=("$(echo "${es}" | awk -F ';' '{print $1}')")
- successes+=("$(echo "${es}" | awk -F ';' '{print $2}')")
- failures+=("$(echo "${es}" | awk -F ';' '{print $3}')")
- commands+=("$(echo "${es}" | awk -F ';' '{print $4}')")
- done
+ # action type: either m or i
+ action="$(echo "${es}" | awk -F ';' '{print $1}')"
- OLD_IFS=$IFS; IFS=$'@'
+ if [ "${action}" = "m" ]; then
- if [[ -n "${prompts[$key]}" && -n "${successes[$key]}" && -n "${failures[$key]}" ]]; then
+ start="$(echo "${es}" | awk -F ';' '{print $2}')"
+ end="$(echo "${es}" | awk -F ';' '{print $3}')"
+ patterns="$(echo "${es}" | awk -F ';' '{print $4}')"
+
cat << EOF
- - name: ${uart_number}_${key}
- prompts: ['${prompts[$key]}']
- script:
- - name: result
- command: ${commands[$key]}
+- test:
+ monitors:
+ - name: tests
+ start: '${start}'
+ end: '${end}'
EOF
+ # Patterns are separated by '@'
+ OLD_IFS=$IFS; IFS=$'@'
+ for p in ${patterns}; do
+ cat << EOF
+ pattern: '$p'
+EOF
+ done
+ IFS=$OLD_IFS
cat << EOF
+ fixupdict:
+ PASS: pass
+ FAIL: fail
+EOF
+ fi # end of monitor action
+
+ if [ "${action}" = "i" ]; then
+
+ prompts="$(echo "${es}" | awk -F ';' '{print $2}')"
+ successes="$(echo "${es}" | awk -F ';' '{print $3}')"
+ failures="$(echo "${es}" | awk -F ';' '{print $4}')"
+ commands="$(echo "${es}" | awk -F ';' '{print $5}')"
+
+ cat << EOF
+- test:
+ interactive:
+EOF
+ OLD_IFS=$IFS; IFS=$'@'
+
+ if [[ -n "${prompts}" && -n "${successes}" && -n "${failures}" ]]; then
+ cat << EOF
+ - name: interactive_${uart_number}_${key}
+ prompts: ['${prompts}']
+ script:
+EOF
+ if [ -z "${commands}" ]; then
+ cat <<EOF
+ - name: interactive_command_${uart_number}_${key}
+ command:
+EOF
+ else
+ for c in ${commands}; do
+ cat <<EOF
+ - name: interactive_command_${uart_number}_${key}
+ command: $c
+EOF
+ done
+ fi
+ cat << EOF
successes:
EOF
- for s in ${successes[$key]}; do
- cat <<EOF
+ for s in ${successes}; do
+ cat <<EOF
- message: '$s'
EOF
- done
- cat << EOF
+ done
+ cat << EOF
failures:
EOF
- for f in ${failures[$key]}; do
- cat <<EOF
+ for f in ${failures}; do
+ cat <<EOF
- message: '$f'
EOF
- done
- elif [[ -n "${prompts[$key]}" && -n "${successes[$key]}" ]]; then
- cat << EOF
- - name: ${uart_number}_${key}
- prompts: ['${prompts[$key]}']
+ done
+ elif [[ -n "${prompts}" && -n "${successes}" ]]; then
+ cat << EOF
+ - name: interactive_${uart_number}_${key}
+ prompts: ['${prompts}']
script:
- - name: result
- command: ${commands[$key]}
+EOF
+
+ if [ -z "${commands}" ]; then
+ cat <<EOF
+ - name: interactive_command_${uart_number}_${key}
+ command:
+EOF
+ else
+ for c in ${commands}; do
+ cat <<EOF
+ - name: interactive_command_${uart_number}_${key}
+ command: $c
+EOF
+ done
+ fi
+ cat << EOF
successes:
EOF
- for s in ${successes[$key]}; do
- cat <<EOF
+ for s in ${successes}; do
+ cat <<EOF
- message: '$s'
EOF
- done
- elif [[ -n "${prompts[$key]}" && -n "${failures[$key]}" ]]; then
- cat << EOF
- - name: ${uart_number}_${key}
- prompts: ['${prompts[$key]}']
+ done
+
+ elif [[ -n "${prompts}" && -n "${failures}" ]]; then
+ cat << EOF
+ - name: interactive_${uart_number}_${key}
+ prompts: ['${prompts}']
script:
- - name: result
- command: ${commands[$key]}
+EOF
+ if [ -z "${commands}" ]; then
+ cat <<EOF
+ - name: interactive_command_${uart_number}_${key}
+ command:
+EOF
+ else
+ for c in ${commands}; do
+ cat <<EOF
+ - name: interactive_command_${uart_number}_${key}
+ command: $c
+EOF
+ done
+ fi
+ cat << EOF
failures:
EOF
- for f in ${failures[$key]}; do
- cat <<EOF
+ for f in ${failures}; do
+ cat <<EOF
- message: '$f'
EOF
- done
-
- else
- cat << EOF
- - name: ${uart_number}_${key}
- prompts: ['${prompts[$key]}']
+ done
+ else
+ cat << EOF
+ - name: interactive_${uart_number}_${key}
+ prompts: ['${prompts}']
script:
- - name: result
- command: ${commands[$key]}
EOF
- fi
- IFS=$OLD_IFS
- done
+ if [ -z "${commands}" ]; then
+ cat <<EOF
+ - name: interactive_command_${uart_number}_${key}
+ command:
+EOF
+ else
+ for c in ${commands}; do
+ cat <<EOF
+ - name: interactive_command_${uart_number}_${key}
+ command: $c
+EOF
+ done
+ fi
+ fi
+
+ IFS=$OLD_IFS
+ fi # end of interactive action
+
+ done # end of expect loop
+
fi
- done
+ done # end of uart loop
}
docker_registry_append() {
diff --git a/lava-expect/README.md b/lava-expect/README.md
index 4aad2f9..2a9f3fd 100644
--- a/lava-expect/README.md
+++ b/lava-expect/README.md
@@ -5,52 +5,116 @@
the latter for Open CI (LAVA). Note that any contribution into the expect scripts
**must be done in both folders**, otherwise expect test coverage will differ.
-# LAVA Expect Scripts
+## LAVA Test Actions
The `lava-expect` script does exactly the same as its counterpart under the `expect`
-folder. However, LAVA uses [Test Interactive Actions](https://validation.linaro.org/static/docs/v2/actions-test.html#interactive-test-action)
-where it expects success or failure strings. The CI would take these `lava-expect`
-scripts and converted into LAVA Test Interactive Actions, so the only task on these files is to define either successes
-or failures strings and probably the order of appearance.
+folder. However, LAVA would use either [Interactive Test Actions](https://validation.linaro.org/static/docs/v2/actions-test.html#interactive-test-action)
+or [Monitor Test Actions](https://validation.linaro.org/static/docs/v2/monitors.html) to
+support possible scenarios. In other words, expect scripts are transformed into either
+interactive or monitor test actions.
+
+In the `lava-expect` scripts, both types of actions, interactive and monitor, are defined
+using the same array variable, `expect_string` but each array element would contain either
+a leading `i` indicating interactive actions or `m` indicating monitor actions.
+
+
+Interactive actions are used in the following scenarios
+
+* Matching a literal and single-event string, i.e. matching `Booting Trusted Firmware`
+* Matching literal string in strict order of appearance, i.e. matching `BL1: Booting BL31`
+after `BL1: Booting BL2`
+* Matching literal string, a prompt, following a pass/fail criteria
+* Input commands at the bootloader or command prompt
+
+Monitor actions are used in the following scenario
+
+* regex matching through the log, i.e. 'Digest(\s|\w):\s(\w{2}\s){16}'.
+
+The following sections go in detail providing syntactic details for each scenario.
+
+### Interactive Actions Strings
To better understand how `expect` scripts translates into `lava-expect`, we can compare similar
-scripts, i.e. `expect/cactus.exp` vesus `lava-expect/cactus.exp`. Let's compare these two:
+scripts, i.e. `expect/disable_dyn_auth_tftf.exp` versus `lava-expect/disable_dyn_auth_tftf.exp` which only requires interactive
+actions. Let's compare these two:
-* `expect/cactus.exp`
+* `expect/disable_dyn_auth_tftf.exp`
```
-.
-.
-source [file join [file dirname [info script]] handle-arguments.inc]
+source [file join [file dirname [info script]] disable_dyn_auth.inc]
-expect_string "Booting test Secure Partition Cactus"
+expect_string "Booting trusted firmware test framework" "Starting TFTF"
+expect_re "Running at NS-EL(1|2)"
-source [file join [file dirname [info script]] uart-hold.inc]
+expect {
+ "Tests Failed : 0" {
+ expect_string "Exiting tests." "<<TFTF Success>>"
+ exit_uart 0
+ }
+ "Tests Passed : 0" {
+ puts "<<TFTF no tests passed>>"
+ exit_uart -1
+ }
+ -re "Tests Failed : \[^0]" {
+ puts "<<TFTF Fail>>"
+ exit_uart -1
+ }
+ timeout {
+ exit_timeout
+ }
+}
+
+exit_uart -1
```
-* and its counterpart `lava-expect/cactus.exp` (note, the same filename but different folder)
+* and its counterpart `lava-expect/disable_dyn_auth_tftf.exp` (note, the same filename but different folder)
```
-.
-.
-expect_string+=("Booting test Secure Partition Cactus")
+source $ci_root/lava-expect/disable_dyn_auth.inc
-source $ci_root/lava-expect/uart-hold.inc
+prompt='Booting trusted firmware test framework'
+successes='Running at NS-EL(1|2)'
+expect_string+=("i;${prompt};${successes}")
+
+prompt='Tests Failed : 0'
+successes='Exiting tests.'
+failures='Tests Passed : 0'
+expect_string+=("i;${prompt};${successes};${failures}")
```
-As seen, the same *expect string* appears in both, but in case
-of `lava-expect/cactus.exp`, which is written in bash, the variable to be
-used is `expect_string` and its *expect string* **must be** appended (`+=`) as an
-**array element**. Appending is important, otherwise previous *expect strings* would be
-replaced by the assigment (`=`).
+The first thing to notice is that all strings are literal (no regex is required) and each are expected
+just once, so interactive actions are the choice.
-In case we want to indicate the **order** of expected scripts and the **pass/fail
-criteria**, the *expect string* syntax is a bit more complex but with a few examples,
-it can be quickly understood.
+As seen, the same *expect strings* appears in both, but in case of `lava-expect/disable_dyn_auth_tftf.exp`,
+is it written in *bash* language and **appending** elements into `expect_string`, which is the variable
+that ultimately is transformed into interactive test actions by CI scripts.
-For example, in an hypothetical scenario, we want to first match A, then after A,
-match B or C for success and match D or E for failures. This would be the `lava-expect`
-definition script (to be located under `lava-expect` folder)
+It is worth noting that each *expect string* **must be** appended `+=` as an
+**array element** of `expect_string`, otherwise, and assignment operator `=` would remove
+previous defined expect strings. Also note the leading **`i`** character in the array element,
+indicating a interactive actions.
+
+As indicated above, interactive actions match strings in a specific **order** with a **pass/fail
+criteria**. For the above example, the first expected match is called the `prompt` (in LAVA terms),
+and following it, the passing criteria is defined through the `successes` variable and the failing
+criteria through `failures` variable, defining these at the appended `expect_string` element:
+
+```
+prompt='Tests Failed : 0'
+successes='Exiting tests.'
+failures='Tests Passed : 0'
+expect_string+=("i;${prompt};${successes};${failures}")
+```
+
+Each *interactive action string* must follow a certain syntax as seen in the above example
+
+```
+expect_string+=("i;${prompt};${successes};${failures}")
+```
+
+In general, we first match the `prompt`, then after `prompt`,
+match `successes` and `failures` for pass/fail strings. In case different strings
+define the pass/fail criteria, these can be separated with a `@` character:
```
prompt='A'
@@ -59,9 +123,92 @@
expect_string+=("${prompt};${successes};${failures}")
```
-As you can see, `prompt` defines the first match, in this case `A`, then `successes` defines
-possible success strings, in this case `B` and `C`, separated by `@` sign, and the same
-pattern applies for failure strings, but in this case, matching these would tell LAVA
-to fail the job.
+### Monitor Action Strings
-For a real examples, compare similar scripts (the same filename) in both expect folders.
+If the corresponding expect string is a regular expression, a *regex* and/or input commands, one should
+use LAVA [Monitor Test Actions](https://validation.linaro.org/static/docs/v2/monitors.html). Besides the
+regex strings, monitors requires a start and end strings.
+
+As in the previous section, it is best if understood with a real example, the `expect/linux-tpm.exp`
+
+```
+set non_zero_pcr "(?!(\\s00){16})((\\s(\[0-9a-f\]){2}){16}\\s)"
+
+expect {
+
+ -re "Digest(\\s|\\w)*:\\s(\\w{2}\\s){16}|\
+ : (\\w{2}\\s){16}|\
+ Event(\\s|\\w)*:\\s\\w+\\s" {
+ puts $digest_log $expect_out(0,string)
+ exp_continue
+ }
+
+ -exact "Booting BL31" {
+ close $digest_log
+ }
+
+ timeout {
+ exit_timeout
+ }
+}
+
+expect {
+ "login" {
+ send "root\n"
+ }
+
+ timeout {
+ exit_timeout
+ }
+}
+
+expect {
+ "#" {
+ # Load the fTPM driver and retrieves PCR0
+ send "ftpm\n"
+ }
+
+ timeout {
+ exit_timeout
+ }
+}
+
+for {set i 1} {$i < 11} {incr i} {
+ send "pcrread -ha $i\n"
+
+ expect {
+ -re "(\\s00){16}\\s+(00\\s){16}" { }
+
+ -re $non_zero_pcr {
+ exit_uart -1
+ }
+
+ timeout {
+ exit_timeout
+ }
+ }
+}
+```
+
+which is translated into `lava-expect/linux-tpm.exp`
+
+```
+non_zero_pcr='(?!(\s00){16})((\s([0-9a-f]){2}){16}\s)'
+
+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:')
+
+expect_string+=("i;#;${non_zero_pcr};;root@ftpm")
+
+zero_pcr="(\s00){16}\s+(00\s){16}"
+for i in $(seq 1 11); do
+ expect_string+=("i;#;${zero_pcr};;pcrread -ha $i")
+done
+```
+
+In this case, translation required monitor and interactive strings. For the monitor strings, this is the syntax
+
+```
+expect_string+=('<start match>;<end match>;<regex 1>@<regex 2>@...')
+```
diff --git a/lava-expect/busybox.inc b/lava-expect/busybox.inc
index a437906..538344d 100644
--- a/lava-expect/busybox.inc
+++ b/lava-expect/busybox.inc
@@ -8,5 +8,5 @@
# This script is not standalone and should be sourced by a top expect script.
#
-expect_string+=('init.sh')
-expect_string+=('.* # ')
+expect_string+=('i;init.sh')
+expect_string+=('i;.* # ')
diff --git a/lava-expect/cactus.exp b/lava-expect/cactus.exp
index 2762ec9..71ffe16 100644
--- a/lava-expect/cactus.exp
+++ b/lava-expect/cactus.exp
@@ -6,6 +6,6 @@
# Expect script for the test Secure Partition Cactus
#
-expect_string+=('Booting test Secure Partition Cactus')
+expect_string+=('i;Booting test Secure Partition Cactus')
source $ci_root/lava-expect/uart-hold.inc
diff --git a/lava-expect/crash_panic.exp b/lava-expect/crash_panic.exp
index 8c443b5..35122f6 100644
--- a/lava-expect/crash_panic.exp
+++ b/lava-expect/crash_panic.exp
@@ -6,4 +6,4 @@
# Expect script for Trusted Firmware Test Framework
#
-expect_string+=('PANIC at PC :')
+expect_string+=('i;PANIC at PC :')
diff --git a/lava-expect/crash_roxlattables_unhandled_exception_at_el3.exp b/lava-expect/crash_roxlattables_unhandled_exception_at_el3.exp
index 3667411..2fbd0ee 100644
--- a/lava-expect/crash_roxlattables_unhandled_exception_at_el3.exp
+++ b/lava-expect/crash_roxlattables_unhandled_exception_at_el3.exp
@@ -6,85 +6,85 @@
# Expect script for Trusted Firmware Test Framework
#
-expect_string+=('Translation tables are now read-only at EL3.')
-expect_string+=('Unhandled Exception in EL3.')
-expect_string+=('x30')
-expect_string+=('x0')
-expect_string+=('x1')
-expect_string+=('x2')
-expect_string+=('x3')
-expect_string+=('x4')
-expect_string+=('x5')
-expect_string+=('x6')
-expect_string+=('x7')
-expect_string+=('x8')
-expect_string+=('x9')
-expect_string+=('x10')
-expect_string+=('x11')
-expect_string+=('x12')
-expect_string+=('x13')
-expect_string+=('x14')
-expect_string+=('x15')
-expect_string+=('x16')
-expect_string+=('x17')
-expect_string+=('x18')
-expect_string+=('x19')
-expect_string+=('x20')
-expect_string+=('x21')
-expect_string+=('x22')
-expect_string+=('x23')
-expect_string+=('x24')
-expect_string+=('x25')
-expect_string+=('x26')
-expect_string+=('x27')
-expect_string+=('x28')
-expect_string+=('x29')
-expect_string+=('scr_el3')
-expect_string+=('sctlr_el3')
-expect_string+=('cptr_el3')
-expect_string+=('tcr_el3')
-expect_string+=('daif')
-expect_string+=('mair_el3')
-expect_string+=('spsr_el3')
-expect_string+=('elr_el3')
-expect_string+=('ttbr0_el3')
-expect_string+=('esr_el3')
-expect_string+=('far_el3')
-expect_string+=('spsr_el1')
-expect_string+=('elr_el1')
-expect_string+=('spsr_abt')
-expect_string+=('spsr_und')
-expect_string+=('spsr_irq')
-expect_string+=('spsr_fiq')
-expect_string+=('sctlr_el1')
-expect_string+=('actlr_el1')
-expect_string+=('cpacr_el1')
-expect_string+=('csselr_el1')
-expect_string+=('sp_el1')
-expect_string+=('esr_el1')
-expect_string+=('ttbr0_el1')
-expect_string+=('ttbr1_el1')
-expect_string+=('mair_el1')
-expect_string+=('amair_el1')
-expect_string+=('tcr_el1')
-expect_string+=('tpidr_el1')
-expect_string+=('tpidr_el0')
-expect_string+=('tpidrro_el0')
-expect_string+=('par_el1')
-expect_string+=('mpidr_el1')
-expect_string+=('afsr0_el1')
-expect_string+=('afsr1_el1')
-expect_string+=('contextidr_el1')
-expect_string+=('vbar_el1')
-expect_string+=('cntp_ctl_el0')
-expect_string+=('cntp_cval_el0')
-expect_string+=('cntv_ctl_el0')
-expect_string+=('cntv_cval_el0')
-expect_string+=('cntkctl_el1')
-expect_string+=('sp_el0')
-expect_string+=('isr_el1')
-expect_string+=('dacr32_el2')
-expect_string+=('ifsr32_el2')
-expect_string+=('icc_hppir0_el1')
-expect_string+=('icc_hppir1_el1')
-expect_string+=('icc_ctlr_el3')
+expect_string+=('i;Translation tables are now read-only at EL3.')
+expect_string+=('i;Unhandled Exception in EL3.')
+expect_string+=('i;x30')
+expect_string+=('i;x0')
+expect_string+=('i;x1')
+expect_string+=('i;x2')
+expect_string+=('i;x3')
+expect_string+=('i;x4')
+expect_string+=('i;x5')
+expect_string+=('i;x6')
+expect_string+=('i;x7')
+expect_string+=('i;x8')
+expect_string+=('i;x9')
+expect_string+=('i;x10')
+expect_string+=('i;x11')
+expect_string+=('i;x12')
+expect_string+=('i;x13')
+expect_string+=('i;x14')
+expect_string+=('i;x15')
+expect_string+=('i;x16')
+expect_string+=('i;x17')
+expect_string+=('i;x18')
+expect_string+=('i;x19')
+expect_string+=('i;x20')
+expect_string+=('i;x21')
+expect_string+=('i;x22')
+expect_string+=('i;x23')
+expect_string+=('i;x24')
+expect_string+=('i;x25')
+expect_string+=('i;x26')
+expect_string+=('i;x27')
+expect_string+=('i;x28')
+expect_string+=('i;x29')
+expect_string+=('i;scr_el3')
+expect_string+=('i;sctlr_el3')
+expect_string+=('i;cptr_el3')
+expect_string+=('i;tcr_el3')
+expect_string+=('i;daif')
+expect_string+=('i;mair_el3')
+expect_string+=('i;spsr_el3')
+expect_string+=('i;elr_el3')
+expect_string+=('i;ttbr0_el3')
+expect_string+=('i;esr_el3')
+expect_string+=('i;far_el3')
+expect_string+=('i;spsr_el1')
+expect_string+=('i;elr_el1')
+expect_string+=('i;spsr_abt')
+expect_string+=('i;spsr_und')
+expect_string+=('i;spsr_irq')
+expect_string+=('i;spsr_fiq')
+expect_string+=('i;sctlr_el1')
+expect_string+=('i;actlr_el1')
+expect_string+=('i;cpacr_el1')
+expect_string+=('i;csselr_el1')
+expect_string+=('i;sp_el1')
+expect_string+=('i;esr_el1')
+expect_string+=('i;ttbr0_el1')
+expect_string+=('i;ttbr1_el1')
+expect_string+=('i;mair_el1')
+expect_string+=('i;amair_el1')
+expect_string+=('i;tcr_el1')
+expect_string+=('i;tpidr_el1')
+expect_string+=('i;tpidr_el0')
+expect_string+=('i;tpidrro_el0')
+expect_string+=('i;par_el1')
+expect_string+=('i;mpidr_el1')
+expect_string+=('i;afsr0_el1')
+expect_string+=('i;afsr1_el1')
+expect_string+=('i;contextidr_el1')
+expect_string+=('i;vbar_el1')
+expect_string+=('i;cntp_ctl_el0')
+expect_string+=('i;cntp_cval_el0')
+expect_string+=('i;cntv_ctl_el0')
+expect_string+=('i;cntv_cval_el0')
+expect_string+=('i;cntkctl_el1')
+expect_string+=('i;sp_el0')
+expect_string+=('i;isr_el1')
+expect_string+=('i;dacr32_el2')
+expect_string+=('i;ifsr32_el2')
+expect_string+=('i;icc_hppir0_el1')
+expect_string+=('i;icc_hppir1_el1')
+expect_string+=('i;icc_ctlr_el3')
diff --git a/lava-expect/crash_test.exp b/lava-expect/crash_test.exp
index 4ec8f3f..f967195 100644
--- a/lava-expect/crash_test.exp
+++ b/lava-expect/crash_test.exp
@@ -6,87 +6,87 @@
# Expect script for Trusted Firmware Test Framework
#
-expect_string+=('Unhandled External Abort received')
-expect_string+=('BACKTRACE: START: plat_ea_handler')
-expect_string+=('BACKTRACE: END: plat_ea_handler')
-expect_string+=('PANIC in EL3')
-expect_string+=('x30')
-expect_string+=('x0')
-expect_string+=('x1')
-expect_string+=('x2')
-expect_string+=('x3')
-expect_string+=('x4')
-expect_string+=('x5')
-expect_string+=('x6')
-expect_string+=('x7')
-expect_string+=('x8')
-expect_string+=('x9')
-expect_string+=('x10')
-expect_string+=('x11')
-expect_string+=('x12')
-expect_string+=('x13')
-expect_string+=('x14')
-expect_string+=('x15')
-expect_string+=('x16')
-expect_string+=('x17')
-expect_string+=('x18')
-expect_string+=('x19')
-expect_string+=('x20')
-expect_string+=('x21')
-expect_string+=('x22')
-expect_string+=('x23')
-expect_string+=('x24')
-expect_string+=('x25')
-expect_string+=('x26')
-expect_string+=('x27')
-expect_string+=('x28')
-expect_string+=('x29')
-expect_string+=('scr_el3')
-expect_string+=('sctlr_el3')
-expect_string+=('cptr_el3')
-expect_string+=('tcr_el3')
-expect_string+=('daif')
-expect_string+=('mair_el3')
-expect_string+=('spsr_el3')
-expect_string+=('elr_el3')
-expect_string+=('ttbr0_el3')
-expect_string+=('esr_el3')
-expect_string+=('far_el3')
-expect_string+=('spsr_el1')
-expect_string+=('elr_el1')
-expect_string+=('spsr_abt')
-expect_string+=('spsr_und')
-expect_string+=('spsr_irq')
-expect_string+=('spsr_fiq')
-expect_string+=('sctlr_el1')
-expect_string+=('actlr_el1')
-expect_string+=('cpacr_el1')
-expect_string+=('csselr_el1')
-expect_string+=('sp_el1')
-expect_string+=('esr_el1')
-expect_string+=('ttbr0_el1')
-expect_string+=('ttbr1_el1')
-expect_string+=('mair_el1')
-expect_string+=('amair_el1')
-expect_string+=('tcr_el1')
-expect_string+=('tpidr_el1')
-expect_string+=('tpidr_el0')
-expect_string+=('tpidrro_el0')
-expect_string+=('par_el1')
-expect_string+=('mpidr_el1')
-expect_string+=('afsr0_el1')
-expect_string+=('afsr1_el1')
-expect_string+=('contextidr_el1')
-expect_string+=('vbar_el1')
-expect_string+=('cntp_ctl_el0')
-expect_string+=('cntp_cval_el0')
-expect_string+=('cntv_ctl_el0')
-expect_string+=('cntv_cval_el0')
-expect_string+=('cntkctl_el1')
-expect_string+=('sp_el0')
-expect_string+=('isr_el1')
-expect_string+=('dacr32_el2')
-expect_string+=('ifsr32_el2')
-expect_string+=('icc_hppir0_el1')
-expect_string+=('icc_hppir1_el1')
-expect_string+=('icc_ctlr_el3')
+expect_string+=('i;Unhandled External Abort received')
+expect_string+=('i;BACKTRACE: START: plat_ea_handler')
+expect_string+=('i;BACKTRACE: END: plat_ea_handler')
+expect_string+=('i;PANIC in EL3')
+expect_string+=('i;x30')
+expect_string+=('i;x0')
+expect_string+=('i;x1')
+expect_string+=('i;x2')
+expect_string+=('i;x3')
+expect_string+=('i;x4')
+expect_string+=('i;x5')
+expect_string+=('i;x6')
+expect_string+=('i;x7')
+expect_string+=('i;x8')
+expect_string+=('i;x9')
+expect_string+=('i;x10')
+expect_string+=('i;x11')
+expect_string+=('i;x12')
+expect_string+=('i;x13')
+expect_string+=('i;x14')
+expect_string+=('i;x15')
+expect_string+=('i;x16')
+expect_string+=('i;x17')
+expect_string+=('i;x18')
+expect_string+=('i;x19')
+expect_string+=('i;x20')
+expect_string+=('i;x21')
+expect_string+=('i;x22')
+expect_string+=('i;x23')
+expect_string+=('i;x24')
+expect_string+=('i;x25')
+expect_string+=('i;x26')
+expect_string+=('i;x27')
+expect_string+=('i;x28')
+expect_string+=('i;x29')
+expect_string+=('i;scr_el3')
+expect_string+=('i;sctlr_el3')
+expect_string+=('i;cptr_el3')
+expect_string+=('i;tcr_el3')
+expect_string+=('i;daif')
+expect_string+=('i;mair_el3')
+expect_string+=('i;spsr_el3')
+expect_string+=('i;elr_el3')
+expect_string+=('i;ttbr0_el3')
+expect_string+=('i;esr_el3')
+expect_string+=('i;far_el3')
+expect_string+=('i;spsr_el1')
+expect_string+=('i;elr_el1')
+expect_string+=('i;spsr_abt')
+expect_string+=('i;spsr_und')
+expect_string+=('i;spsr_irq')
+expect_string+=('i;spsr_fiq')
+expect_string+=('i;sctlr_el1')
+expect_string+=('i;actlr_el1')
+expect_string+=('i;cpacr_el1')
+expect_string+=('i;csselr_el1')
+expect_string+=('i;sp_el1')
+expect_string+=('i;esr_el1')
+expect_string+=('i;ttbr0_el1')
+expect_string+=('i;ttbr1_el1')
+expect_string+=('i;mair_el1')
+expect_string+=('i;amair_el1')
+expect_string+=('i;tcr_el1')
+expect_string+=('i;tpidr_el1')
+expect_string+=('i;tpidr_el0')
+expect_string+=('i;tpidrro_el0')
+expect_string+=('i;par_el1')
+expect_string+=('i;mpidr_el1')
+expect_string+=('i;afsr0_el1')
+expect_string+=('i;afsr1_el1')
+expect_string+=('i;contextidr_el1')
+expect_string+=('i;vbar_el1')
+expect_string+=('i;cntp_ctl_el0')
+expect_string+=('i;cntp_cval_el0')
+expect_string+=('i;cntv_ctl_el0')
+expect_string+=('i;cntv_cval_el0')
+expect_string+=('i;cntkctl_el1')
+expect_string+=('i;sp_el0')
+expect_string+=('i;isr_el1')
+expect_string+=('i;dacr32_el2')
+expect_string+=('i;ifsr32_el2')
+expect_string+=('i;icc_hppir0_el1')
+expect_string+=('i;icc_hppir1_el1')
+expect_string+=('i;icc_ctlr_el3')
diff --git a/lava-expect/disable_dyn_auth.inc b/lava-expect/disable_dyn_auth.inc
index a50a31a..93be4f5 100644
--- a/lava-expect/disable_dyn_auth.inc
+++ b/lava-expect/disable_dyn_auth.inc
@@ -8,7 +8,7 @@
# This script tries to catch if dynamic authentication of images is enabled
# during trusted board boot(BL2). The authentication is done using certificates.
-expect_string+=('BL1: Booting BL2')
+expect_string+=('i;BL1: Booting BL2')
prompt='Disabling authentication of images dynamically'
# Catch all loading of authentication certificates i.e.,
@@ -22,6 +22,6 @@
# SOC_FW_CONTENT_CERT_ID U(13)
# TRUSTED_OS_FW_CONTENT_CERT_ID U(14)
# NON_TRUSTED_FW_CONTENT_CERT_ID U(15)
-expect_string+=("${prompt};;Loading image id=(6|7|8|9|10|11|12|13|14|15) at address ")
+expect_string+=("i;${prompt};;Loading image id=(6|7|8|9|10|11|12|13|14|15) at address ")
-expect_string+=('BL1: Booting BL31')
+expect_string+=('i;BL1: Booting BL31')
diff --git a/lava-expect/disable_dyn_auth_tftf.exp b/lava-expect/disable_dyn_auth_tftf.exp
index 1b8eff7..e67f4a5 100644
--- a/lava-expect/disable_dyn_auth_tftf.exp
+++ b/lava-expect/disable_dyn_auth_tftf.exp
@@ -10,9 +10,9 @@
prompt='Booting trusted firmware test framework'
successes='Running at NS-EL(1|2)'
-expect_string+=("${prompt};${successes}")
+expect_string+=("i;${prompt};${successes}")
prompt='Tests Failed : 0'
successes='Exiting tests.'
failures='Tests Passed : 0'
-expect_string+=("${prompt};${successes};${failures}")
+expect_string+=("i;${prompt};${successes};${failures}")
diff --git a/lava-expect/el3-test-payload.exp b/lava-expect/el3-test-payload.exp
index d4379c5..a5f46f5 100644
--- a/lava-expect/el3-test-payload.exp
+++ b/lava-expect/el3-test-payload.exp
@@ -11,5 +11,5 @@
# Trusted Firmware boot section
source $ci_root/lava-expect/trusted-firmware.inc
-expect_string+=('Booting the EL3 test payload')
-expect_string+=('All CPUs booted!')
+expect_string+=('i;Booting the EL3 test payload')
+expect_string+=('i;All CPUs booted!')
diff --git a/lava-expect/ivy.exp b/lava-expect/ivy.exp
index 89bf442..facb929 100644
--- a/lava-expect/ivy.exp
+++ b/lava-expect/ivy.exp
@@ -6,6 +6,6 @@
# Expect script for the test Secure Partition Ivy
#
-expect_string+=('Booting test Secure Partition Ivy')
+expect_string+=('i;Booting test Secure Partition Ivy')
source $ci_root/lava-expect/uart-hold.inc
diff --git a/lava-expect/linux-bl33.exp b/lava-expect/linux-bl33.exp
index 1f0565d..5135a41 100644
--- a/lava-expect/linux-bl33.exp
+++ b/lava-expect/linux-bl33.exp
@@ -10,12 +10,12 @@
source $ci_root/lava-expect/trusted-firmware.inc
# Linux kernel boot section
-expect_string+=('Booting Linux on physical CPU')
-expect_string+=('Linux version')
+expect_string+=('i;Booting Linux on physical CPU')
+expect_string+=('i;Linux version')
# The kernel prints some information it takes from the preloaded DTB.
# Check for following information to see that we actually got the right DTB.
# 1. Machine model
# 2. Command line passed via the "/chosen" node
-expect_string+=('Machine model: FVP (Base|Foundation)')
-expect_string+=('Kernel command line: console=ttyAMA0')
+expect_string+=('i;Machine model: FVP (Base|Foundation)')
+expect_string+=('i;Kernel command line: console=ttyAMA0')
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
+
diff --git a/lava-expect/linux.inc b/lava-expect/linux.inc
index 8430f2b..9c8b367 100644
--- a/lava-expect/linux.inc
+++ b/lava-expect/linux.inc
@@ -11,6 +11,6 @@
num_cpus=8
fi
-expect_string+=('Linux version')
-expect_string+=("SMP: Total of ${num_cpus} processors activated")
-expect_string+=('Freeing unused kernel memory')
+expect_string+=('i;Linux version')
+expect_string+=("i;SMP: Total of ${num_cpus} processors activated")
+expect_string+=('i;Freeing unused kernel memory')
diff --git a/lava-expect/openembedded.inc b/lava-expect/openembedded.inc
index a816299..f3378e3 100644
--- a/lava-expect/openembedded.inc
+++ b/lava-expect/openembedded.inc
@@ -8,5 +8,5 @@
# This script is not standalone and should be sourced by a top expect script.
#
-expect_string+=('INIT:')
-expect_string+=('root@genericarmv8:~#;(Power down|System halted);;shutdown -h now\r')
+expect_string+=('i;INIT:')
+expect_string+=('i;root@genericarmv8:~#;(Power down|System halted);;shutdown -h now\r')
diff --git a/lava-expect/readonly_el1_xlat_tables.exp b/lava-expect/readonly_el1_xlat_tables.exp
index 43b935e..2aa8389 100644
--- a/lava-expect/readonly_el1_xlat_tables.exp
+++ b/lava-expect/readonly_el1_xlat_tables.exp
@@ -6,4 +6,4 @@
# Expect script for Trusted Firmware Test Framework
#
-expect_string+=('Translation tables are now read-only at EL1.')
+expect_string+=('i;Translation tables are now read-only at EL1.')
diff --git a/lava-expect/spm-edk2-uart0.exp b/lava-expect/spm-edk2-uart0.exp
index f635c99..9753328 100644
--- a/lava-expect/spm-edk2-uart0.exp
+++ b/lava-expect/spm-edk2-uart0.exp
@@ -12,16 +12,16 @@
source $ci_root/lava-expect/trusted-firmware.inc
# EDK2 section
-expect_string+=('UEFI firmware')
+expect_string+=('i;UEFI firmware')
-expect_string+=('UEFI Interactive Shell')
+expect_string+=('i;UEFI Interactive Shell')
-expect_string+=('any other key to continue.;;;\r')
+expect_string+=('i;any other key to continue.;;;\r')
-expect_string+=('Shell>;;;fs0:\r')
+expect_string+=('i;Shell>;;;fs0:\r')
-expect_string+=('FS0:;;;UefiInfo.efi\r')
+expect_string+=('i;FS0:;;;UefiInfo.efi\r')
-expect_string+=('Loading driver at .* UefiInfo.efi')
+expect_string+=('i;Loading driver at .* UefiInfo.efi')
-expect_string+=('FS0:')
+expect_string+=('i;FS0:')
diff --git a/lava-expect/spm-linux-uart0.exp b/lava-expect/spm-linux-uart0.exp
index ebab8a7..668f372 100644
--- a/lava-expect/spm-linux-uart0.exp
+++ b/lava-expect/spm-linux-uart0.exp
@@ -4,6 +4,6 @@
# SPDX-License-Identifier: BSD-3-Clause
#
-expect_string+=('Please press Enter to activate this console.;;;\r')
-expect_string+=('/ # ;;;insmod hafnium.ko\n')
-expect_string+=('Hafnium successfully loaded with 1 VMs:')
+expect_string+=('i;Please press Enter to activate this console.;;;\r')
+expect_string+=('i;/ # ;;;insmod hafnium.ko\n')
+expect_string+=('i;Hafnium successfully loaded with 1 VMs:')
diff --git a/lava-expect/tftf-aarch32.exp b/lava-expect/tftf-aarch32.exp
index 4627317..16c893c 100644
--- a/lava-expect/tftf-aarch32.exp
+++ b/lava-expect/tftf-aarch32.exp
@@ -10,8 +10,8 @@
prompt='Booting trusted firmware test framework'
successes='Running in AArch32 HYP mode'
-expect_string+=("${prompt};${successes}")
+expect_string+=("i;${prompt};${successes}")
prompt='Tests Failed : 0'
failures='Tests Passed : 0'
-expect_string+=("${prompt};;${failures}")
+expect_string+=("i;${prompt};;${failures}")
diff --git a/lava-expect/tftf.exp b/lava-expect/tftf.exp
index 8640ffe..243f7cd 100644
--- a/lava-expect/tftf.exp
+++ b/lava-expect/tftf.exp
@@ -10,9 +10,9 @@
prompt='Booting trusted firmware test framework'
successes='Running at NS-EL(1|2)'
-expect_string+=("${prompt};${successes}")
+expect_string+=("i;${prompt};${successes}")
prompt='Tests Failed : 0'
successes='Exiting tests.'
failures='Tests Passed : 0'
-expect_string+=("${prompt};${successes};${failures}")
+expect_string+=("i;${prompt};${successes};${failures}")
diff --git a/lava-expect/tftf_fault.exp b/lava-expect/tftf_fault.exp
index d9bce3a..86561e3 100644
--- a/lava-expect/tftf_fault.exp
+++ b/lava-expect/tftf_fault.exp
@@ -8,5 +8,5 @@
# Expect the test to have set a fault message
if [ -n "${tftf_fault_msg}" ]; then
- expect_string+=("${tftf_fault_msg}")
+ expect_string+=("i;${tftf_fault_msg}")
fi
diff --git a/lava-expect/trusted-firmware-aarch32.inc b/lava-expect/trusted-firmware-aarch32.inc
index 31ca9de..ae02ec4 100644
--- a/lava-expect/trusted-firmware-aarch32.inc
+++ b/lava-expect/trusted-firmware-aarch32.inc
@@ -11,7 +11,7 @@
# 'skip_early_boot_msgs'.
if [ -z "$skip_early_boot_msgs" ]; then
- expect_string+=('Booting Trusted Firmware')
+ expect_string+=('i;Booting Trusted Firmware')
prompt='BL1: Booting BL2'
# Catch all 3 possible BL2 loading error messages, namely:
@@ -19,9 +19,9 @@
# "Failed to load BL2 firmware."
# "Failure in post image load handling of BL2"
failures='Fail.*load.*BL2'
- expect_string+=("${prompt};;${failures}")
+ expect_string+=("i;${prompt};;${failures}")
- expect_string+=('BL1: Booting BL32')
+ expect_string+=('i;BL1: Booting BL32')
fi
-expect_string+=('SP_MIN:')
+expect_string+=('i;SP_MIN:')
diff --git a/lava-expect/trusted-firmware-load-error.exp b/lava-expect/trusted-firmware-load-error.exp
index f198bda..5bef49f 100644
--- a/lava-expect/trusted-firmware-load-error.exp
+++ b/lava-expect/trusted-firmware-load-error.exp
@@ -5,4 +5,4 @@
#
# Expect an error while loading BL2 image.
-expect_string+=('Loading of FW_CONFIG failed;;BL1: Booting BL2')
+expect_string+=('i;Loading of FW_CONFIG failed;;BL1: Booting BL2')
diff --git a/lava-expect/trusted-firmware-rst-to-bl31.inc b/lava-expect/trusted-firmware-rst-to-bl31.inc
index f77906c..af9dc04 100644
--- a/lava-expect/trusted-firmware-rst-to-bl31.inc
+++ b/lava-expect/trusted-firmware-rst-to-bl31.inc
@@ -6,4 +6,4 @@
# Script to interact with Trusted Firmware when resetting to BL31.
#
-expect_string+=('NOTICE: BL3-?1:')
+expect_string+=('i;NOTICE: BL3-?1:')
diff --git a/lava-expect/trusted-firmware.inc b/lava-expect/trusted-firmware.inc
index 7133da6..4d38e09 100644
--- a/lava-expect/trusted-firmware.inc
+++ b/lava-expect/trusted-firmware.inc
@@ -10,7 +10,7 @@
# for them by inspecting the environment variable 'skip_early_boot_msgs'.
if [ -z "$skip_early_boot_msgs" ]; then
- expect_string+=('Booting Trusted Firmware')
+ expect_string+=('i;Booting Trusted Firmware')
prompt='Booting BL2'
# Catch all 3 possible BL2 loading error messages, namely:
@@ -18,7 +18,7 @@
# "Failed to load BL2 firmware."
# "Failure in post image load handling of BL2"
failures='Fail.*load.*BL2'
- expect_string+=("${prompt};;${failures}")
+ expect_string+=("i;${prompt};;${failures}")
- expect_string+=('BL1: Booting BL31')
+ expect_string+=('i;BL1: Booting BL31')
fi
diff --git a/lava-expect/ubsan-test-trap.exp b/lava-expect/ubsan-test-trap.exp
index f1ac565..373f50b 100644
--- a/lava-expect/ubsan-test-trap.exp
+++ b/lava-expect/ubsan-test-trap.exp
@@ -9,4 +9,4 @@
# Value for trap BRK instruction
trap_value=0x00003e8
-expect_string+=("Unexpected BRK instruction with value $trap_value")
+expect_string+=("i;Unexpected BRK instruction with value $trap_value")