diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2006-11-15 14:10:06 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2006-11-15 14:10:06 +0000 |
commit | 7c6dac1e24be1cd6d9b137f2055ac3fbc1cccff8 (patch) | |
tree | 31cfb7809c569fb01a36a9dc6b6e2daa2d3d7fb3 /testsuites/psxtests/psxrwlock01 | |
parent | 2006-11-15 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-7c6dac1e24be1cd6d9b137f2055ac3fbc1cccff8.tar.bz2 |
2006-11-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* psxrwlock01/.cvsignore, psxrwlock01/Makefile.am, psxrwlock01/main.c,
psxrwlock01/psxrwlock01.scn, psxrwlock01/test.c,
psxspin01/.cvsignore, psxspin01/Makefile.am, psxspin01/main.c,
psxspin01/psxspin01.scn, psxspin01/test.c: New files.
Diffstat (limited to 'testsuites/psxtests/psxrwlock01')
-rw-r--r-- | testsuites/psxtests/psxrwlock01/.cvsignore | 2 | ||||
-rw-r--r-- | testsuites/psxtests/psxrwlock01/Makefile.am | 30 | ||||
-rw-r--r-- | testsuites/psxtests/psxrwlock01/main.c | 47 | ||||
-rw-r--r-- | testsuites/psxtests/psxrwlock01/psxrwlock01.scn | 0 | ||||
-rw-r--r-- | testsuites/psxtests/psxrwlock01/test.c | 268 |
5 files changed, 347 insertions, 0 deletions
diff --git a/testsuites/psxtests/psxrwlock01/.cvsignore b/testsuites/psxtests/psxrwlock01/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/psxtests/psxrwlock01/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/psxtests/psxrwlock01/Makefile.am b/testsuites/psxtests/psxrwlock01/Makefile.am new file mode 100644 index 0000000000..3780b8d1dd --- /dev/null +++ b/testsuites/psxtests/psxrwlock01/Makefile.am @@ -0,0 +1,30 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = psxrwlock01.exe +psxrwlock01_exe_SOURCES = main.c test.c ../include/pmacros.h + +scndir = $(rtems_testsdir) +dist_scn_DATA = psxrwlock01.scn + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +psxrwlock01_exe_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel) + +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(psxrwlock01_exe_OBJECTS) $(psxrwlock01_exe_LDADD) +LINK_LIBS = $(psxrwlock01_exe_LDLIBS) + +psxrwlock01.exe$(EXEEXT): $(psxrwlock01_exe_OBJECTS) \ + $(psxrwlock01_exe_DEPENDENCIES) + @rm -f psxrwlock01.exe$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtests/psxrwlock01/main.c b/testsuites/psxtests/psxrwlock01/main.c new file mode 100644 index 0000000000..adf3e32ec3 --- /dev/null +++ b/testsuites/psxtests/psxrwlock01/main.c @@ -0,0 +1,47 @@ +/* + * Simple test program -- simplified version of sample test hello. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#define TEST_INIT + +#include <bsp.h> +#include <pmacros.h> + +void test_main( void ); + +rtems_task Init( + rtems_task_argument ignored +) +{ + test_main(); + rtems_test_exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 2 + +#define CONFIGURE_MAXIMUM_POSIX_RWLOCKS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE +#define CONFIGURE_INIT_TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE * 2) +#define CONFIGURE_INIT_TASK_PRIORITY 2 +#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> + +/* end of file */ diff --git a/testsuites/psxtests/psxrwlock01/psxrwlock01.scn b/testsuites/psxtests/psxrwlock01/psxrwlock01.scn new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuites/psxtests/psxrwlock01/psxrwlock01.scn diff --git a/testsuites/psxtests/psxrwlock01/test.c b/testsuites/psxtests/psxrwlock01/test.c new file mode 100644 index 0000000000..cbe80967bf --- /dev/null +++ b/testsuites/psxtests/psxrwlock01/test.c @@ -0,0 +1,268 @@ +/* + * This test exercises the POSIX RWLock manager. + * + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include <assert.h> +#include <stdio.h> +#include <errno.h> +#include <stdlib.h> + +/* #define __USE_XOPEN2K XXX already defined on GNU/Linux */ +#include <pthread.h> + +#define NUMBER_THREADS 2 +pthread_t ThreadIds[NUMBER_THREADS]; +pthread_rwlock_t RWLock; + +void *RWLockThread(void *arg) +{ + return NULL; +} + +/* + * main entry point to the test + */ + +#if defined(__rtems__) +int test_main(void) +#else +int main( + int argc, + char **argv +) +#endif +{ + pthread_rwlock_t rwlock; + pthread_rwlockattr_t attr; + int status; + int p; + pthread_t thread_id; + int i; + struct timespec abstime; + + puts( "\n\n*** POSIX RWLOCK TEST 01 ***" ); + + /*************** NULL POINTER CHECKS *****************/ + puts( "pthread_rwlockattr_init( NULL ) -- EINVAL" ); + status = pthread_rwlockattr_init( NULL ); + assert( status == EINVAL ); + + puts( "pthread_rwlockattr_setpshared( NULL, private ) -- EINVAL" ); + status = pthread_rwlockattr_setpshared( NULL, PTHREAD_PROCESS_PRIVATE ); + assert( status == EINVAL ); + + puts( "pthread_rwlockattr_setpshared( NULL, shared ) -- EINVAL" ); + status = pthread_rwlockattr_setpshared( NULL, PTHREAD_PROCESS_SHARED ); + assert( status == EINVAL ); + + puts( "pthread_rwlockattr_getpshared( NULL, &p ) -- EINVAL" ); + status = pthread_rwlockattr_getpshared( NULL, &p ); + assert( status == EINVAL ); + + puts( "pthread_rwlockattr_destroy( NULL ) -- EINVAL" ); + status = pthread_rwlockattr_destroy( NULL ); + assert( status == EINVAL ); + + /*************** NOT INITIALIZED CHECKS *****************/ + /* cheat visibility */ + attr.is_initialized = 0; + puts( "pthread_rwlockattr_setpshared( &attr, shared ) -- EINVAL" ); + status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_SHARED ); + assert( status == EINVAL ); + + puts( "pthread_rwlockattr_getpshared( &attr, NULL ) -- EINVAL" ); + status = pthread_rwlockattr_getpshared( &attr, NULL ); + assert( status == EINVAL ); + + puts( "pthread_rwlockattr_destroy( &attr ) -- EINVAL" ); + status = pthread_rwlockattr_destroy( &attr ); + assert( status == EINVAL ); + + + /*************** ACTUALLY WORK THIS TIME *****************/ + + puts( "pthread_rwlockattr_init( &attr ) -- OK" ); + status = pthread_rwlockattr_init( &attr ); + assert( status == 0 ); + + puts( "pthread_rwlockattr_setpshared( &attr, private ) -- OK" ); + status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE ); + assert( status == 0 ); + + puts( "pthread_rwlockattr_getpshared( &attr, &p ) -- OK" ); + status = pthread_rwlockattr_getpshared( &attr, &p ); + assert( status == 0 ); + assert( p == PTHREAD_PROCESS_PRIVATE ); + + puts( "pthread_rwlockattr_setpshared( &attr, shared ) -- OK" ); + status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_SHARED ); + assert( status == 0 ); + + puts( "pthread_rwlockattr_getpshared( &attr, &p ) -- OK" ); + status = pthread_rwlockattr_getpshared( &attr, &p ); + assert( status == 0 ); + assert( p == PTHREAD_PROCESS_SHARED ); + + /*************** BAD PSHARED CHECK *****************/ + puts( "pthread_rwlockattr_setpshared( &attr, private ) -- EINVAL" ); + status = pthread_rwlockattr_setpshared( &attr, ~PTHREAD_PROCESS_PRIVATE ); + assert( status == EINVAL ); + + /*************** DESTROY/REUSE CHECK *****************/ + puts( "pthread_rwlockattr_destroy( &attr ) -- OK" ); + status = pthread_rwlockattr_destroy( &attr ); + assert( status == 0 ); + + puts( "pthread_rwlockattr_getpshared( &attr, &p ) destroyed -- EINVAL" ); + status = pthread_rwlockattr_getpshared( &attr, &p ); + assert( status == EINVAL ); + + + /* XXX _init error checks */ + + /*************** NULL ID ARGUMENT CHECKS *****************/ + puts( "pthread_rwlock_init(NULL, &attr) -- EINVAL" ); + status = pthread_rwlock_init(NULL, &attr); + assert( status == EINVAL ); + + puts( "pthread_rwlock_init(&rwlock, NULL) -- EINVAL" ); + status = pthread_rwlock_init(&rwlock, NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_destroy(NULL) -- EINVAL" ); + status = pthread_rwlock_destroy(NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_rdlock(NULL) -- EINVAL" ); + status = pthread_rwlock_rdlock(NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_tryrdlock(NULL) -- EINVAL" ); + status = pthread_rwlock_tryrdlock(NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_timedrdlock( NULL, &abstime) -- EINVAL" ); + status = pthread_rwlock_timedrdlock( NULL, &abstime); + assert( status == EINVAL ); + + puts( "pthread_rwlock_timedrdlock( &rwlock, NULL) -- EINVAL" ); + status = pthread_rwlock_timedrdlock( &rwlock, NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_timedrdlock( &rwlock, NULL) -- EINVAL" ); + status = pthread_rwlock_timedrdlock( &rwlock, NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_wrlock(NULL) -- EINVAL" ); + status = pthread_rwlock_wrlock(NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_trywrlock(NULL) -- EINVAL" ); + status = pthread_rwlock_trywrlock(NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_timedwrlock( NULL, &abstime) -- EINVAL" ); + status = pthread_rwlock_timedwrlock( NULL, &abstime ); + assert( status == EINVAL ); + + puts( "pthread_rwlock_timedwrlock( &rwlock, NULL) -- EINVAL" ); + status = pthread_rwlock_timedwrlock( &rwlock, NULL); + assert( status == EINVAL ); + + + /*************** BAD ID CHECK *****************/ + rwlock = 1; + + /* XXX make a valid abstime */ + + puts( "pthread_rwlock_destroy(BadId) -- EINVAL" ); + status = pthread_rwlock_destroy(&rwlock); + assert( status == EINVAL ); + + puts( "pthread_rwlock_rdlock(BadId) -- EINVAL" ); + status = pthread_rwlock_rdlock(NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_tryrdlock(BadId) -- EINVAL" ); + status = pthread_rwlock_tryrdlock(NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_timedrdlock( BadId, &abstime) -- EINVAL" ); + status = pthread_rwlock_timedrdlock( NULL, &abstime); + assert( status == EINVAL ); + + puts( "pthread_rwlock_timedrdlock( &rwlock, BadId) -- EINVAL" ); + status = pthread_rwlock_timedrdlock( &rwlock, NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_timedrdlock( &rwlock, BadId) -- EINVAL" ); + status = pthread_rwlock_timedrdlock( &rwlock, NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_wrlock(BadId) -- EINVAL" ); + status = pthread_rwlock_wrlock(NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_trywrlock(BadId) -- EINVAL" ); + status = pthread_rwlock_trywrlock(NULL); + assert( status == EINVAL ); + + puts( "pthread_rwlock_timedwrlock( BadId, &abstime) -- EINVAL" ); + status = pthread_rwlock_timedwrlock( &rwlock, &abstime ); + assert( status == EINVAL ); + + /*************** BAD ABSTIME CHECK *****************/ + + /* in the past */ + abstime.tv_sec = 0; + abstime.tv_nsec = 0; + + /* invalid tv_nsec */ + abstime.tv_sec = 0; + abstime.tv_nsec = 0x7fffffffL; + + + + /*************** ACTUALLY CREATE ONE CHECK *****************/ + puts( "pthread_rwlockattr_init( &attr ) -- OK" ); + status = pthread_rwlockattr_init( &attr ); + assert( status == 0 ); + + puts( "pthread_rwlock_init( &rwlock, &attr ) -- OK" ); + status = pthread_rwlock_init( &rwlock, &attr ); + assert( status == 0 ); + assert( rwlock != 0 ); + + puts( "pthread_rwlock_destroy( &rwlock ) -- OK" ); + status = pthread_rwlock_destroy( &rwlock ); + assert( status == 0 ); + +#if 0 + /*************** CREATE TESTS AND LET THEM RELEASE *****************/ + puts( "pthread_rwlock_init( &RWLock, &attr, 2 ) -- OK" ); + status = pthread_rwlock_init( &RWLock, &attr, 2 ); + assert( status == 0 ); + assert( rwlock != 0 ); + + for (i=0 ; i<NUMBER_THREADS ; i++ ) { + printf( "Init: pthread_create - thread %d OK\n", i+1 ); + status = pthread_create(&ThreadIds[i], NULL, RWLockThread, &ThreadIds[i]); + assert( !status ); + + sleep(1); + } +#endif + + /*************** END OF TEST *****************/ + puts( "*** END OF POSIX RWLOCK TEST 01 ***" ); + exit(0); +} |