diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-10-11 22:32:03 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-10-11 22:32:03 +0000 |
commit | a45069732331cadcc578fc6957a1e164dc4fed4b (patch) | |
tree | 0294e937dc6f0bf329047b6dbf4f589f323053d0 /testsuites/psxtests/psxalarm01 | |
parent | 2009-10-11 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-a45069732331cadcc578fc6957a1e164dc4fed4b.tar.bz2 |
2009-10-11 Joel Sherrill <joel.sherrill@OARcorp.com>
* Makefile.am, configure.ac: Add new test to ensure that canceling an
alarm works as defined.
* psxalarm01/.cvsignore, psxalarm01/Makefile.am, psxalarm01/init.c,
psxalarm01/psxalarm01.doc, psxalarm01/psxalarm01.scn: New files.
Diffstat (limited to 'testsuites/psxtests/psxalarm01')
-rw-r--r-- | testsuites/psxtests/psxalarm01/.cvsignore | 2 | ||||
-rw-r--r-- | testsuites/psxtests/psxalarm01/Makefile.am | 29 | ||||
-rw-r--r-- | testsuites/psxtests/psxalarm01/init.c | 126 | ||||
-rw-r--r-- | testsuites/psxtests/psxalarm01/psxalarm01.doc | 21 | ||||
-rw-r--r-- | testsuites/psxtests/psxalarm01/psxalarm01.scn | 9 |
5 files changed, 187 insertions, 0 deletions
diff --git a/testsuites/psxtests/psxalarm01/.cvsignore b/testsuites/psxtests/psxalarm01/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/psxtests/psxalarm01/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/psxtests/psxalarm01/Makefile.am b/testsuites/psxtests/psxalarm01/Makefile.am new file mode 100644 index 0000000000..ab9b5a4a85 --- /dev/null +++ b/testsuites/psxtests/psxalarm01/Makefile.am @@ -0,0 +1,29 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = psxalarm01 +psxalarm01_SOURCES = init.c ../include/pmacros.h + +dist_rtems_tests_DATA = psxalarm01.scn +dist_rtems_tests_DATA += psxalarm01.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +psxalarm01_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel) + +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(psxalarm01_OBJECTS) $(psxalarm01_LDADD) +LINK_LIBS = $(psxalarm01_LDLIBS) + +psxalarm01$(EXEEXT): $(psxalarm01_OBJECTS) $(psxalarm01_DEPENDENCIES) + @rm -f psxalarm01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtests/psxalarm01/init.c b/testsuites/psxtests/psxalarm01/init.c new file mode 100644 index 0000000000..e09adfa8d8 --- /dev/null +++ b/testsuites/psxtests/psxalarm01/init.c @@ -0,0 +1,126 @@ +/* + * 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> + +volatile int Signal_occurred; +volatile int Signal_count; +void Signal_handler( int signo ); +void Signal_info_handler( + int signo, + siginfo_t *info, + void *context +); + +void Signal_handler( + int signo +) +{ + Signal_count++; + printf( + "Signal: %d caught by 0x%x (%d)\n", + signo, + pthread_self(), + Signal_count + ); + Signal_occurred = 1; +} + +void Signal_info_handler( + int signo, + siginfo_t *info, + void *context +) +{ + Signal_count++; + printf( + "Signal_info: %d caught by 0x%x (%d) si_signo= %d si_code= %d value= %d\n", + signo, + pthread_self(), + Signal_count, + info->si_signo, + info->si_code, + info->si_value.sival_int + ); + Signal_occurred = 1; +} + +void *POSIX_Init( + void *argument +) +{ + unsigned int remaining; + int sc; + struct sigaction act; + sigset_t mask; + sigset_t pending_set; + sigset_t oset; + struct timespec timeout; + siginfo_t info; + + puts( "\n\n*** POSIX ALARM TEST 01 ***" ); + + /* install a signal handler for SIGALRM and unblock it */ + + sc = sigemptyset( &act.sa_mask ); + assert( !sc ); + + act.sa_handler = Signal_handler; + act.sa_flags = 0; + + sigaction( SIGALRM, &act, NULL ); + + sc = sigemptyset( &mask ); + assert( !sc ); + + sc = sigaddset( &mask, SIGALRM ); + assert( !sc ); + + puts( "Init: Unblock SIGALRM" ); + sc = sigprocmask( SIG_UNBLOCK, &mask, NULL ); + assert( !sc ); + + /* schedule the alarm */ + + puts( "Init: Firing alarm in 1 second" ); + remaining = alarm( 1 ); + printf( "Init: %d seconds left on previous alarm\n", sc ); + assert( !sc ); + + puts( "Init: Wait for alarm" ); + sleep( 2 ); + + puts( "Init: Cancel alarm" ); + remaining = alarm( 0 ); + printf( "Init: %d seconds left on previous alarm\n", remaining ); + assert( remaining == 0 ); + + puts( "*** END OF POSIX ALARM TEST 01***" ); + rtems_test_exit( 0 ); + + return NULL; /* just so the compiler thinks we returned something */ +} + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 1 + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE +#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE \ + (RTEMS_MINIMUM_STACK_SIZE * 4) + +#define CONFIGURE_INIT +#include <rtems/confdefs.h> + diff --git a/testsuites/psxtests/psxalarm01/psxalarm01.doc b/testsuites/psxtests/psxalarm01/psxalarm01.doc new file mode 100644 index 0000000000..42f05d45a6 --- /dev/null +++ b/testsuites/psxtests/psxalarm01/psxalarm01.doc @@ -0,0 +1,21 @@ +# +# $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: psxalarm01 + +directives: + alarm + +concepts: + ++ Verifies that canceling an active alarm works. diff --git a/testsuites/psxtests/psxalarm01/psxalarm01.scn b/testsuites/psxtests/psxalarm01/psxalarm01.scn new file mode 100644 index 0000000000..0cc3a3031f --- /dev/null +++ b/testsuites/psxtests/psxalarm01/psxalarm01.scn @@ -0,0 +1,9 @@ +*** POSIX ALARM TEST 01 *** +Init: Unblock SIGALRM +Init: Firing alarm in 1 second +Init: 0 seconds left on previous alarm +Init: Wait for alarm +Signal: 14 caught by 0xb010001 (1) +Init: Cancel alarm +Init: 0 seconds left on previous alarm +*** END OF POSIX ALARM TEST 01*** |