summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2012-11-24 17:40:26 -0800
committerKenneth Graunke <kenneth@whitecape.org>2012-11-24 17:40:26 -0800
commit53a5b78d4ed126f1f45f021b55cd3abf3a28ac24 (patch)
tree4304c39957319e191971dcab84420522195e6ffe
parentfb20d2346e18185104a2d934a9c707d4cd2d8d31 (diff)
start switching to sqlite; misc stuff.
-rw-r--r--framework/database.py56
-rw-r--r--framework/process.py4
-rwxr-xr-xprograms/run.py25
3 files changed, 67 insertions, 18 deletions
diff --git a/framework/database.py b/framework/database.py
new file mode 100644
index 0000000..fb7b1e3
--- /dev/null
+++ b/framework/database.py
@@ -0,0 +1,56 @@
+#
+# Copyright © 2012 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+#
+import apsw
+import sys
+import os.path as path
+import xdg.BaseDirectory as xdg
+
+__all__ = ['load']
+
+databaseFile = path.join(xdg.save_data_path('robyn'), 'results.db')
+
+def load():
+ '''Load the results database, creating it if it doesn't exist.
+
+ Will exit the program if it fails.'''
+ try:
+ connection = apsw.Connection(databaseFile)
+ cursor = connection.cursor()
+
+ cursor.execute('''CREATE TABLE IF NOT EXISTS runs
+ (date INTEGER,
+ name TEXT,
+ driver TEXT,
+ sysinfo TEXT)''')
+ cursor.execute('''CREATE TABLE IF NOT EXISTS results
+ (run_id INTEGER,
+ test_name TEXT,
+ command TEXT,
+ result TEXT,
+ return_code INTEGER,
+ errors TEXT,
+ output TEXT)''')
+ return cursor
+ except OSError as e:
+ print('error: could not open results database', str(e), '\n')
+ sys.exit(0)
diff --git a/framework/process.py b/framework/process.py
index b1100a6..9bfa836 100644
--- a/framework/process.py
+++ b/framework/process.py
@@ -28,14 +28,14 @@ import subprocess
__all__ = ['runProgram']
def runProgram(cmd, timeout, env = None):
- """Run a program with a timeout in case it never terminates.
+ '''Run a program with a timeout in case it never terminates.
cmd -- List of command and arguments. See subprocess.Popen.
timeout -- Fractional number of seconds to wait before killing the program.
env -- A dictionary containing additional environment variables to set.
Returns a 4-tuple: (stdout, stderr, return code, <finished before timeout>)
- """
+ '''
if env:
fullEnv = os.environ.copy()
diff --git a/programs/run.py b/programs/run.py
index 9a39e58..544bb79 100755
--- a/programs/run.py
+++ b/programs/run.py
@@ -31,10 +31,10 @@ import os
import os.path as path
import sys
+import framework.database
import framework.suites
-from framework.suites import TestSuite
-def main(argv):
+def parseArguments(argv):
p = ArgumentParser(prog='robyn run', description='A GPU test runner')
p.add_argument('-d', '--dry-run', action='store_true',
help='Do not actually run tests, but show what would be performed',
@@ -52,23 +52,16 @@ def main(argv):
p.add_argument('--valgrind', action='store_true',
help="Run tests in Valgrind's memcheck tool.",
default=False)
+ p.add_argument('-r', '--results', action='store',
+ metavar='<results database>',
+ help='Specify an alternate result database (defaults to ~/.local/share/robyn/results.db))')
p.add_argument('suites', nargs='+')
- p.add_argument('resultDir', metavar='<result directory>')
- options = p.parse_args(argv)
-
- # Make/reuse the results directory
- resultDir = path.abspath(options.resultDir)
+ return p.parse_args(argv)
- if path.isdir(resultDir):
- resume = True
- else:
- resume = False
- try:
- os.makedirs(resultDir)
- except OSError as e:
- print('error: could not create results dir:', str(e), '\n')
- sys.exit(0)
+def main(argv):
+ options = parseArguments(argv)
+ framework.database.load()
suites = framework.suites.loadSuiteInfo(options.suites, True)
for test in sorted(suites['piglit'].tests.keys()):