refactor: move LAVA job definition templates into independent files

This change introduces a new script function to expand the variables in
a file. With this, we can move the LAVA YAML job template descriptions,
which are currently embedded inside individual HEREDOCs, into their own
files.

Signed-off-by: Chris Kay <chris.kay@arm.com>
Change-Id: I09805ab4b6894a371e63a944d113ca2f475a806b
diff --git a/script/gen_fvp_linux_yaml.sh b/script/gen_fvp_linux_yaml.sh
index ab58683..68ef6eb 100755
--- a/script/gen_fvp_linux_yaml.sh
+++ b/script/gen_fvp_linux_yaml.sh
@@ -11,140 +11,9 @@
 # file also includes references to ${UPPERCASE} which are just normal shell
 # variables, replaced on spot.
 
+ci_root="$(readlink -f "$(dirname "$0")/..")"
+source "$ci_root/utils.sh"
+
 . $(dirname $0)/gen_gerrit_meta.sh
 
-cat <<EOF
-metadata:
-  test_config: {TEST_CONFIG}
-  fvp_model: {MODEL}
-  build_url: ${BUILD_URL}
-${gerrit_meta}
-
-device_type: fvp
-job_name: fvp-linux-{TEST_CONFIG}
-
-timeouts:
-  connection:
-    seconds: 10
-  job:
-    minutes: 30
-  action:
-    minutes: 20
-  actions:
-    auto-login-action:
-      minutes: 5
-    lava-test-monitor:
-      minutes: 5
-    lava-test-interactive:
-      minutes: 15
-    lava-test-shell:
-      seconds: 300
-    http-download:
-      minutes: 2
-    download-retry:
-      minutes: 2
-    fvp-deploy:
-      minutes: 5
-
-priority: medium
-visibility: public
-
-actions:
-- deploy:
-    to: fvp
-    images:
-      backup_fip:
-        url: {BACKUP_FIP}
-      bl1:
-        url: {BL1}
-      bl2:
-        url: {BL2}
-      bl31:
-        url: {BL31}
-      bl32:
-        url: {BL32}
-      busybox:
-        url: {BUSYBOX}
-        compression: gz
-      cactus_primary:
-        url: {CACTUS_PRIMARY}
-      cactus_secondary:
-        url: {CACTUS_SECONDARY}
-      cactus_tertiary:
-        url: {CACTUS_TERTIARY}
-      coverage_trace_plugin:
-        url: {COVERAGE_TRACE_PLUGIN}
-      dtb:
-        url: {DTB}
-      el3_payload:
-        url: {EL3_PAYLOAD}
-      fvp_spmc_manifest_dtb:
-        url: {FVP_SPMC_MANIFEST_DTB}
-      fip:
-        url: {FIP}
-      fip_gpt:
-        url: {FIP_GPT}
-      fwu_fip:
-        url: {FWU_FIP}
-      generic_trace:
-        url: {GENERIC_TRACE}
-      hafnium:
-        url: {HAFNIUM}
-      image:
-        url: {IMAGE}
-      ivy:
-        url: {IVY}
-      manifest_dtb:
-        url: {MANIFEST_DTB}
-      mcp_rom:
-        url: {MCP_ROM}
-      mcp_rom_hyphen:
-        url: {MCP_ROM_HYPHEN}
-      ns_bl1u:
-        url: {NS_BL1U}
-      ns_bl2u:
-        url: {NS_BL2U}
-      ramdisk:
-        url: {RAMDISK}
-      romlib:
-        url: {ROMLIB}
-      rootfs:
-        url: {ROOTFS}
-        compression: gz
-      secure_hafnium:
-        url: {SECURE_HAFNIUM}
-      scp_ram:
-        url: {SCP_RAM}
-      scp_ram_hyphen:
-        url: {SCP_RAM_HYPHEN}
-      scp_rom:
-        url: {SCP_ROM}
-      scp_rom_hyphen:
-        url: {SCP_ROM_HYPHEN}
-      spm:
-        url: {SPM}
-      tftf:
-        url: {TFTF}
-      tmp:
-        url: {TMP}
-      uboot:
-        url: {UBOOT}
-
-- boot:
-    method: fvp
-    license_variable: ARMLMD_LICENSE_FILE={ARMLMD_LICENSE_FILE}
-    docker:
-      name: {BOOT_DOCKER_NAME}
-      local: true
-    image: {BOOT_IMAGE_DIR}/{BOOT_IMAGE_BIN}
-    version_string: {BOOT_VERSION_STRING}
-    console_string: 'terminal_0: Listening for serial connection on port (?P<PORT>\d+)'
-    feedbacks:
-      - '(?P<NAME>terminal_1): Listening for serial connection on port (?P<PORT>\d+)'
-      - '(?P<NAME>terminal_2): Listening for serial connection on port (?P<PORT>\d+)'
-      - '(?P<NAME>terminal_3): Listening for serial connection on port (?P<PORT>\d+)'
-    timeout:
-      minutes: 30
-    arguments:
-{BOOT_ARGUMENTS}
-EOF
+expand_template "$(dirname "$0")/lava-templates/fvp-linux.yaml"
diff --git a/script/gen_fvp_tftf_yaml.sh b/script/gen_fvp_tftf_yaml.sh
index 69e7f5c..5c024ca 100755
--- a/script/gen_fvp_tftf_yaml.sh
+++ b/script/gen_fvp_tftf_yaml.sh
@@ -11,152 +11,9 @@
 # file also includes references to ${UPPERCASE} which are just normal shell
 # variables, replaced on spot.
 
