2007-12-19 Jennifer Averett <jennifer.averett@OARcorp.com>

* Makefile.am, configure.ac: Added posix signal test
	* psxsignal01/Makefile.am, psxsignal01/init.c,
	psxsignal01/psxsignal01.scn, psxsignal01/system.h,
	psxsignal01/task1.c: New files.
This commit is contained in:
Jennifer Averett
2007-12-19 18:41:15 +00:00
parent bbd655a3d5
commit 7689b49ee9
8 changed files with 398 additions and 1 deletions

View File

@@ -1,3 +1,10 @@
2007-12-19 Jennifer Averett <jennifer.averett@OARcorp.com>
* Makefile.am, configure.ac: Added posix signal test
* psxsignal01/Makefile.am, psxsignal01/init.c,
psxsignal01/psxsignal01.scn, psxsignal01/system.h,
psxsignal01/task1.c: New files.
2007-12-17 Joel Sherrill <joel.sherrill@OARcorp.com>
* Makefile.am, configure.ac: Add test for sysconf().

View File

@@ -6,7 +6,7 @@ ACLOCAL_AMFLAGS = -I ../aclocal
SUBDIRS = psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
psx10 psx11 psx12 psxtime psxtimer01 psxtimer02 psxcancel psxbarrier01 \
psxmsgq01 psxrwlock01 psxsem01 psxspin01 psxenosys psxsysconf
psxmsgq01 psxrwlock01 psxsem01 psxspin01 psxenosys psxsignal01 psxsysconf
## File IO tests
SUBDIRS += psxfile01 psxreaddir psxstat psxmount psx13 psxchroot01

View File

@@ -52,6 +52,7 @@ psxreaddir/Makefile
psxrdwrv/Makefile
psxrwlock01/Makefile
psxsem01/Makefile
psxsignal01/Makefile
psxspin01/Makefile
psxstat/Makefile
psxsysconf/Makefile

View File

@@ -0,0 +1,28 @@
##
## $Id$
##
MANAGERS = all
rtems_tests_PROGRAMS = psxsignal01.exe
psxsignal01_exe_SOURCES = init.c task1.c system.h ../include/pmacros.h
dist_rtems_tests_DATA = psxsignal01.scn
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am
psxsignal01_exe_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
AM_CPPFLAGS += -I$(top_srcdir)/include
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
LINK_OBJS = $(psxsignal01_exe_OBJECTS) $(psxsignal01_exe_LDADD)
LINK_LIBS = $(psxsignal01_exe_LDLIBS)
psxsignal01.exe$(EXEEXT): $(psxsignal01_exe_OBJECTS) $(psxsignal01_exe_DEPENDENCIES)
@rm -f psxsignal01.exe$(EXEEXT)
$(make-exe)
include $(top_srcdir)/../automake/local.am

View File

@@ -0,0 +1,231 @@
/*
* COPYRIGHT (c) 1989-1999.
* 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$
*/
#define CONFIGURE_INIT
#include "system.h"
#include <signal.h>
#include <errno.h>
typedef void (*sighandler_t)(int);
sighandler_t signal(int signum, sighandler_t handler);
extern void _POSIX_signals_Abnormal_termination_handler( int signo );
volatile int Signal_occurred;
volatile int Signal_count;
void Handler_1(
int signo
)
{
Signal_count++;
printf(
"Handler_1: Signal: %d caught by 0x%x (%d)\n",
signo,
pthread_self(),
Signal_count
);
Signal_occurred = 1;
}
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;
}
rtems_timer_service_routine Signal_duringISR_TSR(
rtems_id ignored_id,
void *ignored_address
)
{
int status;
status = kill( getpid(), SIGUSR1 );
}
void *POSIX_Init(
void *argument
)
{
int status;
struct sigaction act;
sigset_t mask;
sigset_t pending_set;
sigset_t oset;
struct timespec timeout;
siginfo_t info;
sighandler_t oldHandler;
sighandler_t newHandler;
rtems_interval start, end;
puts( "\n\n*** POSIX TEST SIGNAL ***" );
/* set the time of day, and print our buffer in multiple ways */
set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
/* get id of this thread */
Init_id = pthread_self();
printf( "Init's ID is 0x%08x\n", Init_id );
Signal_occurred = 0;
Signal_count = 0;
act.sa_handler = Handler_1;
act.sa_flags = 0;
sigaction( SIGUSR1, &act, NULL );
sigaction( SIGFPE, &act, NULL );
sigaction( SIGILL, &act, NULL );
sigaction( SIGSEGV, &act, NULL );
/*
* If we have the signal pending with default, we will die.
*/
puts("Validate signal with SIG_DFL");
signal( SIGUSR1, SIG_DFL );
status = kill( getpid(), SIGUSR1 );
status = sleep( 1 );
puts("Validate signal with SIG_IGN");
signal( SIGUSR1, SIG_IGN );
status = kill( getpid(), SIGUSR1 );
status = sleep( 1 );
/* unblock Signal and see if it happened */
status = sigemptyset( &mask );
assert( !status );
status = sigaddset( &mask, SIGUSR1 );
assert( !status );
status = sigaddset( &mask, SIGFPE );
assert( !status );
status = sigaddset( &mask, SIGILL );
assert( !status );
status = sigaddset( &mask, SIGSEGV );
assert( !status );
puts( "Init: Unblock SIGUSR1 SIGFPE SIGILL SIGSEGV" );
status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
assert( !status );
/* install a signal handler for SIGUSR1 */
Signal_occurred = 0;
Signal_count = 0;
act.sa_handler = Handler_1;
act.sa_flags = 0;
sigaction( SIGUSR1, &act, NULL );
Signal_count = 0;
Signal_occurred = 0;
newHandler = Signal_handler;
oldHandler = signal( SIGUSR1, newHandler );
if (oldHandler == Handler_1 )
puts("Init: signal return value verified");
else
puts("Init: ERROR==> signal unexpected return value" );
status = sleep( 1 );
puts( "Init: send SIGUSR1 to process" );
status = kill( getpid(), SIGUSR1 );
status = sleep( 5 );
puts( "Init: send SIGFPE to process" );
status = _kill_r( NULL, getpid(), SIGFPE );
status = sleep(5);
puts( "Init: send SIGILL to process" );
status = _kill_r( NULL, getpid(), SIGILL );
status = sleep(5);
puts( "Init: send SIGSEGV to process" );
status = _kill_r( NULL, getpid(), SIGSEGV );
status = sleep(5);
Timer_name[0]= rtems_build_name( 'T', 'M', '1', ' ' );
status = rtems_timer_create( Timer_name[0], &Timer_id[0]);
Signal_count = 0;
Signal_occurred = 0;
puts( "Init: send SIGUSR1 to process from a TSR (interruptible sleep)" );
status = rtems_timer_fire_after(
Timer_id[ 0 ],
1,
Signal_duringISR_TSR,
NULL
);
sleep(5);
/* signal occurs during interruptible sleep */
/* now schedule another one to fire but do not sleep */
puts( "Init: send SIGUSR1 to process from a TSR (spin)" );
rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start );
Signal_count = 0;
Signal_occurred = 0;
status = rtems_timer_fire_after(
Timer_id[ 0 ],
10,
Signal_duringISR_TSR,
NULL
);
do {
rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &end );
} while ( !Signal_occurred && ((end - start) <= 800));
if ( !Signal_occurred ) {
puts( "Signal did not occur" );
rtems_test_exit(0);
}
/* end of install a signal handler for SIGUSR1 */
Signal_occurred = 0;
puts("*** Validate unexpected program termination ***");
_POSIX_signals_Abnormal_termination_handler( SIGUSR1 );
status = sleep( 1 );
puts( "ERROR==> Expected program termination");
puts( "*** END OF POSIX TEST SIGNAL ***" );
rtems_test_exit(0);
return NULL; /* just so the compiler thinks we returned something */
}

