Sebastian Huber commented: https://gitlab.rtems.org/rtems/prequal/rtems-central/-/merge_requests/20#note_151752 The interrupt controller is not specified by the RISC-V ISA. So, I think adding a special case at the architecture level is not the right approach. For example, the griscv BSP uses an interrupt controller with a maximum priority less than `UINT32_MAX`. All the present interrupt validation tests have a structural issue. They contain the loop over all interrupt vectors directly in the action requirement. This is not the right approach. It is better to use an action requirement which produces a test run function by defining a test header through the `test-header` attribute. Then call the test run function for all interrupt vectors. This approach allows to using the `${.:skip}` feature. Please have a look at the following patch: ```diff commit ac43535e2e8dcbceeb44fba17375de9c4fd05abb Author: Sebastian Huber <[email protected]> Date: Sun Jan 12 13:58:38 2025 +0100 spec: Rework get/set interrupt priority Add support for RISC-V PLIC. This interrupt controller supports a maximum priority of UINT32_MAX. diff --git a/spec/rtems/intr/req/get-priority.yml b/spec/rtems/intr/req/get-priority.yml index 332e656ebc..3a1f100627 100644 --- a/spec/rtems/intr/req/get-priority.yml +++ b/spec/rtems/intr/req/get-priority.yml @@ -11,25 +11,25 @@ post-conditions: states: - name: Ok test-code: | - ctx->expected_status = RTEMS_SUCCESSFUL; + T_rsc_success( ctx->status ); text: | The return status of ${../if/get-priority:/name} shall be ${../../status/if/successful:/name}. - name: InvAddr test-code: | - ctx->expected_status = RTEMS_INVALID_ADDRESS; + T_rsc( ctx->status, RTEMS_INVALID_ADDRESS ); text: | The return status of ${../if/get-priority:/name} shall be ${../../status/if/invalid-address:/name}. - name: InvId test-code: | - ctx->expected_status = RTEMS_INVALID_ID; + T_rsc( ctx->status, RTEMS_INVALID_ID ); text: | The return status of ${../if/get-priority:/name} shall be ${../../status/if/invalid-id:/name}. - name: Unsat test-code: | - ctx->expected_status = RTEMS_UNSATISFIED; + T_rsc( ctx->status, RTEMS_UNSATISFIED ); text: | The return status of ${../if/get-priority:/name} shall be ${../../status/if/unsatisfied:/name}. @@ -39,7 +39,7 @@ post-conditions: states: - name: Set test-code: | - ctx->expected_priority = PriorityIsSet; + T_ne_u32( ctx->priority_obj, PRIORITY_UNSET ); text: | The value of the object referenced by the ${../if/get-priority:/params[1]/name} parameter shall be set by the @@ -48,26 +48,25 @@ post-conditions: during the directive call. - name: Nop test-code: | - ctx->expected_priority = PriorityIsNotSet; + T_eq_u32( ctx->priority_obj, PRIORITY_UNSET ); text: | The value of the object referenced by the ${../if/get-priority:/params[1]/name} parameter shall not be changed by the directive call. test-epilogue: null - test-prologue: | - ctx->expected_priority = PriorityIsNotSet; + test-prologue: null pre-conditions: - name: Vector states: - name: Valid test-code: | - ctx->valid_vector = true; + ctx->vector = ctx->valid_vector; text: | While the ${../if/get-priority:/params[0]/name} parameter is associated with an interrupt vector. - name: Invalid test-code: | - ctx->valid_vector = false; + ctx->vector = BSP_INTERRUPT_VECTOR_COUNT; text: | While the ${../if/get-priority:/params[0]/name} parameter is not associated with an interrupt vector. @@ -93,13 +92,17 @@ pre-conditions: states: - name: 'Yes' test-code: | - ctx->can_get_priority = true; + if ( !ctx->can_get_priority ) { + ${.:skip} + } text: | While getting the priority for the interrupt vector specified by ${../if/get-priority:/params[0]/name} parameter is supported. - name: 'No' test-code: | - ctx->can_get_priority = false; + if ( ctx->can_get_priority ) { + ${.:skip} + } text: | While getting the priority for the interrupt vector specified by ${../if/get-priority:/params[0]/name} parameter is not supported. @@ -110,56 +113,23 @@ references: [] requirement-type: functional skip-reasons: {} test-action: | - /* Action carried out by CheckGetPriority() */ + ctx->priority_obj = PRIORITY_UNSET; + ctx->status = rtems_interrupt_get_priority( ctx->vector, ctx->priority ); test-brief: null -test-cleanup: | - if ( ctx->valid_vector ) { - rtems_vector_number vector; - - for ( - vector = 0; - vector < BSP_INTERRUPT_VECTOR_COUNT; - ++vector - ) { - rtems_interrupt_attributes attr; - rtems_status_code sc; - - memset( &attr, 0, sizeof( attr ) ); - sc = rtems_interrupt_get_attributes( vector, &attr ); - - if ( sc == RTEMS_INVALID_ID ) { - continue; - } - - T_rsc_success( sc ); - - if ( attr.can_get_priority != ctx->can_get_priority ) { - continue; - } - - CheckGetPriority( ctx, vector ); - } - } else { - CheckGetPriority( ctx, BSP_INTERRUPT_VECTOR_COUNT ); - } +test-cleanup: null test-context: - brief: | - This member provides the object referenced by the - ${../if/get-priority:/params[1]/name} parameter. - description: null - member: | - uint32_t priority_obj -- brief: | - If this member is true, then the ${../if/get-priority:/params[0]/name} - parameter shall be valid. + This member specifies the ${../if/get-priority:/params[0]/name} parameter + value. description: null member: | - bool valid_vector + rtems_vector_number vector - brief: | - If this member is true, then getting the priority shall be supported. + This member provides the object referenced by the + ${../if/get-priority:/params[1]/name} parameter. description: null member: | - bool can_get_priority + uint32_t priority_obj - brief: | This member specifies the ${../if/get-priority:/params[1]/name} parameter value. @@ -167,51 +137,40 @@ test-context: member: | uint32_t *priority - brief: | - This member specifies the expected status. - description: null - member: | - rtems_status_code expected_status -- brief: | - This member specifies the expected value of the priority object. + This member contains the return status. description: null member: | - void (*expected_priority)(uint32_t) + rtems_status_code status test-context-support: null test-description: null -test-header: null +test-header: + code: null + freestanding: false + includes: [] + local-includes: [] + run-params: + - description: | + is a valid interrupt vector number. + dir: in + name: valid_vector + specifier: ${../if/vector-number:/name} ${.:name} + - description: | + is true, if getting the priority is supported. + dir: in + name: can_get_priority + specifier: bool ${.:name} + target: testsuites/validation/tr-intr-get-priority.h test-includes: - rtems.h - bsp/irq-generic.h test-local-includes: -- tx-support.h +- tr-intr-get-priority.h test-prepare: null test-setup: null test-stop: null test-support: | - typedef ${.:/test-context-type} Context; - #define PRIORITY_UNSET (UINT32_MAX - 1234) - - static void PriorityIsSet( uint32_t priority ) - { - T_lt_u32( priority, PRIORITY_UNSET ); - } - - static void PriorityIsNotSet( uint32_t priority ) - { - T_eq_u32( priority, PRIORITY_UNSET ); - } - - static void CheckGetPriority( Context *ctx, rtems_vector_number vector ) - { - rtems_status_code sc; - - ctx->priority_obj = PRIORITY_UNSET; - sc = rtems_interrupt_get_priority( vector, ctx->priority ); - T_rsc( sc, ctx->expected_status ); - (*ctx->expected_priority)( ctx->priority_obj ); - } -test-target: testsuites/validation/tc-intr-get-priority.c +test-target: testsuites/validation/tr-intr-get-priority.c test-teardown: null text: ${.:text-template} transition-map: diff --git a/spec/rtems/intr/req/set-priority.yml b/spec/rtems/intr/req/set-priority.yml index 2a49d0f609..f62f563875 100644 --- a/spec/rtems/intr/req/set-priority.yml +++ b/spec/rtems/intr/req/set-priority.yml @@ -11,25 +11,25 @@ post-conditions: states: - name: Ok test-code: | - ctx->expected_status = RTEMS_SUCCESSFUL; + T_rsc_success( ctx->status ); text: | The return status of ${../if/set-priority:/name} shall be ${../../status/if/successful:/name}. - name: InvId test-code: | - ctx->expected_status = RTEMS_INVALID_ID; + T_rsc( ctx->status, RTEMS_INVALID_ID ); text: | The return status of ${../if/set-priority:/name} shall be ${../../status/if/invalid-id:/name}. - name: InvPrio test-code: | - ctx->expected_status = RTEMS_INVALID_PRIORITY; + T_rsc( ctx->status, RTEMS_INVALID_PRIORITY ); text: | The return status of ${../if/set-priority:/name} shall be ${../../status/if/invalid-priority:/name}. - name: Unsat test-code: | - ctx->expected_status = RTEMS_UNSATISFIED; + T_rsc( ctx->status, RTEMS_UNSATISFIED ); text: | The return status of ${../if/set-priority:/name} shall be ${../../status/if/unsatisfied:/name}. @@ -40,13 +40,13 @@ pre-conditions: states: - name: Valid test-code: | - ctx->valid_vector = true; + ctx->vector = ctx->valid_vector; text: | While the ${../if/set-priority:/params[0]/name} parameter is associated with an interrupt vector. - name: Invalid test-code: | - ctx->valid_vector = false; + ctx->vector = BSP_INTERRUPT_VECTOR_COUNT; text: | While the ${../if/set-priority:/params[0]/name} parameter is not associated with an interrupt vector. @@ -56,13 +56,17 @@ pre-conditions: states: - name: Valid test-code: | - ctx->valid_priority = true; + ctx->priority = ctx->current_priority; text: | While the ${../if/set-priority:/params[1]/name} parameter is a valid priority value. - name: Invalid test-code: | - ctx->valid_priority = false; + if ( ctx->maximum_priority < UINT32_MAX ) { + ctx->priority = UINT32_MAX; + } else { + ${.:skip} + } text: | While the ${../if/set-priority:/params[1]/name} parameter is an invalid priority value. @@ -72,13 +76,17 @@ pre-conditions: states: - name: 'Yes' test-code: | - ctx->can_set_priority = true; + if ( !ctx->can_set_priority ) { + ${.:skip} + } text: | While setting the priority for the interrupt vector specified by ${../if/set-priority:/params[0]/name} parameter is supported. - name: 'No' test-code: | - ctx->can_set_priority = false; + if ( ctx->can_set_priority ) { + ${.:skip} + } text: | While setting the priority for the interrupt vector specified by ${../if/set-priority:/params[0]/name} parameter is not supported. @@ -89,90 +97,72 @@ references: [] requirement-type: functional skip-reasons: {} test-action: | - /* Action carried out by CheckSetPriority() */ + ctx->status = rtems_interrupt_set_priority( ctx->vector, ctx->priority ); test-brief: null test-cleanup: | - if ( ctx->valid_vector ) { - rtems_vector_number vector; - - for ( - vector = 0; - vector < BSP_INTERRUPT_VECTOR_COUNT; - ++vector - ) { - rtems_interrupt_attributes attr; - rtems_status_code sc; - - memset( &attr, 0, sizeof( attr ) ); - sc = rtems_interrupt_get_attributes( vector, &attr ); - - if ( sc == RTEMS_INVALID_ID ) { - continue; - } - - T_rsc_success( sc ); - - if ( attr.can_set_priority != ctx->can_set_priority ) { - continue; - } - - CheckSetPriority( ctx, vector ); - } - } else { - CheckSetPriority( ctx, BSP_INTERRUPT_VECTOR_COUNT ); - } + (void) rtems_interrupt_set_priority( ctx->valid_vector, ctx->current_priority ); test-context: - brief: | - If this member is true, then the ${../if/set-priority:/params[0]/name} - parameter shall be valid. + This member contains the current priority value. description: null member: | - bool valid_vector + uint32_t current_priority - brief: | - If this member is true, then the ${../if/set-priority:/params[1]/name} - parameter shall be valid. + This member specifies the ${../if/set-priority:/params[0]/name} parameter + value. description: null member: | - bool valid_priority + rtems_vector_number vector - brief: | - If this member is true, then setting the priority shall be supported. + This member specifies the ${../if/set-priority:/params[1]/name} parameter + value. description: null member: | - bool can_set_priority + uint32_t priority - brief: | - This member specifies the expected status. + This member contains the return status. description: null member: | - rtems_status_code expected_status + rtems_status_code status test-context-support: null test-description: null -test-header: null +test-header: + code: null + freestanding: false + includes: [] + local-includes: [] + run-params: + - description: | + is a valid interrupt vector number. + dir: in + name: valid_vector + specifier: ${../if/vector-number:/name} ${.:name} + - description: | + is the maximum supported priority value. + dir: in + name: maximum_priority + specifier: uint32_t ${.:name} + - description: | + is true, if setting the priority is supported. + dir: in + name: can_set_priority + specifier: bool ${.:name} + target: testsuites/validation/tr-intr-set-priority.h test-includes: - rtems.h - bsp/irq-generic.h test-local-includes: -- tx-support.h -test-prepare: null +- tr-intr-set-priority.h +test-prepare: | + ctx->current_priority = 0; + (void) rtems_interrupt_get_priority( + ctx->valid_vector, + &ctx->current_priority + ); test-setup: null test-stop: null -test-support: | - typedef ${.:/test-context-type} Context; - - static void CheckSetPriority( Context *ctx, rtems_vector_number vector ) - { - rtems_status_code sc; - uint32_t priority; - - if ( ctx->valid_priority ) { - (void) rtems_interrupt_get_priority( vector, &priority ); - } else { - priority = UINT32_MAX; - } - - sc = rtems_interrupt_set_priority( vector, priority ); - T_rsc( sc, ctx->expected_status ); - } -test-target: testsuites/validation/tc-intr-set-priority.c +test-support: null +test-target: testsuites/validation/tr-intr-set-priority.c test-teardown: null text: ${.:text-template} transition-map: diff --git a/spec/rtems/intr/val/intr.yml b/spec/rtems/intr/val/intr.yml index baabecb478..bf0120d28a 100644 --- a/spec/rtems/intr/val/intr.yml +++ b/spec/rtems/intr/val/intr.yml @@ -199,6 +199,60 @@ test-actions: - role: validation uid: ../req/entry-initialize-info links: [] +- action-brief: | + Check ${../if/get-priority:/name} for each valid vector. + action-code: | + rtems_vector_number vector; + + for ( + vector = 0; + vector < BSP_INTERRUPT_VECTOR_COUNT; + ++vector + ) { + rtems_interrupt_attributes attr; + rtems_status_code sc; + + memset( &attr, 0, sizeof( attr ) ); + sc = rtems_interrupt_get_attributes( vector, &attr ); + + if ( sc == RTEMS_INVALID_ID ) { + continue; + } + + T_rsc_success( sc ); + ${../req/get-priority:/test-run}( vector, attr.can_get_priority ); + } + checks: [] + links: [] +- action-brief: | + Check ${../if/set-priority:/name} for each valid vector. + action-code: | + rtems_vector_number vector; + + for ( + vector = 0; + vector < BSP_INTERRUPT_VECTOR_COUNT; + ++vector + ) { + rtems_interrupt_attributes attr; + rtems_status_code sc; + + memset( &attr, 0, sizeof( attr ) ); + sc = rtems_interrupt_get_attributes( vector, &attr ); + + if ( sc == RTEMS_INVALID_ID ) { + continue; + } + + T_rsc_success( sc ); + ${../req/set-priority:/test-run}( + vector, + attr.maximum_priority, + attr.can_set_priority + ); + } + checks: [] + links: [] test-brief: | Tests some ${../if/group:/name} directives. test-context: [] @@ -206,9 +260,11 @@ test-context-support: null test-description: null test-header: null test-includes: +- bsp/irq-generic.h - rtems.h -- rtems/irq-extension.h test-local-includes: +- tr-intr-get-priority.h +- tr-intr-set-priority.h - tx-support.h test-setup: null test-stop: null ``` -- View it on GitLab: https://gitlab.rtems.org/rtems/prequal/rtems-central/-/merge_requests/20#note_151752 You're receiving this email because of your account on gitlab.rtems.org.
_______________________________________________ bugs mailing list [email protected] http://lists.rtems.org/mailman/listinfo/bugs
