Ignore:
Timestamp:
Jul 9, 2009, 4:13:06 PM (12 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 5, master
Children:
0c5a8be8
Parents:
c45a2ded
Message:

2009-07-09 Joel Sherrill <joel.sherrill@…>

  • malloctest/init.c, malloctest/malloctest.scn: Add heap resize test for shrinking a block enough to need to free the newly unused portion.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/libtests/malloctest/init.c

    rc45a2ded r66abaa1  
    6363
    6464  /* Test realloc that should fail "in place", i.e.,
    65    * fallback to free()--malloc()
     65   * fallback to free()-- malloc()
    6666   */
    6767  p1 = malloc(32);
     
    251251  rc = _Protected_heap_Get_information( &heap, NULL );
    252252  rtems_test_assert( rc == false );
     253}
     254
     255void test_heap_resize(void)
     256{
     257  Heap_Resize_status  rc;
     258  void               *p1;
     259  intptr_t            oldsize;
     260  intptr_t            avail;
     261
     262  puts( "Initialize Test Heap" );
     263  test_heap_init();
     264 
     265  puts( "Allocate most of heap" );
     266  p1 = _Heap_Allocate( &TestHeap, TEST_HEAP_SIZE - 32 );
     267  rtems_test_assert( p1 != NULL );
     268
     269  puts( "Resize (shrink) the area to 8 bytes to ensure remainder gets freed" );
     270  rc = _Heap_Resize_block( &TestHeap, p1, 8, &oldsize, &avail );
     271  rtems_test_assert( rc == HEAP_RESIZE_SUCCESSFUL );
    253272}
    254273
     
    320339  test_heap_info();
    321340  test_protected_heap_info();
     341  test_heap_resize();
    322342
    323343  test_posix_memalign();
Note: See TracChangeset for help on using the changeset viewer.