summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-06-08 22:49:58 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-06-08 22:49:58 +0000
commit93f4ac264c9b14d3606fd65d3736c6fe29341146 (patch)
tree3f97b805dc6d72d179dc71a6e7728cb5e980f49e /testsuites/libtests
parent2009-06-08 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-93f4ac264c9b14d3606fd65d3736c6fe29341146.tar.bz2
2009-06-08 Joel Sherrill <joel.sherrill@OARcorp.com>
* heapwalk/init.c: Add more cases.
Diffstat (limited to 'testsuites/libtests')
-rw-r--r--testsuites/libtests/ChangeLog4
-rw-r--r--testsuites/libtests/heapwalk/init.c44
2 files changed, 46 insertions, 2 deletions
diff --git a/testsuites/libtests/ChangeLog b/testsuites/libtests/ChangeLog
index 64bf46b49c..5660dc7f38 100644
--- a/testsuites/libtests/ChangeLog
+++ b/testsuites/libtests/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-08 Joel Sherrill <joel.sherrill@OARcorp.com>
+
+ * heapwalk/init.c: Add more cases.
+
2009-06-06 Joel Sherrill <joel.sherrill@oarcorp.com>
* heapwalk/init.c: Add more automated corruption capability.
diff --git a/testsuites/libtests/heapwalk/init.c b/testsuites/libtests/heapwalk/init.c
index 92b5fe679c..a3403e2213 100644
--- a/testsuites/libtests/heapwalk/init.c
+++ b/testsuites/libtests/heapwalk/init.c
@@ -20,6 +20,7 @@
#include <errno.h>
#include <string.h>
#include <rtems/score/heap.h>
+#include <rtems/dumpbuf.h>
#define TEST_HEAP_SIZE 1024
uint32_t TestHeapMemory[TEST_HEAP_SIZE];
@@ -46,18 +47,22 @@ void test_heap_walk( int source, bool do_dump )
continue;
/* mark it free -- may or may not have already been */
+printf( "%p -- free\n", i );
TestHeapMemory[i] &= ~0x01;
_Heap_Walk( &TestHeap, source, do_dump );
/* mark it used -- may or may not have already been */
+printf( "%p -- used\n", i );
TestHeapMemory[i] |= 0x01;
_Heap_Walk( &TestHeap, source, do_dump );
/* try 0 and see what that does */
+printf( "%p -- 0x00\n", i );
TestHeapMemory[i] = 0x00;
_Heap_Walk( &TestHeap, source, do_dump );
/* try 0xffffffff and see what that does */
+printf( "%p -- 0xff\n", i );
TestHeapMemory[i] = 0xffffffff;
_Heap_Walk( &TestHeap, source, do_dump );
@@ -74,12 +79,12 @@ void test_walk_freshly_initialized(void)
void test_negative_source_value(void)
{
- test_heap_init();
/*
* Passing a negative value for source so that
* the control enters the if block on line 67
*/
puts( "Passing negative value for source" );
+ test_heap_init();
test_heap_walk( -1, true );
}
@@ -90,7 +95,40 @@ void test_prev_block_flag_check(void)
* Actually covers more than that.
*/
puts( "Calling Heap Walk without initialising" );
- _Heap_Walk( &TestHeap, 0x01, true );
+ test_heap_walk( 1, true );
+}
+
+void test_not_aligned(void)
+{
+ /*
+ * Hack to get to the error case where the blocks are
+ * not on the page size. We initialize a heap with
+ * default settings and change the page size to something
+ * large.
+ */
+ puts( "Testing case of blocks not on page size" );
+ test_heap_init();
+ TestHeap.page_size = 128;
+ test_heap_walk( -1, true );
+}
+
+void test_not_in_free_list(void)
+{
+ void *p1, *p2, *p3;
+
+ /*
+ * Hack to get to the error case where the blocks are
+ * not on the page size. We initialize a heap with
+ * default settings and change the page size to something
+ * large.
+ */
+ puts( "Testing case of blocks not on page size" );
+ test_heap_init();
+ p1 =_Heap_Allocate( &TestHeap, 32 );
+ p2 =_Heap_Allocate( &TestHeap, 32 );
+ p3 =_Heap_Allocate( &TestHeap, 32 );
+ _Heap_Free( &TestHeap, p2 );
+ test_heap_walk( -1, true );
}
rtems_task Init(
@@ -102,6 +140,8 @@ rtems_task Init(
test_prev_block_flag_check();
test_walk_freshly_initialized();
test_negative_source_value();
+ test_not_aligned();
+ test_not_in_free_list();
puts( "*** END OF HEAP WALK TEST ***" );
rtems_test_exit(0);