[rtems-central commit] validation: Support freestanding test cases

Sebastian Huber sebh at rtems.org
Mon Aug 2 05:12:42 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Jul 28 16:28:15 2021 +0200

validation: Support freestanding test cases

---

 rtemsspec/tests/spec-validation/tc5.yml |  1 +
 rtemsspec/tests/spec-validation/tc6.yml |  1 +
 rtemsspec/tests/spec-validation/tc7.yml |  1 +
 rtemsspec/tests/spec-validation/tc8.yml |  1 +
 rtemsspec/tests/test_validation.py      |  6 ++----
 rtemsspec/validation.py                 | 33 +++++++++++++++++++++++----------
 spec/rtems/event/req/send-receive.yml   |  1 +
 spec/rtems/event/val/event-constant.yml |  1 +
 spec/rtems/req/ident-local.yml          |  1 +
 spec/rtems/req/ident.yml                |  1 +
 spec/score/mtx/req/seize-try.yml        |  1 +
 spec/score/mtx/req/seize-wait.yml       |  1 +
 spec/score/sem/req/seize-try.yml        |  1 +
 spec/score/sem/req/seize-wait.yml       |  1 +
 spec/score/tq/req/enqueue-ceiling.yml   |  1 +
 spec/score/tq/req/enqueue-deadlock.yml  |  1 +
 spec/score/tq/req/enqueue-fifo.yml      |  1 +
 spec/score/tq/req/enqueue-mrsp.yml      |  1 +
 spec/score/tq/req/enqueue-priority.yml  |  1 +
 spec/spec/test-header.yml               |  7 +++++++
 20 files changed, 49 insertions(+), 14 deletions(-)

diff --git a/rtemsspec/tests/spec-validation/tc5.yml b/rtemsspec/tests/spec-validation/tc5.yml
index ee60367..0b39181 100644
--- a/rtemsspec/tests/spec-validation/tc5.yml
+++ b/rtemsspec/tests/spec-validation/tc5.yml
@@ -43,6 +43,7 @@ test-description: Test case 5 description.
 test-header:
   code: |
     /* Header code for ${.:/test-run}() */
+  freestanding: true
   includes:
   - d.h
   local-includes:
diff --git a/rtemsspec/tests/spec-validation/tc6.yml b/rtemsspec/tests/spec-validation/tc6.yml
index bf1c60d..ad2c6f4 100644
--- a/rtemsspec/tests/spec-validation/tc6.yml
+++ b/rtemsspec/tests/spec-validation/tc6.yml
@@ -10,6 +10,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes: []
   run-params: []
diff --git a/rtemsspec/tests/spec-validation/tc7.yml b/rtemsspec/tests/spec-validation/tc7.yml
index 93797ce..606546e 100644
--- a/rtemsspec/tests/spec-validation/tc7.yml
+++ b/rtemsspec/tests/spec-validation/tc7.yml
@@ -16,6 +16,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes: []
   run-params: []
diff --git a/rtemsspec/tests/spec-validation/tc8.yml b/rtemsspec/tests/spec-validation/tc8.yml
index 9d44b78..6b90562 100644
--- a/rtemsspec/tests/spec-validation/tc8.yml
+++ b/rtemsspec/tests/spec-validation/tc8.yml
@@ -20,6 +20,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes: []
   run-params: []
diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py
index 1557d50..e5fb890 100644
--- a/rtemsspec/tests/test_validation.py
+++ b/rtemsspec/tests/test_validation.py
@@ -1332,8 +1332,6 @@ static void Tc5_Action_1( Tc5_Context *ctx )
   /* Test case action 1 check 1 code */
 }
 
