diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-07-16 08:31:05 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-07-16 08:58:11 +0200 |
commit | 6ec7f2102e6517c60a70acd1421cbc4106495513 (patch) | |
tree | 41ceedbff1e80abf239f32de5fd3d9e85bc9163c | |
parent | jffs2: Add README (diff) | |
download | rtems-6ec7f2102e6517c60a70acd1421cbc4106495513.tar.bz2 |
posix: Fix rwlock auto initialization
Add more test cases.
-rw-r--r-- | cpukit/posix/src/prwlockunlock.c | 2 | ||||
-rw-r--r-- | testsuites/psxtests/psx05/init.c | 6 | ||||
-rw-r--r-- | testsuites/psxtests/psxcond01/init.c | 37 | ||||
-rw-r--r-- | testsuites/psxtests/psxrwlock01/test.c | 6 |
4 files changed, 50 insertions, 1 deletions
diff --git a/cpukit/posix/src/prwlockunlock.c b/cpukit/posix/src/prwlockunlock.c index 92cc0bfde2..2d34f5e393 100644 --- a/cpukit/posix/src/prwlockunlock.c +++ b/cpukit/posix/src/prwlockunlock.c @@ -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; } diff --git a/testsuites/psxtests/psx05/init.c b/testsuites/psxtests/psx05/init.c index 70e8d4a67d..2459166321 100644 --- a/testsuites/psxtests/psx05/init.c +++ b/testsuites/psxtests/psx05/init.c @@ -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 ); } { diff --git a/testsuites/psxtests/psxcond01/init.c b/testsuites/psxtests/psxcond01/init.c index 69dc5458ca..4d21531c8a 100644 --- a/testsuites/psxtests/psxcond01/init.c +++ b/testsuites/psxtests/psxcond01/init.c @@ -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" ); diff --git a/testsuites/psxtests/psxrwlock01/test.c b/testsuites/psxtests/psxrwlock01/test.c index 341c5d8f28..3599d1f64e 100644 --- a/testsuites/psxtests/psxrwlock01/test.c +++ b/testsuites/psxtests/psxrwlock01/test.c @@ -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 ); } { |