Changeset dfaa1a7 in rtems


Ignore:
Timestamp:
Jan 31, 2008, 10:14:04 PM (12 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.9, master
Children:
c54f3ce
Parents:
b853d288
Message:

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

  • malloctest/init.c: Add more test cases to cover heap better.
Location:
testsuites/libtests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/libtests/ChangeLog

    rb853d288 rdfaa1a7  
     12008-01-31      Joel Sherrill <joel.sherrill@OARcorp.com>
     2
     3        * malloctest/init.c: Add more test cases to cover heap better.
     4
    152008-01-31      Joel Sherrill <joel.sherrill@OARcorp.com>
    26
  • testsuites/libtests/malloctest/init.c

    rb853d288 rdfaa1a7  
    2222 */
    2323
     24#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
    2425#define TEST_INIT
    2526#include "system.h"
     
    9293   * Walk the C Program Heap
    9394   */
     95  puts( "malloc_walk - normal path" );
    9496  malloc_walk( 1234, 0 );
     97
     98  puts( "malloc_walk - in critical section path" );
     99  _Thread_Disable_dispatch();
     100  malloc_walk( 1234, 0 );
     101  _Thread_Enable_dispatch();
    95102
    96103  /*
     
    108115  _Heap_Initialize( &TestHeap, TestHeapMemory, TEST_HEAP_SIZE, 0 );
    109116}
     117
    110118void test_heap_cases_1()
    111119{
     
    144152}
    145153
     154void test_heap_extend()
     155{
     156  void     *p1, *p2, *p3, *p4;
     157  uint32_t  u1, u2;
     158  boolean   ret;
     159
     160  /*
     161   * Easier to hit extend with a dedicated heap.
     162   *
     163   */
     164  _Heap_Initialize( &TestHeap, TestHeapMemory, 512, 0 );
     165
     166  puts( "heap extend - bad address" );
     167  ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory - 512, 512 );
     168  rtems_test_assert( ret == FALSE );
     169
     170  puts( "heap extend - OK" );
     171  ret = _Protected_heap_Extend( &TestHeap, &TestHeapMemory[ 512 ], 512 );
     172  rtems_test_assert( ret == TRUE );
     173}
     174
     175void test_heap_info(void)
     176{
     177  size_t                  s1, s2;
     178  void                   *p1;
     179  int                     sc;
     180  Heap_Information_block  the_info;
     181
     182  s1 = malloc_free_space();
     183  p1 = malloc( 512 );
     184  s2 = malloc_free_space();
     185  puts( "malloc_free_space - check malloc space drops after malloc" );
     186  rtems_test_assert( s1 );
     187  rtems_test_assert( s2 );
     188  rtems_test_assert( s2 <= s1 );
     189  free( p1 );
     190
     191  puts( "malloc_free_space - verify free space returns to previous value" );
     192  s2 = malloc_free_space();
     193  rtems_test_assert( s1 == s2 );
     194
     195  puts( "malloc_info - called with NULL\n" );
     196  sc = malloc_info( NULL );
     197  rtems_test_assert( sc == -1 );
     198
     199  puts( "malloc_info - check free space drops after malloc" );
     200  sc = malloc_info( &the_info );
     201  rtems_test_assert( sc == -1 );
     202  s1 = the_info.Free.largest;
     203
     204  p1 = malloc( 512 );
     205
     206  sc = malloc_info( &the_info );
     207  rtems_test_assert( sc == 0 );
     208  s2 = the_info.Free.largest;
     209
     210  rtems_test_assert( s1 );
     211  rtems_test_assert( s2 );
     212  rtems_test_assert( s2 <= s1 );
     213  free( p1 );
     214
     215  puts( "malloc_info - verify free space returns to previous value" );
     216  sc = malloc_info( &the_info );
     217  rtems_test_assert( sc == 0 );
     218  rtems_test_assert( s1 == the_info.Free.largest );
     219
     220}
     221
    146222/*
    147223 *  A simple test of posix_memalign
     
    194270  test_realloc();
    195271  test_heap_cases_1();
     272  test_heap_extend();
     273  test_heap_info();
    196274
    197275  test_posix_memalign();
Note: See TracChangeset for help on using the changeset viewer.