[rtems-central commit] spec: Check for NULL configuration

Sebastian Huber sebh at rtems.org
Fri Apr 23 06:30:41 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Apr 23 08:29:52 2021 +0200

spec: Check for NULL configuration

---

 spec/rtems/message/if/construct.yml         |   7 +-
 spec/rtems/message/req/construct-errors.yml |  89 +++++++++++++++++++-----
 spec/rtems/task/if/construct.yml            |   7 +-
 spec/rtems/task/req/construct-errors.yml    | 101 +++++++++++++++++++++++-----
 4 files changed, 167 insertions(+), 37 deletions(-)

diff --git a/spec/rtems/message/if/construct.yml b/spec/rtems/message/if/construct.yml
index 0c44794..365bbc2 100644
--- a/spec/rtems/message/if/construct.yml
+++ b/spec/rtems/message/if/construct.yml
@@ -3,7 +3,7 @@ brief: |
   Constructs a message queue from the specified the message queue
   configuration.
 copyrights:
-- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+- Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de)
 definition:
   default:
     attributes: null
@@ -67,12 +67,15 @@ return:
       The requested operation was successful.
     value: ${../../status/if/successful:/name}
   - description: |
-      The ${.:/params[1]/name} parameter was ${/c/if/null:/name}.
+      The ${.:/params[0]/name} parameter was ${/c/if/null:/name}.
     value: ${../../status/if/invalid-address:/name}
   - description: |
       The message queue name in the configuration was invalid.
     value: ${../../status/if/invalid-name:/name}
   - description: |
+      The ${.:/params[1]/name} parameter was ${/c/if/null:/name}.
+    value: ${../../status/if/invalid-address:/name}
+  - description: |
       The maximum number of pending messages in the configuration was zero.
     value: ${../../status/if/invalid-number:/name}
   - description: |
diff --git a/spec/rtems/message/req/construct-errors.yml b/spec/rtems/message/req/construct-errors.yml
index 80f652c..62dc78a 100644
--- a/spec/rtems/message/req/construct-errors.yml
+++ b/spec/rtems/message/req/construct-errors.yml
@@ -95,16 +95,32 @@ post-conditions:
   test-epilogue: null
   test-prologue: null
 pre-conditions:
+- name: Config
+  states:
+  - name: Valid
+    test-code: |
+      ctx->config = &ctx->config_value;
+    text: |
+      While the ${../if/construct:/params[0]/name} parameter references an
+      object of type ${../if/config:/name}.
+  - name: 'Null'
+    test-code: |
+      ctx->config = NULL;
+    text: |
+      While the ${../if/construct:/params[0]/name} parameter is
+      ${/c/if/null:/name}.
+  test-epilogue: null
+  test-prologue: null
 - name: Name
   states:
   - name: Valid
     test-code: |
-      ctx->config.name = NAME;
+      ctx->config_value.name = NAME;
     text: |
       While the name of the message queue configuration is valid.
   - name: Invalid
     test-code: |
-      ctx->config.name = 0;
+      ctx->config_value.name = 0;
     text: |
       While the name of the message queue configuration is invalid.
   test-epilogue: null
@@ -129,19 +145,19 @@ pre-conditions:
   states:
   - name: Valid
     test-code: |
-      ctx->config.maximum_pending_messages = MAX_PENDING_MESSAGES;
+      ctx->config_value.maximum_pending_messages = MAX_PENDING_MESSAGES;
     text: |
       While the maximum number of pending messages of the message queue
       configuration is valid.
   - name: Zero
     test-code: |
-      ctx->config.maximum_pending_messages = 0;
+      ctx->config_value.maximum_pending_messages = 0;
     text: |
       While the maximum number of pending messages of the message queue
       configuration is zero.
   - name: Big
     test-code: |
-      ctx->config.maximum_pending_messages = UINT32_MAX;
+      ctx->config_value.maximum_pending_messages = UINT32_MAX;
     text: |
       While the maximum number of pending messages of the message queue
       configuration is big enough so that a calculation to get the message
@@ -152,30 +168,30 @@ pre-conditions:
   states:
   - name: Valid
     test-code: |
