From a45069732331cadcc578fc6957a1e164dc4fed4b Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Sun, 11 Oct 2009 22:32:03 +0000 Subject: 2009-10-11 Joel Sherrill * 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. --- testsuites/psxtests/ChangeLog | 7 ++ testsuites/psxtests/Makefile.am | 3 +- testsuites/psxtests/configure.ac | 1 + testsuites/psxtests/psxalarm01/.cvsignore | 2 + testsuites/psxtests/psxalarm01/Makefile.am | 29 ++++++ testsuites/psxtests/psxalarm01/init.c | 126 ++++++++++++++++++++++++++ testsuites/psxtests/psxalarm01/psxalarm01.doc | 21 +++++ testsuites/psxtests/psxalarm01/psxalarm01.scn | 9 ++ 8 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 testsuites/psxtests/psxalarm01/.cvsignore create mode 100644 testsuites/psxtests/psxalarm01/Makefile.am create mode 100644 testsuites/psxtests/psxalarm01/init.c create mode 100644 testsuites/psxtests/psxalarm01/psxalarm01.doc create mode 100644 testsuites/psxtests/psxalarm01/psxalarm01.scn (limited to 'testsuites') diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog index 35ac5c9f24..1ca020ab1e 100644 --- a/testsuites/psxtests/ChangeLog +++ b/testsuites/psxtests/ChangeLog @@ -1,3 +1,10 @@ +2009-10-11 Joel Sherrill + + * 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. + 2009-10-11 Joel Sherrill * psxtimer01/psxtimer.c: Actually pass the pointer we initialized. diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index 6a934bcae0..bd3bccd28a 100644 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -7,7 +7,8 @@ ACLOCAL_AMFLAGS = -I ../aclocal SUBDIRS = psxclock if HAS_POSIX SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \ - psx10 psx11 psx12 psx13 psx14 psxautoinit01 psxautoinit02 psxbarrier01 \ + psx10 psx11 psx12 psx13 psx14 psxalarm01 \ + psxautoinit01 psxautoinit02 psxbarrier01 \ psxcancel psxcancel01 psxcleanup psxcond01 psxenosys psxkey01 psxkey02 \ psxkey03 psxitimer psxmsgq01 psxmsgq02 psxmsgq03 psxmsgq04 \ psxmutexattr01 psxobj01 psxrwlock01 psxsem01 psxsignal01 psxsignal02 \ diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac index 2be98b2ae4..0e810d3bec 100644 --- a/testsuites/psxtests/configure.ac +++ b/testsuites/psxtests/configure.ac @@ -43,6 +43,7 @@ psx11/Makefile psx12/Makefile psx13/Makefile psx14/Makefile +psxalarm01/Makefile psxautoinit01/Makefile psxautoinit02/Makefile psxbarrier01/Makefile 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 + +#include +#include + +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 + 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*** -- cgit v1.2.3