dm36x: Add full run of automated test suite via UART + expect. All tests pass on DM36x!

This commit is contained in:
Kelvin Lawson
2013-09-17 23:33:18 +01:00
parent 4e6e30dcb3
commit e0c4cba602
2 changed files with 70 additions and 0 deletions

View File

@@ -4,6 +4,9 @@
# Build all test applications:
# make
#
# Run all tests communicating via UART
# make tests
# Location of build tools and atomthreads sources
KERNEL_DIR=../../../../kernel
@@ -12,6 +15,15 @@ PORT_DIR=../..
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
# Location of TFTP root folder for running tests via U-Boot/TFTP.
# Note, you may need to run the Makefile as root in order to write
# to this folder.
TESTS_TFTPROOT=/var/lib/tftpboot
# TTY device and baudrate for automated tests.
TESTS_TTYDEV=/dev/ttyUSB0
TESTS_TTYBAUD=115200
# Enable stack-checking.
#STACK_CHECK=true
@@ -128,3 +140,11 @@ doxygen:
doxygen ../../Doxyfile
doxygen ./Doxyfile
# Run tests on target with expect and serial output
phony_test_bins = $(addsuffix .sim, $(TEST_BINS))
tests: $(phony_test_bins)
.PHONY: tests $(phony_test_bins)
$(phony_test_bins):
cp $(BUILD_DIR)/$(basename $@) $(TESTS_TFTPROOT)/test.bin
@echo Running test $(basename $@)
./run_test.exp $(TESTS_TTYDEV) $(TESTS_TTYBAUD)

View File

@@ -0,0 +1,50 @@
#!/usr/bin/env expect
# Expect script to check an automated test's results via a serial port
# and check for successful completion.
#
# You are expected to set the target's U-boot up to automatically load
# the app on your TFTP server called "test.bin". Before this script is
# started the Makefile should have copied the next test binary to the
# file "test.bin" in your TFTP root folder. The user must sit and
# hit the reset button after every test completion in order to make
# the board load and run the next test.bin file.
#
# Arguments: <serial_port_device> <baudrate> <test_bin_file>
#
# Returns 0 on successful test run, 1 on failure
# Set the serial port baudrate
stty [lindex $argv 1] < [lindex $argv 0]
# Start the test
spawn cat [lindex $argv 0]
puts "Ready: reset the target!"
# Expect to see the test starting within 60 seconds (give long enough
# for user to reset the board after running the last test).
set timeout 60
# Wait for the test to start ("Go")
expect {
"Go\r" {
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\r" { puts "Test passed"; exit 0 }
"Fail\r" { 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
}
}