File indexing completed on 2025-05-11 08:24:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 #ifdef HAVE_CONFIG_H
0046 #include "config.h"
0047 #endif
0048
0049 #define CONFIGURE_INIT
0050 #include "system.h"
0051 #include "tmacros.h"
0052 #include <signal.h> /* signal facilities */
0053 #include <unistd.h> /* sleep facilities */
0054 #include <time.h> /* time facilities */
0055 #include <stdio.h> /* console facilities */
0056
0057 const char rtems_test_name[] = "PSXTIMER 2";
0058
0059 void *POSIX_Init (
0060 void *argument
0061 )
0062
0063 {
0064 struct timespec now;
0065 struct sigevent event;
0066 int status;
0067 timer_t timer;
0068 timer_t timer1;
0069 struct itimerspec itimer;
0070
0071
0072
0073
0074 event.sigev_notify = SIGEV_SIGNAL;
0075 event.sigev_signo = SIGUSR1;
0076
0077 TEST_BEGIN();
0078
0079 puts( "timer_create - bad clock id - EINVAL" );
0080 status = timer_create( (clockid_t) -1, &event, &timer );
0081 fatal_posix_service_status_errno( status, EINVAL, "bad clock id" );
0082
0083 puts( "timer_create - bad timer id pointer - EINVAL" );
0084 status = timer_create( CLOCK_REALTIME, &event, NULL );
0085 fatal_posix_service_status_errno( status, EINVAL, "bad timer id" );
0086
0087 puts( "timer_create - OK" );
0088 status = timer_create( CLOCK_REALTIME, NULL, &timer );
0089 posix_service_failed( status, "timer_create OK" );
0090
0091 puts( "timer_create - too many - EAGAIN" );
0092 status = timer_create( CLOCK_REALTIME, NULL, &timer1 );
0093 fatal_posix_service_status_errno( status, EAGAIN, "too many" );
0094
0095 puts( "timer_delete - bad id - EINVAL" );
0096 status = timer_delete( timer1 + 1 );
0097 fatal_posix_service_status_errno( status, EINVAL, "bad id" );
0098
0099 puts( "timer_getoverrun - bad id - EINVAL" );
0100 status = timer_getoverrun( timer1 + 1 );
0101 fatal_posix_service_status_errno( status, EINVAL, "bad id" );
0102
0103 puts( "timer_gettime - bad itimer - EINVAL" );
0104 status = timer_gettime( timer1, NULL );
0105 fatal_posix_service_status_errno( status, EINVAL, "bad id" );
0106
0107 puts( "timer_gettime - bad id - EINVAL" );
0108 status = timer_gettime( timer1 + 1, &itimer );
0109 fatal_posix_service_status_errno( status, EINVAL, "bad id" );
0110
0111 puts( "timer_settime - bad itimer pointer - EINVAL" );
0112 status = timer_settime( timer, TIMER_ABSTIME, &itimer, NULL );
0113 fatal_posix_service_status_errno( status, EINVAL, "bad itimer pointer" );
0114
0115 itimer.it_value.tv_nsec = 2000000000;
0116 puts( "timer_settime - bad itimer value - too many nanosecond - EINVAL" );
0117 status = timer_settime( timer, TIMER_ABSTIME, &itimer, NULL );
0118 fatal_posix_service_status_errno( status, EINVAL, "bad itimer value #1" );
0119
0120 itimer.it_value.tv_nsec = -1;
0121 puts( "timer_settime - bad itimer value - negative nanosecond - EINVAL" );
0122 status = timer_settime( timer, TIMER_ABSTIME, &itimer, NULL );
0123 fatal_posix_service_status_errno( status, EINVAL, "bad itimer value #2" );
0124
0125 clock_gettime( CLOCK_REALTIME, &now );
0126 itimer.it_value = now;
0127 itimer.it_value.tv_sec = itimer.it_value.tv_sec - 1;
0128 puts( "timer_settime - bad itimer value - previous time - EINVAL" );
0129 status = timer_settime( timer, TIMER_ABSTIME, &itimer, NULL );
0130 fatal_posix_service_status_errno( status, EINVAL, "bad itimer value #3" );
0131
0132 clock_gettime( CLOCK_REALTIME, &now );
0133 itimer.it_value = now;
0134 itimer.it_value.tv_sec = itimer.it_value.tv_sec + 1;
0135 puts( "timer_settime - bad id - EINVAL" );
0136 status = timer_settime( timer1, TIMER_ABSTIME, &itimer, NULL );
0137 fatal_posix_service_status_errno( status, EINVAL, "bad id" );
0138
0139 itimer.it_value.tv_nsec = 0;
0140 puts( "timer_settime - bad clock value - EINVAL" );
0141 status = timer_settime( timer, 0x80, &itimer, NULL );
0142 fatal_posix_service_status_errno( status, EINVAL, "bad clock value" );
0143
0144 puts( "timer_delete - OK" );
0145 status = timer_delete( timer );
0146 posix_service_failed( status, "timer_delete OK" );
0147
0148 puts( "timer_delete - bad id - EINVAL" );
0149 status = timer_delete( timer );
0150 fatal_posix_service_status_errno( status, EINVAL, "bad id" );
0151
0152 puts( "timer_create (monotonic) - bad timer id pointer - EINVAL" );
0153 status = timer_create( CLOCK_MONOTONIC, &event, NULL );
0154 fatal_posix_service_status_errno( status, EINVAL, "bad timer id" );
0155
0156 puts( "timer_create (monotonic) - OK" );
0157 status = timer_create( CLOCK_MONOTONIC, NULL, &timer );
0158 posix_service_failed( status, "timer_create OK" );
0159
0160 puts( "timer_create (monotonic) - too many - EAGAIN" );
0161 status = timer_create( CLOCK_MONOTONIC, NULL, &timer1 );
0162 fatal_posix_service_status_errno( status, EAGAIN, "too many" );
0163
0164 clock_gettime( CLOCK_MONOTONIC, &now );
0165 itimer.it_value = now;
0166 itimer.it_value.tv_sec = itimer.it_value.tv_sec - 1;
0167 puts( "timer_settime (monotonic) - bad itimer value - previous time - EINVAL" );
0168 status = timer_settime( timer, TIMER_ABSTIME, &itimer, NULL );
0169 fatal_posix_service_status_errno( status, EINVAL, "bad itimer value #3" );
0170
0171 clock_gettime( CLOCK_MONOTONIC, &now );
0172 itimer.it_value = now;
0173 itimer.it_value.tv_sec = itimer.it_value.tv_sec + 1;
0174 puts( "timer_settime (monotonic) - bad id - EINVAL" );
0175 status = timer_settime( timer1, TIMER_ABSTIME, &itimer, NULL );
0176 fatal_posix_service_status_errno( status, EINVAL, "bad id" );
0177
0178 TEST_END();
0179 rtems_test_exit (0);
0180 }