diff --git a/tests/cortexm_common_ldscript/Makefile b/tests/cortexm_common_ldscript/Makefile index 337462fdea5c8553ef209299935b29671ec88c01..4db91761d16b59201f9372bd869b0b4805f4c6a7 100644 --- a/tests/cortexm_common_ldscript/Makefile +++ b/tests/cortexm_common_ldscript/Makefile @@ -25,7 +25,7 @@ include $(RIOTBASE)/Makefile.include # # # # # # # # # # # # # # # # # # # # # # # # # # # # COMPILE_TESTS = test-elffile-overflow test-elffile-fw_rom_length -COMPILE_TESTS += tests-offsets tests-fw_rom_len +COMPILE_TESTS += tests-offsets tests-fw_rom_len tests-rom-overflow all: compile-tests @@ -121,3 +121,24 @@ $(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf: FW_ROM_LEN=$$(($(ROM_LEN_BYTES)/2) $(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf: $(ELFFILES_DEPS) $(Q)$(_LINK) -o $@ .PRECIOUS: $(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf + + +# Test FW_ROM_LEN overflow detection + +OVERFLOW_TESTS = too_big_for_rom offset_and_romlen +tests-rom-overflow: $(OVERFLOW_TESTS:%=test-assert_overflow_%) + + +# Simple FW_ROM_LEN overflow +test-assert_overflow_too_big_for_rom: FW_ROM_LEN=$$(($(ROM_LEN_BYTES) + 1)) + +# ROM_OFFSET and FW_ROM_LEN set ROM_LEN +test-assert_overflow_offset_and_romlen: ROM_OFFSET=0x1000 +test-assert_overflow_offset_and_romlen: FW_ROM_LEN=$(ROM_LEN_BYTES) + +.PHONY: test-assert_overflow_% +test-assert_overflow_%: $(ELFFILES_DEPS) + $(Q) echo -n "Test ROM overflow detection ($*): " + $(Q)\ + { $(_LINK) -o /dev/null 2>&1 | grep -q 'Specified firmware size does not fit in ROM' ; } \ + && echo [OK] || { echo [ERROR] Compilation should have failed >&2; exit 1; }