summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/malloctest/init.c
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/malloctest/init.c
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/malloctest/init.c')
-rw-r--r--testsuites/libtests/malloctest/init.c40
1 files changed, 40 insertions, 0 deletions
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', ' ' );