summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxsignal06
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/psxsignal06
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/psxsignal06')
-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
5 files changed, 186 insertions, 0 deletions
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 ***