File indexing completed on 2025-05-11 08:24:36
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 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #include <sched.h>
0034 #include <sys/utsname.h>
0035
0036 #define CONFIGURE_INIT
0037 #include "system.h"
0038 #include "pritime.h"
0039
0040 #include <rtems/score/todimpl.h>
0041
0042 const char rtems_test_name[] = "PSX 1";
0043
0044 void *POSIX_Init(
0045 void *argument
0046 )
0047 {
0048 struct timespec tr;
0049 int status;
0050 int priority;
0051 pthread_t thread_id;
0052 struct utsname uts;
0053
0054 TEST_BEGIN();
0055
0056
0057
0058 puts( "Init: uname - EFAULT (invalid uts pointer argument)" );
0059 status = uname( NULL );
0060 rtems_test_assert( status == -1 );
0061 rtems_test_assert( errno == EFAULT );
0062
0063 status = uname( &uts );
0064 rtems_test_assert( !status );
0065 printf( "Init: uts.sysname: %s\n", uts.sysname );
0066 printf( "Init: uts.nodename: %s\n", uts.nodename );
0067 printf( "Init: uts.release: %s\n", uts.release );
0068 printf( "Init: uts.version: %s\n", uts.version );
0069 printf( "Init: uts.machine: %s\n", uts.machine );
0070 puts("");
0071
0072
0073
0074 Init_id = pthread_self();
0075 printf( "Init: ID is 0x%08" PRIxpthread_t "\n", Init_id );
0076
0077
0078
0079 priority = sched_get_priority_min( SCHED_FIFO );
0080 printf( "Init: sched_get_priority_min (SCHED_FIFO) -- %d\n", priority );
0081 rtems_test_assert( priority != -1 );
0082
0083 puts( "Init: sched_get_priority_min -- EINVAL (invalid policy)" );
0084 priority = sched_get_priority_min( -1 );
0085 rtems_test_assert( priority == -1 );
0086 rtems_test_assert( errno == EINVAL );
0087
0088
0089
0090 priority = sched_get_priority_max( SCHED_FIFO );
0091 printf( "Init: sched_get_priority_max (SCHED_FIFO) -- %d\n", priority );
0092 rtems_test_assert( priority != -1 );
0093
0094 puts( "Init: sched_get_priority_max -- EINVAL (invalid policy)" );
0095 priority = sched_get_priority_max( -1 );
0096 rtems_test_assert( priority == -1 );
0097 rtems_test_assert( errno == EINVAL );
0098
0099 puts( "Init: sched_rr_get_interval -- ESRCH (invalid PID)" );
0100 status = sched_rr_get_interval( 4, &tr );
0101 rtems_test_assert( status == -1 );
0102 rtems_test_assert( errno == ESRCH );
0103
0104 puts( "Init: sched_rr_get_interval -- EINVAL (invalid interval pointer)" );
0105 status = sched_rr_get_interval( getpid(), NULL );
0106 rtems_test_assert( status == -1 );
0107 rtems_test_assert( errno == EINVAL );
0108
0109
0110
0111 status = sched_rr_get_interval( getpid(), &tr );
0112 printf(
0113 "Init: Round Robin quantum is %" PRIdtime_t " seconds, %ld nanoseconds\n",
0114 tr.tv_sec,
0115 tr.tv_nsec
0116 );
0117 rtems_test_assert( !status );
0118
0119
0120
0121 puts( "Init: pthread_create - SUCCESSFUL" );
0122 status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL );
0123 rtems_test_assert( !status );
0124
0125
0126
0127 puts( "Init: pthread_create - EAGAIN (too many threads)" );
0128 status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL );
0129 rtems_test_assert( status == EAGAIN );
0130
0131 puts( "Init: sched_yield to Task_1" );
0132 status = sched_yield();
0133 rtems_test_assert( !status );
0134
0135
0136
0137
0138
0139 puts( "Init: pthread_exit" );
0140 pthread_exit( NULL );
0141
0142
0143
0144 return NULL;
0145 }