+ci_root="$(readlink -f "$(dirname "$0")/..")"
+source "$ci_root/utils.sh"
+
 . $(dirname $0)/gen_gerrit_meta.sh
 
-cat <<EOF
-metadata:
-  test_config: {TEST_CONFIG}
-  fvp_model: {MODEL}
-  build_url: ${BUILD_URL}
-${gerrit_meta}
-
-device_type: fvp
-job_name: {TEST_CONFIG}
-
-timeouts:
-  job:
-    minutes: 30
-  action:
-    minutes: 20
-  actions:
-    auto-login-action:
-      seconds: 300
-    lava-test-monitor:
-      minutes: 7
-    lava-test-interactive:
-      minutes: 15
-    lava-test-shell:
-      seconds: 300
-    lava-test-retry:
-      seconds: 300
-    http-download:
-      seconds: 120
-    download-retry:
-      seconds: 120
-    fvp-deploy:
-      seconds: 300
-  connection:
-    seconds: 10
-  connections:
-    lava-test-retry:
-      seconds: 300
-    lava-test-monitor:
-      seconds: 300
-    lava-test-shell:
-      seconds: 300
-    bootloader-action:
-      seconds: 300
-    bootloader-retry:
-      seconds: 300
-
-priority: medium
-visibility: public
-
-actions:
-- deploy:
-    to: fvp
-    images:
-      backup_fip:
-        url: {BACKUP_FIP}
-      bl1:
-        url: {BL1}
-      bl2:
-        url: {BL2}
-      bl31:
-        url: {BL31}
-      bl32:
-        url: {BL32}
-      busybox:
-        url: {BUSYBOX}
-        compression: gz
-      cactus_primary:
-        url: {CACTUS_PRIMARY}
-      cactus_secondary:
-        url: {CACTUS_SECONDARY}
-      cactus_tertiary:
-        url: {CACTUS_TERTIARY}
-      coverage_trace_plugin:
-        url: {COVERAGE_TRACE_PLUGIN}
-      dtb:
-        url: {DTB}
-      el3_payload:
-        url: {EL3_PAYLOAD}
-      fvp_spmc_manifest_dtb:
-        url: {FVP_SPMC_MANIFEST_DTB}
-      fip:
-        url: {FIP}
-      fip_gpt:
-        url: {FIP_GPT}
-      fwu_fip:
-        url: {FWU_FIP}
-      generic_trace:
-        url: {GENERIC_TRACE}
-      hafnium:
-        url: {HAFNIUM}
-      image:
-        url: {IMAGE}
-      ivy:
-        url: {IVY}
-      manifest_dtb:
-        url: {MANIFEST_DTB}
-      mcp_rom:
-        url: {MCP_ROM}
-      mcp_rom_hyphen:
-        url: {MCP_ROM_HYPHEN}
-      ns_bl1u:
-        url: {NS_BL1U}
-      ns_bl2u:
-        url: {NS_BL2U}
-      ramdisk:
-        url: {RAMDISK}
-      romlib:
-        url: {ROMLIB}
-      rootfs:
-        url: {ROOTFS}
-        compression: gz
-      secure_hafnium:
-        url: {SECURE_HAFNIUM}
-      scp_ram:
-        url: {SCP_RAM}
-      scp_ram_hyphen:
-        url: {SCP_RAM_HYPHEN}
-      scp_rom:
-        url: {SCP_ROM}
-      scp_rom_hyphen:
-        url: {SCP_ROM_HYPHEN}
-      spm:
-        url: {SPM}
-      tftf:
-        url: {TFTF}
-      tmp:
-        url: {TMP}
-      uboot:
-        url: {UBOOT}
-
-- boot:
-    method: fvp
-    license_variable: ARMLMD_LICENSE_FILE={ARMLMD_LICENSE_FILE}
-    docker:
-      name: {BOOT_DOCKER_NAME}
-      local: true
-    image: {BOOT_IMAGE_DIR}/{BOOT_IMAGE_BIN}
-    version_string: {BOOT_VERSION_STRING}
-    console_string: 'terminal_0: Listening for serial connection on port (?P<PORT>\d+)'
-    feedbacks:
-      - '(?P<NAME>terminal_1): Listening for serial connection on port (?P<PORT>\d+)'
-      - '(?P<NAME>terminal_2): Listening for serial connection on port (?P<PORT>\d+)'
-      - '(?P<NAME>terminal_3): Listening for serial connection on port (?P<PORT>\d+)'
-    arguments:
-{BOOT_ARGUMENTS}
-
-EOF
+expand_template "$(dirname "$0")/lava-templates/fvp-tftf.yaml"
diff --git a/script/gen_juno_linux_reboot_yaml.sh b/script/gen_juno_linux_reboot_yaml.sh
index 324f7f1..20dab75 100755
--- a/script/gen_juno_linux_reboot_yaml.sh
+++ b/script/gen_juno_linux_reboot_yaml.sh
@@ -42,92 +42,4 @@
         tags=""
 fi
 
