qemu: add linux boot tests

Add some basic boot tests for QEMU and supporting scripts to automate
the generation of dependencies. Currently, there are no tests in CI that
utilise the platform. This makes it easier to do testing in CI without
the need for a complex hardware setup.

Change-Id: I98e43ecc56dc44a767590c73963ded7b2cee1cff
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
diff --git a/script/lava-templates/qemu-linux.yaml b/script/lava-templates/qemu-linux.yaml
new file mode 100644
index 0000000..814b20e
--- /dev/null
+++ b/script/lava-templates/qemu-linux.yaml
@@ -0,0 +1,85 @@
+device_type: qemu
+job_name: qemu-linux-${test_config}
+priority: medium
+visibility: public
+
+metadata:
+  test_config: ${test_config}
+  build_url: ${BUILD_URL}
+  emulator: ${model}
+
+$(if [ -n "${gerrit_url}" ]; then
+	cat <<-YAML
+  gerrit_url: "${gerrit_url}"
+	YAML
+fi)
+
+context:
+  arch: aarch64
+  machine: ${machine:-virt}
+  cpu: ${cpu:-max}
+  extra_options:
+$(for boot_argument in "${boot_arguments[@]:?}"; do
+	cat <<-YAML
+	    - ${boot_argument}
+	YAML
+done)
+
+timeouts:
+  job:
+    minutes: 15
+  actions:
+      login-action:
+        minutes: 5
+      auto-login-action:
+        minutes: 2
+      boot-image-retry:
+        minutes: 2
+      boot-qemu-image:
+        minutes: 2
+      bootloader-action:
+        minutes: 3
+      bootloader-commands:
+        minutes: 3
+      bootloader-interrupt:
+        seconds: 30
+      bootloader-retry:
+        minutes: 3
+      download-retry:
+        minutes: 5
+      lava-test-shell:
+        minutes: 3
+      nfs-deploy:
+        minutes: 10
+      power-off:
+        seconds: 10
+      reset-device:
+        seconds: 30
+  connection:
+    minutes: 2
+
+actions:
+- deploy:
+    to: tmpfs
+    images:
+$(for artefact in "${artefacts[@]:?}"; do
+	cat <<-YAML
+      ${artefact:?}:
+        url: ${artefact_urls[${artefact}]:?}
+	YAML
+
+	[[ "${artefact:?}" =~ ^(kernel|bios|initrd)$ ]] && cat <<-YAML
+        image_arg: -${artefact} {${artefact}}
+	YAML
+
+	[[ "${artefact:?}" =~ ^(busybox|initrd)$ ]] && cat <<-YAML
+        compression: gz
+	YAML
+done)
+
+- boot:
+    method: qemu
+    media: tmpfs
+    prompts: ["${prompt}"]
+    timeout:
+      minutes: 2
diff --git a/script/run_local_ci.sh b/script/run_local_ci.sh
index fd71153..a909c14 100755
--- a/script/run_local_ci.sh
+++ b/script/run_local_ci.sh
@@ -130,8 +130,8 @@
 			;;
 
 		"run")
-			# Local runs for FVP or arm_fpga unless asked not to
-			if echo "$RUN_CONFIG" | grep -q "^fvp" && \
+			# Local runs for FVP, QEMU, or arm_fpga unless asked not to
+			if echo "$RUN_CONFIG" | grep -q "^\(fvp\|qemu\)" && \
 					not_upon "$skip_runs"; then
 				echo "running: $config_string" >&5
 				if [ -n "$cc_enable" ]; then