summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-04-16 15:14:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-04-19 16:37:44 +0200
commitb6d4229edc7930b86f4b15cc43d260f87c5aeb1f (patch)
treec433d31645be747dc6b6c0ad592fe8f8cb697505
parentvalidation: Avoid use of uint0_t (diff)
downloadrtems-central-b6d4229edc7930b86f4b15cc43d260f87c5aeb1f.tar.bz2
validation: Assign run parameters early
This allows to use the run parameters in the setup/teardown fixture methods.
-rw-r--r--rtemsspec/tests/spec-validation/tc8.yml34
-rw-r--r--rtemsspec/tests/test_validation.py66
-rw-r--r--rtemsspec/validation.py20
-rw-r--r--spec/rtems/event/req/send-receive.yml1
4 files changed, 108 insertions, 13 deletions
diff --git a/rtemsspec/tests/spec-validation/tc8.yml b/rtemsspec/tests/spec-validation/tc8.yml
new file mode 100644
index 00000000..9d44b78f
--- /dev/null
+++ b/rtemsspec/tests/spec-validation/tc8.yml
@@ -0,0 +1,34 @@
+SPDX-License-Identifier: CC-BY-SA-6.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links: []
+test-actions:
+- action-brief: |
+ Action.
+ action-code: |
+ /* ${step} */
+ checks: []
+ links: []
+test-brief: null
+test-context:
+- brief: null
+ description: null
+ member: |
+ int member
+test-context-support: null
+test-description: null
+test-header:
+ code: null
+ includes: []
+ local-includes: []
+ run-params: []
+ target: tc7.h
+test-includes: []
+test-local-includes: []
+test-setup: null
+test-stop: null
+test-support: null
+test-target: tc34.c
+test-teardown: null
+type: test-case
diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py
index a35ff371..9c6f57ef 100644
--- a/rtemsspec/tests/test_validation.py
+++ b/rtemsspec/tests/test_validation.py
@@ -946,6 +946,7 @@ T_TEST_CASE_FIXTURE( Tc2, &Tc2_Fixture )
* @ingroup RTEMSTestCaseTc5
* @ingroup RTEMSTestCaseTc6
* @ingroup RTEMSTestCaseTc7
+ * @ingroup RTEMSTestCaseTc8
*/
/*
@@ -1361,12 +1362,13 @@ void Tc5_Run( int *a, int b, int *c )
{
Tc5_Context *ctx;
- ctx = T_push_fixture( &Tc5_Node, &Tc5_Fixture );
-
+ ctx = &Tc5_Instance;
ctx->a = a;
ctx->b = b;
ctx->c = c;
+ ctx = T_push_fixture( &Tc5_Node, &Tc5_Fixture );
+
T_plan( 2 );
Tc5_Action_0( ctx );
@@ -1425,6 +1427,61 @@ void Tc7_Run( void )
}
/** @} */
+
+/**
+ * @defgroup RTEMSTestCaseTc8 spec:/tc8
+ *
+ * @ingroup RTEMSTestSuiteTs
+ *
+ * This test case performs the following actions:
+ *
+ * - Action.
+ *
+ * @{
+ */
+
+/**
+ * @brief Test context for spec:/tc8 test case.
+ */
+typedef struct {
+ int member;
+} Tc8_Context;
+
+static Tc8_Context
+ Tc8_Instance;
+
+static T_fixture Tc8_Fixture = {
+ .setup = NULL,
+ .stop = NULL,
+ .teardown = NULL,
+ .scope = NULL,
+ .initial_context = &Tc8_Instance
+};
+
+/**
+ * @brief Action.
+ */
+static void Tc8_Action_0( Tc8_Context *ctx )
+{
+ /* 0 */
+}
+
+static T_fixture_node Tc8_Node;
+
+void Tc8_Run( void )
+{
+ Tc8_Context *ctx;
+
+ ctx = T_push_fixture( &Tc8_Node, &Tc8_Fixture );
+
+ T_plan( 1 );
+
+ Tc8_Action_0( ctx );
+
+ T_pop_fixture();
+}
+
+/** @} */
"""
assert content == src.read()
with open(os.path.join(base_directory, "tc5.h"), "r") as src:
@@ -2170,11 +2227,12 @@ void Action2_Run( int *a, int b, int *c )
Action2_Entry entry;
size_t index;
- ctx = T_push_fixture( &Action2_Node, &Action2_Fixture );
-
+ ctx = &Action2_Instance;
ctx->a = a;
ctx->b = b;
ctx->c = c;
+
+ ctx = T_push_fixture( &Action2_Node, &Action2_Fixture );
ctx->in_action_loop = true;
index = 0;
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:
diff --git a/spec/rtems/event/req/send-receive.yml b/spec/rtems/event/req/send-receive.yml
index 2db1ab1e..0e69100c 100644
--- a/spec/rtems/event/req/send-receive.yml
+++ b/spec/rtems/event/req/send-receive.yml
@@ -482,7 +482,6 @@ test-setup:
code: |
rtems_status_code sc;
- memset( ctx, 0, sizeof( *ctx ) );
ctx->runner_thread = _Thread_Get_executing();
ctx->runner_id = ctx->runner_thread->Object.id;
ctx->worker_wakeup = CreateWakeupSema();