summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-08-04 07:08:38 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-08-19 11:29:34 +0200
commitc127fb3f519dfb5b93a87aa2161c77ab7d95edbf (patch)
tree6bef81073c5c3565620aa485530c346f33401d80
parentcontent: Add to_camel_case() (diff)
downloadrtems-central-c127fb3f519dfb5b93a87aa2161c77ab7d95edbf.tar.bz2
validation: Add test early preparation
-rw-r--r--rtemsspec/tests/spec-validation/action2.yml2
-rw-r--r--rtemsspec/tests/spec-validation/directive.yml1
-rw-r--r--rtemsspec/tests/test_validation.py6
-rw-r--r--rtemsspec/validation.py19
-rw-r--r--spec/req/rtems/ident-local.yml1
-rw-r--r--spec/req/rtems/ident.yml1
-rw-r--r--spec/req/rtems/tasks/ident.yml1
-rw-r--r--spec/spec/requirement-action.yml7
8 files changed, 32 insertions, 6 deletions
diff --git a/rtemsspec/tests/spec-validation/action2.yml b/rtemsspec/tests/spec-validation/action2.yml
index 8f7f6907..9a56d818 100644
--- a/rtemsspec/tests/spec-validation/action2.yml
+++ b/rtemsspec/tests/spec-validation/action2.yml
@@ -124,6 +124,8 @@ test-includes:
test-local-includes:
- b.h
test-name: Action 2
+test-prepare: |
+ /* Prepare */
test-setup:
brief: |
Setup brief.
diff --git a/rtemsspec/tests/spec-validation/directive.yml b/rtemsspec/tests/spec-validation/directive.yml
index 71e583f7..47eef2ec 100644
--- a/rtemsspec/tests/spec-validation/directive.yml
+++ b/rtemsspec/tests/spec-validation/directive.yml
@@ -196,6 +196,7 @@ test-includes:
test-local-includes:
- x.h
test-name: Classic Task Identification
+test-prepare: null
test-setup:
brief: |
Setup brief description.
diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py
index b0a7a3ef..76b9c63e 100644
--- a/rtemsspec/tests/test_validation.py
+++ b/rtemsspec/tests/test_validation.py
@@ -1416,6 +1416,11 @@ static const struct {
}
};
+static void Action2_Prepare( Action2_Context *ctx )
+{
+ /* Prepare */
+}
+
static void Action2_Action( Action2_Context *ctx )
{
/* Action */
@@ -1462,6 +1467,7 @@ void Action2_Run( int *a, int b, int *c )
continue;
}
+ Action2_Prepare( ctx );
Action2_Pre_A_Prepare( ctx, ctx->pcs[ 0 ] );
Action2_Pre_B_Prepare( ctx, ctx->pcs[ 1 ] );
Action2_Action( ctx );
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index a6e6172a..20c69114 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -471,18 +471,24 @@ class _TestDirectiveItem(_TestItem):
content.add([f"}} {self.ident}_TransitionInfo[] = {{", " {"])
content.append(["\n }, {\n".join(info_elements), " }", "};"])
- def _add_action(self, content: CContent) -> None:
- with content.function("static void", f"{self.ident}_Action",
- [f"{self.context} *ctx"]):
- content.append(self.substitute_code(self["test-action"]))
+ def _add_function(self, content: CContent, key: str, name: str) -> None:
+ if self[key] is not None:
+ with content.function("static void", f"{self.ident}_{name}",
+ [f"{self.context} *ctx"]):
+ content.append(self.substitute_code(self[key]))
+
+ def _add_call(self, content: CContent, key: str, name: str) -> None:
+ if self[key] is not None:
+ content.append(f"{self.ident}_{name}( ctx );")
def _add_loop_body(self, content: CContent) -> None:
with content.condition(f"{self.ident}_TransitionInfo[ index ].Skip"):
content.append(["++index;", "continue;"])
content.add_blank_line()
+ self._add_call(content, "test-prepare", "Prepare")
for index, enum in enumerate(self._pre_index_to_enum):
content.append(f"{enum[0]}_Prepare( ctx, ctx->pcs[ {index} ] );")
- content.append(f"{self.ident}_Action( ctx );")
+ self._add_call(content, "test-action", "Action")
transition_map = f"{self.ident}_TransitionMap"
for index, enum in enumerate(self._post_index_to_enum):
content.append([
@@ -642,7 +648,8 @@ class _TestDirectiveItem(_TestItem):
f" .initial_context = &{self.ident}_Instance", "};"
])
self._add_transition_map(content)
- self._add_action(content)
+ self._add_function(content, "test-prepare", "Prepare")
+ self._add_function(content, "test-action", "Action")
self._add_test_case(content, header)
content.add("/** @} */")
diff --git a/spec/req/rtems/ident-local.yml b/spec/req/rtems/ident-local.yml
index 3dff42a6..5df88193 100644
--- a/spec/req/rtems/ident-local.yml
+++ b/spec/req/rtems/ident-local.yml
@@ -127,6 +127,7 @@ test-includes: []
test-local-includes:
- support-object-ident-local.h
test-name: Classic Object Local Ident
+test-prepare: null
test-setup: null
test-stop: null
test-support: null
diff --git a/spec/req/rtems/ident.yml b/spec/req/rtems/ident.yml
index 38ad2f71..b95fcef3 100644
--- a/spec/req/rtems/ident.yml
+++ b/spec/req/rtems/ident.yml
@@ -188,6 +188,7 @@ test-includes: []
test-local-includes:
- support-object-ident.h
test-name: Classic Object Ident
+test-prepare: null
test-setup: null
test-stop: null
test-support: null
diff --git a/spec/req/rtems/tasks/ident.yml b/spec/req/rtems/tasks/ident.yml
index 8875f72f..61e26aa3 100644
--- a/spec/req/rtems/tasks/ident.yml
+++ b/spec/req/rtems/tasks/ident.yml
@@ -75,6 +75,7 @@ test-includes: []
test-local-includes:
- support-object-ident.h
test-name: Classic Task Ident
+test-prepare: null
test-setup:
brief: null
code: |
diff --git a/spec/spec/requirement-action.yml b/spec/spec/requirement-action.yml
index 6afa7879..aacef508 100644
--- a/spec/spec/requirement-action.yml
+++ b/spec/spec/requirement-action.yml
@@ -97,6 +97,7 @@ spec-example: |
test-includes: []
test-local-includes: []
test-name: RedGreenData
+ test-prepare: null
test-setup: null
test-stop: null
test-support: null
@@ -171,6 +172,12 @@ spec-info:
test-name:
description: null
spec-type: test-name
+ test-prepare:
+ description: |
+ If the value is present, then it shall be the early test preparation
+ code. The code is placed in the test action loop body before the
+ test pre-condition preparations.
+ spec-type: optional-str
test-setup:
description: null
spec-type: requirement-action-test-fixture