summaryrefslogtreecommitdiff
path: root/piglit-run.py
diff options
context:
space:
mode:
authorChad Versace <chad@chad-versace.us>2011-07-12 07:18:53 -0700
committerChad Versace <chad@chad-versace.us>2011-07-14 10:25:34 -0700
commitb2ae931c5891a35aa3ddd22159b24e0d532e3b3d (patch)
tree6868805a52fdce7770997ed2cd7bb2b58a25237a /piglit-run.py
parent0a9773ea4d2a795fb0ff77fa92f41dd08af81be0 (diff)
framework: Replace custom serialization format with json
The results file produced by piglit-run.py contains a serialized TestrunResult, and the serialization format was horridly homebrew. This commit replaces that insanity with json. Benefits: - Net loss of 113 lines of code (ignoring comments and empty lines). - By using the json module in the Python standard library, serializing and unserializing is nearly as simple as `json.dump(object, file)` and `json.load(object, file)`. - By using a format that is easy to manipulate, it is now simple to extend Piglit to allow users to embed custom data into the results file. As a side effect, the summary file is no longer needed, so it is no longer produced. Reviewed-by: Paul Berry <stereotype441@gmail.com> Signed-off-by: Chad Versace <chad@chad-versace.us>
Diffstat (limited to 'piglit-run.py')
-rwxr-xr-xpiglit-run.py54
1 files changed, 37 insertions, 17 deletions
diff --git a/piglit-run.py b/piglit-run.py
index 1e6d5158d..d5e85f893 100755
--- a/piglit-run.py
+++ b/piglit-run.py
@@ -23,8 +23,12 @@
from getopt import getopt, GetoptError
+import json
+import os.path as path
import re
import sys, os
+import time
+import traceback
import framework.core as core
from framework.threads import synchronized_self
@@ -120,27 +124,43 @@ def main():
core.checkDir(resultsDir, False)
+ results = core.TestrunResult()
+
+ # Set results.name
+ if OptionName is '':
+ results.name = path.basename(resultsDir)
+ else:
+ results.name = OptionName
+
+ results.__dict__.update(env.collectData())
+
profile = core.loadTestProfile(profileFilename)
- env.file = SyncFileWriter(resultsDir + '/main')
- env.file.writeLine("name: %(name)s" % { 'name': core.encode(OptionName) })
- env.collectData()
- profile.run(env)
- env.file.close()
-
- print "Writing summary file..."
- results = core.loadTestResults(resultsDir)
- for testname, result in results.allTestResults().items():
- if 'info' in result:
- if len(result['info']) > 4096:
- result['info'] = result['info'][0:4096]
- file = open(resultsDir + '/summary', "w")
- results.write(file)
- file.close()
+ time_start = time.time()
+
+ try:
+ profile.run(env, results)
+ except Exception as e:
+ if isinstance(e, KeyboardInterrupt):
+ # When the user interrupts the test run, he may still
+ # want the partial test results. So ignore
+ # KeyboardInterruption and proceed to writing the
+ # result files.
+ pass
+ else:
+ traceback.print_exc()
+ sys.exit(1)
+
+ time_end = time.time()
+ results.time_elapsed = time_end - time_start
+
+ result_filepath = os.path.join(resultsDir, 'main')
+ print("Writing results file...")
+ with open(result_filepath, 'w') as f:
+ results.write(f)
print
print 'Thank you for running Piglit!'
- print 'Summary for submission has been written to ' + resultsDir + '/summary'
-
+ print 'Results have been written to ' + result_filepath
if __name__ == "__main__":
main()