-cat <<EOF
-device_type: juno
-job_name: tf-juno
-
-context:
-  bootloader_prompt: $bootloader_prompt
-
-$tags
-$juno_revision
-
-timeouts:
-  # Global timeout value for the whole job.
-  job:
-    minutes: 30
-  # Unless explicitly overridden, no single action should take more than
-  # 10 minutes to complete.
-  action:
-    minutes: 10
-
-priority: medium
-visibility: public
-
-actions:
-
-- deploy:
-    namespace: recovery
-    to: vemsd
-    recovery_image:
-      url: $recovery_img_url
-      compression: zip
-
-- deploy:
-    namespace: target
-    to: nfs
-    os: $os
-    nfsrootfs:
-      url: $nfs_rootfs
-      compression: gz
-
-- boot:
-    # Drastically increase the timeout for the boot action because of the udev
-    # issues when using TF build config "juno-all-cpu-reset-ops".
-    # TODO: Should increase the timeout only for this TF build config, not all!
-    timeout:
-      minutes: 15
-    namespace: target
-    connection-namespace: recovery
-    method: u-boot
-    commands: norflash
-    auto-login:
-      login_prompt: 'login:'
-      username: root
-    prompts:
-    - $linux_prompt
-
-- test:
-    namespace: target
-    timeout:
-      minutes: 10
-    definitions:
-    - repository:
-        metadata:
-          format: Lava-Test Test Definition 1.0
-          name: container-test-run
-          description: '"Prepare system..."'
-          os:
-          - $os
-          scope:
-          - functional
-        run:
-          steps:
-          - echo "Rebooting..."
-      from: inline
-      name: target-configure
-      path: inline/target-configure.yaml
-
-- boot:
-    timeout:
-      minutes: 15
-    namespace: target
-    connection-namespace: recovery
-    method: u-boot
-    commands: norflash
-    auto-login:
-      login_prompt: 'login:'
-      username: root
-    prompts:
-    - $linux_prompt
-EOF
+expand_template "$(dirname "$0")/lava-templates/juno-linux-reboot.yaml"
diff --git a/script/gen_juno_linux_yaml.sh b/script/gen_juno_linux_yaml.sh
index 8a7df56..fa0130a 100755
--- a/script/gen_juno_linux_yaml.sh
+++ b/script/gen_juno_linux_yaml.sh
@@ -39,58 +39,4 @@
         tags=""
 fi
 
-cat <<EOF
-device_type: juno
-job_name: tf-juno
-
-context:
-  bootloader_prompt: $bootloader_prompt
-
-$tags
-$juno_revision
-
-timeouts:
-  # Global timeout value for the whole job.
-  job:
-    minutes: 30
-  # Unless explicitly overwritten, no single action should take more than
-  # 10 minutes to complete.
-  action:
-    minutes: 10
-
-priority: medium
-visibility: public
-
-actions:
-
-- deploy:
-    namespace: recovery
-    to: vemsd
-    recovery_image:
-      url: $recovery_img_url
-      compression: zip
-
-- deploy:
-    namespace: target
-    to: nfs
-    os: debian
-    nfsrootfs:
-      url: $nfs_rootfs
-      compression: gz
-
-- boot:
-    # Drastically increase the timeout for the boot action because of the udev
-    # issues when using TF build config "juno-all-cpu-reset-ops".
-    # TODO: Should increase the timeout only for this TF build config, not all!
-    timeout:
-      minutes: 15
-    namespace: target
-    connection-namespace: recovery
-    method: u-boot
-    commands: norflash
-    auto-login:
-      login_prompt: 'login:'
-      username: root
-    prompts:
-    - $linux_prompt
-EOF
+expand_template "$(dirname "$0")/lava-templates/juno-linux.yaml"
diff --git a/script/gen_juno_scp_tests_scmi_yaml.sh b/script/gen_juno_scp_tests_scmi_yaml.sh
index 31fac79..9ce0461 100755
--- a/script/gen_juno_scp_tests_scmi_yaml.sh
+++ b/script/gen_juno_scp_tests_scmi_yaml.sh
@@ -37,59 +37,4 @@
         tags=""
 fi
 
-cat <<EOF
-device_type: juno
-job_name: scp-tests-scmi-juno
-
-$tags
-$juno_revision
-
-timeouts:
-  # Global timeout value for the whole job.
-  job:
-    minutes: 10
-  actions:
-    lava-test-monitor:
-      seconds: 180
-  connections:
-    lava-test-monitor:
-      seconds: 180
-
-priority: medium
-visibility: public
-
-actions:
-
-- deploy:
-    timeout:
-      minutes: 5
-    to: vemsd
-    recovery_image:
-      url: $recovery_img_url
-      compression: zip
-
-- boot:
-    method: minimal
-
-- test:
-    timeout:
-      minutes: 8
-
-    monitors:
-    #
-    # Monitor no.1
-    # Monitor the results from all the protocols
-    #
-    - name: SCP-SCMI-ALL-PROTOCOL
-      start: 'BL31: Baremetal test suite: scmi'
-      end: '\*\*\*\* SCMI tests complete \*\*\*\*'
-
-      pattern: '(?P<test_case_id>\d{3}):[\w ]+[\w\n\r[\] :<>&=]*?: (?P<result>CONFORMANT|NON CONFORMANT|SKIPPED)'
-
-      fixupdict:
-        "CONFORMANT": pass
-        "NON CONFORMANT": fail
-        "SKIPPED": skip
-
-
-EOF
+expand_template "$(dirname "$0")/lava-templates/juno-scp-tests-scmi.yaml"
diff --git a/script/gen_juno_tftf_yaml.sh b/script/gen_juno_tftf_yaml.sh
index 2008028..24ac0a2 100755
--- a/script/gen_juno_tftf_yaml.sh
+++ b/script/gen_juno_tftf_yaml.sh
@@ -35,60 +35,4 @@
         tags=""
 fi
 
