diff --git a/testsuites/libtests/ChangeLog b/testsuites/libtests/ChangeLog index af0224274b..c0db39ecfb 100644 --- a/testsuites/libtests/ChangeLog +++ b/testsuites/libtests/ChangeLog @@ -1,3 +1,7 @@ +2007-12-19 Joel Sherrill + + * malloctest/init.c, malloctest/task1.c: Add test for posix_memalign. + 2007-12-14 Joel Sherrill * rtmonuse/init.c, rtmonuse/task1.c: Add period which is unused to diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c index bd5206736c..95019074ee 100644 --- a/testsuites/libtests/malloctest/init.c +++ b/testsuites/libtests/malloctest/init.c @@ -24,6 +24,9 @@ #define TEST_INIT #include "system.h" +#include +#include + /* * A simple test of realloc */ @@ -39,6 +42,41 @@ void test_realloc(void) free(p2); } +/* + * A simple test of posix_memalign + */ +void test_posix_memalign(void) +{ + void *p1, *p2; + int i; + int sc; + + puts( "posix_memalign - NULL return pointer -- EINVAL" ); + sc = posix_memalign( NULL, 32, 8 ); + fatal_posix_service_status( sc, EINVAL, "posix_memalign NULL pointer" ); + + puts( "posix_memalign - alignment of 0 -- EINVAL" ); + sc = posix_memalign( &p1, 0, 8 ); + fatal_posix_service_status( sc, EINVAL, "posix_memalign alignment of 0" ); + + puts( "posix_memalign - alignment of 2-- EINVAL" ); + sc = posix_memalign( &p1, 2, 8 ); + fatal_posix_service_status( sc, EINVAL, "posix_memalign alignment of 2" ); + + for ( i=2 ; i<32 ; i++ ) { + printf( "posix_memalign - alignment of %d -- OK\n", 1 << i ); + sc = posix_memalign( &p1, 1 << i, 8 ); + if ( sc == ENOMEM ) { + printf( "posix_memalign - ran out of memory trying %d\n", 1< /* for malloc_dump, malloc_walk */ -#include /* for memset */ +#include +#include #include #define NUM_PASSES 100 @@ -55,7 +55,7 @@ rtems_task Task_1_through_5( } printf("mallocing %d bytes\n",mem_amt); memset( mem_ptr, mem_amt, mem_amt ); - malloc_dump(); + malloc_report_statistics(); malloc_walk(1,FALSE); status = rtems_task_wake_after( task_number( tid ) * 1 * TICKS_PER_SECOND/4 ); for (i=0; i < mem_amt; i++)