From 92913ab478bee317ae067571b246e37133ad0b80 Mon Sep 17 00:00:00 2001 From: Toby Jaffey Date: Sat, 13 Dec 2025 18:02:43 +0000 Subject: [PATCH] Add test for reading code which is too large --- test/Makefile | 3 ++- test/badcode/Makefile | 2 ++ test/badcode/rom/Makefile | 2 ++ test/badcode/rom/rom.c | 7 +++++++ test/badcode/test/tests.c | 23 +++++++++++++++++++++++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 test/badcode/Makefile create mode 100644 test/badcode/rom/Makefile create mode 100644 test/badcode/rom/rom.c create mode 100644 test/badcode/test/tests.c diff --git a/test/Makefile b/test/Makefile index 4e16274..983a645 100644 --- a/test/Makefile +++ b/test/Makefile @@ -4,7 +4,8 @@ TESTS = \ custom_syscall \ syscall_args \ meter \ - extram + extram \ + badcode RUNCMD = $(foreach TEST,${TESTS},make -C ${TEST} &&) CLEANCMD = $(foreach TEST,${TESTS},make -C ${TEST} clean &&) diff --git a/test/badcode/Makefile b/test/badcode/Makefile new file mode 100644 index 0000000..dc44dd1 --- /dev/null +++ b/test/badcode/Makefile @@ -0,0 +1,2 @@ +TOPDIR=../.. +include ${TOPDIR}/test/common/makefile.common diff --git a/test/badcode/rom/Makefile b/test/badcode/rom/Makefile new file mode 100644 index 0000000..4cd3f50 --- /dev/null +++ b/test/badcode/rom/Makefile @@ -0,0 +1,2 @@ +TOPDIR=../../.. +include ${TOPDIR}/test/common/makefile-rom.common diff --git a/test/badcode/rom/rom.c b/test/badcode/rom/rom.c new file mode 100644 index 0000000..f8416d7 --- /dev/null +++ b/test/badcode/rom/rom.c @@ -0,0 +1,7 @@ +#include "uvm32_target.h" + +void main(void) { + void *p = NULL; + println(p); +} + diff --git a/test/badcode/test/tests.c b/test/badcode/test/tests.c new file mode 100644 index 0000000..05e51c7 --- /dev/null +++ b/test/badcode/test/tests.c @@ -0,0 +1,23 @@ +#include +#include "unity.h" +#include "uvm32.h" +#include "../common/uvm32_common_custom.h" + +#include "rom-header.h" + +static uvm32_state_t vmst; +//static uvm32_evt_t evt; + +void setUp(void) { +} + +void tearDown(void) { +} + +void test_giant_rom(void) { + // try to load a ROM bigger than we have space for + uvm32_init(&vmst); + TEST_ASSERT_EQUAL(false, uvm32_load(&vmst, rom_bin, UVM32_MEMORY_SIZE+1)); // if it reads off end of rom_bin, will crash +} + +