View File

@@ -0,0 +1,19 @@
*** POSIX TEST SIGNAL ***
Init's ID is 0x0b010001
Validate signal with SIG_DFL
Validate signal with SIG_IGN
Init: Unblock SIGUSR1 SIGFPE SIGILL SIGSEGV
Init: signal return value verified
Init: send SIGUSR1 to process
Signal: 25 caught by 0xb010001 (1)
Init: send SIGFPE to process
Handler_1: Signal: 8 caught by 0xb010001 (2)
Init: send SIGILL to process
Handler_1: Signal: 4 caught by 0xb010001 (3)
Init: send SIGSEGV to process
Handler_1: Signal: 11 caught by 0xb010001 (4)
Init: send SIGUSR1 to process from a TSR (interruptible sleep)
Signal: 25 caught by 0xb010001 (1)
Init: send SIGUSR1 to process from a TSR (spin)
Signal: 25 caught by 0xb010001 (1)
*** Validate unexpected program termination ***

View File

@@ -0,0 +1,68 @@
/* system.h
*
* This include file contains information that is included in every
* function in the test set.
*
* COPYRIGHT (c) 1989-1999.
* 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$
*/
/* functions */
#include <pmacros.h>
void *POSIX_Init(
void *argument
);
void *Task_1(
void *argument
);
void *Task_2(
void *argument
);
void *Task_3(
void *argument
);
/* configuration information */
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 4
#define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 5
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE \
(RTEMS_MINIMUM_STACK_SIZE * 4)
#define CONFIGURE_MAXIMUM_TIMERS 1
#include <rtems/confdefs.h>
/* global variables */
#ifdef CONFIGURE_INIT
#define TEST_EXTERN
#else
#define TEST_EXTERN extern
#endif
TEST_EXTERN rtems_id Timer_id[ 1 ]; /* array of timer ids */
TEST_EXTERN rtems_name Timer_name[ 1 ]; /* array of timer names */
TEST_EXTERN pthread_t Init_id;
TEST_EXTERN pthread_t Task1_id;
TEST_EXTERN pthread_t Task2_id;
TEST_EXTERN pthread_t Task3_id;
/* end of include file */

View File

@@ -0,0 +1,43 @@
/* Task_1
*
* This routine serves as a test task.
*
* Input parameters:
* argument - task argument
*
* Output parameters: NONE
*
* COPYRIGHT (c) 1989-1999.
* 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 "system.h"
#include <signal.h>
void *Task_1(
void *argument
)
{
int seconds;
printf( "Task_1: sleeping for 5 seconds\n" );
seconds = sleep( 5 );
printf( "Task_1: %d seconds left\n", seconds );
assert( seconds );
/* switch to Init */
printf( "Task_1: exit\n" );
pthread_exit( NULL );
/* switch to Init */
return NULL; /* just so the compiler thinks we returned something */
}