-cat <<EOF
-device_type: juno
-job_name: tf-juno
-
-$tags
-$juno_revision
-
-timeouts:
-  # Global timeout value for the whole job.
-  job:
-    minutes: 45
-  actions:
-    lava-test-monitor:
-      seconds: 120
-  connections:
-    lava-test-monitor:
-      seconds: 120
-
-priority: medium
-visibility: public
-
-actions:
-
-- deploy:
-    timeout:
-      minutes: 10
-    to: vemsd
-    recovery_image:
-      url: $recovery_img_url
-      compression: zip
-
-- boot:
-    method: minimal
-
-- test:
-    # Timeout for all the TFTF tests to complete.
-    timeout:
-      minutes: 30
-
-    monitors:
-    - name: TFTF
-      # LAVA looks for a testsuite start string...
-      start: 'Booting trusted firmware test framework'
-      # ...and a testsuite end string.
-      end: 'Exiting tests.'
-
-      # For each test case, LAVA looks for a string which includes the testcase
-      # name and result.
-      pattern: "(?s)> Executing '(?P<test_case_id>.+?(?='))'(.*)  TEST COMPLETE\\\s+(?P<result>(Skipped|Passed|Failed|Crashed))"
-
-      # Teach to LAVA how to interpret the TFTF Tests results.
-      fixupdict:
-        Passed: pass
-        Failed: fail
-        Crashed: fail
-        Skipped: skip
-EOF
+expand_template "$(dirname "$0")/lava-templates/juno-tftf.yaml"
diff --git a/script/gen_n1sdp_linux_yaml.sh b/script/gen_n1sdp_linux_yaml.sh
index 36c7f0d..c0a7165 100755
--- a/script/gen_n1sdp_linux_yaml.sh
+++ b/script/gen_n1sdp_linux_yaml.sh
@@ -27,183 +27,4 @@
 
 recovery_img_url="${recovery_img_url:-$(get_recovery_image_url)}"
 
