diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-11-24 16:08:52 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-11-25 07:43:59 +0100 |
commit | 9f9917c544ab7646626569f534b97c3b094aa3df (patch) | |
tree | df77e4436e242524ce9cac8359280bdacb165f24 | |
parent | validation: Add optional begin/end time point (diff) | |
download | rtems-central-9f9917c544ab7646626569f534b97c3b094aa3df.tar.bz2 |
validation: Support optional perf measurements
-rw-r--r-- | rtemsspec/tests/spec-validation/rpr2.yml | 27 | ||||
-rw-r--r-- | rtemsspec/tests/test_validation.py | 29 | ||||
-rw-r--r-- | 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 00000000..5a502fb0 --- /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 b7a37a54..34aeafea 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 14d4f473..d4c9cfd5 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, |