summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2006-11-15 14:09:07 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2006-11-15 14:09:07 +0000
commitb4e79bc271421dd77ae8a5d409c1bd5bf879fe6e (patch)
treee8217fa9c42c97871526ad221382759515c7555f /testsuites
parent2006-11-15 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-b4e79bc271421dd77ae8a5d409c1bd5bf879fe6e.tar.bz2
2006-11-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac: Adding POSIX barriers, POSIX spinlocks, and partial implementation of POSIX rwlocks. * psxbarrier01/.cvsignore, psxbarrier01/Makefile.am, psxbarrier01/psxbarrier01.scn, psxbarrier01/test.c: New files.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/psxtests/ChangeLog7
-rw-r--r--testsuites/psxtests/Makefile.am3
-rw-r--r--testsuites/psxtests/configure.ac3
-rw-r--r--testsuites/psxtests/psxbarrier01/.cvsignore2
-rw-r--r--testsuites/psxtests/psxbarrier01/Makefile.am30
-rw-r--r--testsuites/psxtests/psxbarrier01/psxbarrier01.scn0
-rw-r--r--testsuites/psxtests/psxbarrier01/test.c175
7 files changed, 219 insertions, 1 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog
index 10d8eebedc..76a83f25bd 100644
--- a/testsuites/psxtests/ChangeLog
+++ b/testsuites/psxtests/ChangeLog
@@ -1,3 +1,10 @@
+2006-11-15 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * Makefile.am, configure.ac: Adding POSIX barriers, POSIX spinlocks,
+ and partial implementation of POSIX rwlocks.
+ * psxbarrier01/.cvsignore, psxbarrier01/Makefile.am,
+ psxbarrier01/psxbarrier01.scn, psxbarrier01/test.c: New files.
+
2006-10-30 Joel Sherrill <joel@OARcorp.com>
PR 841/rtems
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index 1e92a47bc4..418b40870f 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -5,7 +5,8 @@
ACLOCAL_AMFLAGS = -I ../aclocal
SUBDIRS = psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
- psx10 psx11 psx12 psxtime psxtimer psxcancel psxmsgq01 psxsem01
+ psx10 psx11 psx12 psxtime psxtimer psxcancel psxbarrier01 psxmsgq01 \
+ psxrwlock01 psxsem01 psxspin01
SUBDIRS += psxfile01 psxreaddir psxstat psxmount psx13 psxchroot01
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index 68c8290a83..15ded022c0 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -39,6 +39,7 @@ psx10/Makefile
psx11/Makefile
psx12/Makefile
psx13/Makefile
+psxbarrier01/Makefile
psxcancel/Makefile
psxchroot01/Makefile
psxfile01/Makefile
@@ -46,7 +47,9 @@ psxhdrs/Makefile
psxmount/Makefile
psxmsgq01/Makefile
psxreaddir/Makefile
+psxrwlock01/Makefile
psxsem01/Makefile
+psxspin01/Makefile
psxstat/Makefile
psxtime/Makefile
psxtimer/Makefile
diff --git a/testsuites/psxtests/psxbarrier01/.cvsignore b/testsuites/psxtests/psxbarrier01/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/psxtests/psxbarrier01/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/psxtests/psxbarrier01/Makefile.am b/testsuites/psxtests/psxbarrier01/Makefile.am
new file mode 100644
index 0000000000..27c5687409
--- /dev/null
+++ b/testsuites/psxtests/psxbarrier01/Makefile.am
@@ -0,0 +1,30 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxbarrier01.exe
+psxbarrier01_exe_SOURCES = main.c test.c ../include/pmacros.h
+
+scndir = $(rtems_testsdir)
+dist_scn_DATA = psxbarrier01.scn
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+psxbarrier01_exe_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxbarrier01_exe_OBJECTS) $(psxbarrier01_exe_LDADD)
+LINK_LIBS = $(psxbarrier01_exe_LDLIBS)
+
+psxbarrier01.exe$(EXEEXT): $(psxbarrier01_exe_OBJECTS) \
+ $(psxbarrier01_exe_DEPENDENCIES)
+ @rm -f psxbarrier01.exe$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxbarrier01/psxbarrier01.scn b/testsuites/psxtests/psxbarrier01/psxbarrier01.scn
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuites/psxtests/psxbarrier01/psxbarrier01.scn
diff --git a/testsuites/psxtests/psxbarrier01/test.c b/testsuites/psxtests/psxbarrier01/test.c
new file mode 100644
index 0000000000..9685c0c8e1
--- /dev/null
+++ b/testsuites/psxtests/psxbarrier01/test.c
@@ -0,0 +1,175 @@
+/*
+ * This test exercises the POSIX Barrier 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_barrier_t Barrier;
+
+void *BarrierThread(void *arg)
+{
+ pthread_t id = *(pthread_t *) arg;
+ int status;
+
+ printf( "pthread_barrier_wait( &Barrier ) for thread 0x%08x\n", id );
+ status = pthread_barrier_wait( &Barrier );
+ if ( id == ThreadIds[NUMBER_THREADS - 1] ) {
+ printf( "pthread_barrier_wait - 0x%08x auto released\n", id );
+ assert( status == PTHREAD_BARRIER_SERIAL_THREAD );
+ } else {
+ printf( "pthread_barrier_wait - 0x%08x released\n", id );
+ assert( status == 0 );
+ }
+
+ return NULL;
+}
+
+/*
+ * main entry point to the test
+ */
+
+#if defined(__rtems__)
+int test_main(void)
+#else
+int main(
+ int argc,
+ char **argv
+)
+#endif
+{
+ pthread_barrier_t barrier;
+ pthread_barrierattr_t attr;
+ int status;
+ int p;
+ pthread_t thread_id;
+ int i;
+
+ puts( "\n\n*** POSIX BARRIER TEST 01 ***" );
+
+ /*************** NULL POINTER CHECKS *****************/
+ puts( "pthread_barrierattr_init( NULL ) -- EINVAL" );
+ status = pthread_barrierattr_init( NULL );
+ assert( status == EINVAL );
+
+ puts( "pthread_barrierattr_setpshared( NULL, private ) -- EINVAL" );
+ status = pthread_barrierattr_setpshared( NULL, PTHREAD_PROCESS_PRIVATE );
+ assert( status == EINVAL );
+
+ puts( "pthread_barrierattr_setpshared( NULL, shared ) -- EINVAL" );
+ status = pthread_barrierattr_setpshared( NULL, PTHREAD_PROCESS_SHARED );
+ assert( status == EINVAL );
+
+ puts( "pthread_barrierattr_getpshared( NULL, &p ) -- EINVAL" );
+ status = pthread_barrierattr_getpshared( NULL, &p );
+ assert( status == EINVAL );
+
+ puts( "pthread_barrierattr_destroy( NULL ) -- EINVAL" );
+ status = pthread_barrierattr_destroy( NULL );
+ assert( status == EINVAL );
+
+ /*************** NOT INITIALIZED CHECKS *****************/
+ /* cheat visibility */
+ attr.is_initialized = 0;
+ puts( "pthread_barrierattr_setpshared( &attr, shared ) -- EINVAL" );
+ status = pthread_barrierattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
+ assert( status == EINVAL );
+
+ puts( "pthread_barrierattr_getpshared( &attr, NULL ) -- EINVAL" );
+ status = pthread_barrierattr_getpshared( &attr, NULL );
+ assert( status == EINVAL );
+
+ puts( "pthread_barrierattr_destroy( &attr ) -- EINVAL" );
+ status = pthread_barrierattr_destroy( &attr );
+ assert( status == EINVAL );
+
+
+ /*************** ACTUALLY WORK THIS TIME *****************/
+
+ puts( "pthread_barrierattr_init( &attr ) -- OK" );
+ status = pthread_barrierattr_init( &attr );
+ assert( status == 0 );
+
+ puts( "pthread_barrierattr_setpshared( &attr, private ) -- OK" );
+ status = pthread_barrierattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE );
+ assert( status == 0 );
+
+ puts( "pthread_barrierattr_getpshared( &attr, &p ) -- OK" );
+ status = pthread_barrierattr_getpshared( &attr, &p );
+ assert( status == 0 );
+ assert( p == PTHREAD_PROCESS_PRIVATE );
+
+ puts( "pthread_barrierattr_setpshared( &attr, shared ) -- OK" );
+ status = pthread_barrierattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
+ assert( status == 0 );
+
+ puts( "pthread_barrierattr_getpshared( &attr, &p ) -- OK" );
+ status = pthread_barrierattr_getpshared( &attr, &p );
+ assert( status == 0 );
+ assert( p == PTHREAD_PROCESS_SHARED );
+
+ /*************** BAD PSHARED CHECK *****************/
+ puts( "pthread_barrierattr_setpshared( &attr, private ) -- EINVAL" );
+ status = pthread_barrierattr_setpshared( &attr, ~PTHREAD_PROCESS_PRIVATE );
+ assert( status == EINVAL );
+
+ /*************** DESTROY/REUSE CHECK *****************/
+ puts( "pthread_barrierattr_destroy( &attr ) -- OK" );
+ status = pthread_barrierattr_destroy( &attr );
+ assert( status == 0 );
+
+ puts( "pthread_barrierattr_getpshared( &attr, &p ) destroyed -- EINVAL" );
+ status = pthread_barrierattr_getpshared( &attr, &p );
+ assert( status == EINVAL );
+
+
+ /* XXX _init error checks */
+
+ /*************** ACTUALLY CREATE ONE CHECK *****************/
+ puts( "pthread_barrierattr_init( &attr ) -- OK" );
+ status = pthread_barrierattr_init( &attr );
+ assert( status == 0 );
+
+ puts( "pthread_barrier_init( &barrier, &attr, 2 ) -- OK" );
+ status = pthread_barrier_init( &barrier, &attr, 2 );
+ assert( status == 0 );
+ assert( barrier != 0 );
+
+ puts( "pthread_barrier_destroy( &barrier ) -- OK" );
+ status = pthread_barrier_destroy( &barrier );
+ assert( status == 0 );
+
+ /*************** CREATE TESTS AND LET THEM RELEASE *****************/
+ puts( "pthread_barrier_init( &Barrier, &attr, 2 ) -- OK" );
+ status = pthread_barrier_init( &Barrier, &attr, 2 );
+ assert( status == 0 );
+ assert( barrier != 0 );
+
+ for (i=0 ; i<NUMBER_THREADS ; i++ ) {
+ printf( "Init: pthread_create - thread %d OK\n", i+1 );
+ status = pthread_create(&ThreadIds[i], NULL, BarrierThread, &ThreadIds[i]);
+ assert( !status );
+
+ sleep(1);
+ }
+
+ /*************** END OF TEST *****************/
+ puts( "*** END OF POSIX BARRIER TEST 01 ***" );
+ exit(0);
+}