forked from Imagelibrary/rtems
posix: Fix rwlock auto initialization
Add more test cases.
This commit is contained in:
@@ -35,7 +35,7 @@ bool _POSIX_RWLock_Auto_initialization( POSIX_RWLock_Control *the_rwlock )
|
||||
return false;
|
||||
}
|
||||
|
||||
the_rwlock->flags = POSIX_RWLOCK_MAGIC;
|
||||
the_rwlock->flags = (uintptr_t) the_rwlock ^ POSIX_RWLOCK_MAGIC;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -374,6 +374,12 @@ static void test_mutex_auto_initialization( void )
|
||||
|
||||
eno = pthread_mutex_lock( &mutex );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_mutex_unlock( &mutex );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_mutex_destroy( &mutex );
|
||||
rtems_test_assert( eno == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -51,6 +51,41 @@ void *BlockingThread(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void test_cond_auto_initialization( void )
|
||||
{
|
||||
int eno;
|
||||
|
||||
{
|
||||
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
eno = pthread_cond_destroy( &cond );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_cond_destroy( &cond );
|
||||
rtems_test_assert( eno == EINVAL );
|
||||
}
|
||||
|
||||
{
|
||||
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
eno = pthread_cond_signal( &cond );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_cond_destroy( &cond );
|
||||
rtems_test_assert( eno == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
eno = pthread_cond_broadcast( &cond );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_cond_destroy( &cond );
|
||||
rtems_test_assert( eno == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void *POSIX_Init(
|
||||
void *argument
|
||||
)
|
||||
@@ -60,6 +95,8 @@ void *POSIX_Init(
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
test_cond_auto_initialization();
|
||||
|
||||
puts( "Init - pthread_mutex_init - Mutex1 - OK" );
|
||||
sc = pthread_mutex_init( &Mutex1, NULL );
|
||||
fatal_posix_service_status( sc, 0, "mutex1 create ok" );
|
||||
|
||||
@@ -259,6 +259,12 @@ static void test_rwlock_auto_initialization( void )
|
||||
|
||||
eno = pthread_rwlock_rdlock( &rw );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_rwlock_unlock( &rw );
|
||||
rtems_test_assert( eno == 0 );
|
||||
|
||||
eno = pthread_rwlock_destroy( &rw );
|
||||
rtems_test_assert( eno == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user