Changeset 5f6a4a2 in rtems


Ignore:
Timestamp:
Jun 10, 2009, 3:28:10 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
293a0a4
Parents:
e050d9a
Message:

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

  • heapwalk/init.c: Add test code for first free block pointer not aligned.
Location:
testsuites/libtests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/libtests/ChangeLog

    re050d9a r5f6a4a2  
     12009-06-10      Joel Sherrill <joel.sherrill@OARcorp.com>
     2
     3        * heapwalk/init.c: Add test code for first free block pointer not
     4        aligned.
     5
    162009-06-08      Joel Sherrill <joel.sherrill@OARcorp.com>
    27
  • testsuites/libtests/heapwalk/init.c

    re050d9a r5f6a4a2  
    22 *  Test of Heap Walker
    33 *
    4  *  COPYRIGHT (c) 1989-2008.
     4 *  COPYRIGHT (c) 1989-2009.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
     
    3333}
    3434
    35 void test_heap_walk( int source, bool do_dump )
     35void test_heap_walk_body( int source, bool do_dump );
     36
     37void test_heap_walk( int source )
     38{
     39  test_heap_walk_body( source, true );
     40  test_heap_walk_body( source, false );
     41}
     42
     43void test_heap_walk_body( int source, bool do_dump )
    3644{
    3745  int i, j, original;
    3846
    3947  _Heap_Walk( &TestHeap, source, do_dump );
    40  
     48
    4149  /*
    4250   *  Now corrupt all non-zero values
     
    4856
    4957    /* mark it free -- may or may not have already been */
    50 printf( "%p -- free\n", i );
    51     TestHeapMemory[i] &= ~0x01;   
     58    TestHeapMemory[i] &= ~0x01;
    5259    _Heap_Walk( &TestHeap, source, do_dump );
    5360
    5461    /* mark it used -- may or may not have already been */
    55 printf( "%p -- used\n", i );
    56     TestHeapMemory[i] |= 0x01;   
     62    TestHeapMemory[i] |= 0x01;
    5763    _Heap_Walk( &TestHeap, source, do_dump );
    5864
     65    /* try values of 2-7 in the last three bits -- push alignment issues */
     66    for (j=2 ; j<=7 ; j++) {
     67      TestHeapMemory[i] = (TestHeapMemory[i] & ~0x7) | j;
     68      _Heap_Walk( &TestHeap, source, do_dump );
     69    }
     70
     71
    5972    /* try 0 and see what that does */
    60 printf( "%p -- 0x00\n", i );
    61     TestHeapMemory[i] = 0x00;   
     73    TestHeapMemory[i] = 0x00;
    6274    _Heap_Walk( &TestHeap, source, do_dump );
    6375
    6476    /* try 0xffffffff and see what that does */
    65 printf( "%p -- 0xff\n", i );
    66     TestHeapMemory[i] = 0xffffffff;   
     77    TestHeapMemory[i] = 0xffffffff;
    6778    _Heap_Walk( &TestHeap, source, do_dump );
    6879
     
    7586  puts( "Walk freshly initialized heap" );
    7687  test_heap_init();
    77   test_heap_walk(1, true);
     88  test_heap_walk(1);
    7889}
    7990
     
    8697  puts( "Passing negative value for source" );
    8798  test_heap_init();
    88   test_heap_walk( -1, true );
     99  test_heap_walk( -1 );
    89100}
    90101
     
    96107   */
    97108  puts( "Calling Heap Walk without initialising" );
    98   test_heap_walk( 1, true );
     109  test_heap_walk( 1 );
    99110}
    100111
     
    110121  test_heap_init();
    111122  TestHeap.page_size = 128;
    112   test_heap_walk( -1, true );
     123  test_heap_walk( -1 );
     124}
     125
     126void test_first_block_not_aligned(void)
     127{
     128  /*
     129   * Hack to get to the error case where the blocks are
     130   * not on the page size.  We initialize a heap with
     131   * default settings and change the page size to something
     132   * large.
     133   */
     134  puts( "Testing case of blocks not on page size" );
     135  test_heap_init();
     136  _Heap_Head(&TestHeap)->next = (void *)1;
     137  test_heap_walk( -1 );
    113138}
    114139
     
    129154  p3 =_Heap_Allocate( &TestHeap, 32 );
    130155  _Heap_Free( &TestHeap, p2 );
    131   test_heap_walk( -1, true );
     156  test_heap_walk( -1 );
    132157}
    133158
     
    143168  test_not_aligned();
    144169  test_not_in_free_list();
     170  test_first_block_not_aligned();
    145171
    146172  puts( "*** END OF HEAP WALK TEST ***" );
Note: See TracChangeset for help on using the changeset viewer.