commit d6466702b5b3f0e95858fda46311db450af5ea86
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Jan 16 14:06:03 2015 +0100
XmlProcessing: handle invalid recipe exception
When lnst-ctl reads an invalid recipe xml file it would crash with an
exception, ignoring any other recipes that should have been tested.
This commit fixes that issue by handling the exception and instead of
ending the controller, setting the recipe result to FAIL and continuing
to the next recipe if posible.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst-ctl | 26 +++++++++++++++++++-------
lnst/Controller/XmlProcessing.py | 2 +-
2 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index d249c32..128b6df 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -24,6 +24,7 @@ from lnst.Common.Utils import mkdir_p
from lnst.Controller.NetTestController import NetTestController, NetTestError
from lnst.Controller.NetTestController import NoMatchError
from lnst.Controller.NetTestResultSerializer import NetTestResultSerializer
+from lnst.Controller.XmlProcessing import XmlProcessingError
RETVAL_PASS = 0
RETVAL_FAIL = 1
@@ -94,13 +95,24 @@ def get_recipe_result(action, file_path, log_ctl, res_serializer,
recipe_head_log_entry(file_path, matches)
res_serializer.add_recipe(file_path, matches)
- nettestctl = NetTestController(file_path, log_ctl,
- res_serializer=res_serializer,
- pool_checks=pool_checks,
- packet_capture=packet_capture,
- defined_aliases=defined_aliases,
- overriden_aliases=overriden_aliases,
- reduce_sync=reduce_sync)
+ res = {}
+ try:
+ nettestctl = NetTestController(file_path, log_ctl,
+ res_serializer=res_serializer,
+ pool_checks=pool_checks,
+ packet_capture=packet_capture,
+ defined_aliases=defined_aliases,
+ overriden_aliases=overriden_aliases,
+ reduce_sync=reduce_sync)
+ except XmlProcessingError as err:
+ log_exc_traceback()
+ logging.error(err)
+ res["passed"] = False
+ res["err_msg"] = str(err)
+ retval = RETVAL_ERR
+ res_serializer.set_recipe_result(res)
+ return retval
+
while True:
res = {}
if matches == 1:
diff --git a/lnst/Controller/XmlProcessing.py b/lnst/Controller/XmlProcessing.py
index 40debae..b8d1127 100644
--- a/lnst/Controller/XmlProcessing.py
+++ b/lnst/Controller/XmlProcessing.py
@@ -67,7 +67,7 @@ class XmlProcessingError(Exception):
if self._line or self._col:
loc = "%s%s:" % (line, col)
- return "%s:%s %s" % (filename, loc, self._msg)
+ return "Parser error: %s:%s %s" % (filename, loc, self._msg)
class XmlDataIterator:
def __init__(self, iterator):
Show replies by date