-static T_fixture_node Tc5_Node;
-
 void Tc5_Run( int *a, int b, int *c )
 {
   Tc5_Context *ctx;
@@ -1343,14 +1341,14 @@ void Tc5_Run( int *a, int b, int *c )
   ctx->b = b;
   ctx->c = c;
 
-  ctx = T_push_fixture( &Tc5_Node, &Tc5_Fixture );
+  ctx = T_case_begin( "Tc5", &Tc5_Fixture );
 
   T_plan( 2 );
 
   Tc5_Action_0( ctx );
   Tc5_Action_1( ctx );
 
-  T_pop_fixture();
+  T_case_end();
 }
 
 /** @} */
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index 0d96117..8e14869 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -392,6 +392,27 @@ class _TestItem:
                 for param in header["run-params"]
             ])
 
+    def _add_runner_prologue_and_epilogue(self, content: CContent,
+                                          prologue: CContent,
+                                          epilogue: CContent,
+                                          fixture: str) -> None:
+        header = self["test-header"]
+        if self.context == "void":
+            result = None
+        else:
+            prologue.add(f"{self.context} *ctx;")
+            self.assign_run_params(prologue, header)
+            result = "ctx ="
+        if header["freestanding"]:
+            prologue.call_function(result, "T_case_begin",
+                                   [f"\"{self.ident}\"", fixture])
+            epilogue.add("T_case_end();")
+        else:
+            content.add(f"static T_fixture_node {self.ident}_Node;")
+            prologue.call_function(result, "T_push_fixture",
+                                   [f"&{self.ident}_Node", fixture])
+            epilogue.add("T_pop_fixture();")
+
     def generate(self, content: CContent, base_directory: str,
                  test_case_to_suites: Dict[str, List["_TestItem"]]) -> None:
         """ Generates the content. """
@@ -411,16 +432,8 @@ class _TestItem:
             if self._mapper.steps > 0 and not fixture:
                 fixture = "&T_empty_fixture"
             if fixture:
-                content.add(f"static T_fixture_node {self.ident}_Node;")
-                if self.context == "void":
-                    result = None
-                else:
-                    prologue.add(f"{self.context} *ctx;")
-                    self.assign_run_params(prologue, header)
-                    result = "ctx ="
-                prologue.call_function(result, "T_push_fixture",
-                                       [f"&{self.ident}_Node", fixture])
-                epilogue.add("T_pop_fixture();")
+                self._add_runner_prologue_and_epilogue(content, prologue,
+                                                       epilogue, fixture)
             align = True
         else:
             ret = ""
diff --git a/spec/rtems/event/req/send-receive.yml b/spec/rtems/event/req/send-receive.yml
index 2bd65db..ccee2f3 100644
--- a/spec/rtems/event/req/send-receive.yml
+++ b/spec/rtems/event/req/send-receive.yml
@@ -427,6 +427,7 @@ test-context-support: |
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes:
   - rtems.h
   - rtems/score/thread.h
diff --git a/spec/rtems/event/val/event-constant.yml b/spec/rtems/event/val/event-constant.yml
index 77ba10c..6d9e863 100644
--- a/spec/rtems/event/val/event-constant.yml
+++ b/spec/rtems/event/val/event-constant.yml
@@ -416,6 +416,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes:
   - rtems.h
   local-includes: []
diff --git a/spec/rtems/req/ident-local.yml b/spec/rtems/req/ident-local.yml
index c5da44e..2b7406c 100644
--- a/spec/rtems/req/ident-local.yml
+++ b/spec/rtems/req/ident-local.yml
@@ -112,6 +112,7 @@ test-header:
   code: |
     #define ClassicObjectLocalIdentName \
       rtems_build_name( 'I', 'D', 'N', 'T' )
+  freestanding: false
   includes:
   - rtems.h
   local-includes: []
diff --git a/spec/rtems/req/ident.yml b/spec/rtems/req/ident.yml
index 098779d..c2df762 100644
--- a/spec/rtems/req/ident.yml
+++ b/spec/rtems/req/ident.yml
@@ -172,6 +172,7 @@ test-header:
   code: |
     #define ClassicObjectIdentName \
       rtems_build_name( 'I', 'D', 'N', 'T' )
+  freestanding: false
   includes:
   - rtems.h
   local-includes: []
