Changeset 5d478af in rtems


Ignore:
Timestamp:
Feb 22, 2016, 8:40:16 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
287a70f
Parents:
452f6ba9
git-author:
Sebastian Huber <sebastian.huber@…> (02/22/16 08:40:16)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/22/16 14:32:59)
Message:

psxtests/psxualarm: Add test cases

Update #2344.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/psxualarm/init.c

    r452f6ba9 r5d478af  
    1515#include "system.h"
    1616#include <signal.h>
     17#include <signal.h>
    1718#include <unistd.h>
    1819#include <errno.h>
     
    2021const char rtems_test_name[] = "PSXUALARM";
    2122
    22 /* forward declarations to avoid warnings */
    23 void Signal_handler(int signo);
    24 rtems_timer_service_routine Signal_duringISR_TSR(
    25   rtems_id  ignored_id,
    26   void     *ignored_address
    27 );
    28 
    29 typedef void (*sighandler_t)(int);
    30 sighandler_t signal(int signum, sighandler_t handler);
    31 extern void _POSIX_signals_Abnormal_termination_handler( int signo );
    32 
    33 volatile int Signal_occurred;
    3423volatile int Signal_count;
    3524
    36 void Signal_handler(
     25static void Signal_handler(
    3726  int signo
    3827)
     
    4534    Signal_count
    4635  );
    47   Signal_occurred = 1;
    4836}
    49 
    50 rtems_timer_service_routine Signal_duringISR_TSR(
    51   rtems_id  ignored_id,
    52   void     *ignored_address
    53 )
    54 {
    55   int               status;
    56 
    57   status = kill( getpid(), SIGUSR1 );
    58   rtems_test_assert( status == 0 );
    59 }
    60 
    6137
    6238void *POSIX_Init(
     
    8056  printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
    8157
    82   Signal_occurred = 0;
    83   Signal_count = 0;
    84 
    8558  /* Validate ualarm is ignored if signal not caught */
    8659  act.sa_handler = Signal_handler;
    8760  act.sa_flags   = 0;
    8861  sigaction( SIGALRM, &act, NULL );
    89   puts( "Init: ualarm in 100000 us" );
    90   sleep(3);
    91   result = ualarm(100000,0);
     62  puts( "Init: ualarm in 500000 us" );
     63  result = ualarm( 500000, 0 );
    9264  rtems_test_assert( result == 0 );
    93  
    94   status = sleep(10);
     65
     66  status = sleep( 1 );
    9567  rtems_test_assert( status == 0 );
     68  rtems_test_assert( Signal_count == 0 );
    9669
    9770  /* unblock Signal and see if it happened */
     
    10376  status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
    10477  rtems_test_assert( !status );
    105   status = sleep(10);
     78
     79  status = sleep( 1 );
     80  rtems_test_assert( status == 0 );
     81  rtems_test_assert( Signal_count == 0 );
     82
     83  result = ualarm( 500000, 0 );
     84  rtems_test_assert( result == 0 );
     85
     86  status = sleep( 1 );
     87  rtems_test_assert( status == 0 );
     88  rtems_test_assert( Signal_count == 1 );
    10689
    10790  /* stop ularm */
    108   puts( "Init: clear ualarm with 0,0" );
    109   result = ualarm(0,0);
    110   status = sleep(10);
     91  puts( "Init: clear ualarm with 0, 0" );
     92  result = ualarm( 0, 0 );
     93  rtems_test_assert( result == 0 );
     94
     95  result = ualarm( 500000, 1000000 );
     96  rtems_test_assert( result == 0 );
     97
     98  status = sleep( 1 );
     99  rtems_test_assert( status == 0 );
     100  rtems_test_assert( Signal_count == 2 );
     101
     102  status = sleep( 1 );
     103  rtems_test_assert( status == 0 );
     104  rtems_test_assert( Signal_count == 3 );
     105
     106  result = ualarm( 0, 0 );
     107  rtems_test_assert( result == 1000000 );
    111108
    112109  TEST_END();
Note: See TracChangeset for help on using the changeset viewer.