diff --git a/ports/arm/platforms/qemu_integratorcp/Makefile b/ports/arm/platforms/qemu_integratorcp/Makefile index dd76588..077317e 100644 --- a/ports/arm/platforms/qemu_integratorcp/Makefile +++ b/ports/arm/platforms/qemu_integratorcp/Makefile @@ -11,6 +11,7 @@ TESTS_DIR=../../../../tests PORT_DIR=../.. CC=arm-none-eabi-gcc OBJCOPY=arm-none-eabi-objcopy +QEMU=qemu-system-arm # Enable stack-checking. #STACK_CHECK=true @@ -114,3 +115,10 @@ clean: doxygen: doxygen $(KERNEL_DIR)/Doxyfile doxygen ./Doxyfile + +# Run tests within simavr simulator +phony_qemu_elfs = $(addsuffix .sim, $(TEST_ELFS)) +qemutests: $(phony_qemu_elfs) +.PHONY: qemutests $(phony_qemu_elfs) +$(phony_qemu_elfs): + ./run_test.exp $(QEMU) $(BUILD_DIR)/$(basename $@) diff --git a/ports/arm/platforms/qemu_integratorcp/run_test.exp b/ports/arm/platforms/qemu_integratorcp/run_test.exp new file mode 100755 index 0000000..73c68bc --- /dev/null +++ b/ports/arm/platforms/qemu_integratorcp/run_test.exp @@ -0,0 +1,39 @@ +#!/usr/bin/env expect + +# Expect script to run an automated test within QEMU and check for successful +# completion. +# +# Arguments: +# +# Returns 0 on successful test run within QEMU, 1 on failure + + +# Start the test +spawn [lindex $argv 0] -M integratorcp -semihosting -nographic -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 + } +} +