diff --git a/spec/score/mtx/req/seize-try.yml b/spec/score/mtx/req/seize-try.yml
index deba253..18ada09 100644
--- a/spec/score/mtx/req/seize-try.yml
+++ b/spec/score/mtx/req/seize-try.yml
@@ -213,6 +213,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes:
   - tx-thread-queue.h
diff --git a/spec/score/mtx/req/seize-wait.yml b/spec/score/mtx/req/seize-wait.yml
index 39ff491..6d3396f 100644
--- a/spec/score/mtx/req/seize-wait.yml
+++ b/spec/score/mtx/req/seize-wait.yml
@@ -205,6 +205,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes:
   - tx-thread-queue.h
diff --git a/spec/score/sem/req/seize-try.yml b/spec/score/sem/req/seize-try.yml
index 3dd79b7..685f992 100644
--- a/spec/score/sem/req/seize-try.yml
+++ b/spec/score/sem/req/seize-try.yml
@@ -82,6 +82,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes:
   - tx-thread-queue.h
diff --git a/spec/score/sem/req/seize-wait.yml b/spec/score/sem/req/seize-wait.yml
index 98616bd..ba68fe5 100644
--- a/spec/score/sem/req/seize-wait.yml
+++ b/spec/score/sem/req/seize-wait.yml
@@ -101,6 +101,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes:
   - tx-thread-queue.h
diff --git a/spec/score/tq/req/enqueue-ceiling.yml b/spec/score/tq/req/enqueue-ceiling.yml
index bc8dd85..b38ea3a 100644
--- a/spec/score/tq/req/enqueue-ceiling.yml
+++ b/spec/score/tq/req/enqueue-ceiling.yml
@@ -259,6 +259,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes:
   - tx-thread-queue.h
diff --git a/spec/score/tq/req/enqueue-deadlock.yml b/spec/score/tq/req/enqueue-deadlock.yml
index 4857ab5..44bd72d 100644
--- a/spec/score/tq/req/enqueue-deadlock.yml
+++ b/spec/score/tq/req/enqueue-deadlock.yml
@@ -114,6 +114,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes:
   - tx-thread-queue.h
diff --git a/spec/score/tq/req/enqueue-fifo.yml b/spec/score/tq/req/enqueue-fifo.yml
index 5c4974e..0a879e2 100644
--- a/spec/score/tq/req/enqueue-fifo.yml
+++ b/spec/score/tq/req/enqueue-fifo.yml
@@ -68,6 +68,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes:
   - tx-thread-queue.h
diff --git a/spec/score/tq/req/enqueue-mrsp.yml b/spec/score/tq/req/enqueue-mrsp.yml
index 38bfc33..faf0825 100644
--- a/spec/score/tq/req/enqueue-mrsp.yml
+++ b/spec/score/tq/req/enqueue-mrsp.yml
@@ -290,6 +290,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes:
   - tx-thread-queue.h
diff --git a/spec/score/tq/req/enqueue-priority.yml b/spec/score/tq/req/enqueue-priority.yml
index 06be6ba..a8fd1f9 100644
--- a/spec/score/tq/req/enqueue-priority.yml
+++ b/spec/score/tq/req/enqueue-priority.yml
@@ -295,6 +295,7 @@ test-context-support: null
 test-description: null
 test-header:
   code: null
+  freestanding: false
   includes: []
   local-includes:
   - tx-thread-queue.h
diff --git a/spec/spec/test-header.yml b/spec/spec/test-header.yml
index a15fc5d..76509f4 100644
--- a/spec/spec/test-header.yml
+++ b/spec/spec/test-header.yml
@@ -16,6 +16,13 @@ spec-info:
           header code is placed at file scope after the general test
           declarations and before the test run function declaration.
         spec-type: optional-str
+      freestanding:
+        description: |
+          The value shall be ``true``, if the test case is freestanding,
+          otherwise ``false``.  Freestanding test cases are not statically
+          registered.  Instead the generated test runner uses
+          :c:func:`T_case_begin` and :c:func:`T_case_end`.
+        spec-type: bool
       includes:
         description: |
           It shall be a list of header files included by the header file via



More information about the vc mailing list