summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxsignal03
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-29 18:31:20 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-29 18:31:20 +0000
commit2ad8f85825189ddddfcdae122bb442c05bd44dfa (patch)
tree657ec4790f0aedbca0505416cc8f22880dbfea9a /testsuites/psxtests/psxsignal03
parent2009-07-29 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-2ad8f85825189ddddfcdae122bb442c05bd44dfa.tar.bz2
2009-07-29 Joel Sherrill <joel.sherrill@OARcorp.com>
* Makefile.am, configure.ac: Add test to address cases where a thread is waiting on a signal (sigwait) and we send it. Also address case where there are too many queued signals. * psxsignal03/.cvsignore, psxsignal03/Makefile.am, psxsignal03/init.c, psxsignal03/psxsignal03.doc, psxsignal03/psxsignal03.scn: New files.
Diffstat (limited to 'testsuites/psxtests/psxsignal03')
-rw-r--r--testsuites/psxtests/psxsignal03/.cvsignore2
-rw-r--r--testsuites/psxtests/psxsignal03/Makefile.am29
-rw-r--r--testsuites/psxtests/psxsignal03/init.c161
-rw-r--r--testsuites/psxtests/psxsignal03/psxsignal03.doc31
-rw-r--r--testsuites/psxtests/psxsignal03/psxsignal03.scn17
5 files changed, 240 insertions, 0 deletions
diff --git a/testsuites/psxtests/psxsignal03/.cvsignore b/testsuites/psxtests/psxsignal03/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/psxtests/psxsignal03/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/psxtests/psxsignal03/Makefile.am b/testsuites/psxtests/psxsignal03/Makefile.am
new file mode 100644
index 0000000000..9b2bc70a20
--- /dev/null
+++ b/testsuites/psxtests/psxsignal03/Makefile.am
@@ -0,0 +1,29 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxsignal03
+psxsignal03_SOURCES = init.c ../include/pmacros.h
+
+dist_rtems_tests_DATA = psxsignal03.scn
+dist_rtems_tests_DATA += psxsignal03.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+psxsignal03_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxsignal03_OBJECTS) $(psxsignal03_LDADD)
+LINK_LIBS = $(psxsignal03_LDLIBS)
+
+psxsignal03$(EXEEXT): $(psxsignal03_OBJECTS) $(psxsignal03_DEPENDENCIES)
+ @rm -f psxsignal03$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxsignal03/init.c b/testsuites/psxtests/psxsignal03/init.c
new file mode 100644
index 0000000000..9b457aecae
--- /dev/null
+++ b/testsuites/psxtests/psxsignal03/init.c
@@ -0,0 +1,161 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * 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 <pmacros.h>
+#include <signal.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sched.h>
+
+volatile bool Signal_occurred;
+volatile pthread_t Signal_thread;
+
+void Signal_handler(
+ int signo,
+ siginfo_t *info,
+ void *arg
+)
+{
+ Signal_occurred = true;
+ Signal_thread = pthread_self();
+}
+
+void *Test_Thread(void *arg)
+{
+ bool blocked = *((bool *)arg);
+ const char *name;
+ int sc;
+ sigset_t mask;
+ sigset_t wait_mask;
+ sigset_t pending_set;
+ sigset_t oset;
+ siginfo_t info;
+
+ if ( blocked )
+ name = "SignalBlocked";
+ else
+ name = "SignalNotBlocked";
+
+ /* build unblocked mask */
+ sc = sigemptyset( &mask );
+ assert( !sc );
+
+ printf( "%s - Unblock SIGUSR1\n", name );
+ sc = sigaddset( &mask, SIGUSR1 );
+ assert( !sc );
+
+ if ( !blocked ) {
+ printf( "%s - Unblock SIGUSR2\n", name );
+ sc = sigaddset( &mask, SIGUSR2 );
+ assert( !sc );
+ }
+
+ /* unblocked signals */
+ sc = pthread_sigmask( SIG_UNBLOCK, &mask, NULL );
+ assert( !sc );
+
+ /* build wait mask */
+ sc = sigemptyset( &wait_mask );
+ assert( !sc );
+
+ sc = sigaddset( &wait_mask, SIGUSR1 );
+ assert( !sc );
+
+ /* wait for a signal */
+ memset( &info, 0, sizeof(info) );
+
+ printf( "%s - Wait for SIGUSR1 unblocked\n", name );
+ sigwaitinfo( &wait_mask, &info );
+ assert( !sc );
+
+ printf( "%s - siginfo.si_signo=%d\n", name, info.si_signo );
+ printf( "%s - siginfo.si_code=%d\n", name, info.si_code );
+ printf( "%s - siginfo.si_value=0x%08x\n", name, info.si_value );
+
+ assert( info.si_signo == SIGUSR2 );
+ assert( info.si_code == SI_USER );
+
+ printf( "%s - exiting\n", name );
+ return NULL;
+}
+
+void *POSIX_Init(
+ void *argument
+)
+{
+ int i;
+ int sc;
+ pthread_t id;
+ struct sigaction act;
+ bool trueArg = true;
+ bool falseArg = false;
+
+ puts( "\n\n*** POSIX TEST SIGNAL 03 ***" );
+
+ Signal_occurred = false;
+
+ act.sa_handler = NULL;
+ act.sa_sigaction = Signal_handler;
+ act.sa_flags = SA_SIGINFO;
+ sigaction( SIGUSR1, &act, NULL );
+ sigaction( SIGUSR2, &act, NULL );
+
+ /* create threads */
+ sc = pthread_create( &id, NULL, Test_Thread, &falseArg );
+ assert( !sc );
+
+ sc = pthread_create( &id, NULL, Test_Thread, &trueArg );
+ assert( !sc );
+
+ puts( "Init - sleep - let threads settle - OK" );
+ usleep(500000);
+
+ puts( "Init - sleep - SignalBlocked thread settle - OK" );
+ usleep(500000);
+
+ puts( "Init - sending SIGUSR2 - deliver to one thread" );
+ sc = kill( getpid(), SIGUSR2 );
+ assert( !sc );
+
+ puts( "Init - sending SIGUSR2 - deliver to other thread" );
+ sc = kill( getpid(), SIGUSR2 );
+ assert( !sc );
+
+ puts( "Init - sending SIGUSR2 - expect EAGAIN" );
+ sc = kill( getpid(), SIGUSR2 );
+ assert( sc == -1 );
+ assert( errno == EAGAIN );
+
+ puts( "Init - sleep - let thread report if it unblocked - OK" );
+ usleep(500000);
+
+ /* we are just sigwait'ing the signal, not delivering it */
+ assert( Signal_occurred == true );
+
+ puts( "*** END OF POSIX TEST SIGNAL 03 ***" );
+ rtems_test_exit(0);
+
+ return NULL; /* just so the compiler thinks we returned something */
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 3
+#define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 1
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
diff --git a/testsuites/psxtests/psxsignal03/psxsignal03.doc b/testsuites/psxtests/psxsignal03/psxsignal03.doc
new file mode 100644
index 0000000000..2e06dd4b72
--- /dev/null
+++ b/testsuites/psxtests/psxsignal03/psxsignal03.doc
@@ -0,0 +1,31 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989-2009.
+# 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: psxsignal03
+
+directives:
+
+ sigemptyset
+ sigaddset
+ pthread_sigmask
+ sigwaitinfo
+ sigaction
+ pthread_create
+ kill
+ kill
+
+concepts:
+
++ Ensure the the algorithm in killinfo.c which decides which
+ thread waiting on a signal is given a process wide signal to
+ dispatch.
diff --git a/testsuites/psxtests/psxsignal03/psxsignal03.scn b/testsuites/psxtests/psxsignal03/psxsignal03.scn
new file mode 100644
index 0000000000..1854533bc6
--- /dev/null
+++ b/testsuites/psxtests/psxsignal03/psxsignal03.scn
@@ -0,0 +1,17 @@
+*** POSIX TEST SIGNAL 03 ***
+Init - sleep - let threads settle - OK
+SignalNotBlocked - Unblock SIGUSR1
+SignalNotBlocked - Unblock SIGUSR2
+SignalNotBlocked - Wait for SIGUSR1 unblocked
+SignalBlocked - Unblock SIGUSR1
+SignalBlocked - Wait for SIGUSR1 unblocked
+Init - sleep - SignalBlocked thread settle - OK
+Init - sending SIGUSR2 - deliver to one thread
+Init - sending SIGUSR2 - deliver to other thread
+Init - sending SIGUSR2 - expect EAGAIN
+Init - sleep - let thread report if it unblocked - OK
+SignalNotBlocked - siginfo.si_signo=26
+SignalNotBlocked - siginfo.si_code=1
+SignalNotBlocked - siginfo.si_value=0x02034474
+SignalNotBlocked - exiting
+*** END OF POSIX TEST SIGNAL 03 ***