summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-02-04 13:16:42 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-02-04 14:23:33 +0100
commit25d5b7267e9d1e5fb132b60ee514dad846676b97 (patch)
treef4d71149751d6538a6ef07291c11980524bc332b
parentvalidation: Move actions to separate functions (diff)
downloadrtems-central-25d5b7267e9d1e5fb132b60ee514dad846676b97.tar.bz2
validation: Do not pass NULL context
-rw-r--r--rtemsspec/tests/test_validation.py32
-rw-r--r--rtemsspec/validation.py22
2 files changed, 26 insertions, 28 deletions
diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py
index 7269a0ef..700e1c9e 100644
--- a/rtemsspec/tests/test_validation.py
+++ b/rtemsspec/tests/test_validation.py
@@ -858,14 +858,14 @@ T_TEST_CASE_FIXTURE( Directive, &Directive_Fixture )
/* Test case support code */
-static void Tc_Action_0( void *ctx )
+static void Tc_Action_0( void )
{
/* Test case action 0 code */
/* Test case action 0 check 0 code: Accounts for 123 test plan steps */
/* Test case action 0 check 1 code; step 123 */
}
-static void Tc_Action_1( void *ctx )
+static void Tc_Action_1( void )
{
/* Test case action 1 code */
/* Test case action 1 check 0 code; step 124 */
@@ -877,14 +877,10 @@ static void Tc_Action_1( void *ctx )
*/
T_TEST_CASE( Tc )
{
- void *ctx;
-
- ctx = T_fixture_context();
-
T_plan( 125 );
- Tc_Action_0( ctx );
- Tc_Action_1( ctx );
+ Tc_Action_0();
+ Tc_Action_1();
}
/** @} */
@@ -1259,7 +1255,7 @@ T_TEST_CASE_FIXTURE( Rtm, &Rtm_Fixture )
* @{
*/
-static void Tc3_Action_0( void *ctx )
+static void Tc3_Action_0( void )
{
/* Test case 3 action 0 code */
/* Test case 3 action 0 check 0 code; step 0 */
@@ -1270,13 +1266,9 @@ static void Tc3_Action_0( void *ctx )
*/
T_TEST_CASE( Tc3 )
{
- void *ctx;
-
- ctx = T_fixture_context();
-
T_plan( 1 );
- Tc3_Action_0( ctx );
+ Tc3_Action_0();
}
/** @} */
@@ -1298,9 +1290,6 @@ T_TEST_CASE( Tc3 )
*/
T_TEST_CASE( Tc4 )
{
- void *ctx;
-
- ctx = T_fixture_context();
}
/** @} */
@@ -1411,7 +1400,6 @@ void Tc5_Run( int *a, int b, int *c )
void Tc6_Run( void )
{
- void *ctx;
}
/** @} */
@@ -1428,7 +1416,7 @@ void Tc6_Run( void )
* @{
*/
-static void Tc7_Action_0( void *ctx )
+static void Tc7_Action_0( void )
{
/* 0 */
}
@@ -1437,13 +1425,11 @@ static T_fixture_node Tc7_Node;
void Tc7_Run( void )
{
- void *ctx;
-
- ctx = T_push_fixture( &Tc7_Node, &T_empty_fixture );
+ T_push_fixture( &Tc7_Node, &T_empty_fixture );
T_plan( 1 );
- Tc7_Action_0( ctx );
+ Tc7_Action_0();
T_pop_fixture();
}
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index ea263d88..f2f2d786 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -192,9 +192,14 @@ class _TestItem:
actions = CContent()
for index, action in enumerate(self["test-actions"]):
method = f"{self._ident}_Action_{index}"
+ if self.context == "void":
+ args = []
+ params = []
+ else:
+ args = ["ctx"]
+ params = [f"{self.context} *ctx"]
actions.gap = False
- actions.call_function(None, method, ["ctx"])
- params = [f"{self.context} *ctx"]
+ actions.call_function(None, method, args)
with content.function("static void", method, params):
content.add(self.substitute_code(action["action"]))
for check in action["checks"]:
@@ -372,7 +377,6 @@ class _TestItem:
actions = self._add_test_case_actions(content)
header = self["test-header"]
prologue = CContent()
- prologue.add([f"{self.context} *ctx;"])
epilogue = CContent()
if header:
self.generate_header(base_directory, header)
@@ -383,7 +387,12 @@ class _TestItem:
fixture = "&T_empty_fixture"
if fixture:
content.add(f"static T_fixture_node {self.ident}_Node;")
- prologue.call_function("ctx =", "T_push_fixture",
+ if self.context == "void":
+ result = None
+ else:
+ prologue.add(f"{self.context} *ctx;")
+ result = "ctx ="
+ prologue.call_function(result, "T_push_fixture",
[f"&{self.ident}_Node", fixture])
prologue.add([
f"ctx->{param['name']} = {param['name']};"
@@ -399,7 +408,10 @@ class _TestItem:
name = "T_TEST_CASE_FIXTURE"
else:
name = "T_TEST_CASE"
- prologue.add("ctx = T_fixture_context();")
+ if self.context != "void":
+ prologue.add([
+ f"{self.context} *ctx;", "", "ctx = T_fixture_context();"
+ ])
align = False
with content.function_block(
f"void T_case_body_{self.ident}( void )"):