summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2015-09-30 14:51:26 -0700
committerDylan Baker <baker.dylan.c@gmail.com>2015-10-01 10:18:24 -0700
commit2b690c5755165e7325abafef977d86357db727fe (patch)
tree0fe645d49f2e9f48cff15d5915f115e01e7713bc
parentb9e49a94975337b5930815a15c659fc72ff3122d (diff)
framework: add exception back to TestResult class
Like command, this somehow didn't get moved to the new TestResult class. Generally this isn't a problem since this is a very uncommon path, but in some cases this does get hit, and it would cause an exception in the runner threads. Python has very bad exception handling in threads, namely it doesn't have any; this results in an exception being raised and remaining uncaught, terminating the thread, which in turn results in the test result being incomplete, even though it should have been crash. This patch fixes that situation. Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com> Tested-by: Mark Janes <mark.a.janes@intel.com> Reviewed-by: Mark Janes <mark.a.janes@intel.com>
-rw-r--r--framework/results.py7
-rw-r--r--framework/tests/results_tests.py10
2 files changed, 15 insertions, 2 deletions
diff --git a/framework/results.py b/framework/results.py
index 8d3fe170f..26f438066 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -106,7 +106,8 @@ class StringDescriptor(object): # pylint: disable=too-few-public-methods
class TestResult(object):
"""An object represting the result of a single test."""
__slots__ = ['returncode', '_err', '_out', 'time', 'command', 'traceback',
- 'environment', 'subtests', 'dmesg', '__result', 'images']
+ 'environment', 'subtests', 'dmesg', '__result', 'images',
+ 'exception']
err = StringDescriptor('_err')
out = StringDescriptor('_out')
@@ -119,6 +120,7 @@ class TestResult(object):
self.dmesg = str()
self.images = None
self.traceback = None
+ self.exception = None
if result:
self.result = result
else:
@@ -155,6 +157,7 @@ class TestResult(object):
'returncode': self.returncode,
'subtests': self.subtests,
'time': self.time,
+ 'exception': self.exception,
}
return obj
@@ -174,7 +177,7 @@ class TestResult(object):
inst = cls()
# TODO: There's probably a more clever way to do this
- for each in ['returncode', 'time', 'command',
+ for each in ['returncode', 'time', 'command', 'exception',
'environment', 'result', 'dmesg']:
if each in dict_:
setattr(inst, each, dict_[each])
diff --git a/framework/tests/results_tests.py b/framework/tests/results_tests.py
index 728d4797a..1b11df036 100644
--- a/framework/tests/results_tests.py
+++ b/framework/tests/results_tests.py
@@ -194,6 +194,7 @@ class TestTestResult_to_json(object):
'b': 'fail',
},
'result': 'crash',
+ 'exception': 'an exception',
}
test = results.TestResult.from_dict(cls.dict)
@@ -212,6 +213,10 @@ class TestTestResult_to_json(object):
"""results.TestResult.to_json: sets the out correctly"""
nt.eq_(self.dict['out'], self.json['out'])
+ def test_out(self):
+ """results.TestResult.to_json: sets the exception correctly"""
+ nt.eq_(self.dict['exception'], self.json['exception'])
+
def test_time(self):
"""results.TestResult.to_json: sets the time correctly"""
nt.eq_(self.dict['time'], self.json['time'])
@@ -244,6 +249,7 @@ class TestTestResult_from_dict(object):
'b': 'fail',
},
'result': 'crash',
+ 'exception': 'an exception',
}
cls.test = results.TestResult.from_dict(cls.dict)
@@ -268,6 +274,10 @@ class TestTestResult_from_dict(object):
"""results.TestResult.from_dict: sets environment properly"""
nt.eq_(self.test.environment, self.dict['environment'])
+ def test_exception(self):
+ """results.TestResult.from_dict: sets exception properly"""
+ nt.eq_(self.test.exception, self.dict['exception'])
+
def test_subtests(self):
"""results.TestResult.from_dict: sets subtests properly"""
nt.eq_(self.test.subtests, self.dict['subtests'])