File indexing completed on 2025-05-11 08:24:48
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 #define CONFIGURE_INIT
0034 #include "system.h"
0035
0036 #define MESSAGE_SIZE (sizeof(long) * 4)
0037
0038 const char rtems_test_name[] = "SP SEMAPHORE ERROR 01";
0039
0040 rtems_task Init(
0041 rtems_task_argument argument
0042 )
0043 {
0044 rtems_status_code status;
0045
0046 TEST_BEGIN();
0047
0048 Semaphore_name[ 1 ] = rtems_build_name( 'S', 'M', '1', ' ' );
0049 Semaphore_name[ 2 ] = rtems_build_name( 'S', 'M', '2', ' ' );
0050 Semaphore_name[ 3 ] = rtems_build_name( 'S', 'M', '3', ' ' );
0051
0052
0053 status = rtems_semaphore_create(
0054 Semaphore_name[ 1 ],
0055 UINT32_MAX,
0056 RTEMS_COUNTING_SEMAPHORE,
0057 0,
0058 &Semaphore_id[ 1 ]
0059 );
0060 fatal_directive_status(
0061 status,
0062 RTEMS_SUCCESSFUL,
0063 "rtems_semaphore_create"
0064 );
0065 puts( "TA1 - rtems_semaphore_create - RTEMS_SUCCESSFUL" );
0066 status = rtems_semaphore_release( Semaphore_id[ 1 ] );
0067 fatal_directive_status(
0068 status,
0069 RTEMS_UNSATISFIED,
0070 "rtems_semaphore_release"
0071 );
0072 puts( "TA1 - rtems_semaphore_release - RTEMS_UNSATISFIED" );
0073 status = rtems_semaphore_delete( Semaphore_id[ 1 ] );
0074 fatal_directive_status(
0075 status,
0076 RTEMS_SUCCESSFUL,
0077 "rtems_semaphore_delete"
0078 );
0079 puts( "TA1 - rtems_semaphore_delete - RTEMS_SUCCESSFUL" );
0080
0081
0082 status = rtems_semaphore_create(
0083 0,
0084 1,
0085 RTEMS_DEFAULT_ATTRIBUTES,
0086 RTEMS_NO_PRIORITY,
0087 &Junk_id
0088 );
0089 fatal_directive_status(
0090 status,
0091 RTEMS_INVALID_NAME,
0092 "rtems_semaphore_create with illegal name"
0093 );
0094 puts( "TA1 - rtems_semaphore_create - RTEMS_INVALID_NAME" );
0095
0096
0097 status = rtems_semaphore_create(
0098 Semaphore_name[ 1 ],
0099 1,
0100 RTEMS_DEFAULT_ATTRIBUTES,
0101 RTEMS_NO_PRIORITY,
0102 NULL
0103 );
0104 fatal_directive_status(
0105 status,
0106 RTEMS_INVALID_ADDRESS,
0107 "rtems_semaphore_create with NULL param"
0108 );
0109 puts( "TA1 - rtems_semaphore_create - RTEMS_INVALID_ADDRESS" );
0110
0111
0112 status = rtems_semaphore_create(
0113 Semaphore_name[ 1 ],
0114 1,
0115 RTEMS_DEFAULT_ATTRIBUTES,
0116 RTEMS_NO_PRIORITY,
0117 &Semaphore_id[ 1 ]
0118 );
0119 directive_failed( status, "rtems_semaphore_create" );
0120 puts( "TA1 - rtems_semaphore_create - 1 - RTEMS_SUCCESSFUL" );
0121
0122 status = rtems_semaphore_create(
0123 Semaphore_name[ 2 ],
0124 1,
0125 RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
0126 RTEMS_NO_PRIORITY,
0127 &Semaphore_id[ 2 ]
0128 );
0129 directive_failed( status, "rtems_semaphore_create" );
0130 puts( "TA1 - rtems_semaphore_create - 2 - RTEMS_SUCCESSFUL" );
0131
0132 do {
0133 status = rtems_semaphore_create(
0134 Semaphore_name[ 3 ],
0135 1,
0136 RTEMS_DEFAULT_ATTRIBUTES,
0137 RTEMS_NO_PRIORITY,
0138 &Junk_id
0139 );
0140 } while (status == RTEMS_SUCCESSFUL);
0141
0142 fatal_directive_status(
0143 status,
0144 RTEMS_TOO_MANY,
0145 "rtems_semaphore_create of too many"
0146 );
0147 puts( "TA1 - rtems_semaphore_create - 3 - RTEMS_TOO_MANY" );
0148
0149 status = rtems_semaphore_create(
0150 Semaphore_name[ 1 ],
0151 1,
0152 RTEMS_INHERIT_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_FIFO,
0153 RTEMS_NO_PRIORITY,
0154 &Junk_id
0155 );
0156 fatal_directive_status(
0157 status,
0158 RTEMS_NOT_DEFINED,
0159 "rtems_semaphore_create of RTEMS_FIFO RTEMS_INHERIT_PRIORITY"
0160 );
0161 puts( "TA1 - rtems_semaphore_create - FIFO and inherit - RTEMS_NOT_DEFINED" );
0162
0163 status = rtems_semaphore_create(
0164 Semaphore_name[ 1 ],
0165 1,
0166 RTEMS_PRIORITY_CEILING | RTEMS_BINARY_SEMAPHORE | RTEMS_FIFO,
0167 RTEMS_NO_PRIORITY,
0168 &Junk_id
0169 );
0170 fatal_directive_status(
0171 status,
0172 RTEMS_NOT_DEFINED,
0173 "rtems_semaphore_create of RTEMS_FIFO RTEMS_CEILING_PRIORITY"
0174 );
0175 puts( "TA1 - rtems_semaphore_create - FIFO and ceiling - RTEMS_NOT_DEFINED" );
0176
0177 status = rtems_semaphore_create(
0178 Semaphore_name[ 1 ],
0179 1,
0180 RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY_CEILING |
0181 RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY,
0182 10,
0183 &Junk_id
0184 );
0185 fatal_directive_status(
0186 status,
0187 RTEMS_NOT_DEFINED,
0188 "rtems_semaphore_create of binary with ceiling and inherit"
0189 );
0190 puts(
0191 "TA1 - rtems_semaphore_create - ceiling and inherit - RTEMS_NOT_DEFINED" );
0192
0193 status = rtems_semaphore_create(
0194 Semaphore_name[ 1 ],
0195 1,
0196 RTEMS_INHERIT_PRIORITY | RTEMS_COUNTING_SEMAPHORE | RTEMS_PRIORITY,
0197 RTEMS_NO_PRIORITY,
0198 &Junk_id
0199 );
0200 fatal_directive_status(
0201 status,
0202 RTEMS_NOT_DEFINED,
0203 "rtems_semaphore_create of RTEMS_COUNTING_SEMAPHORE RTEMS_INHERIT_PRIORITY"
0204 );
0205 puts( "TA1 - rtems_semaphore_create - RTEMS_NOT_DEFINED" );
0206
0207 status = rtems_semaphore_create(
0208 Semaphore_name[ 1 ],
0209 2,
0210 RTEMS_BINARY_SEMAPHORE,
0211 RTEMS_NO_PRIORITY,
0212 &Junk_id
0213 );
0214 fatal_directive_status(
0215 status,
0216 RTEMS_INVALID_NUMBER,
0217 "rtems_semaphore_create of binary semaphore with count > 1"
0218 );
0219 puts( "TA1 - rtems_semaphore_create - RTEMS_INVALID_NUMBER" );
0220
0221 status = rtems_semaphore_delete( 100 );
0222 fatal_directive_status(
0223 status,
0224 RTEMS_INVALID_ID,
0225 "rtems_semaphore_delete with illegal id"
0226 );
0227 puts( "TA1 - rtems_semaphore_delete - RTEMS_INVALID_ID" );
0228
0229 status = rtems_semaphore_delete( rtems_build_id( 1, 0, 0, 0 ) );
0230 fatal_directive_status(
0231 status,
0232 RTEMS_INVALID_ID,
0233 "rtems_semaphore_delete with local illegal id"
0234 );
0235 puts( "TA1 - rtems_semaphore_delete - local RTEMS_INVALID_ID" );
0236
0237 status = rtems_semaphore_ident( 100, RTEMS_SEARCH_ALL_NODES, &Junk_id );
0238 fatal_directive_status(
0239 status,
0240 RTEMS_INVALID_NAME,
0241 "rtems_semaphore_ident will illegal name (local)"
0242 );
0243 puts( "TA1 - rtems_semaphore_ident - global RTEMS_INVALID_NAME" );
0244
0245 status = rtems_semaphore_ident( 100, 1, &Junk_id );
0246 fatal_directive_status(
0247 status,
0248 RTEMS_INVALID_NAME,
0249 "rtems_semaphore_ident will illegal name (global)"
0250 );
0251 puts( "TA1 - rtems_semaphore_ident - local RTEMS_INVALID_NAME" );
0252
0253 status = rtems_semaphore_release( 100 );
0254 fatal_directive_status(
0255 status,
0256 RTEMS_INVALID_ID,
0257 "rtems_semaphore_release with illegal id"
0258 );
0259 puts( "TA1 - rtems_semaphore_release - RTEMS_INVALID_ID" );
0260
0261 status = rtems_semaphore_flush( 100 );
0262 fatal_directive_status(
0263 status,
0264 RTEMS_INVALID_ID,
0265 "rtems_semaphore_flush with illegal id"
0266 );
0267 puts( "TA1 - rtems_semaphore_flush - RTEMS_INVALID_ID" );
0268
0269 TEST_END();
0270 }