Added funtionality to run an automated test of all testsuite applications

directly from the build system on the qemu "board".
This commit is contained in:
Tido Klaassen
2015-07-15 18:24:27 +02:00
parent 00a339e3fe
commit f6ee11c088
3 changed files with 66 additions and 4 deletions

View File

@@ -12,4 +12,16 @@ OOCD_INTERFACE ?= stlink-v2-1
OOCD_BOARD ?= st_nucleo_f103rb
objs += board_setup.o
# aobjs += helloworld.o
# aobjs += helloworld.o
# Special requirements for running automated tests with QEMU
QEMU ?= qemu-system-gnuarmeclipse
.DEFAULT_GOAL := all
.SECONDEXPANSION:
.PHONY: qemutests
qemutests: $$(addsuffix .sim, $$(sort $$(build_telfs)))
%.sim: $$(basename $$@)
boards/qemu/run_test.exp $(QEMU) $(*)

View File

@@ -15,7 +15,17 @@ a usable target.
After installing you can use it to run the test binaries like this:
```
qemu-system-gnuarmeclipse -nographic -monitor null -serial stdio \
-semihosting --semihosting-config target=native \
--machine NUCLEO-F103RB --kernel build/kern1.elf --verbose
qemu-system-gnuarmeclipse -nographic -monitor null \
-semihosting --machine NUCLEO-F103RB \
--verbose --kernel build/kern1.elf
```
The whole test suite can be run in an automatic way from the build system by
using the tool `expect`.
```
make BOARD=qemu QEMU=/path/to/your/qemu/binary qemutests
```
If your qemu-binary is called `qemu-system-gnuarmeclipse` and is located
in your search path, you can omit the `QEMU=...` part.

View File

@@ -0,0 +1,40 @@
#!/usr/bin/env expect
# Expect script to run an automated test within the simulator (QEMU) and
# check for successful completion.
#
# Arguments: <path_to_qemu> <test_elf_file>
#
# Returns 0 on successful test run within QEMU, 1 on failure
# Start the test
spawn [lindex $argv 0] -nographic -monitor null -semihosting \
--machine NUCLEO-F103RB --kernel [lindex $argv 1]
# Expect to see the test starting within 10 seconds
set timeout 10
# Wait for the test to start ("Go")
expect {
"Go" {
puts "Test started"
# The test could take up to 3 minutes to complete once started
set timeout 180
# Now expect to see "Pass" or "Fail" within 3 minutes
expect {
"Pass" { puts "Test passed"; exit 0 }
"Fail" { puts "Test failed"; exit 1 }
timeout { puts "Test timed out without completing"; exit 1 }
}
}
timeout {
# Didn't receive "Go" within 10 seconds
puts "Test failed to start ('Go' not seen)"
exit 1
}
}