From b6d4229edc7930b86f4b15cc43d260f87c5aeb1f Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 16 Apr 2021 15:14:50 +0200 Subject: validation: Assign run parameters early This allows to use the run parameters in the setup/teardown fixture methods. --- rtemsspec/validation.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'rtemsspec/validation.py') diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py index 4cb7cba6..2d60d99b 100644 --- a/rtemsspec/validation.py +++ b/rtemsspec/validation.py @@ -383,6 +383,15 @@ class _TestItem: ]) return f"&{self.ident}_Fixture" + def assign_run_params(self, content: CContent, header: Dict[str, + Any]) -> None: + """ Assigns the run parameters to the context. """ + if header["run-params"]: + content.add([f"ctx = &{self.ident}_Instance;"] + [ + f"ctx->{param['name']} = {param['name']};" + for param in header["run-params"] + ]) + def generate(self, content: CContent, base_directory: str, test_case_to_suites: Dict[str, List["_TestItem"]]) -> None: """ Generates the content. """ @@ -407,13 +416,10 @@ class _TestItem: 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]) - prologue.add([ - f"ctx->{param['name']} = {param['name']};" - for param in header["run-params"] - ]) epilogue.add("T_pop_fixture();") align = True else: @@ -1175,12 +1181,10 @@ class _ActionRequirementTestItem(_TestItem): name = f"{self.ident}_Run" params = self._get_run_params(header) prologue.add([f"{self.context} *ctx;", entry, "size_t index;"]) + self.assign_run_params(prologue, header) prologue.call_function("ctx =", "T_push_fixture", [f"&{self.ident}_Node", f"&{fixture}"]) - prologue.add([ - f"ctx->{param['name']} = {param['name']};" - for param in header["run-params"] - ] + ["ctx->in_action_loop = true;", "index = 0;"]) + prologue.append(["ctx->in_action_loop = true;", "index = 0;"]) epilogue.add("T_pop_fixture();") align = True else: -- cgit v1.2.3