mirror of
https://github.com/stnolting/neorv32.git
synced 2025-04-24 14:17:51 -04:00
[processor_check] add malloc/heap test
This commit is contained in:
parent
db2b492343
commit
e2f87b4658
3 changed files with 37 additions and 2 deletions
|
@ -158,7 +158,7 @@ begin
|
|||
if ci_mode then
|
||||
-- No need to send the full expectation in one big chunk
|
||||
check_uart(net, uart1_rx_handle, nul & nul);
|
||||
check_uart(net, uart1_rx_handle, "0/55" & cr & lf);
|
||||
check_uart(net, uart1_rx_handle, "0/56" & cr & lf);
|
||||
end if;
|
||||
|
||||
-- Wait until all expected data has been received
|
||||
|
|
|
@ -1688,6 +1688,41 @@ int main() {
|
|||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// Check dynamic memory allocation
|
||||
// ----------------------------------------------------------
|
||||
neorv32_cpu_csr_write(CSR_MCAUSE, mcause_never_c);
|
||||
PRINT_STANDARD("[%i] heap/malloc ", cnt_test);
|
||||
|
||||
tmp_a = (uint32_t)neorv32_heap_size_c;
|
||||
|
||||
if (tmp_a >= 3096) { // sufficient heap for this test?
|
||||
cnt_test++;
|
||||
|
||||
uint8_t *malloc_a = (uint8_t*)malloc(8 * sizeof(uint8_t));
|
||||
uint8_t *malloc_b = (uint8_t*)malloc(tmp_a * sizeof(uint8_t));
|
||||
free(malloc_b);
|
||||
uint8_t *malloc_c = (uint8_t*)malloc(8 * sizeof(uint8_t));
|
||||
free(malloc_c);
|
||||
free(malloc_a);
|
||||
|
||||
if ((((uint32_t)neorv32_heap_begin_c + tmp_a) == (uint32_t)neorv32_heap_end_c) && // correct heap layout
|
||||
(malloc_a != NULL) && // malloc successful
|
||||
(malloc_b == NULL) && // malloc failed due to exhausted heap
|
||||
(malloc_c != NULL) && // malloc successful
|
||||
(malloc_a != malloc_c) && // allocated different base addresses
|
||||
(neorv32_cpu_csr_read(CSR_MCAUSE) == mcause_never_c)) { // no exception
|
||||
test_ok();
|
||||
}
|
||||
else {
|
||||
test_fail();
|
||||
}
|
||||
}
|
||||
else {
|
||||
PRINT_STANDARD("[n.a.]\n");
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// Test WFI ("sleep") instruction (executed in user mode), wakeup via MTIME
|
||||
// mstatus.mie is cleared before to check if machine-mode IRQ still trigger in user-mode
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
override GHDL_RUN_FLAGS ?= --stop-time=15ms
|
||||
override EFFORT = -Os
|
||||
override MARCH = rv32ima_zba_zbb_zbs_zicsr_zifencei_zicond
|
||||
override USER_FLAGS += -flto
|
||||
override USER_FLAGS += -flto -Wl,--defsym,__neorv32_heap_size=3096
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue