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.
This commit is contained in:
Joel Sherrill
2009-10-11 22:32:03 +00:00
parent f46fddfced
commit a450697323
8 changed files with 197 additions and 1 deletions

View File

@@ -1,3 +1,10 @@
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.
2009-10-11 Joel Sherrill <joel.sherrill@OARcorp.com>
* psxtimer01/psxtimer.c: Actually pass the pointer we initialized.

View File

@@ -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 \

View File

@@ -43,6 +43,7 @@ psx11/Makefile
psx12/Makefile
psx13/Makefile
psx14/Makefile
psxalarm01/Makefile
psxautoinit01/Makefile
psxautoinit02/Makefile
psxbarrier01/Makefile

View File

@@ -0,0 +1,2 @@
Makefile
Makefile.in

View File

@@ -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

View File

@@ -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>

View File

@@ -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.

View File

@@ -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***