mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-16 00:18:11 -07:00
unit tests: test aligment by 8
This commit is contained in:
@@ -51,6 +51,11 @@ static void test_memmgr_malloc(const size_t allocation_size) {
|
||||
error_message = "malloc failed";
|
||||
}
|
||||
|
||||
// test that memory is aligned by 8 bytes
|
||||
if(((uintptr_t)ptr % 8) != 0) {
|
||||
error_message = "memory is not aligned by 8 bytes after malloc";
|
||||
}
|
||||
|
||||
// test that memory is zero-initialized after allocation
|
||||
for(size_t i = 0; i < allocation_size; i++) {
|
||||
if(ptr[i] != 0) {
|
||||
@@ -102,6 +107,11 @@ static void test_memmgr_realloc(const size_t allocation_size) {
|
||||
error_message = "realloc(NULL) failed";
|
||||
}
|
||||
|
||||
// test that memory is aligned by 8 bytes
|
||||
if(((uintptr_t)ptr % 8) != 0) {
|
||||
error_message = "memory is not aligned by 8 bytes after realloc";
|
||||
}
|
||||
|
||||
// test that memory is zero-initialized after allocation
|
||||
for(size_t i = 0; i < allocation_size; i++) {
|
||||
if(ptr[i] != 0) {
|
||||
@@ -127,6 +137,11 @@ static void test_memmgr_realloc(const size_t allocation_size) {
|
||||
}
|
||||
}
|
||||
|
||||
// test that memory is aligned by 8 bytes
|
||||
if(((uintptr_t)ptr % 8) != 0) {
|
||||
error_message = "memory is not aligned by 8 bytes after realloc";
|
||||
}
|
||||
|
||||
// test that remaining memory is zero-initialized
|
||||
size_t non_zero_count = 0;
|
||||
for(size_t i = allocation_size; i < allocation_size * 2; i++) {
|
||||
@@ -293,4 +308,18 @@ void test_furi_memmgr_advanced(void) {
|
||||
free(guards[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_furi_memmgr_aligned8(void) {
|
||||
const size_t repeat_count = 100;
|
||||
|
||||
for(size_t i = 0; i < repeat_count; i++) {
|
||||
uintptr_t ptr = (uintptr_t)malloc(10);
|
||||
mu_assert_int_eq(0, ptr % 8);
|
||||
ptr = (uintptr_t)realloc((void*)ptr, 20);
|
||||
mu_assert_int_eq(0, ptr % 8);
|
||||
ptr = (uintptr_t)realloc((void*)ptr, 30);
|
||||
mu_assert_int_eq(0, ptr % 8);
|
||||
free((void*)ptr);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ void test_furi_pubsub(void);
|
||||
|
||||
void test_furi_memmgr(void);
|
||||
void test_furi_memmgr_advanced(void);
|
||||
void test_furi_memmgr_aligned8(void);
|
||||
|
||||
static int foo = 0;
|
||||
|
||||
@@ -39,6 +40,7 @@ MU_TEST(mu_test_furi_memmgr) {
|
||||
// that memory management is working fine
|
||||
test_furi_memmgr();
|
||||
test_furi_memmgr_advanced();
|
||||
test_furi_memmgr_aligned8();
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(test_suite) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,63.0,,
|
||||
Version,+,64.0,,
|
||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
|
||||
@@ -593,9 +593,7 @@ Function,-,acosh,double,double
|
||||
Function,-,acoshf,float,float
|
||||
Function,-,acoshl,long double,long double
|
||||
Function,-,acosl,long double,long double
|
||||
Function,-,aligned_alloc,void*,"size_t, size_t"
|
||||
Function,+,aligned_free,void,void*
|
||||
Function,+,aligned_malloc,void*,"size_t, size_t"
|
||||
Function,+,aligned_alloc,void*,"size_t, size_t"
|
||||
Function,-,arc4random,__uint32_t,
|
||||
Function,-,arc4random_buf,void,"void*, size_t"
|
||||
Function,-,arc4random_uniform,__uint32_t,__uint32_t
|
||||
@@ -2412,7 +2410,8 @@ Function,+,memchr,void*,"const void*, int, size_t"
|
||||
Function,+,memcmp,int,"const void*, const void*, size_t"
|
||||
Function,+,memcpy,void*,"void*, const void*, size_t"
|
||||
Function,-,memmem,void*,"const void*, size_t, const void*, size_t"
|
||||
Function,-,memmgr_alloc_from_pool,void*,size_t
|
||||
Function,+,memmgr_aux_pool_alloc,void*,size_t
|
||||
Function,+,memmgr_aux_pool_get_free,size_t,
|
||||
Function,+,memmgr_get_free_heap,size_t,
|
||||
Function,+,memmgr_get_minimum_free_heap,size_t,
|
||||
Function,+,memmgr_get_total_heap,size_t,
|
||||
@@ -2420,8 +2419,7 @@ Function,+,memmgr_heap_disable_thread_trace,void,FuriThreadId
|
||||
Function,+,memmgr_heap_enable_thread_trace,void,FuriThreadId
|
||||
Function,+,memmgr_heap_get_max_free_block,size_t,
|
||||
Function,+,memmgr_heap_get_thread_memory,size_t,FuriThreadId
|
||||
Function,+,memmgr_heap_printf_free_blocks,void,
|
||||
Function,-,memmgr_pool_get_free,size_t,
|
||||
Function,+,memmgr_heap_walk_blocks,void,"BlockWalker, void*"
|
||||
Function,-,memmgr_pool_get_max_block,size_t,
|
||||
Function,+,memmove,void*,"void*, const void*, size_t"
|
||||
Function,-,mempcpy,void*,"void*, const void*, size_t"
|
||||
|
||||
|
Reference in New Issue
Block a user