Changeset 22c7a64 in rtems


Ignore:
Timestamp:
Jun 25, 2013, 10:22:23 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
b4062c3f
Parents:
d79973d
git-author:
Sebastian Huber <sebastian.huber@…> (06/25/13 10:22:23)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/25/13 15:06:24)
Message:

psxtests/psxkey02: Simplify

This avoids problems with debugging enabled.

Location:
testsuites/psxtests/psxkey02
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/psxkey02/init.c

    rd79973d r22c7a64  
    1414#include <pthread.h>
    1515#include <errno.h>
     16#include <rtems/libcsupport.h>
    1617#include "tmacros.h"
    1718#include "pmacros.h"
     
    2526{
    2627  pthread_key_t           key;
    27   int                     sc;
    28   bool                    sb;
    29   Heap_Information_block  start;
    30   Heap_Information_block  info;
    31   size_t                  to_alloc;
     28  int                     eno;
     29  bool                    ok;
     30  uintptr_t               to_alloc;
    3231  void                   *alloced;
     32  rtems_resource_snapshot snapshot;
     33  void                   *greedy;
    3334
    3435  puts( "\n\n*** TEST KEY 02 ***" );
    3536
    36   puts( "Init - rtems_workspace_get_information - OK" );
    37   sb = rtems_workspace_get_information( &start );
    38   rtems_test_assert( sb );
    39 
    40   #if 0
    41     printf( "Init - workspace free = %d\n", start.Free.largest );
    42     printf( "Init - workspace free blocks = %d\n", start.Free.number );
    43   #endif
    44   rtems_test_assert( start.Free.number == 1 );
    45   to_alloc = start.Free.largest;
    46 
    47   /* find the largest we can actually allocate */
    48   while ( 1 ) {
    49     sb = rtems_workspace_allocate( to_alloc, &alloced );
    50     if ( sb )
    51       break;
    52     to_alloc -= 4;
    53   }
    54 
    55   rtems_workspace_free( alloced );
    56 
    57   #if 0
    58     printf( "Init - start with to_alloc of = %d\n", to_alloc );
    59   #endif
    60 
    61   /*
    62    * Verify heap is still in same shape if we couldn't allocate a task
    63    */
    64   sb = rtems_workspace_get_information( &info );
    65   rtems_test_assert( sb );
    66   rtems_test_assert( info.Free.largest == start.Free.largest );
    67   rtems_test_assert( info.Free.number  == start.Free.number  );
     37  greedy = rtems_workspace_greedy_allocate_all_except_largest( &to_alloc );
     38  rtems_resource_snapshot_take( &snapshot );
    6839
    6940  puts( "Init - pthread_key_create - ENOMEM" );
    70   while (1) {
     41  while ( to_alloc > 8 ) {
     42    ok = rtems_workspace_allocate( to_alloc, &alloced );
     43    rtems_test_assert( ok );
    7144
    72     sb = rtems_workspace_allocate( to_alloc, &alloced );
    73     rtems_test_assert( sb );
     45    eno = pthread_key_create( &key, NULL );
    7446
    75     sc = pthread_key_create( &key, NULL );
    76 
    77     /* free the memory we snagged, then check the status */
    7847    rtems_workspace_free( alloced );
    7948
    80     if ( !sc )
     49    if ( eno == 0 )
    8150      break;
    8251
    83     if ( sc != ENOMEM ) {
    84       printf( "key create returned %s\n", strerror(sc) );
    85       rtems_test_exit(0);
    86     }
     52    rtems_test_assert( eno == ENOMEM );
    8753
    8854    /*
    8955     * Verify heap is still in same shape if we couldn't allocate a task
    9056     */
    91     sb = rtems_workspace_get_information( &info );
    92     #if 0
    93       printf( "Init - workspace free/blocks = %d/%d\n",
    94         info.Free.largest, info.Free.number );
    95     #endif
    96     rtems_test_assert( sb );
    97     rtems_test_assert( info.Free.largest == start.Free.largest );
    98     rtems_test_assert( info.Free.number  == start.Free.number  );
     57    ok = rtems_resource_snapshot_check( &snapshot );
     58    rtems_test_assert( ok );
    9959
    10060    to_alloc -= 8;
    101     if ( to_alloc == 0 )
    102      break;
    10361  }
    10462
    105   if ( sc )
    106     rtems_test_exit(0);
     63  rtems_test_assert( eno == 0 );
    10764
    10865  /*
     
    11067   */
    11168  puts( "Init - pthread_key_delete - OK" );
    112   sc = pthread_key_delete( key );
    113   rtems_test_assert( sc == 0 );
     69  eno = pthread_key_delete( key );
     70  rtems_test_assert( eno == 0 );
    11471
    11572  puts( "Init - verify workspace has same memory" );
    116   sb = rtems_workspace_get_information( &info );
    117   #if 0
    118     printf( "Init - workspace free/blocks = %d/%d\n",
    119       info.Free.largest, info.Free.number );
    120   #endif
    121   rtems_test_assert( sb );
    122   rtems_test_assert( info.Free.largest == start.Free.largest );
    123   rtems_test_assert( info.Free.number  == start.Free.number  );
     73  ok = rtems_resource_snapshot_check( &snapshot );
     74  rtems_test_assert( ok );
     75
     76  rtems_workspace_greedy_free( greedy );
    12477
    12578  puts( "*** END OF TEST KEY 02 ***" );
  • testsuites/psxtests/psxkey02/psxkey02.scn

    rd79973d r22c7a64  
    11*** TEST KEY 02 ***
    2 Init - rtems_workspace_get_information - OK
    32Init - pthread_key_create - ENOMEM
    43Init - pthread_key_delete - OK
Note: See TracChangeset for help on using the changeset viewer.