summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-12-19 16:05:32 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-12-19 16:05:32 +0000
commite1a22c112c47779a598a9b2180a9130a2d58024e (patch)
tree1ddd4a9d701ddbc7f84b18ea3fccadf677f0e3ec /testsuites/libtests
parent2007-12-19 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-e1a22c112c47779a598a9b2180a9130a2d58024e.tar.bz2
2007-12-19 Joel Sherrill <joel.sherrill@OARcorp.com>
* malloctest/init.c, malloctest/task1.c: Add test for posix_memalign.
Diffstat (limited to 'testsuites/libtests')
-rw-r--r--testsuites/libtests/ChangeLog4
-rw-r--r--testsuites/libtests/malloctest/init.c40
-rw-r--r--testsuites/libtests/malloctest/task1.c6
3 files changed, 47 insertions, 3 deletions
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 <joel.sherrill@OARcorp.com>
+
+ * malloctest/init.c, malloctest/task1.c: Add test for posix_memalign.
+
2007-12-14 Joel Sherrill <joel.sherrill@OARcorp.com>
* 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 <stdlib.h>
+#include <errno.h>
+
/*
* 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<<i );
+ break;
+ }
+ posix_service_failed( sc, "posix_memalign alignment OK" );
+
+ free( p1 );
+ }
+
+}
+
rtems_task Init(
rtems_task_argument argument
)
@@ -54,6 +92,8 @@ rtems_task Init(
test_realloc();
+ test_posix_memalign();
+
Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
diff --git a/testsuites/libtests/malloctest/task1.c b/testsuites/libtests/malloctest/task1.c
index 575dc5189b..8568710ba5 100644
--- a/testsuites/libtests/malloctest/task1.c
+++ b/testsuites/libtests/malloctest/task1.c
@@ -14,8 +14,8 @@
*/
#include "system.h"
-#include <rtems/libcsupport.h> /* for malloc_dump, malloc_walk */
-#include <string.h> /* for memset */
+#include <rtems/malloc.h>
+#include <string.h>
#include <stdlib.h>
#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++)