diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libc/test_malloc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/libc/test_malloc.c b/tests/libc/test_malloc.c index aaff2da..b20ee62 100644 --- a/tests/libc/test_malloc.c +++ b/tests/libc/test_malloc.c @@ -19,6 +19,25 @@ int main( void ) size_t n = strlcpy( s, s1, strlen( s1 ) + 1 ); if( n != 11 ) exit( 1 ); if( strcmp( s, s1 ) != 0 ) exit( 1 ); + free( s ); + + if( memory_manager.size != heap_size - sizeof( memory_chunk_t ) ) exit( 1 ); + if( memory_manager.offset != (uint32_t)&buf ) exit( 1 ); + if( memory_manager_stats_used( &memory_manager ) != 0 ) exit( 1 ); + if( memory_manager_stats_free( &memory_manager ) != heap_size - sizeof( memory_chunk_t ) ) exit( 1 ); + + char *v[120]; + for( int i = 0; i < 120; i++ ) { + v[i] = (char *)malloc( i ); + if( v[i] == NULL ) exit( 1 ); + } + + for( int i = 119; i >= 0; i-- ) { + free( v[i] ); + } + + if( memory_manager_stats_used( &memory_manager ) != 0 ) exit( 1 ); + if( memory_manager_stats_free( &memory_manager ) != heap_size - sizeof( memory_chunk_t ) ) exit( 1 ); exit( 0 ); } |