lava-expect: Rename to expect-lava

To sort together (in directory listings, etc.) with the original expect/
directory and recently added expect-post/ directory. That will make
relationship between them clearer and hopefully will help avoid
mistakes/omissions (e.g., any change done to expect/ should have a
corresponding change in expect-lava/ or expect-post/, and all 3
dirs will be right on the eyes / at the fingertips to make that
hard to forget).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: I5505f8051ef98271062edd7f7e796833643ea2ac
diff --git a/expect-lava/README.md b/expect-lava/README.md
new file mode 100644
index 0000000..9fd5821
--- /dev/null
+++ b/expect-lava/README.md
@@ -0,0 +1,216 @@
+# Expect Scripts
+
+The project tracks two set of expect scripts under two different folders, `expect` and
+`expect-lava`, the former required for local (non-LAVA) or Internal CI (Arm CI) and
+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 Test Actions
+
+The `expect-lava` script does exactly the same as its counterpart under the `expect`
+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 `expect-lava` 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 `expect-lava`, we can compare similar
+scripts, i.e. `expect/disable_dyn_auth_tftf.exp` versus `expect-lava/disable_dyn_auth_tftf.exp` which only requires interactive
+actions. Let's compare these two:
+
+* `expect/disable_dyn_auth_tftf.exp`
+
+```
+source [file join [file dirname [info script]] disable_dyn_auth.inc]
+
+expect_string "Booting trusted firmware test framework" "Starting TFTF"
+expect_re "Running at NS-EL(1|2)"
+
+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 `expect-lava/disable_dyn_auth_tftf.exp` (note, the same filename but different folder)
+
+```
+source $ci_root/expect-lava/disable_dyn_auth.inc
+
+prompt='Booting trusted firmware test framework'
+expect_string+=("i;${prompt}")
+
+prompt='Running at NS-EL(1|2)'
+expect_string+=("i;${prompt}")
+
+prompt='Tests Failed  : 0'
+expect_string+=("i;${prompt}")
+
+prompt='Exiting tests.'
+failures='Tests Passed  : 0'
+expect_string+=("i;${prompt};;${failures}")
+```
+
+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.
+
+As seen, the same *expect strings* appears in both, but in case of `expect-lava/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.
+
+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**.
+For the above example, expect strings are matched setting the `prompt` and an optional
+`failures` value, the latter indicating a possible failure string.
+
+*Interactive action strings* should follow the following syntax
+
+```
+expect_string+=("i;<prompts>[;<successes>;<failures>;<commands>]")
+```
+
+Indicating the `prompts` to match, which can be one or several separated by the `@` char and
+optional `successeses`, `failures` and `commands` strings.
+
+One good way to explain (or at least understand it) is: If expect_string has a format of `i;<expected>`,
+then output will be matched for `<expected>` (until the end of output or timeout, lack of match is a
+failure in either case). Otherwise, the format is: `i;<prompts>;[<successeses>];[<failures>];[<commands>]`;
+a `<command>` will be sent to DUT, if specified; any output will be matched until next `<prompts>`;
+if `<successes>` is specified, it must be matched **before** appearance of prompt for this testcase
+to be successful (if `<successes>` is not matched before prompt, it's a failure); alternatively,
+if `<failures>` is matched, it's a fast-track failure (otherwise the lack of success output is
+enough to record a failure).
+
+Again, this prompts/successes/failures form makes a good sense if actively sending a `<command>`
+and much less sense if not sending any `<command>`. Between these 2 main forms: *passively* matching output
+vs *actively* sending a command to a shell and checking its results, there can be other use cases
+which can be encoded with the full form, but then those would be corner/niche cases most of the cases.
+
+### Monitor Action Strings
+
+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 `expect-lava/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/expect-lava/busybox.inc b/expect-lava/busybox.inc
new file mode 100644
index 0000000..538344d
--- /dev/null
+++ b/expect-lava/busybox.inc
@@ -0,0 +1,12 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to interact with a Busybox filesystem
+#
+# This script is not standalone and should be sourced by a top expect script.
+#
+
+expect_string+=('i;init.sh')
+expect_string+=('i;.* # ')
diff --git a/expect-lava/cactus.exp b/expect-lava/cactus.exp
new file mode 100644
index 0000000..6400aac
--- /dev/null
+++ b/expect-lava/cactus.exp
@@ -0,0 +1,11 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for the test Secure Partition Cactus
+#
+
+expect_string+=('i;Booting test Secure Partition Cactus')
+
+source $ci_root/expect-lava/uart-hold.inc
diff --git a/expect-lava/crash_panic.exp b/expect-lava/crash_panic.exp
new file mode 100644
index 0000000..35122f6
--- /dev/null
+++ b/expect-lava/crash_panic.exp
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+expect_string+=('i;PANIC at PC :')
diff --git a/expect-lava/crash_roxlattables_unhandled_exception_at_el3.exp b/expect-lava/crash_roxlattables_unhandled_exception_at_el3.exp
new file mode 100644
index 0000000..2fbd0ee
--- /dev/null
+++ b/expect-lava/crash_roxlattables_unhandled_exception_at_el3.exp
@@ -0,0 +1,90 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+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/expect-lava/crash_test.exp b/expect-lava/crash_test.exp
new file mode 100644
index 0000000..f967195
--- /dev/null
+++ b/expect-lava/crash_test.exp
@@ -0,0 +1,92 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+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/expect-lava/disable_dyn_auth.inc b/expect-lava/disable_dyn_auth.inc
new file mode 100644
index 0000000..93be4f5
--- /dev/null
+++ b/expect-lava/disable_dyn_auth.inc
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to interact with an TF-A built with Trusted Board Boot
+#
+# 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+=('i;BL1: Booting BL2')
+
+prompt='Disabling authentication of images dynamically'
+# Catch all loading of authentication certificates i.e.,
+# TRUSTED_BOOT_FW_CERT_ID         U(6)
+# TRUSTED_KEY_CERT_ID             U(7)
+# SCP_FW_KEY_CERT_ID              U(8)
+# SOC_FW_KEY_CERT_ID              U(9)
+# TRUSTED_OS_FW_KEY_CERT_ID       U(10)
+# NON_TRUSTED_FW_KEY_CERT_ID      U(11)
+# SCP_FW_CONTENT_CERT_ID          U(12)
+# 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+=("i;${prompt};;Loading image id=(6|7|8|9|10|11|12|13|14|15) at address ")
+
+expect_string+=('i;BL1: Booting BL31')
diff --git a/expect-lava/disable_dyn_auth_tftf.exp b/expect-lava/disable_dyn_auth_tftf.exp
new file mode 100644
index 0000000..71f29c0
--- /dev/null
+++ b/expect-lava/disable_dyn_auth_tftf.exp
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+source $ci_root/expect-lava/disable_dyn_auth.inc
+
+prompt='Booting trusted firmware test framework'
+expect_string+=("i;${prompt}")
+
+prompt='Running at NS-EL(1|2)'
+expect_string+=("i;${prompt}")
+
+prompt='Tests Failed  : 0'
+expect_string+=("i;${prompt}")
+
+prompt='Exiting tests.'
+failures='Tests Passed  : 0'
+expect_string+=("i;${prompt};;${failures}")
diff --git a/expect-lava/el3-test-payload.exp b/expect-lava/el3-test-payload.exp
new file mode 100644
index 0000000..3c0347b
--- /dev/null
+++ b/expect-lava/el3-test-payload.exp
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware + EL3 Test Payload
+#
+# Refer to handle-arguments.inc for the list of parameters.
+#
+
+# Trusted Firmware boot section
+source $ci_root/expect-lava/trusted-firmware.inc
+
+expect_string+=('i;Booting the EL3 test payload')
+expect_string+=('i;All CPUs booted!')
diff --git a/expect-lava/fvp-r-yocto.exp b/expect-lava/fvp-r-yocto.exp
new file mode 100644
index 0000000..9f56db2
--- /dev/null
+++ b/expect-lava/fvp-r-yocto.exp
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for booting Yocto linux on FVP-R
+#
+
+# FVP-R BL1
+expect_string+=('i;Booting Trusted Firmware')
+expect_string+=('i;BL1: Booting BL33')
+
+# Uboot
+expect_string+=('i;U-Boot')
+
+# Yocto
+expect_string+=('i;Booting Linux on physical CPU')
+expect_string+=('i;fvp-baser-aemv8r64 login:;;;root\n')
+expect_string+=('i;#')
diff --git a/expect-lava/hold_uart.exp b/expect-lava/hold_uart.exp
new file mode 100644
index 0000000..4dc417b
--- /dev/null
+++ b/expect-lava/hold_uart.exp
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script
+#
+
+# Original TCL expect/ArmCI description:
+# If we exit from the uart, and if that had lots of prints, then the model
+# will stall. This may also occur even when the uart does not have any print.
+# See: https://jira.arm.com/browse/SDDKW-43675. So, we wait here expect for
+# something that never arrives.
+
+# This functionality is not required for LAVA tests, so this file is empty.
+# See also ../expect-post/hold_uart.exp
diff --git a/expect-lava/ivy.exp b/expect-lava/ivy.exp
new file mode 100644
index 0000000..c5e2b50
--- /dev/null
+++ b/expect-lava/ivy.exp
@@ -0,0 +1,11 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for the test Secure Partition Ivy
+#
+
+expect_string+=('i;Booting test Secure Partition Ivy')
+
+source $ci_root/expect-lava/uart-hold.inc
diff --git a/expect-lava/linux-bl33.exp b/expect-lava/linux-bl33.exp
new file mode 100644
index 0000000..8224534
--- /dev/null
+++ b/expect-lava/linux-bl33.exp
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware + Linux boot process
+#
+
+# Trusted Firmware boot section
+source $ci_root/expect-lava/trusted-firmware.inc
+
+# Linux kernel boot section
+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+=('i;Machine model: FVP (Base|Foundation)')
+expect_string+=('i;Kernel command line: console=ttyAMA0')
diff --git a/expect-lava/linux-oe-rst-bl31.exp b/expect-lava/linux-oe-rst-bl31.exp
new file mode 100644
index 0000000..1c54d71
--- /dev/null
+++ b/expect-lava/linux-oe-rst-bl31.exp
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware + U-Boot + Linux boot process with
+# OpenEmbedded rootfs in /dev/vda2
+# TF with reset to BL3-1
+#
+
+# Trusted Firmware boot section
+source $ci_root/expect-lava/trusted-firmware-rst-to-bl31.inc
+
+# Linux kernel boot section
+source $ci_root/expect-lava/linux.inc
+
+# OpenEmbedded filesystem section
+source $ci_root/expect-lava/openembedded.inc
diff --git a/expect-lava/linux-oe.exp b/expect-lava/linux-oe.exp
new file mode 100644
index 0000000..1dc8ae4
--- /dev/null
+++ b/expect-lava/linux-oe.exp
@@ -0,0 +1,17 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware + U-Boot + Linux boot process with
+# OpenEmbedded rootfs in /dev/vda2
+#
+
+# Trusted Firmware boot section
+source $ci_root/expect-lava/trusted-firmware.inc
+
+# Linux kernel boot section
+source $ci_root/expect-lava/linux.inc
+
+# OpenEmbedded filesystem section
+source $ci_root/expect-lava/openembedded.inc
diff --git a/expect-lava/linux-rd-busybox-aarch32.exp b/expect-lava/linux-rd-busybox-aarch32.exp
new file mode 100644
index 0000000..3c9d660
--- /dev/null
+++ b/expect-lava/linux-rd-busybox-aarch32.exp
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for AArch32 Trusted Firmware + U-Boot + Linux boot process
+# with a AArch32 minimal initrd. The linux image must be a zImage and the
+# initrd must include the U-boot header.
+# TF with reset to BL1
+#
+
+# Trusted Firmware boot section
+source $ci_root/expect-lava/trusted-firmware-aarch32.inc
+
+# Linux kernel boot section
+source $ci_root/expect-lava/linux.inc
+
+# Busybox filesystem section
+source $ci_root/expect-lava/busybox.inc
diff --git a/expect-lava/linux-rd-busybox.exp b/expect-lava/linux-rd-busybox.exp
new file mode 100644
index 0000000..ca389a9
--- /dev/null
+++ b/expect-lava/linux-rd-busybox.exp
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware + UEFI + Linux boot process with RAM Disk
+#
+
+# Trusted Firmware boot section
+source $ci_root/expect-lava/trusted-firmware.inc
+
+# Linux kernel boot section
+source $ci_root/expect-lava/linux.inc
+
+# Busybox filesystem section
+source $ci_root/expect-lava/busybox.inc
diff --git a/expect-lava/linux-tpm-384.exp b/expect-lava/linux-tpm-384.exp
new file mode 100644
index 0000000..fd92838
--- /dev/null
+++ b/expect-lava/linux-tpm-384.exp
@@ -0,0 +1,28 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Linux/Buildroot using Measured Boot & fTPM
+# It is a copy of linux-tpm.exp which doesn't check PCR0,PCR1
+# value, as that doesn't apply to this config
+#
+
+# 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:")
+
+# Login then load the fTPM driver
+# Note: Do not check sanity of PCR0
+expect_string+=("i;#;;;root")
+expect_string+=("i;;;;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 2 11); do
+    expect_string+=("i;#")
+    expect_string+=("i;${zero_pcr};;;pcrread -ha $i")
+done
diff --git a/expect-lava/linux-tpm.exp b/expect-lava/linux-tpm.exp
new file mode 100644
index 0000000..fb02652
--- /dev/null
+++ b/expect-lava/linux-tpm.exp
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Linux/Buildroot using Measured Boot & fTPM
+#
+
+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:")
+
+# Login then load the fTPM driver and retrieves PCR0
+# Pass condition: PCR0 and PCR1 must not be all zeros.
+expect_string+=("i;#;;;root")
+expect_string+=("i;${non_zero_pcr};;;ftpm")
+expect_string+=("i;#")
+expect_string+=("i;${non_zero_pcr};;;pcrread -ha 1")
+
+# 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 2 11); do
+    expect_string+=("i;#")
+    expect_string+=("i;${zero_pcr};;;pcrread -ha $i")
+done
diff --git a/expect-lava/linux.inc b/expect-lava/linux.inc
new file mode 100644
index 0000000..9c8b367
--- /dev/null
+++ b/expect-lava/linux.inc
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to interact with a Linux kernel
+#
+
+# Expect 8 CPUs in total by default
+if [ -z "${num_cpus}" ]; then
+	num_cpus=8
+fi
+
+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/expect-lava/openembedded.inc b/expect-lava/openembedded.inc
new file mode 100644
index 0000000..75137b5
--- /dev/null
+++ b/expect-lava/openembedded.inc
@@ -0,0 +1,13 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to interact with an OpenEmbedded file system
+#
+# This script is not standalone and should be sourced by a top expect script.
+#
+
+expect_string+=('i;INIT:')
+expect_string+=('i;root@genericarmv8:~#')
+expect_string+=('i;(Power down|System halted);;;shutdown -h now')
diff --git a/expect-lava/readonly_el1_xlat_tables.exp b/expect-lava/readonly_el1_xlat_tables.exp
new file mode 100644
index 0000000..2aa8389
--- /dev/null
+++ b/expect-lava/readonly_el1_xlat_tables.exp
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+expect_string+=('i;Translation tables are now read-only at EL1.')
diff --git a/expect-lava/spm-edk2-uart0.exp b/expect-lava/spm-edk2-uart0.exp
new file mode 100644
index 0000000..c914cc6
--- /dev/null
+++ b/expect-lava/spm-edk2-uart0.exp
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware + EDK2 UART0
+#
+# Refer to handle-arguments.inc for the list of parameters.
+#
+
+# Trusted Firmware boot section
+source $ci_root/expect-lava/trusted-firmware.inc
+
+# EDK2 section
+expect_string+=('i;UEFI firmware')
+
+expect_string+=('i;UEFI Interactive Shell')
+
+expect_string+=('i;any other key to continue.')
+
+expect_string+=('i;Shell>;;;\r')
+
+expect_string+=('i;FS0:;;;fs0:\r')
+
+expect_string+=('i;FS0:;Loading driver at .* UefiInfo.efi;;UefiInfo.efi\r')
diff --git a/expect-lava/spm-edk2-uart2.exp b/expect-lava/spm-edk2-uart2.exp
new file mode 100644
index 0000000..b84b825
--- /dev/null
+++ b/expect-lava/spm-edk2-uart2.exp
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Standalone MM partition UART2
+#
+
+# Handled by ../expect-post/spm-edk2-uart2.exp
diff --git a/expect-lava/spm-linux-uart0.exp b/expect-lava/spm-linux-uart0.exp
new file mode 100644
index 0000000..b2959d6
--- /dev/null
+++ b/expect-lava/spm-linux-uart0.exp
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+expect_string+=('i;Please press Enter to activate this console.')
+expect_string+=('i;/ # ;;;\r')
+expect_string+=('i;Hafnium successfully loaded with 1 VMs:;;;insmod hafnium.ko')
diff --git a/expect-lava/spm-optee-sp-uart1.exp b/expect-lava/spm-optee-sp-uart1.exp
new file mode 100644
index 0000000..aa57540
--- /dev/null
+++ b/expect-lava/spm-optee-sp-uart1.exp
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
diff --git a/expect-lava/spm-uart2.exp b/expect-lava/spm-uart2.exp
new file mode 100644
index 0000000..5bee324
--- /dev/null
+++ b/expect-lava/spm-uart2.exp
@@ -0,0 +1,7 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+# Handled by ../expect-post/spm-uart2.exp
diff --git a/expect-lava/tftf-aarch32.exp b/expect-lava/tftf-aarch32.exp
new file mode 100644
index 0000000..2f52c6c
--- /dev/null
+++ b/expect-lava/tftf-aarch32.exp
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+source $ci_root/expect-lava/trusted-firmware-aarch32.inc
+
+prompt='Booting trusted firmware test framework'
+expect_string+=("i;${prompt}")
+
+prompt='Running in AArch32 HYP mode'
+expect_string+=("i;${prompt}")
+
+prompt='Tests Failed  : 0'
+expect_string+=("i;${prompt}")
+
+prompt='Exiting tests.'
+failures='Tests Passed  : 0'
+expect_string+=("i;${prompt};;${failures}")
diff --git a/expect-lava/tftf.exp b/expect-lava/tftf.exp
new file mode 100644
index 0000000..68b5b5c
--- /dev/null
+++ b/expect-lava/tftf.exp
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+source $ci_root/expect-lava/trusted-firmware.inc
+
+prompt='Booting trusted firmware test framework'
+expect_string+=("i;${prompt}")
+
+prompt='Running at NS-EL(1|2)'
+expect_string+=("i;${prompt}")
+
+prompt='Tests Failed  : 0'
+expect_string+=("i;${prompt}")
+
+prompt='Exiting tests.'
+failures='Tests Passed  : 0'
+expect_string+=("i;${prompt};;${failures}")
diff --git a/expect-lava/tftf_fault.exp b/expect-lava/tftf_fault.exp
new file mode 100644
index 0000000..86561e3
--- /dev/null
+++ b/expect-lava/tftf_fault.exp
@@ -0,0 +1,12 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script
+#
+
+# Expect the test to have set a fault message
+if [ -n "${tftf_fault_msg}" ]; then
+    expect_string+=("i;${tftf_fault_msg}")
+fi
diff --git a/expect-lava/timeout.exp b/expect-lava/timeout.exp
new file mode 100644
index 0000000..7c84a7f
--- /dev/null
+++ b/expect-lava/timeout.exp
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+# TODO
diff --git a/expect-lava/timeout_spmin_roxlattables.exp b/expect-lava/timeout_spmin_roxlattables.exp
new file mode 100644
index 0000000..c37c7dc
--- /dev/null
+++ b/expect-lava/timeout_spmin_roxlattables.exp
@@ -0,0 +1,8 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+# TODO
diff --git a/expect-lava/timeout_test.exp b/expect-lava/timeout_test.exp
new file mode 100644
index 0000000..4852695
--- /dev/null
+++ b/expect-lava/timeout_test.exp
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+# TODO
diff --git a/expect-lava/tpm-logs.exp b/expect-lava/tpm-logs.exp
new file mode 100644
index 0000000..da7a9de
--- /dev/null
+++ b/expect-lava/tpm-logs.exp
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for fTPM debug logs
+#
+
+# Handled by ../expect-post/tpm-logs.exp
diff --git a/expect-lava/trusted-firmware-aarch32.inc b/expect-lava/trusted-firmware-aarch32.inc
new file mode 100644
index 0000000..ae02ec4
--- /dev/null
+++ b/expect-lava/trusted-firmware-aarch32.inc
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to interact with AArch32 Trusted Firmware-A.
+#
+
+# Initial boot message won't be present if we're starting at SP_MIN. Skip
+# waiting for them by inspecting the environment variable
+# 'skip_early_boot_msgs'.
+if [ -z "$skip_early_boot_msgs" ]; then
+
+        expect_string+=('i;Booting Trusted Firmware')
+
+        prompt='BL1: Booting BL2'
+        # Catch all 3 possible BL2 loading error messages, namely:
+        #   "Failure in pre image load handling of BL2"
+        #   "Failed to load BL2 firmware."
+        #   "Failure in post image load handling of BL2"
+        failures='Fail.*load.*BL2'
+        expect_string+=("i;${prompt};;${failures}")
+
+	expect_string+=('i;BL1: Booting BL32')
+fi
+
+expect_string+=('i;SP_MIN:')
diff --git a/expect-lava/trusted-firmware-load-error.exp b/expect-lava/trusted-firmware-load-error.exp
new file mode 100644
index 0000000..5bef49f
--- /dev/null
+++ b/expect-lava/trusted-firmware-load-error.exp
@@ -0,0 +1,8 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+# Expect an error while loading BL2 image.
+expect_string+=('i;Loading of FW_CONFIG failed;;BL1: Booting BL2')
diff --git a/expect-lava/trusted-firmware-rst-to-bl31.inc b/expect-lava/trusted-firmware-rst-to-bl31.inc
new file mode 100644
index 0000000..af9dc04
--- /dev/null
+++ b/expect-lava/trusted-firmware-rst-to-bl31.inc
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to interact with Trusted Firmware when resetting to BL31.
+#
+
+expect_string+=('i;NOTICE:  BL3-?1:')
diff --git a/expect-lava/trusted-firmware.inc b/expect-lava/trusted-firmware.inc
new file mode 100644
index 0000000..4d38e09
--- /dev/null
+++ b/expect-lava/trusted-firmware.inc
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to interact with AArch64 Trusted Firmware-A.
+#
+
+# Initial boot message won't be present if we're starting at BL31. Skip waiting
+# for them by inspecting the environment variable 'skip_early_boot_msgs'.
+if [ -z "$skip_early_boot_msgs" ]; then
+
+        expect_string+=('i;Booting Trusted Firmware')
+
+        prompt='Booting BL2'
+        # Catch all 3 possible BL2 loading error messages, namely:
+        #   "Failure in pre image load handling of BL2"
+        #   "Failed to load BL2 firmware."
+        #   "Failure in post image load handling of BL2"
+        failures='Fail.*load.*BL2'
+        expect_string+=("i;${prompt};;${failures}")
+
+	expect_string+=('i;BL1: Booting BL31')
+fi
diff --git a/expect-lava/tsp.exp b/expect-lava/tsp.exp
new file mode 100644
index 0000000..3cc6558
--- /dev/null
+++ b/expect-lava/tsp.exp
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for TSP
+#
+
+# Handled by ../expect-post/tsp.exp
diff --git a/expect-lava/uart-hold.inc b/expect-lava/uart-hold.inc
new file mode 100644
index 0000000..5752699
--- /dev/null
+++ b/expect-lava/uart-hold.inc
@@ -0,0 +1,11 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Original TCL expect/ArmCI description:
+# If we exit from a secondary uart, and if that had lots of prints, then the
+# model will stall. See: https://jira.arm.com/browse/SDDKW-43675. So, we wait
+# here expect for something that never arrives.
+
+# This functionality is not required for LAVA tests, so this file is empty.
diff --git a/expect-lava/ubsan-test-trap.exp b/expect-lava/ubsan-test-trap.exp
new file mode 100644
index 0000000..373f50b
--- /dev/null
+++ b/expect-lava/ubsan-test-trap.exp
@@ -0,0 +1,12 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+# Value for trap BRK instruction
+trap_value=0x00003e8
+
+expect_string+=("i;Unexpected BRK instruction with value $trap_value")
diff --git a/expect-lava/unhandled_exception_at_el3.exp b/expect-lava/unhandled_exception_at_el3.exp
new file mode 100644
index 0000000..1ac84c0
--- /dev/null
+++ b/expect-lava/unhandled_exception_at_el3.exp
@@ -0,0 +1,89 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+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')