From 8ecc0ac652f765e52ae7dce719580a03f058492e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= <gaetan.harter@fu-berlin.de> Date: Wed, 13 Jun 2018 18:03:29 +0200 Subject: [PATCH] cortexm_common_ldscript: add test for _fw_rom_length overflow Verify that specifying a too big _fw_rom_length for the rom is detected and prevent compilation. --- tests/cortexm_common_ldscript/Makefile | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/cortexm_common_ldscript/Makefile b/tests/cortexm_common_ldscript/Makefile index 337462fdea..4db91761d1 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; } -- GitLab