[Piglit] [PATCH] framework/results.py: write and restore traceback.

baker.dylan.c at gmail.com baker.dylan.c at gmail.com
Mon Dec 7 17:07:10 PST 2015


From: Dylan Baker <baker.dylan.c at gmail.com>

Storing recording the traceback into the object is nice and all, but it
would be really nice if it was written and read from disk too.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/results.py             |  3 ++-
 framework/tests/results_tests.py | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/framework/results.py b/framework/results.py
index eeffcb7..5d73100 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -197,6 +197,7 @@ class TestResult(object):
             'time': self.time,
             'exception': self.exception,
             'dmesg': self.dmesg,
+            'traceback': self.traceback,
         }
         return obj
 
@@ -216,7 +217,7 @@ class TestResult(object):
         inst = cls()
 
         for each in ['returncode', 'command', 'exception', 'environment',
-                     'time', 'result', 'dmesg']:
+                     'time', 'result', 'dmesg', 'traceback']:
             if each in dict_:
                 setattr(inst, each, dict_[each])
 
diff --git a/framework/tests/results_tests.py b/framework/tests/results_tests.py
index 83c2ae2..5e9d55a 100644
--- a/framework/tests/results_tests.py
+++ b/framework/tests/results_tests.py
@@ -205,6 +205,7 @@ class TestTestResult_to_json(object):
             'result': 'crash',
             'exception': 'an exception',
             'dmesg': 'this is dmesg',
+            'traceback': 'this is a traceback',
         }
 
         test = results.TestResult.from_dict(cls.dict)
@@ -247,6 +248,10 @@ class TestTestResult_to_json(object):
         """results.TestResult.to_json: Adds the dmesg attribute"""
         nt.eq_(self.json['dmesg'], 'this is dmesg')
 
+    def test_traceback(self):
+        """results.TestResult.to_json: Adds the traceback attribute"""
+        nt.eq_(self.json['traceback'], 'this is a traceback')
+
 
 class TestTestResult_from_dict(object):
     """Tests for the from_dict method."""
@@ -265,6 +270,7 @@ class TestTestResult_from_dict(object):
             'result': 'crash',
             'exception': 'an exception',
             'dmesg': 'this is dmesg',
+            'traceback': 'this is a traceback',
         }
 
         cls.test = results.TestResult.from_dict(cls.dict)
@@ -306,6 +312,10 @@ class TestTestResult_from_dict(object):
         """results.TestResult.from_dict: sets dmesg properly"""
         nt.eq_(self.test.dmesg, self.dict['dmesg'])
 
+    def test_traceback(self):
+        """results.TestResult.to_json: Adds the traceback attribute"""
+        nt.eq_(self.test.traceback, self.dict['traceback'])
+
 
 def test_TestResult_update():
     """results.TestResult.update: result is updated"""
-- 
2.6.3



More information about the Piglit mailing list