From bdc468a9c52ff89ff79fab84a1cbc6bfa8c872ca Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 22 Sep 2017 08:22:11 +0200 Subject: posix: Allow PTHREAD_PROCESS_SHARED for rwlocks Close #3153. --- testsuites/psxtests/psxrwlock01/test.c | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'testsuites') diff --git a/testsuites/psxtests/psxrwlock01/test.c b/testsuites/psxtests/psxrwlock01/test.c index e201293328..268f581a3e 100644 --- a/testsuites/psxtests/psxrwlock01/test.c +++ b/testsuites/psxtests/psxrwlock01/test.c @@ -90,6 +90,42 @@ void *WriteLockThread(void *arg) return NULL; } +static void test_pshared_init(void) +{ + pthread_rwlock_t rwlock; + pthread_rwlockattr_t attr; + int eno; + + eno = pthread_rwlockattr_init(&attr); + rtems_test_assert(eno == 0); + + eno = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE); + rtems_test_assert(eno == 0); + + eno = pthread_rwlock_init(&rwlock, &attr); + rtems_test_assert(eno == 0); + + eno = pthread_rwlock_destroy(&rwlock); + rtems_test_assert(eno == 0); + + eno = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); + rtems_test_assert(eno == 0); + + eno = pthread_rwlock_init(&rwlock, &attr); + rtems_test_assert(eno == 0); + + eno = pthread_rwlock_destroy(&rwlock); + rtems_test_assert(eno == 0); + + attr.process_shared = -1; + + eno = pthread_rwlock_init(&rwlock, &attr); + rtems_test_assert(eno == EINVAL); + + eno = pthread_rwlockattr_destroy(&attr); + rtems_test_assert(eno == 0); +} + /* * main entry point to the test */ @@ -113,6 +149,8 @@ int main( TEST_BEGIN(); + test_pshared_init(); + /*************** NULL POINTER CHECKS *****************/ puts( "pthread_rwlockattr_init( NULL ) -- EINVAL" ); status = pthread_rwlockattr_init( NULL ); -- cgit v1.2.3