Changeset f2a7fa02 in rtems


Ignore:
Timestamp:
Jan 31, 2008, 4:06:21 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.9, master
Children:
c87593f
Parents:
56c5cf09
Message:

2008-01-31 Joel Sherrill <joel.sherrill@…>

  • malloctest/init.c: Add new test cases per Sergei. Make some of the stranger cases operate directly on a freshly initialized heap. This should make them more reproducible.
Location:
testsuites/libtests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/libtests/ChangeLog

    r56c5cf09 rf2a7fa02  
     12008-01-31      Joel Sherrill <joel.sherrill@OARcorp.com>
     2
     3        * malloctest/init.c: Add new test cases per Sergei. Make some of the
     4        stranger cases operate directly on a freshly initialized heap. This
     5        should make them more reproducible.
     6
    172008-01-29      Joel Sherrill <joel.sherrill@OARcorp.com>
    28
  • testsuites/libtests/malloctest/init.c

    r56c5cf09 rf2a7fa02  
    1212 *  Output parameters:  NONE
    1313 *
    14  *  COPYRIGHT (c) 1989-2007.
     14 *  COPYRIGHT (c) 1989-2008.
    1515 *  On-Line Applications Research Corporation (OAR).
    1616 *
     
    9898   */
    9999  p4 = realloc( test_realloc, 32 );
     100}
     101
     102#define TEST_HEAP_SIZE 1024
     103uint8_t TestHeapMemory[TEST_HEAP_SIZE];
     104Heap_Control TestHeap;
     105
     106void test_heap_init()
     107{
     108  _Heap_Initialize( &TestHeap, TestHeapMemory, TEST_HEAP_SIZE, 0 );
     109}
     110void test_heap_cases_1()
     111{
     112  void     *p1, *p2, *p3, *p4;
     113  uint32_t  u1, u2;
     114  Heap_Resize_status rsc;
    100115
    101116  /*
     
    105120   * code like this:
    106121   */
    107    p1 = malloc(12);
    108    p2 = malloc(32);
    109    p3 = malloc(32);
    110    free(p2);
    111    sc = rtems_memalign(&p2, 8, 28);
    112    free(p1);
    113    free(p2);
    114    free(p3);
    115 
    116    /*
    117     *  Odd case in resizing a block.  Again test case outline per Sergei
    118     */
    119    p1 = malloc(32);
    120    p2 = malloc(8);
    121    p3 = malloc(32);
    122    free(p2);
    123    p4 = realloc(p1, 42);
    124    free(p3);
    125    free(p4);
    126 
     122  test_heap_init();
     123  p1 = _Heap_Allocate( &TestHeap, 12 );
     124  p2 = _Heap_Allocate( &TestHeap, 32 );
     125  p3 = _Heap_Allocate( &TestHeap, 32 );
     126  _Heap_Free( &TestHeap, p2 );
     127  p2 = _Heap_Allocate_aligned( &TestHeap, 8, 28 );
     128  _Heap_Free( &TestHeap, p1 );
     129  _Heap_Free( &TestHeap, p2 );
     130  _Heap_Free( &TestHeap, p3 );
     131
     132  /*
     133   *  Odd case in resizing a block.  Again test case outline per Sergei
     134   */
     135  test_heap_init();
     136  p1 = _Heap_Allocate( &TestHeap, 32 );
     137  p2 = _Heap_Allocate( &TestHeap, 8 );
     138  p3 = _Heap_Allocate( &TestHeap, 32 );
     139  _Heap_Free( &TestHeap, p2 );
     140  rsc = _Heap_Resize_block( &TestHeap, p1, 41, &u1, &u2 );
     141  /* XXX what should we expect */
     142  _Heap_Free( &TestHeap, p3 );
     143  _Heap_Free( &TestHeap, p4 );
    127144}
    128145
     
    176193
    177194  test_realloc();
     195  test_heap_cases_1();
    178196
    179197  test_posix_memalign();
Note: See TracChangeset for help on using the changeset viewer.