Changeset fc0756e in rtems for testsuites/support


Ignore:
Timestamp:
Apr 14, 2015, 3:01:05 PM (5 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
5049dca
Parents:
0a73de2
git-author:
Joel Sherrill <joel.sherrill@…> (04/14/15 15:01:05)
git-committer:
Joel Sherrill <joel.sherrill@…> (04/14/15 16:17:10)
Message:

Add test assertion for allocator mutex being unlocked

The Allocator Mutex should not be locked outside a tested
service call. In an SMP test or heavily multithreaded test,
this is possible since another thread could have the lock
for an extended period of time but this is not the norm
for the tests.

updates 2319.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/support/include/tmacros.h

    r0a73de2 rfc0756e  
    4747 *  mode/state of the test.  Normally it should be 0 when in task space.
    4848 *
    49  *  This test is only valid when in a non smp system.  In an smp system
     49 *  This test is only valid when in a non-SMP system.  In an smp system
    5050 *  another cpu may be accessing the core at any point when this core
    5151 *  does not have it locked.
     
    7171
    7272/*
     73 *  Check that that the allocator mutex is not locked. It should never
     74 *  be locked unless inside a service which is allocating a resource.
     75 *
     76 *  This test is only valid when in a non-SMP system.  In an SMP system
     77 *  another cpu may be allocating a resource while we are computing.
     78 */
     79#if defined SMPTEST
     80  #define check_if_allocator_mutex_is_unlocked()
     81#else
     82  #include <rtems/score/apimutex.h>
     83  #define check_if_allocator_mutex_is_unlocked() \
     84    do { \
     85      if ( _RTEMS_Check_if_allocator_is_locked() ) { \
     86        printk( \
     87          "\nRTEMS Allocator Mutex is locked and should not be.\n" \
     88          "Detected at %s:%d\n", \
     89          __FILE__, \
     90          __LINE__ \
     91        ); \
     92        FLUSH_OUTPUT(); \
     93        rtems_test_exit( 1 ); \
     94      } \
     95    } while ( 0 )
     96#endif
     97
     98/*
    7399 *  These macros properly report errors within the Classic API
    74100 */
     
    96122  do { \
    97123    check_dispatch_disable_level( _level ); \
     124    check_if_allocator_mutex_is_unlocked(); \
    98125    fatal_directive_check_status_only( _stat, _desired, _msg ); \
    99126  } while ( 0 )
     
    113140    long statx = _stat; \
    114141    check_dispatch_disable_level( 0 ); \
     142    check_if_allocator_mutex_is_unlocked(); \
    115143    printf( "\n%s FAILED -- expected (%d - %s) got (%ld %d - %s)\n", \
    116144            (_msg), _desired, strerror(_desired), \
     
    126154  do { \
    127155    check_dispatch_disable_level( _level ); \
     156    check_if_allocator_mutex_is_unlocked(); \
    128157    if ( (_stat) != (_desired) ) { \
    129158      printf( "\n%s FAILED -- expected (%d - %s) got (%d - %s)\n", \
     
    135164    } \
    136165  } while ( 0 )
     166
     167/*
     168 * This macro evaluates the semaphore id returned.
     169 */
     170#define fatal_posix_sem( _ptr, _msg ) \
     171  if ( (_ptr != SEM_FAILED) ) { \
     172    check_dispatch_disable_level( 0 ); \
     173    printf( "\n%s FAILED -- expected (-1) got (%p - %d/%s)\n", \
     174            (_msg), _ptr, errno, strerror(errno) ); \
     175    FLUSH_OUTPUT(); \
     176    rtems_test_exit( -1 ); \
     177  }
     178
     179/*
     180 * This macro evaluates the message queue id returned.
     181 */
     182#define fatal_posix_mqd( _ptr, _msg ) \
     183  if ( (_ptr != (mqd_t) -1) ) { \
     184    check_dispatch_disable_level( 0 ); \
     185    printf( "\n%s FAILED -- expected (-1) got (%" PRId32 " - %d/%s)\n", \
     186            (_msg), _ptr, errno, strerror(errno) ); \
     187    FLUSH_OUTPUT(); \
     188    rtems_test_exit( -1 ); \
     189  }
    137190
    138191/*
Note: See TracChangeset for help on using the changeset viewer.