Changeset b9acb4e in rtems


Ignore:
Timestamp:
Jun 25, 2013, 12:03:51 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
8ebc680
Parents:
83889708
git-author:
Sebastian Huber <sebastian.huber@…> (06/25/13 12:03:51)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/25/13 15:06:16)
Message:

sptests/sp64: Simplify

This avoids problems with debugging enabled.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/sp64/init.c

    r83889708 rb9acb4e  
    1111#include "config.h"
    1212#endif
     13
     14#include <rtems/libcsupport.h>
    1315
    1416#include "tmacros.h"
     
    2729  rtems_id                region2;
    2830  rtems_status_code       sc;
    29   bool                    sb;
    30   Heap_Information_block  start;
    31   Heap_Information_block  info;
    32   size_t                  to_alloc;
     31  bool                    ok;
     32  uintptr_t               to_alloc;
    3333  void                   *alloced;
     34  rtems_resource_snapshot snapshot;
     35  void                   *greedy;
    3436
    3537  puts( "\n\n*** TEST 64 ***" );
     
    4446    &region1
    4547  );
    46   directive_failed( sc, "rtems_region_create of RN1" );
     48  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    4749
    48   puts( "Init - rtems_workspace_get_information - OK" );
    49   sb = rtems_workspace_get_information( &start );
    50   rtems_test_assert( sb );
    51 
    52   #if 0
    53     printf( "Init - workspace free = %d\n", start.Free.largest );
    54     printf( "Init - workspace free blocks = %d\n", start.Free.number );
    55   #endif
    56   rtems_test_assert( start.Free.number == 1 );
    57   to_alloc = start.Free.largest;
    58 
    59   /* find the largest we can actually allocate */
    60   while ( 1 ) {
    61     sb = rtems_workspace_allocate( to_alloc, &alloced );
    62     if ( sb )
    63       break;
    64     to_alloc -= 4;
    65   }
    66 
    67   rtems_workspace_free( alloced );
    68 
    69   #if 0
    70     printf( "Init - start with to_alloc of = %d\n", to_alloc );
    71   #endif
    72 
    73   /*
    74    * Verify heap is still in same shape if we couldn't allocate a region
    75    */
    76   sb = rtems_workspace_get_information( &info );
    77   rtems_test_assert( sb );
    78   rtems_test_assert( info.Free.largest == start.Free.largest );
    79   rtems_test_assert( info.Free.number  == start.Free.number  );
     50  greedy = rtems_workspace_greedy_allocate_all_except_largest( &to_alloc );
     51  rtems_resource_snapshot_take( &snapshot );
    8052
    8153  puts( "Init - rtems_region_create - auto-extend - RTEMS_UNSATISFIED" );
    82   while (1) {
    83 
    84     sb = rtems_workspace_allocate( to_alloc, &alloced );
    85     rtems_test_assert( sb );
     54  while ( to_alloc > 8 ) {
     55    ok = rtems_workspace_allocate( to_alloc, &alloced );
     56    rtems_test_assert( ok );
    8657
    8758    sc = rtems_region_create(
     
    9465    );
    9566
    96     /* free the memory we snagged, then check the status */
    9767    rtems_workspace_free( alloced );
    9868
     
    10070      break;
    10171
    102     if ( sc != RTEMS_TOO_MANY ) {
    103       printf( "region create returned %d or %s\n", sc, rtems_status_text(sc) );
    104       rtems_test_exit(0);
    105     }
     72    rtems_test_assert( sc == RTEMS_TOO_MANY );
    10673
    10774    /*
    10875     * Verify heap is still in same shape if we couldn't allocate a region
    10976     */
    110     sb = rtems_workspace_get_information( &info );
    111     #if 0
    112       printf( "Init - workspace free/blocks = %d/%d\n",
    113         info.Free.largest, info.Free.number );
    114     #endif
    115     rtems_test_assert( sb );
    116     rtems_test_assert( info.Free.largest == start.Free.largest );
    117     rtems_test_assert( info.Free.number  == start.Free.number  );
     77    ok = rtems_resource_snapshot_check( &snapshot );
     78    rtems_test_assert( ok );
    11879
    11980    to_alloc -= 8;
    120     if ( to_alloc == 0 )
    121      break;
    12281  }
    12382
    124   if ( sc )
    125     rtems_test_exit(0);
     83  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    12684
    12785  /*
     
    13088  puts( "Init - rtems_region_delete - OK" );
    13189  sc = rtems_region_delete( region2 );
    132   rtems_test_assert( sc == 0 );
     90  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
    13391
    134   /*
    135    *  Although it is intuitive that after deleting the region the
    136    *  object space would shrink and go back to its original shape,
    137    *  we could end up with fragmentation which prevents a simple
    138    *  check from verifying this.
    139    */
    140   #if 0
    141     puts( "Init - verify workspace has same memory" );
    142     sb = rtems_workspace_get_information( &info );
    143     #if 0
    144         printf( "Init - workspace free/blocks = %d/%d\n",
    145       info.Free.largest, info.Free.number );
    146     #endif
    147     rtems_test_assert( sb );
    148     rtems_test_assert( info.Free.largest == start.Free.largest );
    149     rtems_test_assert( info.Free.number  == start.Free.number  );
    150   #endif
     92  puts( "Init - verify workspace has same memory" );
     93  ok = rtems_resource_snapshot_check( &snapshot );
     94  rtems_test_assert( ok );
     95  rtems_workspace_greedy_free( greedy );
    15196
    15297  puts( "*** END OF TEST 64 ***" );
     
    159104#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
    160105
    161 #define CONFIGURE_MAXIMUM_TASKS         2
    162 #define CONFIGURE_MAXIMUM_REGIONS       rtems_resource_unlimited(1)
     106#define CONFIGURE_MAXIMUM_TASKS         1
     107#define CONFIGURE_MAXIMUM_REGIONS       rtems_resource_unlimited( 2 )
    163108#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
     109
     110#define CONFIGURE_MEMORY_OVERHEAD 1
    164111
    165112#define CONFIGURE_INIT
Note: See TracChangeset for help on using the changeset viewer.