diff options
Diffstat (limited to 'spec/score/sem/req/seize-wait.yml')
-rw-r--r-- | spec/score/sem/req/seize-wait.yml | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/spec/score/sem/req/seize-wait.yml b/spec/score/sem/req/seize-wait.yml new file mode 100644 index 00000000..9b135ada --- /dev/null +++ b/spec/score/sem/req/seize-wait.yml @@ -0,0 +1,182 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +functional-type: action +links: [] +post-conditions: +- name: Status + states: + - name: Ok + test-code: | + status = TQEnqueue( &ctx->tq_ctx->base, ctx->tq_ctx->base.wait ); + T_eq_int( status, Status( ctx, STATUS_SUCCESSFUL ) ); + text: | + The return status of the directive call shall be derived from + ${../../status/if/successful:/name}. + - name: Enqueued + test-code: | + if ( ctx->tq_ctx->base.discipline == TQ_FIFO ) { + ${../../tq/req/enqueue-fifo:/test-run}( &ctx->tq_ctx->base ); + } else { + ${../../tq/req/enqueue-priority:/test-run}( &ctx->tq_ctx->base ); + } + text: | + The calling task shall be enqueued in the specified order on the thread + queue used by the semaphore. + test-epilogue: null + test-prologue: | + Status_Control status; +- name: Count + states: + - name: Nop + test-code: | + /* Checked by GetProperties() */ + text: | + The count of the semaphore shall not be modified. + - name: MinusOne + test-code: | + T_eq_u32( TQSemGetCount( ctx->tq_ctx ), 0 ); + text: | + The count of the semaphore shall be decremented by one. + test-epilogue: null + test-prologue: null +- name: Timer + states: + - name: Optional + test-code: | + /* Checked by GetProperties() */ + text: | + Where the directive was called with a timeout in clock ticks, the thread + timer of the calling task shall fire after the specified clock ticks. + + Where the directive was called without a timeout, the thread timer of the + calling task shall be inactive. + - name: 'No' + test-code: | + T_eq_int( + T_get_thread_timer_state( RTEMS_SELF ), + T_THREAD_TIMER_INACTIVE + ); + text: | + The thread timer of the calling task shall be inactive. + test-epilogue: null + test-prologue: null +pre-conditions: +- name: Count + states: + - name: Zero + test-code: | + /* Done by Prepare() */ + text: | + The count of the semaphore shall be zero. + - name: Positive + test-code: | + TQSemSetCount( ctx->tq_ctx, 1 ); + text: | + The count of the semaphore shall be greater than zero. + test-epilogue: null + test-prologue: null +rationale: null +references: [] +requirement-type: functional +skip-reasons: {} +test-action: | + /* Action performed by Status post-condition */ +test-brief: null +test-cleanup: null +test-context: [] +test-context-support: null +test-description: null +test-header: + code: null + includes: [] + local-includes: + - tx-thread-queue.h + run-params: + - description: | + is the semaphore thread queue context. + dir: inout + name: tq_ctx + specifier: TQSemContext *${.:name} + target: testsuites/validation/tr-sem-seize-wait.h +test-includes: +- rtems/score/statesimpl.h +test-local-includes: +- tr-sem-seize-wait.h +- tr-tq-enqueue-fifo.h +- tr-tq-enqueue-priority.h +test-prepare: | + ctx->tq_ctx->base.prepare = Prepare; + ctx->tq_ctx->base.cleanup = Cleanup; + ctx->tq_ctx->base.get_properties = GetProperties; +test-setup: null +test-stop: null +test-support: | + typedef ScoreSemReqSeizeWait_Context Context; + + static Status_Control Status( const Context *ctx, Status_Control status ) + { + return TQConvertStatus( &ctx->tq_ctx->base, status ); + } + + static void Prepare( TQContext *base ) + { + TQSemContext *ctx; + + ctx = (TQSemContext *) base; + TQSemSetCount( ctx, 0 ); + } + + static void Cleanup( TQContext *base ) + { + TQSemContext *ctx; + + ctx = (TQSemContext *) base; + TQSemSetCount( ctx, 1 ); + } + + static void GetProperties( TQContext *base, TQWorkerKind enqueued_worker ) + { + TQSemContext *ctx; + T_thread_timer_state timer_state; + + ctx = (TQSemContext *) base; + T_eq_u32( + ctx->base.worker_tcb[ enqueued_worker ]->current_state, + STATES_WAITING_FOR_SEMAPHORE + ); + + timer_state = T_get_thread_timer_state( + ctx->base.worker_id[ enqueued_worker ] + ); + + if ( base->wait == TQ_WAIT_TICKS ) { + T_eq_int( timer_state, T_THREAD_TIMER_SCHEDULED ); + } else { + T_eq_int( timer_state, T_THREAD_TIMER_INACTIVE ); + } + + T_eq_u32( TQSemGetCount( ctx ), 0 ); + } +test-target: testsuites/validation/tr-sem-seize-wait.c +test-teardown: null +text: ${.:text-template} +transition-map: +- enabled-by: true + post-conditions: + Status: Ok + Count: MinusOne + Timer: 'No' + pre-conditions: + Count: + - Positive +- enabled-by: true + post-conditions: + Status: Enqueued + Count: Nop + Timer: Optional + pre-conditions: + Count: + - Zero +type: requirement |