-cat <<EOF
-device_type: n1sdp
-job_name: tf-n1sdp
-timeouts:
-  job:
-    minutes: 30
-
-priority: medium
-visibility: public
-context:
-  extra_nfsroot_args: ',vers=3'
-  extra_kernel_args: rootwait
-actions:
-#
-# Any firmware bundle deployed must be configured to boot automatically without
-# intervention. This means "PMIC_FORCE" must be set "TRUE" in the config file
-# to be deployed.
-#
-#
-# Deploy a firmware bundle with the customised "uefi.bin" installed. This
-# enables an EFI network driver, allowing us to force a TFTP boot from GRUB (assuming cobbler is setup)
-#
-- deploy:
-    namespace: recovery
-    to: flasher
-    images:
-      recovery_image:
-        url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/n1sdp-board-firmware-force-netboot.zip
-        compression: zip
-
-- deploy:
-    namespace: debian
-    to: tftp
-    os: debian
-    kernel:
-      url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/debian/linux
-      type: image
-    ramdisk:
-      url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/debian/ramdisk.img
-    nfsrootfs:
-      url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/debian/debian-buster-arm64-rootfs.tar.xz
-      compression: xz
-
-- boot:
-    namespace: recovery
-    timeout:
-      minutes: 3
-    method: minimal
-    parameters:
-      kernel-start-message: ''
-    prompts: ['Cmd>']
-
-- boot:
-    namespace: uart1
-    method: new_connection
-    connection: uart1
-
-- boot:
-    namespace: debian
-    connection-namespace: uart1
-    timeout:
-      minutes: 5
-    method: grub
-    commands: nfs
-    prompts:
-      - '/ # '
-
-- test:
-    namespace: debian
-    timeout:
-      minutes: 5
-    definitions:
-      - repository:
-          metadata:
-            format: Lava-Test Test Definition 1.0
-            name: device-network
-            description: '"Test device network connection"'
-            os:
-              - debian
-            scope:
-              - functional
-          run:
-            steps:
-              - apt -q update
-              - apt -q install -y iputils-ping
-              - ping -c 5 www.arm.com || lava-test-raise "Device failed to reach a remote host"
-              - hostname -I
-        from: inline
-        name: device-network
-        path: inline/device-network.yaml
-
-- test:
-    namespace: debian
-    timeout:
-      minutes: 5
-    definitions:
-      - repository:
-          metadata:
-            format: Lava-Test Test Definition 1.0
-            name: install-dependancies
-            description: '"Install dependancies for secondary media deployment"'
-            os:
-              - debian
-            scope:
-              - functional
-          run:
-            steps:
-              - apt-get update -q
-              - apt-get install -qy wget
-        from: inline
-        name: install-dependancies
-        path: inline/install-dependancies.yaml
-
-- deploy:
-    namespace: secondary_media
-    connection-namespace: uart1
-    timeout:
-      minutes: 10
-    to: usb
-    os: busybox
-    images:
-      image:
-        url: "$n1sdp_prebuilts/busybox.img"
-    uniquify: false
-    device: usb_storage_device
-    download:
-      tool: /usr/bin/wget
-      prompt: HTTP request sent, awaiting response
-      options: --no-check-certificate --no-proxy --connect-timeout=30 -S --progress=dot:giga -O - {DOWNLOAD_URL}
-
-#
-# Deploy the primary board firmware bundle (this time without the additinal
-# network driver).
-#
-- deploy:
-    namespace: recovery
-    to: flasher
-    images:
-      recovery_image:
-        url: $recovery_img_url
-        compression: zip
-
-#
-# Do not verify the flash second time around as cached serial output on the
-# connection will immediately match the prompt.
-#
-- boot:
-    namespace: secondary_media
-    timeout:
-      minutes: 10
-    method: minimal
-    prompts:
-      - '/ #'
-    transfer_overlay:
-      download_command: wget -S
-      unpack_command: tar -C / -xzf
-
-- test:
-    namespace: secondary_media
-    timeout:
-      minutes: 5
-    definitions:
-      - repository:
-          metadata:
-            format: Lava-Test Test Definition 1.0
-            name: linux-console-test-in-deployed-image
-            description: '"Run LAVA test steps inside the deployed image"'
-            os:
-              - oe
-            scope:
-              - functional
-          run:
-            steps:
-              - fdisk -l
-              - ip addr show
-              - cat /proc/cpuinfo
-        from: inline
-        name: linux-console-test
-        path: inline/linux-console-test.yaml
-EOF
+expand_template "$(dirname "$0")/lava-templates/n1sdp-linux.yaml"
diff --git a/script/lava-templates/fvp-linux.yaml b/script/lava-templates/fvp-linux.yaml
new file mode 100644
index 0000000..ab1c64a
--- /dev/null
+++ b/script/lava-templates/fvp-linux.yaml
@@ -0,0 +1,133 @@
+metadata:
+  test_config: {TEST_CONFIG}
+  fvp_model: {MODEL}
+  build_url: ${BUILD_URL}
+${gerrit_meta}
+
+device_type: fvp
+job_name: fvp-linux-{TEST_CONFIG}
+
+timeouts:
+  connection:
+    seconds: 10
+  job:
+    minutes: 30
+  action:
+    minutes: 20
+  actions:
+    auto-login-action:
+      minutes: 5
+    lava-test-monitor:
+      minutes: 5
+    lava-test-interactive:
+      minutes: 15
+    lava-test-shell:
+      seconds: 300
+    http-download:
+      minutes: 2
+    download-retry:
+      minutes: 2
+    fvp-deploy:
+      minutes: 5
+
+priority: medium
+visibility: public
+
+actions:
+- deploy:
+    to: fvp
+    images:
+      backup_fip:
+        url: {BACKUP_FIP}
+      bl1:
+        url: {BL1}
+      bl2:
+        url: {BL2}
+      bl31:
+        url: {BL31}
+      bl32:
+        url: {BL32}
+      busybox:
+        url: {BUSYBOX}
+        compression: gz
+      cactus_primary:
+        url: {CACTUS_PRIMARY}
+      cactus_secondary:
+        url: {CACTUS_SECONDARY}
+      cactus_tertiary:
+        url: {CACTUS_TERTIARY}
+      coverage_trace_plugin:
+        url: {COVERAGE_TRACE_PLUGIN}
+      dtb:
+        url: {DTB}
+      el3_payload:
+        url: {EL3_PAYLOAD}
+      fvp_spmc_manifest_dtb:
+        url: {FVP_SPMC_MANIFEST_DTB}
+      fip:
+        url: {FIP}
+      fip_gpt:
+        url: {FIP_GPT}
+      fwu_fip:
+        url: {FWU_FIP}
+      generic_trace:
+        url: {GENERIC_TRACE}
+      hafnium:
+        url: {HAFNIUM}
+      image:
+        url: {IMAGE}
+      ivy:
+        url: {IVY}
+      manifest_dtb:
+        url: {MANIFEST_DTB}
+      mcp_rom:
+        url: {MCP_ROM}
+      mcp_rom_hyphen:
+        url: {MCP_ROM_HYPHEN}
+      ns_bl1u:
+        url: {NS_BL1U}
+      ns_bl2u:
+        url: {NS_BL2U}
+      ramdisk:
+        url: {RAMDISK}
+      romlib:
+        url: {ROMLIB}
+      rootfs:
+        url: {ROOTFS}
+        compression: gz
+      secure_hafnium:
+        url: {SECURE_HAFNIUM}
+      scp_ram:
+        url: {SCP_RAM}
+      scp_ram_hyphen:
+        url: {SCP_RAM_HYPHEN}
+      scp_rom:
+        url: {SCP_ROM}
+      scp_rom_hyphen:
+        url: {SCP_ROM_HYPHEN}
+      spm:
+        url: {SPM}
+      tftf:
+        url: {TFTF}
+      tmp:
+        url: {TMP}
+      uboot:
+        url: {UBOOT}
+
+- boot:
+    method: fvp
+    license_variable: ARMLMD_LICENSE_FILE={ARMLMD_LICENSE_FILE}
+    docker:
+      name: {BOOT_DOCKER_NAME}
+      local: true
+    image: {BOOT_IMAGE_DIR}/{BOOT_IMAGE_BIN}
+    version_string: {BOOT_VERSION_STRING}
+    console_string: 'terminal_0: Listening for serial connection on port (?P<PORT>\d+)'
+    feedbacks:
+      - '(?P<NAME>terminal_1): Listening for serial connection on port (?P<PORT>\d+)'
+      - '(?P<NAME>terminal_2): Listening for serial connection on port (?P<PORT>\d+)'
+      - '(?P<NAME>terminal_3): Listening for serial connection on port (?P<PORT>\d+)'
+    timeout:
+      minutes: 30
+    arguments:
+{BOOT_ARGUMENTS}
diff --git a/script/lava-templates/fvp-tftf.yaml b/script/lava-templates/fvp-tftf.yaml
new file mode 100644
index 0000000..903947a
--- /dev/null
+++ b/script/lava-templates/fvp-tftf.yaml
@@ -0,0 +1,144 @@
+metadata:
+  test_config: {TEST_CONFIG}
+  fvp_model: {MODEL}
+  build_url: ${BUILD_URL}
+${gerrit_meta}
+
+device_type: fvp
+job_name: {TEST_CONFIG}
+
+timeouts:
+  job:
+    minutes: 30
+  action:
+    minutes: 20
+  actions:
+    auto-login-action:
+      seconds: 300
+    lava-test-monitor:
+      minutes: 7
+    lava-test-interactive:
+      minutes: 15
+    lava-test-shell:
+      seconds: 300
+    lava-test-retry:
+      seconds: 300
+    http-download:
+      seconds: 120
+    download-retry:
+      seconds: 120
+    fvp-deploy:
+      seconds: 300
+  connection:
+    seconds: 10
+  connections:
+    lava-test-retry:
+      seconds: 300
+    lava-test-monitor:
+      seconds: 300
+    lava-test-shell:
+      seconds: 300
+    bootloader-action:
+      seconds: 300
+    bootloader-retry:
+      seconds: 300
+
+priority: medium
+visibility: public
+
+actions:
+- deploy:
+    to: fvp
+    images:
+      backup_fip:
+        url: {BACKUP_FIP}
+      bl1:
+        url: {BL1}
+      bl2:
+        url: {BL2}
+      bl31:
+        url: {BL31}
+      bl32:
+        url: {BL32}
+      busybox:
+        url: {BUSYBOX}
+        compression: gz
+      cactus_primary:
+        url: {CACTUS_PRIMARY}
+      cactus_secondary:
+        url: {CACTUS_SECONDARY}
+      cactus_tertiary:
+        url: {CACTUS_TERTIARY}
+      coverage_trace_plugin:
+        url: {COVERAGE_TRACE_PLUGIN}
+      dtb:
+        url: {DTB}
+      el3_payload:
+        url: {EL3_PAYLOAD}
+      fvp_spmc_manifest_dtb:
+        url: {FVP_SPMC_MANIFEST_DTB}
+      fip:
+        url: {FIP}
+      fip_gpt:
+        url: {FIP_GPT}
+      fwu_fip:
+        url: {FWU_FIP}
+      generic_trace:
+        url: {GENERIC_TRACE}
+      hafnium:
+        url: {HAFNIUM}
+      image:
+        url: {IMAGE}
+      ivy:
+        url: {IVY}
+      manifest_dtb:
+        url: {MANIFEST_DTB}
+      mcp_rom:
+        url: {MCP_ROM}
+      mcp_rom_hyphen:
+        url: {MCP_ROM_HYPHEN}
+      ns_bl1u:
+        url: {NS_BL1U}
+      ns_bl2u:
+        url: {NS_BL2U}
+      ramdisk:
+        url: {RAMDISK}
+      romlib:
+        url: {ROMLIB}
+      rootfs:
+        url: {ROOTFS}
+        compression: gz
+      secure_hafnium:
+        url: {SECURE_HAFNIUM}
+      scp_ram:
+        url: {SCP_RAM}
+      scp_ram_hyphen:
+        url: {SCP_RAM_HYPHEN}
+      scp_rom:
+        url: {SCP_ROM}
+      scp_rom_hyphen:
+        url: {SCP_ROM_HYPHEN}
+      spm:
+        url: {SPM}
+      tftf:
+        url: {TFTF}
+      tmp:
+        url: {TMP}
+      uboot:
+        url: {UBOOT}
+
+- boot:
+    method: fvp
+    license_variable: ARMLMD_LICENSE_FILE={ARMLMD_LICENSE_FILE}
+    docker:
+      name: {BOOT_DOCKER_NAME}
+      local: true
+    image: {BOOT_IMAGE_DIR}/{BOOT_IMAGE_BIN}
+    version_string: {BOOT_VERSION_STRING}
+    console_string: 'terminal_0: Listening for serial connection on port (?P<PORT>\d+)'
+    feedbacks:
+      - '(?P<NAME>terminal_1): Listening for serial connection on port (?P<PORT>\d+)'
+      - '(?P<NAME>terminal_2): Listening for serial connection on port (?P<PORT>\d+)'
+      - '(?P<NAME>terminal_3): Listening for serial connection on port (?P<PORT>\d+)'
+    arguments:
+{BOOT_ARGUMENTS}
diff --git a/script/lava-templates/juno-linux-reboot.yaml b/script/lava-templates/juno-linux-reboot.yaml
new file mode 100644
index 0000000..0541ef5
--- /dev/null
+++ b/script/lava-templates/juno-linux-reboot.yaml
@@ -0,0 +1,87 @@
+device_type: juno
+job_name: tf-juno
+
+context:
+  bootloader_prompt: $bootloader_prompt
+
+$tags
+$juno_revision
+
+timeouts:
+  # Global timeout value for the whole job.
+  job:
+    minutes: 30
+  # Unless explicitly overridden, no single action should take more than
+  # 10 minutes to complete.
+  action:
+    minutes: 10
+
+priority: medium
+visibility: public
+
+actions:
+
+- deploy:
+    namespace: recovery
+    to: vemsd
+    recovery_image:
+      url: $recovery_img_url
+      compression: zip
+
+- deploy:
+    namespace: target
+    to: nfs
+    os: $os
+    nfsrootfs:
+      url: $nfs_rootfs
+      compression: gz
+
+- boot:
+    # Drastically increase the timeout for the boot action because of the udev
+    # issues when using TF build config "juno-all-cpu-reset-ops".
+    # TODO: Should increase the timeout only for this TF build config, not all!
+    timeout:
+      minutes: 15
+    namespace: target
+    connection-namespace: recovery
+    method: u-boot
+    commands: norflash
+    auto-login:
+      login_prompt: 'login:'
+      username: root
+    prompts:
+    - $linux_prompt
+
+- test:
+    namespace: target
+    timeout:
+      minutes: 10
+    definitions:
+    - repository:
+        metadata:
+          format: Lava-Test Test Definition 1.0
+          name: container-test-run
+          description: '"Prepare system..."'
+          os:
+          - $os
+          scope:
+          - functional
+        run:
+          steps:
+          - echo "Rebooting..."
+      from: inline
+      name: target-configure
+      path: inline/target-configure.yaml
+
+- boot:
+    timeout:
+      minutes: 15
+    namespace: target
+    connection-namespace: recovery
+    method: u-boot
+    commands: norflash
+    auto-login:
+      login_prompt: 'login:'
+      username: root
+    prompts:
+    - $linux_prompt
diff --git a/script/lava-templates/juno-linux.yaml b/script/lava-templates/juno-linux.yaml
new file mode 100644
index 0000000..8b4e449
--- /dev/null
+++ b/script/lava-templates/juno-linux.yaml
@@ -0,0 +1,53 @@
+device_type: juno
+job_name: tf-juno
+
+context:
+  bootloader_prompt: $bootloader_prompt
+
+$tags
+$juno_revision
+
+timeouts:
+  # Global timeout value for the whole job.
+  job:
+    minutes: 30
+  # Unless explicitly overwritten, no single action should take more than
+  # 10 minutes to complete.
+  action:
+    minutes: 10
+
+priority: medium
+visibility: public
+
+actions:
+
+- deploy:
+    namespace: recovery
+    to: vemsd
+    recovery_image:
+      url: $recovery_img_url
+      compression: zip
+
+- deploy:
+    namespace: target
+    to: nfs
+    os: debian
+    nfsrootfs:
+      url: $nfs_rootfs
+      compression: gz
+
+- boot:
+    # Drastically increase the timeout for the boot action because of the udev
+    # issues when using TF build config "juno-all-cpu-reset-ops".
+    # TODO: Should increase the timeout only for this TF build config, not all!
+    timeout:
+      minutes: 15
+    namespace: target
+    connection-namespace: recovery
+    method: u-boot
+    commands: norflash
+    auto-login:
+      login_prompt: 'login:'
+      username: root
+    prompts:
+    - $linux_prompt
diff --git a/script/lava-templates/juno-scp-tests-scmi.yaml b/script/lava-templates/juno-scp-tests-scmi.yaml
new file mode 100644
index 0000000..f625dd3
--- /dev/null
+++ b/script/lava-templates/juno-scp-tests-scmi.yaml
@@ -0,0 +1,52 @@
+device_type: juno
+job_name: scp-tests-scmi-juno
+
+$tags
+$juno_revision
+
+timeouts:
+  # Global timeout value for the whole job.
+  job:
+    minutes: 10
+  actions:
+    lava-test-monitor:
+      seconds: 180
+  connections:
+    lava-test-monitor:
+      seconds: 180
+
+priority: medium
+visibility: public
+
+actions:
+
+- deploy:
+    timeout:
+      minutes: 5
+    to: vemsd
+    recovery_image:
+      url: $recovery_img_url
+      compression: zip
+
+- boot:
+    method: minimal
+
+- test:
+    timeout:
+      minutes: 8
+
+    monitors:
+    #
+    # Monitor no.1
+    # Monitor the results from all the protocols
+    #
+    - name: SCP-SCMI-ALL-PROTOCOL
+      start: 'BL31: Baremetal test suite: scmi'
+      end: '\*\*\*\* SCMI tests complete \*\*\*\*'
+
+      pattern: '(?P<test_case_id>\d{3}):[\w ]+[\w\n\r[\] :<>&=]*?: (?P<result>CONFORMANT|NON CONFORMANT|SKIPPED)'
+
+      fixupdict:
+        "CONFORMANT": pass
+        "NON CONFORMANT": fail
+        "SKIPPED": skip
diff --git a/script/lava-templates/juno-tftf.yaml b/script/lava-templates/juno-tftf.yaml
new file mode 100644
index 0000000..bb9f1eb
--- /dev/null
+++ b/script/lava-templates/juno-tftf.yaml
@@ -0,0 +1,55 @@
+device_type: juno
+job_name: tf-juno
+
+$tags
+$juno_revision
+
+timeouts:
+  # Global timeout value for the whole job.
+  job:
+    minutes: 45
+  actions:
+    lava-test-monitor:
+      seconds: 120
+  connections:
+    lava-test-monitor:
+      seconds: 120
+
+priority: medium
+visibility: public
+
+actions:
+
+- deploy:
+    timeout:
+      minutes: 10
+    to: vemsd
+    recovery_image:
+      url: $recovery_img_url
+      compression: zip
+
+- boot:
+    method: minimal
+
+- test:
+    # Timeout for all the TFTF tests to complete.
+    timeout:
+      minutes: 30
+
+    monitors:
+    - name: TFTF
+      # LAVA looks for a testsuite start string...
+      start: 'Booting trusted firmware test framework'
+      # ...and a testsuite end string.
+      end: 'Exiting tests.'
+
+      # For each test case, LAVA looks for a string which includes the testcase
+      # name and result.
+      pattern: "(?s)> Executing '(?P<test_case_id>.+?(?='))'(.*)  TEST COMPLETE\\\s+(?P<result>(Skipped|Passed|Failed|Crashed))"
+
+      # Teach to LAVA how to interpret the TFTF Tests results.
+      fixupdict:
+        Passed: pass
+        Failed: fail
+        Crashed: fail
+        Skipped: skip
diff --git a/script/lava-templates/n1sdp-linux.yaml b/script/lava-templates/n1sdp-linux.yaml
new file mode 100644
index 0000000..0903064
--- /dev/null
+++ b/script/lava-templates/n1sdp-linux.yaml
@@ -0,0 +1,178 @@
+device_type: n1sdp
+job_name: tf-n1sdp
+timeouts:
+  job:
+    minutes: 30
+
+priority: medium
+visibility: public
+context:
+  extra_nfsroot_args: ',vers=3'
+  extra_kernel_args: rootwait
+actions:
+#
+# Any firmware bundle deployed must be configured to boot automatically without
+# intervention. This means "PMIC_FORCE" must be set "TRUE" in the config file
+# to be deployed.
+#
+#
+# Deploy a firmware bundle with the customised "uefi.bin" installed. This
+# enables an EFI network driver, allowing us to force a TFTP boot from GRUB (assuming cobbler is setup)
+#
+- deploy:
+    namespace: recovery
+    to: flasher
+    images:
+      recovery_image:
+        url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/n1sdp-board-firmware-force-netboot.zip
+        compression: zip
+
+- deploy:
+    namespace: debian
+    to: tftp
+    os: debian
+    kernel:
+      url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/debian/linux
+      type: image
+    ramdisk:
+      url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/debian/ramdisk.img
+    nfsrootfs:
+      url: http://files.oss.arm.com/downloads/lava/health-checks/n1sdp/4/debian/debian-buster-arm64-rootfs.tar.xz
+      compression: xz
+
+- boot:
+    namespace: recovery
+    timeout:
+      minutes: 3
+    method: minimal
+    parameters:
+      kernel-start-message: ''
+    prompts: ['Cmd>']
+
+- boot:
+    namespace: uart1
+    method: new_connection
+    connection: uart1
+
+- boot:
+    namespace: debian
+    connection-namespace: uart1
+    timeout:
+      minutes: 5
+    method: grub
+    commands: nfs
+    prompts:
+      - '/ # '
+
+- test:
+    namespace: debian
+    timeout:
+      minutes: 5
+    definitions:
+      - repository:
+          metadata:
+            format: Lava-Test Test Definition 1.0
+            name: device-network
+            description: '"Test device network connection"'
+            os:
+              - debian
+            scope:
+              - functional
+          run:
+            steps:
+              - apt -q update
+              - apt -q install -y iputils-ping
+              - ping -c 5 www.arm.com || lava-test-raise "Device failed to reach a remote host"
+              - hostname -I
+        from: inline
+        name: device-network
+        path: inline/device-network.yaml
+
+- test:
+    namespace: debian
+    timeout:
+      minutes: 5
+    definitions:
+      - repository:
+          metadata:
+            format: Lava-Test Test Definition 1.0
+            name: install-dependancies
+            description: '"Install dependancies for secondary media deployment"'
+            os:
+              - debian
+            scope:
+              - functional
+          run:
+            steps:
+              - apt-get update -q
+              - apt-get install -qy wget
+        from: inline
+        name: install-dependancies
+        path: inline/install-dependancies.yaml
+
+- deploy:
+    namespace: secondary_media
+    connection-namespace: uart1
+    timeout:
+      minutes: 10
+    to: usb
+    os: busybox
+    images:
+      image:
+        url: "$n1sdp_prebuilts/busybox.img"
+    uniquify: false
+    device: usb_storage_device
+    download:
+      tool: /usr/bin/wget
+      prompt: HTTP request sent, awaiting response
+      options: --no-check-certificate --no-proxy --connect-timeout=30 -S --progress=dot:giga -O - {DOWNLOAD_URL}
+
+#
+# Deploy the primary board firmware bundle (this time without the additinal
+# network driver).
+#
+- deploy:
+    namespace: recovery
+    to: flasher
+    images:
+      recovery_image:
+        url: $recovery_img_url
+        compression: zip
+
+#
+# Do not verify the flash second time around as cached serial output on the
+# connection will immediately match the prompt.
+#
+- boot:
+    namespace: secondary_media
+    timeout:
+      minutes: 10
+    method: minimal
+    prompts:
+      - '/ #'
+    transfer_overlay:
+      download_command: wget -S
+      unpack_command: tar -C / -xzf
+
+- test:
+    namespace: secondary_media
+    timeout:
+      minutes: 5
+    definitions:
+      - repository:
+          metadata:
+            format: Lava-Test Test Definition 1.0
+            name: linux-console-test-in-deployed-image
+            description: '"Run LAVA test steps inside the deployed image"'
+            os:
+              - oe
+            scope:
+              - functional
+          run:
+            steps:
+              - fdisk -l
+              - ip addr show
+              - cat /proc/cpuinfo
+        from: inline
+        name: linux-console-test
+        path: inline/linux-console-test.yaml