summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2011-01-19 15:05:59 -0800
committerIan Romanick <ian.d.romanick@intel.com>2011-01-20 09:22:29 -0800
commit394d23178dd2de3c9f7fb79827a58a5dafc15439 (patch)
tree98527c0ee9f94947d644ac5b3973520365dca00b /framework
parentdd3df3bc3a3ca4949f840030235bf14595558a98 (diff)
modified TestResults::write() for thread safety
made TestResults::write() thread-safe by writing results in one chunk to the file so that when threaded tests are implemented there will be no interleaving. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/core.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/framework/core.py b/framework/core.py
index b237df696..b975cb3cc 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -31,6 +31,7 @@ import subprocess
import sys
import time
import traceback
+from cStringIO import StringIO
__all__ = [
'Environment',
@@ -107,17 +108,19 @@ class TestResult(dict):
return {name: self}
def write(self, file, path):
- print >>file, "@test: " + encode(path)
+ result = StringIO()
+ print >> result, "@test: " + encode(path)
for k in self:
v = self[k]
if type(v) == list:
- print >>file, k + "!"
+ print >> result, k + "!"
for s in v:
- print >>file, " " + encode(str(s))
- print >>file, "!"
+ print >> result, " " + encode(str(s))
+ print >> result, "!"
else:
- print >>file, k + ": " + encode(str(v))
- print >>file, "!"
+ print >> result, k + ": " + encode(str(v))
+ print >> result, "!"
+ print >> file, result.getvalue(),
class GroupResult(dict):