-      if ( ctx->config.maximum_pending_messages == UINT32_MAX ) {
+      if ( ctx->config_value.maximum_pending_messages == UINT32_MAX ) {
         /*
          * At least on 64-bit systems we need a bit of help to ensure that we
          * meet the Big state of the MaxPending pre-condition.  The following
          * message size is valid with respect to calculations involving only
          * the message size.
          */
-        ctx->config.maximum_message_size = SIZE_MAX - sizeof( uintptr_t ) +
+        ctx->config_value.maximum_message_size = SIZE_MAX - sizeof( uintptr_t ) +
           1 - sizeof( CORE_message_queue_Buffer );
       } else {
-        ctx->config.maximum_message_size = MAX_MESSAGE_SIZE;
+        ctx->config_value.maximum_message_size = MAX_MESSAGE_SIZE;
       }
     text: |
       While the maximum message size of the message queue configuration is
       valid.
   - name: Zero
     test-code: |
-      ctx->config.maximum_message_size = 0;
+      ctx->config_value.maximum_message_size = 0;
     text: |
       While the maximum message size of the message queue configuration is
       zero.
   - name: Big
     test-code: |
-      ctx->config.maximum_message_size = SIZE_MAX;
+      ctx->config_value.maximum_message_size = SIZE_MAX;
     text: |
       While the maximum message size of the message queue configuration is big
       enough so that a calculation to get the message buffer storage area size
@@ -203,13 +219,13 @@ pre-conditions:
   states:
   - name: Valid
     test-code: |
-      ctx->config.storage_area = buffers;
+      ctx->config_value.storage_area = buffers;
     text: |
       While the message buffer storage area begin pointer of the message queue
       configuration is valid.
   - name: 'Null'
     test-code: |
-      ctx->config.storage_area = NULL;
+      ctx->config_value.storage_area = NULL;
     text: |
       While the message buffer storage area begin pointer of the message queue
       configuration is ${/c/if/null:/name}.
@@ -219,13 +235,13 @@ pre-conditions:
   states:
   - name: Valid
     test-code: |
-      ctx->config.storage_size = sizeof( buffers );
+      ctx->config_value.storage_size = sizeof( buffers );
     text: |
       While the message buffer storage area size of the message queue
       configuration is valid.
   - name: Invalid
     test-code: |
-      ctx->config.storage_size = SIZE_MAX;
+      ctx->config_value.storage_size = SIZE_MAX;
     text: |
       While the message buffer storage area size of the message queue
       configuration is invalid.
@@ -236,7 +252,7 @@ references: []
 requirement-type: functional
 skip-reasons: {}
 test-action: |
-  ctx->status = rtems_message_queue_construct( &ctx->config, ctx->id );
+  ctx->status = rtems_message_queue_construct( ctx->config, ctx->id );
 test-brief: null
 test-cleanup: |
   if ( ctx->id_value != INVALID_ID ) {
@@ -257,7 +273,11 @@ test-context:
 - brief: null
   description: null
   member: |
-    rtems_message_queue_config config
+    const rtems_message_queue_config *config
+- brief: null
+  description: null
+  member: |
+    rtems_message_queue_config config_value
 - brief: null
   description: null
   member: |
@@ -279,7 +299,7 @@ test-includes:
 test-local-includes: []
 test-prepare: |
   ctx->id_value = INVALID_ID;
-  memset( &ctx->config, 0, sizeof( ctx->config ) );
+  memset( &ctx->config_value, 0, sizeof( ctx->config_value ) );
 test-setup: null
 test-stop: null
 test-support: |
@@ -333,6 +353,8 @@ transition-map:
     - Valid
     AreaSize:
     - Valid
+    Config:
+    - Valid
     Id:
     - Id
     MaxPending:
@@ -345,12 +367,29 @@ transition-map:
     - 'Yes'
 - enabled-by: true
   post-conditions:
+    Status: InvAddr
+    Name: Invalid
+    IdVar: Nop
+  pre-conditions:
+    Area: all
+    AreaSize: all
+    Config:
+    - 'Null'
+    Id: all
+    MaxPending: all
+    MaxSize: all
+    Name: all
+    Free: all
+- enabled-by: true
+  post-conditions:
     Status: InvName
     Name: Invalid
     IdVar: Nop
   pre-conditions:
     Area: all
     AreaSize: all
+    Config:
+    - Valid
     Id: all
     MaxPending: all
     MaxSize: all
@@ -365,6 +404,8 @@ transition-map:
   pre-conditions:
     Area: all
     AreaSize: all
+    Config:
+    - Valid
     Id:
     - 'Null'
     MaxPending: all
@@ -380,6 +421,8 @@ transition-map:
   pre-conditions:
     Area: all
     AreaSize: all
+    Config:
+    - Valid
     Id:
     - Id
     MaxPending:
@@ -396,6 +439,8 @@ transition-map:
   pre-conditions:
     Area: all
     AreaSize: all
+    Config:
+    - Valid
     Id:
     - Id
     MaxPending:
@@ -414,6 +459,8 @@ transition-map:
   pre-conditions:
     Area: all
     AreaSize: all
+    Config:
+    - Valid
     Id:
     - Id
     MaxPending:
@@ -434,6 +481,8 @@ transition-map:
   pre-conditions:
     Area: all
     AreaSize: all
+    Config:
+    - Valid
     Id:
     - Id
     MaxPending:
@@ -452,6 +501,8 @@ transition-map:
   pre-conditions:
     Area: all
     AreaSize: all
+    Config:
+    - Valid
     Id:
     - Id
     MaxPending:
@@ -472,6 +523,8 @@ transition-map:
     Area:
     - 'Null'
     AreaSize: all
+    Config:
+    - Valid
     Id:
     - Id
     MaxPending:
@@ -492,6 +545,8 @@ transition-map:
     - Valid
     AreaSize:
     - Invalid
+    Config:
+    - Valid
     Id:
     - Id
     MaxPending:
diff --git a/spec/rtems/task/if/construct.yml b/spec/rtems/task/if/construct.yml
index b0c7659..4cacfe4 100644
--- a/spec/rtems/task/if/construct.yml
+++ b/spec/rtems/task/if/construct.yml
@@ -2,7 +2,7 @@ SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
 brief: |
   Constructs a task from the specified the task configuration.
 copyrights:
-- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+- Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de)
 definition:
   default:
     attributes: null
@@ -79,12 +79,15 @@ return:
       The requested operation was successful.
     value: ${../../status/if/successful:/name}
   - description: |
-      The ${.:/params[1]/name} parameter was ${/c/if/null:/name}.
+      The ${.:/params[0]/name} parameter was ${/c/if/null:/name}.
     value: ${../../status/if/invalid-address:/name}
   - description: |
       The task name was invalid.
     value: ${../../status/if/invalid-name:/name}
   - description: |
+      The ${.:/params[1]/name} parameter was ${/c/if/null:/name}.
+    value: ${../../status/if/invalid-address:/name}
+  - description: |
       The initial task priority was invalid.
     value: ${../../status/if/invalid-priority:/name}
   - description: |
diff --git a/spec/rtems/task/req/construct-errors.yml b/spec/rtems/task/req/construct-errors.yml
index 7e80d27..9864d06 100644
--- a/spec/rtems/task/req/construct-errors.yml
+++ b/spec/rtems/task/req/construct-errors.yml
@@ -143,16 +143,32 @@ post-conditions:
   test-epilogue: null
   test-prologue: null
 pre-conditions:
+- name: Config
+  states:
+  - name: Valid
+    test-code: |
+      ctx->config = &ctx->config_value;
+    text: |
+      While the ${../if/construct:/params[0]/name} parameter references an
+      object of type ${../if/config:/name}.
+  - name: 'Null'
+    test-code: |
+      ctx->config = NULL;
+    text: |
+      While the ${../if/construct:/params[0]/name} parameter is
+      ${/c/if/null:/name}.
+  test-epilogue: null
+  test-prologue: null
 - name: Name
   states:
   - name: Valid
     test-code: |
-      ctx->config.name = NAME;
+      ctx->config_value.name = NAME;
     text: |
       While the name of the task configuration is valid.
   - name: Inv
     test-code: |
-      ctx->config.name = 0;
+      ctx->config_value.name = 0;
     text: |
       While the name of the task configuration is invalid.
   test-epilogue: null
@@ -177,7 +193,7 @@ pre-conditions:
   states:
   - name: 'Yes'
     test-code: |
-      ctx->config.attributes |= RTEMS_SYSTEM_TASK;
+      ctx->config_value.attributes |= RTEMS_SYSTEM_TASK;
     text: |
       While the attributes of the task configuration specifies a system task.
   - name: 'No'
@@ -192,18 +208,18 @@ pre-conditions:
   states:
   - name: Valid
     test-code: |
-      ctx->config.initial_priority = 254;
+      ctx->config_value.initial_priority = 254;
     text: |
       While the initial priority of the task configuration is valid and
       non-zero.
   - name: Zero
     test-code: |
-      ctx->config.initial_priority = 0;
+      ctx->config_value.initial_priority = 0;
     text: |
       While the initial priority of the task configuration is zero.
   - name: Inv
     test-code: |
-      ctx->config.initial_priority = 0xffffffff;
+      ctx->config_value.initial_priority = 0xffffffff;
     text: |
       While the initial priority of the task configuration is invalid.
   test-epilogue: null
@@ -226,13 +242,13 @@ pre-conditions:
   states:
   - name: Enough
     test-code: |
-      ctx->config.maximum_thread_local_storage_size = MAX_TLS_SIZE;
+      ctx->config_value.maximum_thread_local_storage_size = MAX_TLS_SIZE;
     text: |
       While the maximum thread-local storage size of the task configuration is
       greater than or equal to the thread-local storage size.
   - name: Small
     test-code: |
-      ctx->config.maximum_thread_local_storage_size = 0;
+      ctx->config_value.maximum_thread_local_storage_size = 0;
     text: |
       While the maximum thread-local storage size of the task configuration is
       less than the thread-local storage size.
@@ -276,11 +292,11 @@ test-action: |
   ctx->create_extension_calls = 0;
   ctx->delete_extension_calls = 0;
   ctx->storage_free_calls = 0;
-  ctx->config.storage_size = RTEMS_TASK_STORAGE_SIZE(
-    ctx->config.maximum_thread_local_storage_size + ctx->stack_size,
-    ctx->config.attributes
+  ctx->config_value.storage_size = RTEMS_TASK_STORAGE_SIZE(
+    ctx->config_value.maximum_thread_local_storage_size + ctx->stack_size,
+    ctx->config_value.attributes
   );
-  ctx->status = rtems_task_construct( &ctx->config, ctx->id );
+  ctx->status = rtems_task_construct( ctx->config, ctx->id );
 test-brief: null
 test-cleanup: |
   if ( ctx->id_value != INVALID_ID ) {
@@ -301,7 +317,11 @@ test-context:
 - brief: null
   description: null
   member: |
-    rtems_task_config config
+    const rtems_task_config *config
+- brief: null
+  description: null
+  member: |
+    rtems_task_config config_value
 - brief: null
   description: null
   member: |
@@ -353,9 +373,9 @@ test-prepare: |
   _RTEMS_Unlock_allocator();
 
   ctx->id_value = INVALID_ID;
-  memset( &ctx->config, 0, sizeof( ctx->config ) );
-  ctx->config.storage_area = task_storage,
-  ctx->config.storage_free = StorageFree;
+  memset( &ctx->config_value, 0, sizeof( ctx->config_value ) );
+  ctx->config_value.storage_area = task_storage,
+  ctx->config_value.storage_free = StorageFree;
 test-setup:
   brief: null
   code: |
@@ -464,6 +484,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext:
     - Ok
     Id:
@@ -488,6 +510,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext:
     - Ok
     Id:
@@ -506,6 +530,25 @@ transition-map:
     - 'Yes'
 - enabled-by: true
   post-conditions:
+    Status: InvAddr
+    Name: Invalid
+    IdVar: Nop
+    CreateExt: 'No'
+    DelExt: 'No'
+    StoFree: 'No'
+  pre-conditions:
+    Config:
+    - 'Null'
+    Ext: all
+    Id: all
+    Name: all
+    SysTsk: all
+    Prio: all
+    Stack: all
+    TLS: all
+    Free: all
+- enabled-by: true
+  post-conditions:
     Status: InvSize
     Name: Invalid
     IdVar: Nop
@@ -513,6 +556,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext: all
     Id:
     - Valid
@@ -537,6 +582,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext: all
     Id:
     - Valid
@@ -561,6 +608,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext: all
     Id:
     - Valid
@@ -585,6 +634,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext: all
     Id: all
     Name:
@@ -603,6 +654,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext: all
     Id:
     - 'Null'
@@ -622,6 +675,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext: all
     Id:
     - Valid
@@ -643,6 +698,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext: all
     Id:
     - Valid
@@ -665,6 +722,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext: all
     Id:
     - Valid
@@ -686,6 +745,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext: all
     Id:
     - Valid
@@ -708,6 +769,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext: all
     Id:
     - Valid
@@ -730,6 +793,8 @@ transition-map:
     DelExt: 'No'
     StoFree: 'No'
   pre-conditions:
+    Config:
+    - Valid
     Ext: all
     Id:
     - Valid
@@ -753,6 +818,8 @@ transition-map:
     DelExt: 'Yes'
     StoFree: 'Yes'
   pre-conditions:
+    Config:
+    - Valid
     Ext:
     - Err
     Id:
@@ -777,6 +844,8 @@ transition-map:
     DelExt: 'Yes'
     StoFree: 'Yes'
   pre-conditions:
+    Config:
+    - Valid
     Ext:
     - Err
     Id:



More information about the vc mailing list