[rtems-central commit] validation: Support optional perf measurements

Sebastian Huber sebh at rtems.org
Thu Nov 25 08:20:28 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Nov 24 16:08:52 2021 +0100

validation: Support optional perf measurements

---

 rtemsspec/tests/spec-validation/rpr2.yml | 27 +++++++++++++++++++++++++++
 rtemsspec/tests/test_validation.py       | 29 +++++++++++++++++++++++++++++
 rtemsspec/validation.py                  | 18 +++++++++++++++---
 3 files changed, 71 insertions(+), 3 deletions(-)

diff --git a/rtemsspec/tests/spec-validation/rpr2.yml b/rtemsspec/tests/spec-validation/rpr2.yml
new file mode 100644
index 0000000..5a502fb
--- /dev/null
+++ b/rtemsspec/tests/spec-validation/rpr2.yml
@@ -0,0 +1,27 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: FOOBAR
+limits: {}
+links:
+- role: runtime-measurement-request
+  uid: rtm
+non-functional-type: performance-runtime
+params: {}
+rationale: null
+references: []
+requirement-type: non-functional
+test-body:
+  brief: |
+    Body brief.
+  code: |
+    /* Body code */
+  description: |
+    Body description.
+test-cleanup: null
+test-prepare: null
+test-setup: null
+test-teardown: null
+text: |
+  Text.
+type: requirement
diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py
index b7a37a5..34aeafe 100644
--- a/rtemsspec/tests/test_validation.py
+++ b/rtemsspec/tests/test_validation.py
@@ -1184,6 +1184,26 @@ static void Rpr_Cleanup( Rtm_Context *ctx )
   /* Cleanup code */
 }
 
+#if defined(FOOBAR)
+/**
+ * @brief Body brief.
+ *
+ * Body description.
+ */
+static void Rpr2_Body( Rtm_Context *ctx )
+{
+  /* Body code */
+}
+
+static void Rpr2_Body_Wrap( void *arg )
+{
+  Rtm_Context *ctx;
+
+  ctx = arg;
+  Rpr2_Body( ctx );
+}
+#endif
+
 /**
  * @fn void T_case_body_Rtm( void )
  */
@@ -1200,6 +1220,15 @@ T_TEST_CASE_FIXTURE( Rtm, &Rtm_Fixture )
   T_measure_runtime( ctx->context, &ctx->request );
   Rpr_Cleanup( ctx );
   Rtm_Cleanup( ctx );
+
+  #if defined(FOOBAR)
+  ctx->request.name = "Rpr2";
+  ctx->request.setup = NULL;
+  ctx->request.body = Rpr2_Body_Wrap;
+  ctx->request.teardown = NULL;
+  T_measure_runtime( ctx->context, &ctx->request );
+  Rtm_Cleanup( ctx );
+  #endif
 }
 
 /** @} */
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index 14d4f47..d4c9cfd 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -32,9 +32,10 @@ import os
 import re
 from typing import Any, Dict, List, Optional, Tuple
 
-from rtemsspec.content import CContent, CInclude, \
-    GenericContent, get_integer_type, get_value_params, get_value_plural, \
-    get_value_doxygen_group, get_value_doxygen_function, to_camel_case
+from rtemsspec.content import CContent, CInclude, enabled_by_to_exp, \
+    ExpressionMapper, GenericContent, get_integer_type, get_value_params, \
+    get_value_plural, get_value_doxygen_group, get_value_doxygen_function, \
+    to_camel_case
 from rtemsspec.items import Item, ItemCache, \
     ItemGetValueContext, ItemMapper
 from rtemsspec.transitionmap import TransitionMap
@@ -921,6 +922,14 @@ class _RuntimeMeasurementTestItem(_TestItem):
         for item in self.item.children("runtime-measurement-request"):
             req = _RuntimeMeasurementRequestItem(item, self.context)
             requests.add_blank_line()
+            enabled_by = item["enabled-by"]
+            use_enabled_by = not isinstance(enabled_by, bool) or not enabled_by
+            if use_enabled_by:
+                exp = enabled_by_to_exp(enabled_by, ExpressionMapper())
+                if_exp = f"#if {exp}"
+                requests.add(if_exp)
+                content.add(if_exp)
+                content.gap = False
             _add_call_method(requests, prepare)
             name = req.add_support_method(content,
                                           "test-prepare",
@@ -955,6 +964,9 @@ class _RuntimeMeasurementTestItem(_TestItem):
                                           do_wrap=False)
             _add_call_method(requests, name)
             _add_call_method(requests, cleanup)
+            if use_enabled_by:
+                requests.append("#endif")
+                content.append("#endif")
         return requests
 
     def generate(self, content: CContent, base_directory: str,



More information about the vc mailing list