forked from Imagelibrary/rtems
2010-10-21 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac: New test to ensure pthread_cond_wait() and sleep() (e.g. interruptible blocking and sleeping) are interruptible by signal. * psxsignal06/.cvsignore, psxsignal06/Makefile.am, psxsignal06/init.c, psxsignal06/psxsignal06.doc, psxsignal06/psxsignal06.scn: New files.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2010-10-21 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* Makefile.am, configure.ac: New test to ensure pthread_cond_wait() and
|
||||
sleep() (e.g. interruptible blocking and sleeping) are interruptible
|
||||
by signal.
|
||||
* psxsignal06/.cvsignore, psxsignal06/Makefile.am, psxsignal06/init.c,
|
||||
psxsignal06/psxsignal06.doc, psxsignal06/psxsignal06.scn: New files.
|
||||
|
||||
2010-10-21 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* psx02/init.c, psx02/task.c, psx03/init.c, psx04/init.c,
|
||||
|
||||
@@ -13,7 +13,8 @@ SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
|
||||
psxcond01 psxenosys psxkey01 psxkey02 psxkey03 \
|
||||
psxitimer psxmsgq01 psxmsgq02 psxmsgq03 psxmsgq04 \
|
||||
psxmutexattr01 psxobj01 psxrwlock01 psxsem01 psxsignal01 psxsignal02 \
|
||||
psxsignal03 psxsignal04 psxsignal05 psxspin01 psxspin02 psxsysconf \
|
||||
psxsignal03 psxsignal04 psxsignal05 psxsignal06 \
|
||||
psxspin01 psxspin02 psxsysconf \
|
||||
psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \
|
||||
psxintrcritical01 psxstack01 psxstack02
|
||||
endif
|
||||
|
||||
@@ -142,6 +142,7 @@ psxsignal02/Makefile
|
||||
psxsignal03/Makefile
|
||||
psxsignal04/Makefile
|
||||
psxsignal05/Makefile
|
||||
psxsignal06/Makefile
|
||||
psxspin01/Makefile
|
||||
psxspin02/Makefile
|
||||
psxstack01/Makefile
|
||||
|
||||
2
testsuites/psxtests/psxsignal06/.cvsignore
Normal file
2
testsuites/psxtests/psxsignal06/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
25
testsuites/psxtests/psxsignal06/Makefile.am
Normal file
25
testsuites/psxtests/psxsignal06/Makefile.am
Normal file
@@ -0,0 +1,25 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
rtems_tests_PROGRAMS = psxsignal06
|
||||
psxsignal06_SOURCES = init.c
|
||||
|
||||
dist_rtems_tests_DATA = psxsignal06.scn
|
||||
dist_rtems_tests_DATA += psxsignal06.doc
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../automake/compile.am
|
||||
include $(top_srcdir)/../automake/leaf.am
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/include
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
|
||||
LINK_OBJS = $(psxsignal06_OBJECTS) $(psxsignal06_LDADD)
|
||||
LINK_LIBS = $(psxsignal06_LDLIBS)
|
||||
|
||||
psxsignal06$(EXEEXT): $(psxsignal06_OBJECTS) $(psxsignal06_DEPENDENCIES)
|
||||
@rm -f psxsignal06$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
124
testsuites/psxtests/psxsignal06/init.c
Normal file
124
testsuites/psxtests/psxsignal06/init.c
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2010.
|
||||
* 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 <tmacros.h>
|
||||
#include "test_support.h"
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
pthread_t ThreadId;
|
||||
pthread_cond_t CondVarId;
|
||||
pthread_mutex_t MutexId;
|
||||
|
||||
void Handler(
|
||||
int signo
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void *TestThread(
|
||||
void *argument
|
||||
)
|
||||
{
|
||||
int status;
|
||||
sigset_t mask;
|
||||
struct sigaction act;
|
||||
unsigned int left;
|
||||
|
||||
/* unblock SIGUSR1 */
|
||||
status = sigemptyset( &mask );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
status = sigaddset( &mask, SIGUSR1 );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Test: Unblock SIGUSR1" );
|
||||
status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
/* install a signal handler for SIGUSR1 */
|
||||
act.sa_handler = Handler;
|
||||
act.sa_flags = 0;
|
||||
sigaction( SIGUSR1, &act, NULL );
|
||||
|
||||
/* interrupting condition wait returns 0 */
|
||||
puts( "Test: pthread_cond_wait - OK" );
|
||||
status = pthread_cond_wait( &CondVarId, &MutexId );
|
||||
rtems_test_assert( !status );
|
||||
puts( "Test: pthread_cond_wait - interrupted by signal" );
|
||||
|
||||
left = sleep( 10 );
|
||||
printf( "Test: seconds left=%d\n", left );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *POSIX_Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
{
|
||||
int status;
|
||||
|
||||
puts( "\n\n*** POSIX TEST SIGNAL 06 ***" );
|
||||
|
||||
puts( "Init: pthread_cond_init - OK" );
|
||||
status = pthread_cond_init( &CondVarId, NULL );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_init - OK" );
|
||||
status = pthread_mutex_init( &MutexId, NULL );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_create - OK" );
|
||||
status = pthread_create( &ThreadId, NULL, TestThread, NULL );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
sleep( 1 );
|
||||
|
||||
/* let TestThread run */
|
||||
|
||||
puts( "Init: pthread_kill - SIGUSR to Test Thread - OK" );
|
||||
status = pthread_kill( ThreadId, SIGUSR1 );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
sleep( 2 );
|
||||
|
||||
/* let TestThread run */
|
||||
|
||||
puts( "Init: pthread_kill - SIGUSR to Test Thread - OK" );
|
||||
status = pthread_kill( ThreadId, SIGUSR1 );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
sleep( 1 );
|
||||
|
||||
/* let TestThread run */
|
||||
|
||||
|
||||
|
||||
puts( "*** END OF POSIX TEST SIGNAL 06 ***" );
|
||||
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
|
||||
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
|
||||
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1
|
||||
|
||||
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
#include <rtems/confdefs.h>
|
||||
/* end of file */
|
||||
24
testsuites/psxtests/psxsignal06/psxsignal06.doc
Normal file
24
testsuites/psxtests/psxsignal06/psxsignal06.doc
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# COPYRIGHT (c) 1989-2010.
|
||||
# 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: psxsignal06
|
||||
|
||||
directives:
|
||||
|
||||
pthread_cond_wait
|
||||
sleep
|
||||
pthread_kill
|
||||
|
||||
concepts:
|
||||
|
||||
+ Ensure that sleep and pthread_cond_wait are properly interrupted by a signal.
|
||||
11
testsuites/psxtests/psxsignal06/psxsignal06.scn
Normal file
11
testsuites/psxtests/psxsignal06/psxsignal06.scn
Normal file
@@ -0,0 +1,11 @@
|
||||
*** POSIX TEST SIGNAL 06 ***
|
||||
Init: pthread_cond_init - OK
|
||||
Init: pthread_mutex_init - OK
|
||||
Init: pthread_create - OK
|
||||
Test: Unblock SIGUSR1
|
||||
Test: pthread_cond_wait - OK
|
||||
Init: pthread_kill - SIGUSR to Test Thread - OK
|
||||
Test: pthread_cond_wait - interrupted by signal
|
||||
Init: pthread_kill - SIGUSR to Test Thread - OK
|
||||
Test: seconds left=8
|
||||
*** END OF POSIX TEST SIGNAL 06 ***
|
||||
Reference in New Issue
Block a user