summaryrefslogtreecommitdiff
path: root/ubuntu
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2014-04-10 11:39:38 +0100
committerAlex Bennée <alex.bennee@linaro.org>2017-07-24 12:38:53 +0100
commit8db3a012ea1afe89a81a68cb18cb7bcafd194142 (patch)
tree37051880d936690a7a3707c6a2477f02651f327d /ubuntu
parent639348834f14ff689ad32ecbb21011eace4e2b6d (diff)
new: add qemu-system-test definition and expect scripts
As we need to send commands to the qemu console to shutdown cleanly and it is a pain to custom build a rootfs to just run a test we use an expect wrapper for controlling qemu. The whole thing is controlled by a wrapper so several TESTS can be run in one definition and the results kept together. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Change-Id: I82ae7305ce2cdd8d3cef05621f4e4eace7d35bb7 -- v2 - fix boot test message v3 - include the IMAGE name in the test result - add wget dep v4 - more updates
Diffstat (limited to 'ubuntu')
-rw-r--r--ubuntu/qemu-system-test.yaml39
-rwxr-xr-xubuntu/scripts/qemu-boot.expect29
-rwxr-xr-xubuntu/scripts/qemu-stress.expect38
-rwxr-xr-xubuntu/scripts/qemu-system-tests.sh31
4 files changed, 137 insertions, 0 deletions
diff --git a/ubuntu/qemu-system-test.yaml b/ubuntu/qemu-system-test.yaml
new file mode 100644
index 0000000..f2afedd
--- /dev/null
+++ b/ubuntu/qemu-system-test.yaml
@@ -0,0 +1,39 @@
+metadata:
+ name: qemu-system-test
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "Setup and run a test on QEMU System Image"
+ maintainer:
+ - alex.bennee@linaro.org
+ os:
+ - ubuntu
+ scope:
+ - functional
+ devices:
+ - kvm
+
+params:
+ # This is a combined image and initrd/rootfs that qemu can boot
+ IMAGE: http://people.linaro.org/~alex.bennee/images/aarch64-linux-buildroot.img
+ # List of tests to run
+ TESTS: boot
+ # The QEMU executable
+ QEMU_BIN: /usr/local/bin/qemu-system-aarch64
+ # The QEMU machine definitions
+ QEMU_MACHINE: virt
+ QEMU_ARGS: -cpu cortex-a57 -nographic -smp 1 -m 396
+ # The arguments passed to the kernel
+ KERNEL_ARGS: console=ttyAMA0
+
+install:
+ steps:
+ - cd /home
+ - wget -O image ${IMAGE}
+
+ deps:
+ - wget
+ - expect
+
+run:
+ steps:
+ - export QEMU_BIN QEMU_MACHINE QEMU_ARGS KERNEL_ARGS IMAGE
+ - ubuntu/scripts/qemu-system-tests.sh ${TESTS}
diff --git a/ubuntu/scripts/qemu-boot.expect b/ubuntu/scripts/qemu-boot.expect
new file mode 100755
index 0000000..ad8cb13
--- /dev/null
+++ b/ubuntu/scripts/qemu-boot.expect
@@ -0,0 +1,29 @@
+#!/usr/bin/expect --
+#
+# Run qemu-system and check we can boot and shutdown
+#
+
+if {[llength $argv] == 0} {
+ send_user "Usage: boot.expect <qemu invocation>\n"
+ exit 1
+}
+
+set timeout 20
+spawn {*}$argv
+expect {
+ "buildroot login: " { send -- "root\r" }
+ timeout { send "# boot failed"; exit 1 }
+}
+
+
+expect "# "
+send -- "uname -a\r"
+expect "# "
+set timeout 10
+send -- "halt -d 5\r"
+expect {
+ "reboot: System halted" { send -- "c"; expect "(qemu) "; send -- "quit\r" }
+ timeout { send "# shutdown failed"; exit 2 }
+}
+expect eof
+exit 0
diff --git a/ubuntu/scripts/qemu-stress.expect b/ubuntu/scripts/qemu-stress.expect
new file mode 100755
index 0000000..fdab3a2
--- /dev/null
+++ b/ubuntu/scripts/qemu-stress.expect
@@ -0,0 +1,38 @@
+#!/usr/bin/expect --
+#
+# Run qemu-system and spawn the stress benchmark
+#
+
+if {[llength $argv] == 0} {
+ send_user "Usage: stress.expect <qemu invocation>\n"
+ exit 1
+}
+
+set exit_status 0
+set timeout 20
+spawn {*}$argv
+expect "buildroot login: "
+send -- "root\r"
+expect "# "
+set timeout 40
+send -- "stress --cpu 4 --io 4 --vm 2 --vm-bytes 64M -d 2 --hdd-bytes 32M --timeout 30s\r"
+expect {
+ "successful run completed in *s" { expect "# "; send "# found success\n" }
+ timeout { send "# time waiting for stress to finish\n"; set exit_status 1 }
+}
+expect "# "
+set timeout 10
+send -- "echo \$?\r"
+expect {
+ "0\r\r" { send "# found success\n" }
+ "1\r\r" { send "# found failure\n"; set exit_status 2 }
+ timeout { send "# time out looking for result\n"; set exit_status 3 }
+}
+expect "# "
+send -- "halt -d 5\r"
+expect "reboot: System halted"
+send -- "c"
+expect "(qemu) "
+send -- "quit\r"
+expect eof
+exit $exit_status
diff --git a/ubuntu/scripts/qemu-system-tests.sh b/ubuntu/scripts/qemu-system-tests.sh
new file mode 100755
index 0000000..b681699
--- /dev/null
+++ b/ubuntu/scripts/qemu-system-tests.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# A simple wrapper to run a series of expect based system tests
+#
+# This expects the follow environment variables to be set:
+# QEMU_BIN - path to binary
+# QEMU_ARGS - arguments to run
+# QEMU_MACHINE - machine type
+# KERNEL_ARGS - arguments to kernel
+# IMAGE - URL to image
+#
+# It expects the system test image to be in /home/image
+#
+# The expect script that will control QEMU, prefix will be qemu- and suffix .expect
+#
+
+pushd `dirname $0` > /dev/null
+BASE=`pwd -P`
+popd > /dev/null
+
+IMAGE_FILE=${IMAGE##*/}
+IMAGE_NAME=${IMAGE_FILE%.*}
+
+: ${KERNEL_IMAGE}=/home/image
+
+for test in $@; do
+ lava-test-case qemu-${test}-${QEMU_MACHINE}-${IMAGE_NAME} \
+ --shell ${BASE}/qemu-${test}.expect ${QEMU_BIN} ${QEMU_ARGS} -machine type=${QEMU_MACHINE} \
+ -kernel ${KERNEL_IMAGE} -append "${KERNEL_ARGS}"
+done
+