summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-31 16:17:02 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-31 16:17:02 +0000
commite6e75e20f76c6302bcb4fc3572c00873a464283f (patch)
tree194fe84b40c35edfaada406f29da8eaf46cc9769
parent2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff)
downloadrtems-e6e75e20f76c6302bcb4fc3572c00873a464283f.tar.bz2
2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1867/cpukit * Makefile.am, configure.ac, psx12/task.c, psxrwlock01/test.c: Correct implementation of pthread_exit() and pthread_join() to support the case where a thread is joinable but calls pthread_exit() before a thread has attempted to join. * psx16/.cvsignore, psx16/Makefile.am, psx16/init.c, psx16/psx16.doc, psx16/psx16.scn: New files.
-rw-r--r--testsuites/psxtests/ChangeLog20
-rw-r--r--testsuites/psxtests/Makefile.am6
-rw-r--r--testsuites/psxtests/configure.ac1
-rw-r--r--testsuites/psxtests/psx12/task.c5
-rw-r--r--testsuites/psxtests/psx16/.cvsignore2
-rw-r--r--testsuites/psxtests/psx16/Makefile.am25
-rw-r--r--testsuites/psxtests/psx16/init.c78
-rw-r--r--testsuites/psxtests/psx16/psx16.doc24
-rw-r--r--testsuites/psxtests/psx16/psx16.scn6
-rw-r--r--testsuites/psxtests/psxrwlock01/test.c10
10 files changed, 169 insertions, 8 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog
index c86b97bfad..f241463258 100644
--- a/testsuites/psxtests/ChangeLog
+++ b/testsuites/psxtests/ChangeLog
@@ -1,4 +1,14 @@
-2008-09-06 Ralf Corsépius <ralf.corsepius@rtems.org>
+2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com>
+
+ PR 1867/cpukit
+ * Makefile.am, configure.ac, psx12/task.c, psxrwlock01/test.c: Correct
+ implementation of pthread_exit() and pthread_join() to support the
+ case where a thread is joinable but calls pthread_exit() before a
+ thread has attempted to join.
+ * psx16/.cvsignore, psx16/Makefile.am, psx16/init.c, psx16/psx16.doc,
+ psx16/psx16.scn: New files.
+
+2008-09-06 Ralf Corsépius <ralf.corsepius@rtems.org>
* psxcleanup/psxcleanup.c, psxfatal_support/init.c,
psxfatal_support/system.h: Convert to "bool".
@@ -226,7 +236,7 @@
* psxrwlock01/main.c, psxrwlock01/test.c: Improve rwlock test to
include normal blocking and unblocking on timeout.
-2006-12-02 Ralf Corsépius <ralf.corsepius@rtems.org>
+2006-12-02 Ralf Corsépius <ralf.corsepius@rtems.org>
* configure.ac: New BUG-REPORT address.
@@ -260,11 +270,11 @@
* psxsem01/init.c: Make sem_timedwait more conformant to Open Group
specification.
-2006-10-17 Ralf Corsépius <ralf.corsepius@rtems.org>
+2006-10-17 Ralf Corsépius <ralf.corsepius@rtems.org>
* configure.ac: Require autoconf-2.60. Require automake-1.10.
-2006-07-11 Ralf Corsépius <ralf.corsepius@rtems.org>
+2006-07-11 Ralf Corsépius <ralf.corsepius@rtems.org>
* psx01/Makefile.am, psx02/Makefile.am, psx03/Makefile.am,
psx04/Makefile.am, psx05/Makefile.am, psx06/Makefile.am,
@@ -450,7 +460,7 @@
* psxfile01/test.c, psxmsgq01/init.c, psxstat/test.c,
psxtimer/psxtimer.c: Eliminate warnings and typos.
-2004-02-26 Sébastien Barré <sbarre@sdelcc.com>
+2004-02-26 Sébastien Barré <sbarre@sdelcc.com>
PR 582/core
* psxmsgq01/init.c, psxmsgq01/psxmsgq01.scn: Fix the POSIX message
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index bfcc089328..70d9734663 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -5,9 +5,9 @@
ACLOCAL_AMFLAGS = -I ../aclocal
SUBDIRS = psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
- psx10 psx11 psx12 psx13 psx14 psxcleanup psxtime psxtimer01 psxtimer02 \
- psxcancel psxbarrier01 psxmsgq01 psxmsgq02 psxrwlock01 psxsem01 \
- psxspin01 psxenosys psxsignal01 psxsysconf psxualarm psxkey01 \
+ psx10 psx11 psx12 psx13 psx14 psx16 psxcleanup psxtime psxtimer01 \
+ psxtimer02 psxcancel psxbarrier01 psxmsgq01 psxmsgq02 psxrwlock01
+ psxsem01 psxspin01 psxenosys psxsignal01 psxsysconf psxualarm psxkey01 \
psxfatal01 psxfatal02
## File IO tests
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index 35dc04e7bb..d7f1c7d0d6 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -41,6 +41,7 @@ psx11/Makefile
psx12/Makefile
psx13/Makefile
psx14/Makefile
+psx16/Makefile
psxbarrier01/Makefile
psxcancel/Makefile
psxchroot01/Makefile
diff --git a/testsuites/psxtests/psx12/task.c b/testsuites/psxtests/psx12/task.c
index 67e5a68e40..1d3804da4f 100644
--- a/testsuites/psxtests/psx12/task.c
+++ b/testsuites/psxtests/psx12/task.c
@@ -26,6 +26,11 @@ void *Task_1(
void *argument
)
{
+ /*
+ * Detach ourselves so we don't wait for a join that won't happen.
+ */
+ pthread_detach( pthread_self() );
+
puts( "Task_1: exitting" );
pthread_exit( NULL );
diff --git a/testsuites/psxtests/psx16/.cvsignore b/testsuites/psxtests/psx16/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/psxtests/psx16/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/psxtests/psx16/Makefile.am b/testsuites/psxtests/psx16/Makefile.am
new file mode 100644
index 0000000000..048d896440
--- /dev/null
+++ b/testsuites/psxtests/psx16/Makefile.am
@@ -0,0 +1,25 @@
+##
+## $Id$
+##
+
+rtems_tests_PROGRAMS = psx16
+psx16_SOURCES = init.c
+
+dist_rtems_tests_DATA = psx16.scn
+dist_rtems_tests_DATA += psx16.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psx16_OBJECTS) $(psx16_LDADD)
+LINK_LIBS = $(psx16_LDLIBS)
+
+psx16$(EXEEXT): $(psx16_OBJECTS) $(psx16_DEPENDENCIES)
+ @rm -f psx16$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psx16/init.c b/testsuites/psxtests/psx16/init.c
new file mode 100644
index 0000000000..c829d9aadd
--- /dev/null
+++ b/testsuites/psxtests/psx16/init.c
@@ -0,0 +1,78 @@
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * 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 <tmacros.h>
+#include "test_support.h"
+#include <pthread.h>
+
+int Index;
+
+void *TestThread(
+ void *argument
+)
+{
+ int *index = (int *)argument;
+
+ *index = 7;
+
+ puts( "TestThread exiting" );
+ return argument;
+}
+
+void *POSIX_Init(
+ rtems_task_argument argument
+)
+{
+ int status;
+ pthread_t id;
+ pthread_attr_t attr;
+ void *join_return;
+
+ puts( "\n\n*** POSIX TEST PSX16 ***" );
+
+ Index = 5;
+
+ /* Initialize and set thread detached attribute */
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ puts( "Creating TestThread" );
+ status = pthread_create( &id, &attr, TestThread, (void *)&Index );
+ rtems_test_assert( status == 0 );
+
+ /* let test thread run and exit */
+ puts( "Let TestThread run and exit before we attempt to join" );
+ sleep( 2 );
+
+ join_return = NULL;
+ status = pthread_join( id, &join_return );
+ rtems_test_assert( status == 0 );
+ rtems_test_assert( join_return == &Index );
+ rtems_test_assert( *(int *)join_return == 7 );
+ puts( "Successfully joined with TestThread" );
+
+ puts( "*** END OF POSIX TEST PSX16 ***" );
+
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+/* end of file */
diff --git a/testsuites/psxtests/psx16/psx16.doc b/testsuites/psxtests/psx16/psx16.doc
new file mode 100644
index 0000000000..e646efae52
--- /dev/null
+++ b/testsuites/psxtests/psx16/psx16.doc
@@ -0,0 +1,24 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989-2011.
+# 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.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: psx16
+
+directives:
+
+ pthread_join
+ pthread_exit
+
+concepts:
+
++ Ensure that if a joinable thread exits before it has been joined,
+that it waits for a thread to call pthread_join.
diff --git a/testsuites/psxtests/psx16/psx16.scn b/testsuites/psxtests/psx16/psx16.scn
new file mode 100644
index 0000000000..d01e954a57
--- /dev/null
+++ b/testsuites/psxtests/psx16/psx16.scn
@@ -0,0 +1,6 @@
+*** POSIX TEST PSX16 ***
+Creating TestThread
+Let TestThread run and exit before we attempt to join
+TestThread exiting
+Successfully joined with TestThread
+*** END OF POSIX TEST PSX16 ***
diff --git a/testsuites/psxtests/psxrwlock01/test.c b/testsuites/psxtests/psxrwlock01/test.c
index 270e512a55..9f9a647abb 100644
--- a/testsuites/psxtests/psxrwlock01/test.c
+++ b/testsuites/psxtests/psxrwlock01/test.c
@@ -30,6 +30,11 @@ void *ReadLockThread(void *arg)
{
int status;
+ /*
+ * Detach ourselves so we don't wait for a join that won't happen.
+ */
+ pthread_detach( pthread_self() );
+
puts( "ReadThread - pthread_rwlock_rdlock(RWLock) blocking -- OK" );
status = pthread_rwlock_rdlock(&RWLock);
assert( !status );
@@ -47,6 +52,11 @@ void *WriteLockThread(void *arg)
{
int status;
+ /*
+ * Detach ourselves so we don't wait for a join that won't happen.
+ */
+ pthread_detach( pthread_self() );
+
puts( "WriteThread - pthread_rwlock_wrlock(RWLock) blocking -- OK" );
status = pthread_rwlock_wrlock(&RWLock);
assert( !status );