commit 2feb83820516ae48099178dcea93b95e1980a318
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Jun 5 13:24:18 2013 +0200
add attribute "pass_result" to <command> tags
The added attribute indicates what the expected result of the command
is. The result of the command is then calculated as an equality of the
expected result and recieved result. This can be used to test scenarios
where you expect the command should fail and therefore indicates a
successfull run of the command.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/Machine.py | 3 +++
lnst/Controller/RecipeParse.py | 7 +++++++
recipe-schema.rng | 27 +++++++++++++++++++++++++++
3 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index 006a5a0..2ae008c 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -178,6 +178,9 @@ class Machine(object):
signal.alarm(0)
signal.signal(signal.SIGALRM, prev_handler)
+ if "pass_result" in command:
+ cmd_res["passed"] = cmd_res["passed"] ==
command["pass_result"]
+
return cmd_res
def get_hostname(self):
diff --git a/lnst/Controller/RecipeParse.py b/lnst/Controller/RecipeParse.py
index d2d1171..04cb648 100644
--- a/lnst/Controller/RecipeParse.py
+++ b/lnst/Controller/RecipeParse.py
@@ -452,6 +452,13 @@ class CommandParse(LnstParser):
if self._has_attribute(node, "value"):
command["value"] = self._get_attribute(node, "value")
+ if self._has_attribute(node, "pass_result"):
+ command["pass_result"] = self._get_attribute(node,
"pass_result",
+ bool_it)
+ if command["type"] == "system_config":
+ msg = "Invalid attribute pass_result for command
system_config"
+ raise XmlProcessingError(msg, node)
+
if self._has_attribute(node, "timeout"):
command["timeout"] = self._get_attribute(node, "timeout",
int)
diff --git a/recipe-schema.rng b/recipe-schema.rng
index 57445b4..9f109af 100644
--- a/recipe-schema.rng
+++ b/recipe-schema.rng
@@ -377,6 +377,15 @@
<optional>
<attribute name="source"/>
</optional>
+
+ <optional>
+ <attribute name="pass_result">
+ <choice>
+ <value>true</value>
+ <value>false</value>
+ </choice>
+ </attribute>
+ </optional>
</define>
<define name="system_config">
@@ -450,6 +459,15 @@
<optional>
<attribute name="source"/>
</optional>
+
+ <optional>
+ <attribute name="pass_result">
+ <choice>
+ <value>true</value>
+ <value>false</value>
+ </choice>
+ </attribute>
+ </optional>
</define>
<define name="control_commands">
@@ -484,5 +502,14 @@
<optional>
<attribute name="source"/>
</optional>
+
+ <optional>
+ <attribute name="pass_result">
+ <choice>
+ <value>true</value>
+ <value>false</value>
+ </choice>
+ </attribute>
+ </optional>
</define>
</grammar>
Show replies by thread