[rtems-central commit] validation: Update due to test API changes

Sebastian Huber sebh at rtems.org
Thu Aug 20 14:13:13 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Aug 13 14:47:54 2020 +0200

validation: Update due to test API changes

---

 rtemsspec/tests/test_validation.py | 12 ++++++++----
 rtemsspec/validation.py            | 14 ++++++--------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py
index 665df87..ca7668a 100644
--- a/rtemsspec/tests/test_validation.py
+++ b/rtemsspec/tests/test_validation.py
@@ -492,15 +492,17 @@ static void Directive_Teardown_Wrap( void *arg )
   Directive_Teardown( ctx );
 }
 
-static void Directive_Scope( void *arg, char *buf, size_t n )
+static size_t Directive_Scope( void *arg, char *buf, size_t n )
 {
   Directive_Context *ctx;
 
   ctx = arg;
 
   if ( ctx->in_action_loop ) {
-    T_get_scope( Directive_PreDesc, buf, n, ctx->pcs );
+    return T_get_scope( Directive_PreDesc, buf, n, ctx->pcs );
   }
+
+  return 0;
 }
 
 static T_fixture Directive_Fixture = {
@@ -1348,15 +1350,17 @@ static void Action2_Teardown_Wrap( void *arg )
   Action2_Teardown( ctx );
 }
 
-static void Action2_Scope( void *arg, char *buf, size_t n )
+static size_t Action2_Scope( void *arg, char *buf, size_t n )
 {
   Action2_Context *ctx;
 
   ctx = arg;
 
   if ( ctx->in_action_loop ) {
-    T_get_scope( Action2_PreDesc, buf, n, ctx->pcs );
+    return T_get_scope( Action2_PreDesc, buf, n, ctx->pcs );
   }
+
+  return 0;
 }
 
 static T_fixture Action2_Fixture = {
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index 467a50b..5313902 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -325,17 +325,15 @@ class _TestDirectiveItem(_TestItem):
             f"  {self.ident}_Instance;"
         ])
 
-    def _add_scope_body(self, content: CContent) -> None:
-        with content.condition("ctx->in_action_loop"):
-            content.call_function(
-                None, "T_get_scope",
-                [f"{self.ident}_PreDesc", "buf", "n", "ctx->pcs"])
-
     def _add_fixture_scope(self, content: CContent) -> None:
         params = ["void *arg", "char *buf", "size_t n"]
-        with content.function("static void", f"{self.ident}_Scope", params):
+        with content.function("static size_t", f"{self.ident}_Scope", params):
             content.add([f"{self.context} *ctx;", "", "ctx = arg;"])
-            self._add_scope_body(content)
+            with content.condition("ctx->in_action_loop"):
+                content.call_function(
+                    "return", "T_get_scope",
+                    [f"{self.ident}_PreDesc", "buf", "n", "ctx->pcs"])
+            content.add("return 0;")
 
     def _add_fixture_method(self, content: CContent,
                             info: Optional[Dict[str, Optional[str]]],



More information about the vc mailing list