summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-06-06 18:52:54 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-06-06 18:52:54 +0000
commitf4812a03e3fbbc50f9d0cd4556a3a598c75d2a21 (patch)
tree3a9c0ebad695a90cfaf1f06d52a372466ff298ac /testsuites/libtests
parent2009-06-05 Till Straumann <strauman@slac.stanford.edu> (diff)
downloadrtems-f4812a03e3fbbc50f9d0cd4556a3a598c75d2a21.tar.bz2
2009-06-06 Joel Sherrill <joel.sherrill@oarcorp.com>
* heapwalk/init.c: Add more automated corruption capability.
Diffstat (limited to 'testsuites/libtests')
-rw-r--r--testsuites/libtests/ChangeLog4
-rw-r--r--testsuites/libtests/heapwalk/init.c52
2 files changed, 48 insertions, 8 deletions
diff --git a/testsuites/libtests/ChangeLog b/testsuites/libtests/ChangeLog
index 2720adecf3..64bf46b49c 100644
--- a/testsuites/libtests/ChangeLog
+++ b/testsuites/libtests/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-06 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * heapwalk/init.c: Add more automated corruption capability.
+
2009-06-05 Santosh G Vattam <vattam.santosh@gmail.com>
* heapwalk/heapwalk.scn, heapwalk/init.c: Add a test case.
diff --git a/testsuites/libtests/heapwalk/init.c b/testsuites/libtests/heapwalk/init.c
index ef7732b905..92b5fe679c 100644
--- a/testsuites/libtests/heapwalk/init.c
+++ b/testsuites/libtests/heapwalk/init.c
@@ -18,33 +18,69 @@
#include <stdlib.h>
#include <inttypes.h>
#include <errno.h>
+#include <string.h>
#include <rtems/score/heap.h>
#define TEST_HEAP_SIZE 1024
-uint8_t TestHeapMemory[TEST_HEAP_SIZE];
+uint32_t TestHeapMemory[TEST_HEAP_SIZE];
Heap_Control TestHeap;
void test_heap_init(void)
{
- _Heap_Initialize( &TestHeap, TestHeapMemory, TEST_HEAP_SIZE, 0 );
+ memset( TestHeapMemory, '\0', sizeof(TestHeapMemory) );
+ _Heap_Initialize( &TestHeap, TestHeapMemory, sizeof(TestHeapMemory), 0 );
+}
+
+void test_heap_walk( int source, bool do_dump )
+{
+ int i, j, original;
+
+ _Heap_Walk( &TestHeap, source, do_dump );
+
+ /*
+ * Now corrupt all non-zero values
+ */
+ for (i=0 ; i<TEST_HEAP_SIZE ; i++) {
+ original = TestHeapMemory[i];
+ if ( original == 0 )
+ continue;
+
+ /* mark it free -- may or may not have already been */
+ TestHeapMemory[i] &= ~0x01;
+ _Heap_Walk( &TestHeap, source, do_dump );
+
+ /* mark it used -- may or may not have already been */
+ TestHeapMemory[i] |= 0x01;
+ _Heap_Walk( &TestHeap, source, do_dump );
+
+ /* try 0 and see what that does */
+ TestHeapMemory[i] = 0x00;
+ _Heap_Walk( &TestHeap, source, do_dump );
+
+ /* try 0xffffffff and see what that does */
+ TestHeapMemory[i] = 0xffffffff;
+ _Heap_Walk( &TestHeap, source, do_dump );
+
+ TestHeapMemory[i] = original;
+ }
}
void test_walk_freshly_initialized(void)
{
puts( "Walk freshly initialized heap" );
test_heap_init();
- _Heap_Walk( &TestHeap, 0x01, true );
+ test_heap_walk(1, true);
}
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
- */
+ /*
+ * Passing a negative value for source so that
+ * the control enters the if block on line 67
+ */
puts( "Passing negative value for source" );
- _Heap_Walk( &TestHeap, -1, true );
-
+ test_heap_walk( -1, true );
}
void test_prev_block_flag_check(void)