summaryrefslogtreecommitdiffstats
path: root/spec/score/futex/req
diff options
context:
space:
mode:
Diffstat (limited to 'spec/score/futex/req')
-rw-r--r--spec/score/futex/req/wait.yml167
-rw-r--r--spec/score/futex/req/wake.yml185
2 files changed, 352 insertions, 0 deletions
diff --git a/spec/score/futex/req/wait.yml b/spec/score/futex/req/wait.yml
new file mode 100644
index 00000000..190e134b
--- /dev/null
+++ b/spec/score/futex/req/wait.yml
@@ -0,0 +1,167 @@
+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:
+- role: interface-function
+ uid: ../if/wake
+post-conditions:
+- name: Result
+ states:
+ - name: Zero
+ test-code: |
+ /* This result is checked by Enqueue() */
+ text: |
+ The return status of ${../if/wait:/name} shall be zero.
+ - name: EAGAIN
+ test-code: |
+ eno = _Futex_Wait( &ctx->futex, &ctx->state, ctx->expected_value );
+ T_eq_int( eno, EAGAIN );
+ text: |
+ The return status of ${../if/wait:/name} shall be ${/c/if/eagain:/name}.
+ test-epilogue: null
+ test-prologue: |
+ int eno;
+- name: Enqueue
+ states:
+ - name: 'No'
+ test-code: |
+ /* The runner would block forever */
+ text: |
+ The calling thread shall not be enqueued on the thread queue of the futex
+ object.
+ - name: 'Yes'
+ test-code: |
+ ${../../tq/req/enqueue-fifo:/test-run}( &ctx->tq_ctx );
+ text: |
+ The calling thread shall be enqueued in FIFO order on the thread queue of
+ the futex object.
+ test-epilogue: null
+ test-prologue: null
+pre-conditions:
+- name: State
+ states:
+ - name: Equal
+ test-code: |
+ ctx->expected_value = 0;
+ text: |
+ While the expected futex state value is equal to the actual futex state
+ value.
+ - name: NotEqual
+ test-code: |
+ ctx->expected_value = 1;
+ text: |
+ While the expected futex state value is not equal to the actual futex
+ state value.
+ test-epilogue: null
+ test-prologue: null
+rationale: null
+references: []
+requirement-type: functional
+skip-reasons: {}
+test-action: |
+ /* The action is performed in the post-conditions. */
+test-brief: null
+test-cleanup:
+ _Futex_Destroy( &ctx->futex );
+test-context:
+- brief: |
+ This member contains the thread queue test context.
+ description: null
+ member: |
+ TQContext tq_ctx;
+- brief: |
+ This member specifies the expected futex state value.
+ description: null
+ member: |
+ int expected_value
+- brief: |
+ This member provides the futex object.
+ description: null
+ member: |
+ struct _Futex_Control futex
+- brief: |
+ This member provides the futex state.
+ description: null
+ member: |
+ int state
+test-context-support: null
+test-description: null
+test-header: null
+test-includes:
+- sys/lock.h
+- limits.h
+- rtems.h
+test-local-includes:
+- tx-thread-queue.h
+- tr-tq-enqueue-fifo.h
+test-prepare: |
+ _Futex_Initialize( &ctx->futex );
+ ctx->state = 0;
+test-setup:
+ brief: null
+ code: |
+ memset( ctx, 0, sizeof( *ctx ) );
+ ctx->tq_ctx.discipline = TQ_FIFO;
+ ctx->tq_ctx.wait = TQ_WAIT_FOREVER;
+ ctx->tq_ctx.enqueue_prepare = TQDoNothing;
+ ctx->tq_ctx.enqueue = Enqueue;
+ ctx->tq_ctx.enqueue_done = EnqueueDone;
+ ctx->tq_ctx.surrender = TQDoNothing;
+ ctx->tq_ctx.convert_status = TQConvertStatusPOSIX;
+ TQInitialize( &ctx->tq_ctx );
+ description: null
+test-stop: null
+test-support: |
+ typedef ${.:/test-context-type} Context;
+
+ static Context *ToContext( TQContext *tq_ctx )
+ {
+ return RTEMS_CONTAINER_OF( tq_ctx, Context, tq_ctx );
+ }
+
+ static Status_Control Enqueue( TQContext *tq_ctx, TQWait wait )
+ {
+ Context *ctx;
+ int eno;
+
+ ctx = ToContext( tq_ctx );
+ eno = _Futex_Wait( &ctx->futex, &ctx->state, ctx->expected_value );
+ T_eq_int( eno, 0 );
+
+ return STATUS_BUILD( 0, eno );
+ }
+
+ static void EnqueueDone( TQContext *tq_ctx )
+ {
+ Context *ctx;
+ int count;
+
+ ctx = ToContext( tq_ctx );
+ count = _Futex_Wake( &ctx->futex, INT_MAX );
+ T_eq_int( count, (int) ctx->tq_ctx.how_many );
+ }
+test-target: testsuites/validation/tc-futex-wait.c
+test-teardown:
+ brief: null
+ code: |
+ TQDestroy( &ctx->tq_ctx );
+ description: null
+text: ${.:text-template}
+transition-map:
+- enabled-by: true
+ post-conditions:
+ Result: EAGAIN
+ Enqueue: 'No'
+ pre-conditions:
+ State:
+ - NotEqual
+- enabled-by: true
+ post-conditions:
+ Result: Zero
+ Enqueue: 'Yes'
+ pre-conditions:
+ State:
+ - Equal
+type: requirement
diff --git a/spec/score/futex/req/wake.yml b/spec/score/futex/req/wake.yml
new file mode 100644
index 00000000..87604775
--- /dev/null
+++ b/spec/score/futex/req/wake.yml
@@ -0,0 +1,185 @@
+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:
+- role: interface-function
+ uid: ../if/wake
+post-conditions:
+- name: Result
+ states:
+ - name: Count
+ test-code: |
+ /* This result is checked by Flush() */
+ text: |
+ The return status of ${../if/wake:/name} shall be the count of threads
+ extracted from the thread queue of the futex object.
+ test-epilogue: null
+ test-prologue: null
+- name: Flush
+ states:
+ - name: 'No'
+ test-code: |
+ /* This state is checked by Enqueue() */
+ text: |
+ No thread shall be extracted from the thread queue of the futex object.
+ - name: Partial
+ test-code: |
+ /* This state is checked by Flush() */
+ text: |
+ The first count threads specified by the ``count`` parameter shall be
+ extracted from the thread queue of the futex object in
+ ${/glossary/fifo:/term} order.
+ - name: All
+ test-code: |
+ ${../../tq/req/flush-fifo:/test-run}( &ctx->tq_ctx );
+ text: |
+ All threads shall be extracted from the thread queue of the futex object
+ in ${/glossary/fifo:/term} order.
+ test-epilogue: null
+ test-prologue: null
+pre-conditions:
+- name: Count
+ states:
+ - name: Negative
+ test-code: |
+ /* This state is prepared by Enqueue() */
+ text: |
+ While the ``count`` parameter is less than zero.
+ - name: Partial
+ test-code: |
+ /* This state is prepared by Flush() */
+ text: |
+ While the ``count`` parameter is greater than or equal to zero,
+ while the ``count`` parameter is less than the count of threads enqueued
+ on the thread queue of the futex object.
+ - name: All
+ test-code: |
+ /* This state is prepared by Flush() */
+ text: |
+ While the ``count`` parameter is greater than or equal to zero,
+ while the ``count`` parameter is greater than or equal to the count of
+ threads enqueued on the thread queue of the futex object.
+ test-epilogue: null
+ test-prologue: null
+rationale: null
+references: []
+requirement-type: functional
+skip-reasons: {}
+test-action: |
+ /* The action is performed in the ``Flush`` post-condition ``All`` state. */
+test-brief: null
+test-cleanup:
+ _Futex_Destroy( &ctx->futex );
+test-context:
+- brief: |
+ This member contains the thread queue test context.
+ description: null
+ member: |
+ TQContext tq_ctx;
+- brief: |
+ This member provides the futex object.
+ description: null
+ member: |
+ struct _Futex_Control futex
+- brief: |
+ This member provides the futex state.
+ description: null
+ member: |
+ int state
+test-context-support: null
+test-description: null
+test-header: null
+test-includes:
+- sys/lock.h
+- limits.h
+- rtems.h
+test-local-includes:
+- tx-thread-queue.h
+- tr-tq-flush-fifo.h
+test-prepare: |
+ _Futex_Initialize( &ctx->futex );
+test-setup:
+ brief: null
+ code: |
+ memset( ctx, 0, sizeof( *ctx ) );
+ ctx->tq_ctx.discipline = TQ_FIFO;
+ ctx->tq_ctx.wait = TQ_WAIT_FOREVER;
+ ctx->tq_ctx.enqueue_prepare = TQDoNothing;
+ ctx->tq_ctx.enqueue = Enqueue;
+ ctx->tq_ctx.enqueue_done = TQDoNothing;
+ ctx->tq_ctx.flush = Flush;
+ ctx->tq_ctx.surrender = TQDoNothing;
+ ctx->tq_ctx.convert_status = TQConvertStatusPOSIX;
+ TQInitialize( &ctx->tq_ctx );
+ description: null
+test-stop: null
+test-support: |
+ typedef ${.:/test-context-type} Context;
+
+ static Context *ToContext( TQContext *tq_ctx )
+ {
+ return RTEMS_CONTAINER_OF( tq_ctx, Context, tq_ctx );
+ }
+
+ static Status_Control Enqueue( TQContext *tq_ctx, TQWait wait )
+ {
+ Context *ctx;
+ int count;
+ int eno;
+
+ ctx = ToContext( tq_ctx );
+
+ count = _Futex_Wake( &ctx->futex, -1 );
+ T_eq_int( count, 0 );
+
+ count = _Futex_Wake( &ctx->futex, 0 );
+ T_eq_int( count, 0 );
+
+ eno = _Futex_Wait( &ctx->futex, &ctx->state, 0 );
+ T_eq_int( eno, 0 );
+
+ return STATUS_BUILD( 0, eno );
+ }
+
+ static void Flush( TQContext *tq_ctx )
+ {
+ Context *ctx;
+ int count;
+ int how_many;
+
+ ctx = ToContext( tq_ctx );
+ how_many = (int) ctx->tq_ctx.how_many;
+
+ count = _Futex_Wake( &ctx->futex, 1 );
+ T_eq_int( count, how_many > 0 ? 1 : 0 );
+
+ count = _Futex_Wake( &ctx->futex, INT_MAX );
+ T_eq_int( count, how_many > 1 ? how_many - 1 : 0 );
+ }
+test-target: testsuites/validation/tc-futex-wake.c
+test-teardown:
+ brief: null
+ code: |
+ TQDestroy( &ctx->tq_ctx );
+ description: null
+text: ${.:text-template}
+transition-map:
+- enabled-by: true
+ post-conditions:
+ Result: Count
+ Flush: 'No'
+ pre-conditions:
+ Count:
+ - Negative
+- enabled-by: true
+ post-conditions:
+ Result: Count
+ Flush:
+ - specified-by: Count
+ pre-conditions:
+ Count:
+ - Partial
+ - All
+type: requirement