summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-10-21 22:05:17 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-10-21 22:05:17 +0000
commit4fcd106dd4e09e4142ee0bc9eef0998215a114f1 (patch)
treed307e639b9b3855f2c416a8891f5d0b83d4aaf99 /testsuites/psxtests
parent2010-10-21 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-4fcd106dd4e09e4142ee0bc9eef0998215a114f1.tar.bz2
2010-10-21 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac: New test to ensure pthread_cond_wait() and sleep() (e.g. interruptible blocking and sleeping) are interruptible by signal. * psxsignal06/.cvsignore, psxsignal06/Makefile.am, psxsignal06/init.c, psxsignal06/psxsignal06.doc, psxsignal06/psxsignal06.scn: New files.
Diffstat (limited to 'testsuites/psxtests')
-rw-r--r--testsuites/psxtests/ChangeLog8
-rw-r--r--testsuites/psxtests/Makefile.am3
-rw-r--r--testsuites/psxtests/configure.ac1
-rw-r--r--testsuites/psxtests/psxsignal06/.cvsignore2
-rw-r--r--testsuites/psxtests/psxsignal06/Makefile.am25
-rw-r--r--testsuites/psxtests/psxsignal06/init.c124
-rw-r--r--testsuites/psxtests/psxsignal06/psxsignal06.doc24
-rw-r--r--testsuites/psxtests/psxsignal06/psxsignal06.scn11
8 files changed, 197 insertions, 1 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog
index 271f50ad08..678be85245 100644
--- a/testsuites/psxtests/ChangeLog
+++ b/testsuites/psxtests/ChangeLog
@@ -1,5 +1,13 @@
2010-10-21 Joel Sherrill <joel.sherrill@oarcorp.com>
+ * Makefile.am, configure.ac: New test to ensure pthread_cond_wait() and
+ sleep() (e.g. interruptible blocking and sleeping) are interruptible
+ by signal.
+ * psxsignal06/.cvsignore, psxsignal06/Makefile.am, psxsignal06/init.c,
+ psxsignal06/psxsignal06.doc, psxsignal06/psxsignal06.scn: New files.
+
+2010-10-21 Joel Sherrill <joel.sherrill@oarcorp.com>
+
* psx02/init.c, psx02/task.c, psx03/init.c, psx04/init.c,
psx04/task1.c, psx04/task2.c, psx04/task3.c, psx05/init.c,
psx05/task.c, psx05/task2.c, psx05/task3.c, psx06/init.c,
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index acec97dbf9..0009fc7e73 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -13,7 +13,8 @@ SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
psxcond01 psxenosys psxkey01 psxkey02 psxkey03 \
psxitimer psxmsgq01 psxmsgq02 psxmsgq03 psxmsgq04 \
psxmutexattr01 psxobj01 psxrwlock01 psxsem01 psxsignal01 psxsignal02 \
- psxsignal03 psxsignal04 psxsignal05 psxspin01 psxspin02 psxsysconf \
+ psxsignal03 psxsignal04 psxsignal05 psxsignal06 \
+ psxspin01 psxspin02 psxsysconf \
psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \
psxintrcritical01 psxstack01 psxstack02
endif
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index 756c07365d..458d945f19 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -142,6 +142,7 @@ psxsignal02/Makefile
psxsignal03/Makefile
psxsignal04/Makefile
psxsignal05/Makefile
+psxsignal06/Makefile
psxspin01/Makefile
psxspin02/Makefile
psxstack01/Makefile
diff --git a/testsuites/psxtests/psxsignal06/.cvsignore b/testsuites/psxtests/psxsignal06/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/psxtests/psxsignal06/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/psxtests/psxsignal06/Makefile.am b/testsuites/psxtests/psxsignal06/Makefile.am
new file mode 100644
index 0000000000..7988ebbde4
--- /dev/null
+++ b/testsuites/psxtests/psxsignal06/Makefile.am
@@ -0,0 +1,25 @@
+##
+## $Id$
+##
+
+rtems_tests_PROGRAMS = psxsignal06
+psxsignal06_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxsignal06.scn
+dist_rtems_tests_DATA += psxsignal06.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 = $(psxsignal06_OBJECTS) $(psxsignal06_LDADD)
+LINK_LIBS = $(psxsignal06_LDLIBS)
+
+psxsignal06$(EXEEXT): $(psxsignal06_OBJECTS) $(psxsignal06_DEPENDENCIES)
+ @rm -f psxsignal06$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxsignal06/init.c b/testsuites/psxtests/psxsignal06/init.c
new file mode 100644
index 0000000000..ba513e8220
--- /dev/null
+++ b/testsuites/psxtests/psxsignal06/init.c
@@ -0,0 +1,124 @@
+/*
+ * COPYRIGHT (c) 1989-2010.
+ * 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>
+#include <errno.h>
+
+pthread_t ThreadId;
+pthread_cond_t CondVarId;
+pthread_mutex_t MutexId;
+
+void Handler(
+ int signo
+)
+{
+}
+
+void *TestThread(
+ void *argument
+)
+{
+ int status;
+ sigset_t mask;
+ struct sigaction act;
+ unsigned int left;
+
+ /* unblock SIGUSR1 */
+ status = sigemptyset( &mask );
+ rtems_test_assert( !status );
+
+ status = sigaddset( &mask, SIGUSR1 );
+ rtems_test_assert( !status );
+
+ puts( "Test: Unblock SIGUSR1" );
+ status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
+ rtems_test_assert( !status );
+
+ /* install a signal handler for SIGUSR1 */
+ act.sa_handler = Handler;
+ act.sa_flags = 0;
+ sigaction( SIGUSR1, &act, NULL );
+
+ /* interrupting condition wait returns 0 */
+ puts( "Test: pthread_cond_wait - OK" );
+ status = pthread_cond_wait( &CondVarId, &MutexId );
+ rtems_test_assert( !status );
+ puts( "Test: pthread_cond_wait - interrupted by signal" );
+
+ left = sleep( 10 );
+ printf( "Test: seconds left=%d\n", left );
+
+ return NULL;
+}
+
+void *POSIX_Init(
+ rtems_task_argument argument
+)
+{
+ int status;
+
+ puts( "\n\n*** POSIX TEST SIGNAL 06 ***" );
+
+ puts( "Init: pthread_cond_init - OK" );
+ status = pthread_cond_init( &CondVarId, NULL );
+ rtems_test_assert( !status );
+
+ puts( "Init: pthread_mutex_init - OK" );
+ status = pthread_mutex_init( &MutexId, NULL );
+ rtems_test_assert( !status );
+
+ puts( "Init: pthread_create - OK" );
+ status = pthread_create( &ThreadId, NULL, TestThread, NULL );
+ rtems_test_assert( !status );
+
+ sleep( 1 );
+
+ /* let TestThread run */
+
+ puts( "Init: pthread_kill - SIGUSR to Test Thread - OK" );
+ status = pthread_kill( ThreadId, SIGUSR1 );
+ rtems_test_assert( !status );
+
+ sleep( 2 );
+
+ /* let TestThread run */
+
+ puts( "Init: pthread_kill - SIGUSR to Test Thread - OK" );
+ status = pthread_kill( ThreadId, SIGUSR1 );
+ rtems_test_assert( !status );
+
+ sleep( 1 );
+
+ /* let TestThread run */
+
+
+
+ puts( "*** END OF POSIX TEST SIGNAL 06 ***" );
+
+ 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_MAXIMUM_POSIX_CONDITION_VARIABLES 2
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+/* end of file */
diff --git a/testsuites/psxtests/psxsignal06/psxsignal06.doc b/testsuites/psxtests/psxsignal06/psxsignal06.doc
new file mode 100644
index 0000000000..30ef8f38b0
--- /dev/null
+++ b/testsuites/psxtests/psxsignal06/psxsignal06.doc
@@ -0,0 +1,24 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989-2010.
+# 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: psxsignal06
+
+directives:
+
+ pthread_cond_wait
+ sleep
+ pthread_kill
+
+concepts:
+
++ Ensure that sleep and pthread_cond_wait are properly interrupted by a signal.
diff --git a/testsuites/psxtests/psxsignal06/psxsignal06.scn b/testsuites/psxtests/psxsignal06/psxsignal06.scn
new file mode 100644
index 0000000000..6d006602a0
--- /dev/null
+++ b/testsuites/psxtests/psxsignal06/psxsignal06.scn
@@ -0,0 +1,11 @@
+*** POSIX TEST SIGNAL 06 ***
+Init: pthread_cond_init - OK
+Init: pthread_mutex_init - OK
+Init: pthread_create - OK
+Test: Unblock SIGUSR1
+Test: pthread_cond_wait - OK
+Init: pthread_kill - SIGUSR to Test Thread - OK
+Test: pthread_cond_wait - interrupted by signal
+Init: pthread_kill - SIGUSR to Test Thread - OK
+Test: seconds left=8
+*** END OF POSIX TEST SIGNAL 06 ***