diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-02-22 09:40:16 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-02-22 15:32:59 +0100 |
commit | 5d478af46b2bd928f32cb8977164fe03d161c77f (patch) | |
tree | a2bee84959f293733ef8246988320205c8a84dd5 /testsuites/psxtests/psxualarm/init.c | |
parent | psxtests/psxalarm01: Add adjtime() test case (diff) | |
download | rtems-5d478af46b2bd928f32cb8977164fe03d161c77f.tar.bz2 |
psxtests/psxualarm: Add test cases
Update #2344.
Diffstat (limited to 'testsuites/psxtests/psxualarm/init.c')
-rw-r--r-- | testsuites/psxtests/psxualarm/init.c | 73 |
1 files changed, 35 insertions, 38 deletions
diff --git a/testsuites/psxtests/psxualarm/init.c b/testsuites/psxtests/psxualarm/init.c index ffe4720b50..1ec6473efa 100644 --- a/testsuites/psxtests/psxualarm/init.c +++ b/testsuites/psxtests/psxualarm/init.c @@ -14,26 +14,15 @@ #define CONFIGURE_INIT #include "system.h" #include <signal.h> +#include <signal.h> #include <unistd.h> #include <errno.h> const char rtems_test_name[] = "PSXUALARM"; -/* forward declarations to avoid warnings */ -void Signal_handler(int signo); -rtems_timer_service_routine Signal_duringISR_TSR( - rtems_id ignored_id, - void *ignored_address -); - -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 Signal_handler( +static void Signal_handler( int signo ) { @@ -44,21 +33,8 @@ void Signal_handler( pthread_self(), Signal_count ); - Signal_occurred = 1; -} - -rtems_timer_service_routine Signal_duringISR_TSR( - rtems_id ignored_id, - void *ignored_address -) -{ - int status; - - status = kill( getpid(), SIGUSR1 ); - rtems_test_assert( status == 0 ); } - void *POSIX_Init( void *argument ) @@ -79,20 +55,17 @@ void *POSIX_Init( Init_id = pthread_self(); printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id ); - Signal_occurred = 0; - Signal_count = 0; - /* Validate ualarm is ignored if signal not caught */ act.sa_handler = Signal_handler; act.sa_flags = 0; sigaction( SIGALRM, &act, NULL ); - puts( "Init: ualarm in 100000 us" ); - sleep(3); - result = ualarm(100000,0); + puts( "Init: ualarm in 500000 us" ); + result = ualarm( 500000, 0 ); rtems_test_assert( result == 0 ); - - status = sleep(10); + + status = sleep( 1 ); rtems_test_assert( status == 0 ); + rtems_test_assert( Signal_count == 0 ); /* unblock Signal and see if it happened */ status = sigemptyset( &mask ); @@ -102,12 +75,36 @@ void *POSIX_Init( puts( "Init: Unblock SIGALRM" ); status = sigprocmask( SIG_UNBLOCK, &mask, NULL ); rtems_test_assert( !status ); - status = sleep(10); + + status = sleep( 1 ); + rtems_test_assert( status == 0 ); + rtems_test_assert( Signal_count == 0 ); + + result = ualarm( 500000, 0 ); + rtems_test_assert( result == 0 ); + + status = sleep( 1 ); + rtems_test_assert( status == 0 ); + rtems_test_assert( Signal_count == 1 ); /* stop ularm */ - puts( "Init: clear ualarm with 0,0" ); - result = ualarm(0,0); - status = sleep(10); + puts( "Init: clear ualarm with 0, 0" ); + result = ualarm( 0, 0 ); + rtems_test_assert( result == 0 ); + + result = ualarm( 500000, 1000000 ); + rtems_test_assert( result == 0 ); + + status = sleep( 1 ); + rtems_test_assert( status == 0 ); + rtems_test_assert( Signal_count == 2 ); + + status = sleep( 1 ); + rtems_test_assert( status == 0 ); + rtems_test_assert( Signal_count == 3 ); + + result = ualarm( 0, 0 ); + rtems_test_assert( result == 1000000 ); TEST_END(); rtems_test_exit(0); |