summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/libc/test_malloc.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/libc/test_malloc.c b/tests/libc/test_malloc.c
new file mode 100644
index 0000000..0f74fad
--- /dev/null
+++ b/tests/libc/test_malloc.c
@@ -0,0 +1,24 @@
+#include "stdlib.h"
+#include "string.h"
+
+#define HEAP_SIZE 128 * 1024
+
+int main( void )
+{
+ memory_manager_t memory_manager;
+ char buf[HEAP_SIZE];
+ uint32_t heap_offset = (uint32_t)&buf;
+ size_t heap_size = HEAP_SIZE;
+ memory_manager_init( &memory_manager, heap_offset, heap_size );
+ __stdlib_set_memory_manager( &memory_manager );
+
+ char *s;
+ char *s1 = "test_string";
+
+ s = (char *)malloc( strlen( s1 ) + 1 );
+ size_t n = strlcpy( s, s1, strlen( s1 ) + 1 );
+ if( n != 11 ) return 1;
+ if( strcmp( s, s1 ) != 0 ) return 1;
+
+ return 0;
+}