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 #define CONFIGURE_INIT
0020 #include "system.h"
0021
0022 #include <rtems/score/scheduleredfimpl.h>
0023
0024 const char rtems_test_name[] = "SPQRESLIB";
0025
0026 rtems_id Task_id;
0027 rtems_task_priority Priority;
0028 time_t Period;
0029 time_t Execution;
0030 time_t Phase;
0031
0032 rtems_task Init(
0033 rtems_task_argument argument
0034 )
0035 {
0036 rtems_status_code status;
0037 qres_sid_t server_id, server_id2;
0038 time_t approved_budget, exec_time, abs_time, current_budget;
0039 qres_params_t params, params1, params3;
0040
0041 Priority = 30;
0042 Period = 30;
0043 Execution = 10;
0044 Phase = 0;
0045
0046 params.P = 1;
0047 params.Q = 1;
0048
0049 params1 = params3 = params;
0050 params1.Q = -1;
0051 params3.P = -1;
0052
0053 TEST_BEGIN();
0054
0055
0056 status = rtems_task_create(
0057 rtems_build_name( 'P', 'T', '1', ' ' ),
0058 Priority,
0059 RTEMS_MINIMUM_STACK_SIZE * 4,
0060 RTEMS_DEFAULT_MODES,
0061 RTEMS_DEFAULT_ATTRIBUTES,
0062 &Task_id
0063 );
0064 directive_failed( status, "rtems_task_create loop" );
0065
0066 printf( "Init: Initializing the qres library\n" );
0067 if ( qres_init() )
0068 printf( "ERROR: QRES INITIALIZATION FAILED\n" );
0069
0070
0071 printf( "Init: Create server and Destroy server\n" );
0072 if ( qres_destroy_server( -5 ) !=
0073 QOS_E_INVALID_PARAM )
0074 printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
0075 if ( qres_destroy_server( 5 ) !=
0076 QOS_E_INVALID_PARAM )
0077 printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
0078 if ( qres_destroy_server( 0 ) != QOS_E_NOSERVER )
0079 printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
0080 if ( qres_create_server( ¶ms1, &server_id ) !=
0081 QOS_E_INVALID_PARAM )
0082 printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
0083 if ( qres_create_server( ¶ms3, &server_id ) !=
0084 QOS_E_INVALID_PARAM )
0085 printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
0086 if ( qres_create_server( ¶ms, &server_id2 ) )
0087 printf( "ERROR: CREATE SERVER FAILED\n" );
0088 if ( qres_create_server( ¶ms, &server_id ) )
0089 printf( "ERROR: CREATE SERVER FAILED\n" );
0090 if ( qres_create_server( ¶ms, &server_id ) !=
0091 QOS_E_FULL )
0092 printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
0093
0094
0095 printf( "Init: Attach thread\n" );
0096 if ( qres_attach_thread( -5, 0, RTEMS_SELF ) !=
0097 QOS_E_INVALID_PARAM )
0098 printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
0099 if ( qres_attach_thread( 5, 0, RTEMS_SELF ) !=
0100 QOS_E_INVALID_PARAM )
0101 printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
0102 if ( qres_attach_thread( server_id, 0, 1234 ) !=
0103 QOS_E_INVALID_PARAM )
0104 printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
0105 if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) )
0106 printf( "ERROR: ATTACH THREAD FAILED\n" );
0107 if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) !=
0108 QOS_E_FULL )
0109 printf( "ERROR: ATTACH THREAD AGAIN PASSED UNEXPECTEDLY\n" );
0110 if ( qres_attach_thread( server_id, 0, Task_id ) !=
0111 QOS_E_FULL )
0112 printf( "ERROR: ATTACH THREAD TO FULL SERVER PASSED UNEXPECTEDLY \n" );
0113 if ( qres_destroy_server( server_id ) )
0114 printf( "ERROR: DESTROY SERVER WITH THREAD ATTACHED FAILED\n" );
0115 if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) !=
0116 QOS_E_NOSERVER )
0117 printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
0118
0119 printf( "Init: Detach thread\n" );
0120 if ( qres_detach_thread( -5, 0, RTEMS_SELF ) !=
0121 QOS_E_INVALID_PARAM )
0122 printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
0123 if ( qres_detach_thread( 5, 0, RTEMS_SELF ) !=
0124 QOS_E_INVALID_PARAM )
0125 printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
0126 if ( qres_detach_thread( server_id2, 0, 1234 ) !=
0127 QOS_E_INVALID_PARAM )
0128 printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY \n" );
0129 if ( qres_detach_thread( server_id, 0, RTEMS_SELF ) !=
0130 QOS_E_NOSERVER )
0131 printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY4\n" );
0132 qres_destroy_server( server_id2 );
0133
0134
0135 printf( "Init: Set params and Get params\n" );
0136 if ( qres_set_params( -5, ¶ms ) !=
0137 QOS_E_INVALID_PARAM )
0138 printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
0139 if ( qres_set_params( 5, ¶ms ) !=
0140 QOS_E_INVALID_PARAM )
0141 printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
0142 if ( qres_set_params( server_id, ¶ms ) !=
0143 QOS_E_NOSERVER )
0144 printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
0145
0146 if ( qres_get_params( -5, ¶ms ) !=
0147 QOS_E_INVALID_PARAM )
0148 printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
0149 if ( qres_get_params( 5, ¶ms ) !=
0150 QOS_E_INVALID_PARAM )
0151 printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
0152 if ( qres_get_params( server_id, ¶ms ) !=
0153 QOS_E_NOSERVER )
0154 printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
0155
0156 if ( qres_set_params( server_id, ¶ms1 ) !=
0157 QOS_E_INVALID_PARAM )
0158 printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
0159 if ( qres_set_params( server_id, ¶ms3 ) !=
0160 QOS_E_INVALID_PARAM )
0161 printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
0162
0163
0164 printf( "Init: Get server id\n" );
0165 if ( qres_get_sid( 0, RTEMS_SELF, &server_id ) !=
0166 QOS_E_NOSERVER )
0167 printf( "ERROR: GET SERVER ID PASSED UNEXPECTEDLY\n" );
0168
0169
0170 printf( "Init: Get approved budget\n" );
0171 if ( qres_get_appr_budget( -5, &approved_budget ) !=
0172 QOS_E_INVALID_PARAM )
0173 printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
0174 if ( qres_get_appr_budget( 5, &approved_budget ) !=
0175 QOS_E_INVALID_PARAM )
0176 printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
0177 if ( qres_get_appr_budget( server_id, &approved_budget ) !=
0178 QOS_E_NOSERVER )
0179 printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
0180
0181
0182 printf( "Init: Get current budget\n" );
0183 if ( qres_get_curr_budget( -5, ¤t_budget ) !=
0184 QOS_E_INVALID_PARAM )
0185 printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
0186 if ( qres_get_curr_budget( 5, ¤t_budget ) !=
0187 QOS_E_INVALID_PARAM )
0188 printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
0189 if ( qres_get_curr_budget( server_id, ¤t_budget ) !=
0190 QOS_E_NOSERVER )
0191 printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
0192
0193
0194 printf( "Init: Get execution time\n" );
0195 if ( qres_get_exec_time( -5, &exec_time, &abs_time ) !=
0196 QOS_E_INVALID_PARAM )
0197 printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
0198 if ( qres_get_exec_time( 5, &exec_time, &abs_time ) !=
0199 QOS_E_INVALID_PARAM )
0200 printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
0201 if ( qres_get_exec_time( server_id, &exec_time, &abs_time ) !=
0202 QOS_E_NOSERVER )
0203 printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
0204
0205
0206 printf( "Init: Cleaning up QRES\n" );
0207 if ( qres_cleanup() )
0208 printf( "ERROR: QRES CLEANUP FAILED\n" );
0209 printf( "Init: Initializing the QRES\n" );
0210 if ( qres_init() )
0211 printf( "ERROR: QRES INITIALIZATION FAILED\n" );
0212
0213
0214 printf( "Init: Starting periodic task\n" );
0215 status = rtems_task_start( Task_id, Task_Periodic, 1 );
0216 directive_failed( status, "rtems_task_start periodic" );
0217
0218 rtems_task_exit();
0219 }