Changeset f4812a03 in rtems


Ignore:
Timestamp:
Jun 6, 2009, 6:52:54 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 5, master
Children:
25686a57
Parents:
5cb7096
Message:

2009-06-06 Joel Sherrill <joel.sherrill@…>

  • heapwalk/init.c: Add more automated corruption capability.
Location:
testsuites/libtests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/libtests/ChangeLog

    r5cb7096 rf4812a03  
     12009-06-06      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * heapwalk/init.c: Add more automated corruption capability.
     4
    152009-06-05      Santosh G Vattam <vattam.santosh@gmail.com>
    26
  • testsuites/libtests/heapwalk/init.c

    r5cb7096 rf4812a03  
    1919#include <inttypes.h>
    2020#include <errno.h>
     21#include <string.h>
    2122#include <rtems/score/heap.h>
    2223
    2324#define TEST_HEAP_SIZE 1024
    24 uint8_t TestHeapMemory[TEST_HEAP_SIZE];
     25uint32_t TestHeapMemory[TEST_HEAP_SIZE];
    2526Heap_Control TestHeap;
    2627
    2728void test_heap_init(void)
    2829{
    29   _Heap_Initialize( &TestHeap, TestHeapMemory, TEST_HEAP_SIZE, 0 );
     30  memset( TestHeapMemory, '\0', sizeof(TestHeapMemory) );
     31  _Heap_Initialize( &TestHeap, TestHeapMemory, sizeof(TestHeapMemory), 0 );
     32}
     33
     34void test_heap_walk( int source, bool do_dump )
     35{
     36  int i, j, original;
     37
     38  _Heap_Walk( &TestHeap, source, do_dump );
     39 
     40  /*
     41   *  Now corrupt all non-zero values
     42   */
     43  for (i=0 ; i<TEST_HEAP_SIZE ; i++) {
     44    original = TestHeapMemory[i];
     45    if ( original == 0 )
     46      continue;
     47
     48    /* mark it free -- may or may not have already been */
     49    TestHeapMemory[i] &= ~0x01;   
     50    _Heap_Walk( &TestHeap, source, do_dump );
     51
     52    /* mark it used -- may or may not have already been */
     53    TestHeapMemory[i] |= 0x01;   
     54    _Heap_Walk( &TestHeap, source, do_dump );
     55
     56    /* try 0 and see what that does */
     57    TestHeapMemory[i] = 0x00;   
     58    _Heap_Walk( &TestHeap, source, do_dump );
     59
     60    /* try 0xffffffff and see what that does */
     61    TestHeapMemory[i] = 0xffffffff;   
     62    _Heap_Walk( &TestHeap, source, do_dump );
     63
     64    TestHeapMemory[i] = original;
     65  }
    3066}
    3167
     
    3470  puts( "Walk freshly initialized heap" );
    3571  test_heap_init();
    36   _Heap_Walk( &TestHeap, 0x01, true );
     72  test_heap_walk(1, true);
    3773}
    3874
     
    4076{
    4177  test_heap_init();
    42 /* Passing a negative value for source so that
    43  * the control enters the if block on line 67
    44  */
     78  /*
     79   * Passing a negative value for source so that
     80   * the control enters the if block on line 67
     81   */
    4582  puts( "Passing negative value for source" );
    46   _Heap_Walk( &TestHeap, -1, true );
    47 
     83  test_heap_walk( -1, true );
    4884}
    4985
Note: See TracChangeset for help on using the changeset viewer.