summaryrefslogtreecommitdiff
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>2015-03-09 16:01:02 +0000
commitcc9e493c08c3d01f162a5bb085f80fc35a5d2f85 (patch)
treea0e10e649a9bd1312adadea02be53ab0216d7b92
parent09ba01ff4589bbdbeceb712ab7a24c1b2c61d33b (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's 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
-rw-r--r--ubuntu/qemu-system-test.yaml38
-rwxr-xr-xubuntu/scripts/qemu-boot.expect29
-rwxr-xr-xubuntu/scripts/qemu-stress.expect38
-rwxr-xr-xubuntu/scripts/qemu-system-tests.sh26
4 files changed, 131 insertions, 0 deletions
diff --git a/ubuntu/qemu-system-test.yaml b/ubuntu/qemu-system-test.yaml
new file mode 100644
index 0000000..43a7225
--- /dev/null
+++ b/ubuntu/qemu-system-test.yaml
@@ -0,0 +1,38 @@
+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_ARGS: -machine virt -cpu cortex-a57 -machine type=virt -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_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..e0b1615
--- /dev/null
+++ b/ubuntu/scripts/qemu-system-tests.sh
@@ -0,0 +1,26 @@
+#!/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
+# 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%.*}
+
+for test in $@; do
+ lava-test-case qemu-${test}-${IMAGE_NAME} --shell ${BASE}/qemu-${test}.expect ${QEMU_BIN} ${QEMU_ARGS} -kernel /home/image -append "${KERNEL_ARGS}"
+done
+