[rtems-central commit] spec: Specify thread idle body detail

Sebastian Huber sebh at rtems.org
Thu Jul 7 08:02:37 UTC 2022


Module:    rtems-central
Branch:    master
Commit:    7797dd08dd29d569fbc12dfd1fec0778958aa09a
Changeset: http://git.rtems.org/rtems-central/commit/?id=7797dd08dd29d569fbc12dfd1fec0778958aa09a

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Jul  5 13:22:37 2022 +0200

spec: Specify thread idle body detail

---

 spec/score/thread/req/idle-body-no-return.yml | 14 ++++
 spec/score/thread/val/idle-body-no-return.yml | 99 +++++++++++++++++++++++++++
 2 files changed, 113 insertions(+)

diff --git a/spec/score/thread/req/idle-body-no-return.yml b/spec/score/thread/req/idle-body-no-return.yml
new file mode 100644
index 00000000..d8fafe6f
--- /dev/null
+++ b/spec/score/thread/req/idle-body-no-return.yml
@@ -0,0 +1,14 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links:
+- role: requirement-refinement
+  uid: ../if/group
+functional-type: function
+rationale: null
+references: []
+requirement-type: functional
+text: |
+  The ${/glossary/idletask:/term} body shall not return.
+type: requirement
diff --git a/spec/score/thread/val/idle-body-no-return.yml b/spec/score/thread/val/idle-body-no-return.yml
new file mode 100644
index 00000000..83dbe657
--- /dev/null
+++ b/spec/score/thread/val/idle-body-no-return.yml
@@ -0,0 +1,99 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links: []
+test-actions:
+- action-brief: |
+    Create threads which execute an thread idle body.  Check that the thread
+    idle body does not return.  If it would return, then an
+    ${/score/interr/if/thread-exitted:/name} fatal error would occur.
+  action-code: |
+    SetSelfPriority( PRIO_NORMAL );
+  checks:
+  - brief: |
+      Check that the CPU port thread idle body does not return.
+    code: |
+      CheckIdleBody( ctx, CPUThreadIdleBody );
+    links:
+    - role: validation
+      uid: ../req/idle-body-no-return
+  - brief: |
+      Where the BSP provides an idle thread body, check that it does not
+      return.
+    code: |
+      #if defined(BSP_IDLE_TASK_BODY)
+      CheckIdleBody( ctx, BSPIdleTaskBody );
+      #endif
+    links:
+    - role: validation
+      uid: ../req/idle-body-no-return
+  - brief: |
+      Clean up all used resources.
+    code: |
+      RestoreRunnerPriority();
+    links: []
+  links: []
+test-brief: |
+  Tests thread idle body behaviour.
+test-context:
+- brief: |
+    This member contains a counter.
+  description: null
+  member: |
+    uint32_t counter;
+test-context-support: null
+test-description: null
+test-header: null
+test-includes:
+- bsp.h
+test-local-includes:
+- tx-support.h
+test-setup: null
+test-stop: null
+test-support: |
+  typedef ${.:/test-context-type} Context;
+
+  static void CheckIdleBody( Context *ctx, rtems_task_entry entry )
+  {
+    rtems_id id;
+
+    ctx->counter = 0;
+    id = CreateTask( "WORK", PRIO_LOW );
+    StartTask( id, entry, ctx );
+
+    while ( ctx->counter == 0 ) {
+      rtems_status_code sc;
+
+      sc = rtems_task_wake_after( 1 );
+      T_rsc_success( sc );
+    }
+
+    T_eq_u32( ctx->counter, 1 );
+    DeleteTask( id );
+  }
+
+  static void CPUThreadIdleBody( rtems_task_argument arg )
+  {
+    Context *ctx;
+
+    ctx = (Context *) arg;
+    ++ctx->counter;
+
+    (void) _CPU_Thread_Idle_body( 0 );
+  }
+
+  #if defined(BSP_IDLE_TASK_BODY)
+  static void BSPIdleTaskBody( rtems_task_argument arg )
+  {
+    Context *ctx;
+
+    ctx = (Context *) arg;
+    ++ctx->counter;
+
+    (void) BSP_IDLE_TASK_BODY( 0 );
+  }
+  #endif
+test-target: testsuites/validation/tc-thread-idle-body-no-return.c
+test-teardown: null
+type: test-case



More information about the vc mailing list