aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2018-08-23 17:04:57 -0700
committerTim Newsome <tim@sifive.com>2018-08-23 17:04:57 -0700
commit3e972b3d78bc62914d6920c06cc9e99ef82ed492 (patch)
treeffcd8878c936ba2cf7a0b26c6daec385539fb9ae
parentec9250bb49897c3f2483b6aafb6158fa413a12e7 (diff)
downloadriscv-tests-3e972b3d78bc62914d6920c06cc9e99ef82ed492.zip
riscv-tests-3e972b3d78bc62914d6920c06cc9e99ef82ed492.tar.gz
riscv-tests-3e972b3d78bc62914d6920c06cc9e99ef82ed492.tar.bz2
Get all of the log into the final log file
This allows me to see the final valgrind output on OpenOCD, so I can watch for memory leaks when using --server_cmd "valgrind --leak-check=full openocd".
-rw-r--r--debug/testlib.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/debug/testlib.py b/debug/testlib.py
index 77795c6..1d46b6c 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -299,7 +299,13 @@ class Openocd(object):
def __del__(self):
try:
- self.process.kill()
+ self.process.terminate()
+ start = time.time()
+ while time.time() < start + 10000:
+ if self.process.poll():
+ break
+ else:
+ self.process.kill()
self.process.wait()
except (OSError, AttributeError):
pass
@@ -715,12 +721,15 @@ def header(title, dash='-', length=78):
else:
print dash * length
-def print_log(path):
- header(path)
- for l in open(path, "r"):
+def print_log_handle(name, handle):
+ header(name)
+ for l in handle:
sys.stdout.write(l)
print
+def print_log(path):
+ print_log_handle(path, open(path, "r"))
+
class BaseTest(object):
compiled = {}
@@ -816,10 +825,15 @@ class BaseTest(object):
return result
finally:
+ # Get handles to logs before the files are deleted.
+ logs = []
for log in self.logs:
- print_log(log)
- header("End of logs")
+ logs.append((log, open(log, "r")))
+
self.classTeardown()
+ for name, handle in logs:
+ print_log_handle(name, handle)
+ header("End of logs")
if not result:
result = 'pass'