diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-05-05 14:41:20 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-05-08 21:58:56 +0200 |
commit | 3104df6442f0554896d81a09ccc7c150c6616608 (patch) | |
tree | 3862f1925e157032d710b9c7ed5df4ca12f31cc2 | |
parent | spec: Selectively enable GRLIB (diff) | |
download | rtems-central-3104df6442f0554896d81a09ccc7c150c6616608.tar.bz2 |
spec: Specify the global construction
8 files changed, 221 insertions, 0 deletions
diff --git a/spec/score/thread/req/global-construction-classic-before-entry.yml b/spec/score/thread/req/global-construction-classic-before-entry.yml new file mode 100644 index 00000000..b12efe16 --- /dev/null +++ b/spec/score/thread/req/global-construction-classic-before-entry.yml @@ -0,0 +1,15 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 +copyrights: +- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: requirement-refinement + uid: global-construction +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + Where the global construction is done by the Classic API user initialization + task, the global construction shall be done before the task entry is called. +type: requirement diff --git a/spec/score/thread/req/global-construction-classic.yml b/spec/score/thread/req/global-construction-classic.yml new file mode 100644 index 00000000..2a6b8af5 --- /dev/null +++ b/spec/score/thread/req/global-construction-classic.yml @@ -0,0 +1,15 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 +copyrights: +- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: requirement-refinement + uid: global-construction +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + Where the Classic API user initialization task is configured, the global + construction shall be done by the Classic API user initialization task. +type: requirement diff --git a/spec/score/thread/req/global-construction-constructors.yml b/spec/score/thread/req/global-construction-constructors.yml new file mode 100644 index 00000000..a4eb7822 --- /dev/null +++ b/spec/score/thread/req/global-construction-constructors.yml @@ -0,0 +1,15 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 +copyrights: +- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: requirement-refinement + uid: global-construction +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + When the global construction is done, the global constructors shall be + called. +type: requirement diff --git a/spec/score/thread/req/global-construction-preinit-array-before-constructors.yml b/spec/score/thread/req/global-construction-preinit-array-before-constructors.yml new file mode 100644 index 00000000..094892f1 --- /dev/null +++ b/spec/score/thread/req/global-construction-preinit-array-before-constructors.yml @@ -0,0 +1,17 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 +copyrights: +- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: +- arm +- riscv +links: +- role: requirement-refinement + uid: global-construction +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + The handlers registered in the ``.preinit_array`` table shall be called + before the global constructors. +type: requirement diff --git a/spec/score/thread/req/global-construction-preinit-array.yml b/spec/score/thread/req/global-construction-preinit-array.yml new file mode 100644 index 00000000..cbb34175 --- /dev/null +++ b/spec/score/thread/req/global-construction-preinit-array.yml @@ -0,0 +1,17 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 +copyrights: +- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: +- arm +- riscv +links: +- role: requirement-refinement + uid: global-construction +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + When the global construction is done, the handlers registered in the + ``.preinit_array`` table shall be called. +type: requirement diff --git a/spec/score/thread/req/global-construction.yml b/spec/score/thread/req/global-construction.yml new file mode 100644 index 00000000..aef6d8d8 --- /dev/null +++ b/spec/score/thread/req/global-construction.yml @@ -0,0 +1,14 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 +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 global construction shall be supported. +type: requirement diff --git a/spec/score/thread/val/preinit-array.yml b/spec/score/thread/val/preinit-array.yml new file mode 100644 index 00000000..a7436360 --- /dev/null +++ b/spec/score/thread/val/preinit-array.yml @@ -0,0 +1,85 @@ +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: +- arm +- riscv +links: [] +test-actions: +- action-brief: | + Validate the ``.preinit_array`` constructor invocation. Mark that the test + case executed. + action-code: | + test_case_executed = true; + checks: + - brief: | + Check that the ``.preinit_array`` constructor was called exactly once. + code: | + T_eq_u32( constructor_calls, 1 ); + links: + - role: validation + uid: ../req/global-construction-preinit-array + - brief: | + Check that the ``.preeinit_array`` construction was done by the Classic + API user initialization task. + code: | + T_eq_u32( constructor_id, rtems_task_self() ); + links: + - role: validation + uid: ../req/global-construction-classic + - brief: | + Check that the ``.preinit_array`` constructor was called before the + global constructor invocations. + code: | + T_eq_u32( constructor_counter, 1 ); + T_eq_u32( normal_constructor_counter, 2 ); + links: + - role: validation + uid: ../req/global-construction-preinit-array-before-constructors + links: [] +test-brief: | + Tests the ``.preinit_array`` constructor handling of the C runtime support. +test-context: [] +test-context-support: null +test-description: null +test-header: null +test-includes: +- rtems.h +test-local-includes: [] +test-setup: null +test-stop: null +test-support: | + static bool test_case_executed; + + static bool constructor_test_case_executed; + + static uint32_t counter; + + static uint32_t normal_constructor_counter; + + static uint32_t constructor_counter; + + static uint32_t constructor_calls; + + static rtems_id constructor_id; + + static __attribute__(( __constructor__ )) void NormalConstructor( void ) + { + ++counter; + normal_constructor_counter = counter; + } + + static void Constructor( void ) + { + constructor_test_case_executed = test_case_executed; + ++counter; + constructor_counter = counter; + ++constructor_calls; + constructor_id = rtems_task_self(); + } + + static RTEMS_USED RTEMS_SECTION( ".preinit_array" ) void + ( * const constructor_registration )( void ) = Constructor; +test-target: testsuites/validation/tc-preinit-array.c +test-teardown: null +type: test-case diff --git a/spec/score/thread/val/thread.yml b/spec/score/thread/val/thread.yml index ca735df8..2a5d2f23 100644 --- a/spec/score/thread/val/thread.yml +++ b/spec/score/thread/val/thread.yml @@ -115,6 +115,34 @@ test-actions: RestoreRunnerPriority(); links: [] links: [] +- action-brief: | + Validate the global construction. Mark that the test case executed. + action-code: | + test_case_executed = true; + checks: + - brief: | + Check that the global constructor was called exactly once. + code: | + T_eq_u32( constructor_calls, 1 ); + links: + - role: validation + uid: ../req/global-construction-constructors + - brief: | + Check that the global construction was done by the Classic API user + initialization task. + code: | + T_eq_u32( constructor_id, rtems_task_self() ); + links: + - role: validation + uid: ../req/global-construction-classic + - brief: | + Check that the global constructor was called before the task entry. + code: | + T_false( constructor_test_case_executed ); + links: + - role: validation + uid: ../req/global-construction-classic-before-entry + links: [] test-brief: | Tests general thread behaviour. test-context: @@ -148,6 +176,21 @@ test-stop: null test-support: | typedef ${.:/test-context-type} Context; + static bool test_case_executed; + + static bool constructor_test_case_executed; + + static uint32_t constructor_calls; + + static rtems_id constructor_id; + + static __attribute__(( __constructor__ )) void Constructor( void ) + { + constructor_test_case_executed = test_case_executed; + ++constructor_calls; + constructor_id = rtems_task_self(); + } + static void TaskTerminate( rtems_tcb *executing ) { Context *ctx; |