X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=tests%2FMakefile;h=7bc3d34a40f9d561fc619d508d0b5b6a2d765b6b;hb=27bab459856ad7e06c5c9801722628e77a03e33c;hp=ff2ede5f4d0da2d8c765291114ac66f592e0770e;hpb=d8e5774323d5408e119b5fa3cce1c73c7345e8f7;p=simavr diff --git a/tests/Makefile b/tests/Makefile index ff2ede5..7bc3d34 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,15 +1,9 @@ # -# This makefile take each "at*" file, extracts it's part name -# And compile it into an ELF binary. -# It also disassemble it for debugging purposes. +# This makefile takes each "at*" file, extracts it's part name +# And compiles it into an ELF binary. +# It also disassembles it for debugging purposes. # -# The code is compiled "optimized" to the max. -# -# The wierd "-Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000" -# is used to tell the linker not to discard the .mmcu section, -# otherwise the --gc-sections will delete it. -# -# Copyright 2008, 2009 Michel Pollet +# Copyright 2008-2012 Michel Pollet # # This file is part of simavr. # @@ -27,28 +21,43 @@ # along with simavr. If not, see . sources := $(wildcard at*.c) +simavr = .. + +IPATH += ${simavr}/include +IPATH += ${simavr}/simavr/sim + +tests_src = ${wildcard test_*.c} +tests = ${patsubst %.c, ${OBJ}/%.tst, ${tests_src}} + +all: obj axf tests + +include ../Makefile.common + +tests: ${tests} + +axf: ${sources:.c=.axf} + + +${OBJ}/%.tst: tests.c %.c +ifeq ($(V),1) + $(CC) -MMD ${CPPFLAGS} ${CFLAGS} ${LFLAGS} -o $@ ${patsubst %.h,, ${^}} $(LDFLAGS) +else + @echo TST $@ + @$(CC) -MMD ${CPPFLAGS} ${CFLAGS} ${LFLAGS} -o $@ ${patsubst %.h,, ${^}} $(LDFLAGS) +endif + +run_tests: all + @export LD_LIBRARY_PATH=${simavr}/simavr/${OBJ} ;\ + num_failed=0 ;\ + num_run=0 ;\ + for test in ${OBJ}/test_*.tst; do \ + num_run=$$(($$num_run+1)) ;\ + if ! $$test; then \ + echo "$$test returned with exit value $$?." ;\ + num_failed=$$(($$num_failed+1)) ;\ + fi ;\ + done ;\ + echo "Tests run: $$num_run Successes: $$(($$num_run-$num_failed)) Failures: $$num_failed" -all : ${sources:.c=.axf} ${sources:.c=.hex} ${sources:.c=.s} - -%.hex: %.axf - @avr-objcopy -j .text -j .data -O ihex ${<} ${@} - -%.s: %.axf - @avr-objdump -j .text -j .data -j .bss -d ${<} > ${@} - -%.axf: %.c - @echo CC ${<} - @part=${<} ; part=$${part/_*}; \ - avr-gcc -Wall -g -Os -std=gnu99 \ - -mmcu=$$part \ - -DF_CPU=8000000 \ - -mcall-prologues -fno-inline-small-functions \ - -ffunction-sections -fdata-sections \ - -Wl,--relax,--gc-sections \ - -Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000 \ - -I../include \ - ${<} -o ${@} - @avr-size ${@}|sed '1d' - -clean: - rm -f *.hex *.o *.axf *.s +clean: clean-${OBJ} + rm -f *.axf