diff options
author | Joel Sherrill <joel.sherrill@oarcorp.com> | 2015-04-14 10:01:05 -0500 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@oarcorp.com> | 2015-04-14 11:17:10 -0500 |
commit | fc0756e8d9caf1155e2df1ad4a1282619c6668f1 (patch) | |
tree | bf4aa3a51cac86cfb220a6d34ba7538d60fb780e /testsuites/support/include | |
parent | or1ksim: Fix bug at UART driver. (diff) | |
download | rtems-fc0756e8d9caf1155e2df1ad4a1282619c6668f1.tar.bz2 |
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.
Diffstat (limited to 'testsuites/support/include')
-rw-r--r-- | testsuites/support/include/tmacros.h | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/testsuites/support/include/tmacros.h b/testsuites/support/include/tmacros.h index 2b0df83eff..a67bb956e9 100644 --- a/testsuites/support/include/tmacros.h +++ b/testsuites/support/include/tmacros.h @@ -46,7 +46,7 @@ extern "C" { * Check that that the dispatch disable level is proper for the * mode/state of the test. Normally it should be 0 when in task space. * - * This test is only valid when in a non smp system. In an smp system + * This test is only valid when in a non-SMP system. In an smp system * another cpu may be accessing the core at any point when this core * does not have it locked. */ @@ -70,6 +70,32 @@ extern "C" { #endif /* + * Check that that the allocator mutex is not locked. It should never + * be locked unless inside a service which is allocating a resource. + * + * This test is only valid when in a non-SMP system. In an SMP system + * another cpu may be allocating a resource while we are computing. + */ +#if defined SMPTEST + #define check_if_allocator_mutex_is_unlocked() +#else + #include <rtems/score/apimutex.h> + #define check_if_allocator_mutex_is_unlocked() \ + do { \ + if ( _RTEMS_Check_if_allocator_is_locked() ) { \ + printk( \ + "\nRTEMS Allocator Mutex is locked and should not be.\n" \ + "Detected at %s:%d\n", \ + __FILE__, \ + __LINE__ \ + ); \ + FLUSH_OUTPUT(); \ + rtems_test_exit( 1 ); \ + } \ + } while ( 0 ) +#endif + +/* * These macros properly report errors within the Classic API */ #define directive_failed( _dirstat, _failmsg ) \ @@ -95,6 +121,7 @@ extern "C" { #define fatal_directive_status_with_level( _stat, _desired, _msg, _level ) \ do { \ check_dispatch_disable_level( _level ); \ + check_if_allocator_mutex_is_unlocked(); \ fatal_directive_check_status_only( _stat, _desired, _msg ); \ } while ( 0 ) @@ -112,6 +139,7 @@ extern "C" { if ( (_stat != -1) && (errno) != (_desired) ) { \ long statx = _stat; \ check_dispatch_disable_level( 0 ); \ + check_if_allocator_mutex_is_unlocked(); \ printf( "\n%s FAILED -- expected (%d - %s) got (%ld %d - %s)\n", \ (_msg), _desired, strerror(_desired), \ statx, errno, strerror(errno) ); \ @@ -125,6 +153,7 @@ extern "C" { #define fatal_posix_service_status_with_level( _stat, _desired, _msg, _level ) \ do { \ check_dispatch_disable_level( _level ); \ + check_if_allocator_mutex_is_unlocked(); \ if ( (_stat) != (_desired) ) { \ printf( "\n%s FAILED -- expected (%d - %s) got (%d - %s)\n", \ (_msg), _desired, strerror(_desired), _stat, strerror(_stat) ); \ @@ -136,6 +165,30 @@ extern "C" { } while ( 0 ) /* + * This macro evaluates the semaphore id returned. + */ +#define fatal_posix_sem( _ptr, _msg ) \ + if ( (_ptr != SEM_FAILED) ) { \ + check_dispatch_disable_level( 0 ); \ + printf( "\n%s FAILED -- expected (-1) got (%p - %d/%s)\n", \ + (_msg), _ptr, errno, strerror(errno) ); \ + FLUSH_OUTPUT(); \ + rtems_test_exit( -1 ); \ + } + +/* + * This macro evaluates the message queue id returned. + */ +#define fatal_posix_mqd( _ptr, _msg ) \ + if ( (_ptr != (mqd_t) -1) ) { \ + check_dispatch_disable_level( 0 ); \ + printf( "\n%s FAILED -- expected (-1) got (%" PRId32 " - %d/%s)\n", \ + (_msg), _ptr, errno, strerror(errno) ); \ + FLUSH_OUTPUT(); \ + rtems_test_exit( -1 ); \ + } + +/* * Generic integer version of the error reporting */ |