summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-10-12 12:06:00 +0200
committerPaul Berry <stereotype441@gmail.com>2011-10-13 09:46:24 -0700
commit88ecb306d3582091585f07e4c2087b4b6b51e461 (patch)
tree545ecea7f562d0710269d34bb784b09a7cfefba5
parent022cc63ccea37f8426c86f61b164289a79fa10db (diff)
Make Python scripts independent of the current working directory
The main purpose of this patch is to make piglit independent of the current working directory, so it is possible to package piglit as a RPM package (with binaries symlinked to /usr/bin, most of the files in read-only /usr/lib*/piglit directory, and results somewhere else). So it is now possible to run $ piglit-run tests/quick-driver.tests /tmp/piglit and then with this command $ piglit-summary-html --overwrite /tmp/piglit/results /tmp/piglit/main generate a report in /tmp/piglit/results/index.html & al. Signed-off-by: Matěj Cepl <mcepl@redhat.com> Reviewed-by: Paul Berry <stereotype441@gmail.com>
-rw-r--r--framework/core.py11
-rw-r--r--framework/gleantest.py10
-rwxr-xr-xpiglit-merge-results.py3
-rwxr-xr-xpiglit-run.py7
-rwxr-xr-xpiglit-summary-html.py5
-rw-r--r--tests/all.tests92
-rw-r--r--tests/sanity.tests4
7 files changed, 70 insertions, 62 deletions
diff --git a/framework/core.py b/framework/core.py
index 5c583c72b..e6d9b4d66 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -572,16 +572,17 @@ class TestProfile:
##### Loaders
#############################################################################
-def loadTestProfile(filename):
+def loadTestProfile(filename, resdir):
+ ns = {
+ '__file__': filename,
+ 'res_dir': resdir
+ }
try:
- ns = {
- '__file__': filename
- }
execfile(filename, ns)
- return ns['profile']
except:
traceback.print_exc()
raise Exception('Could not read tests profile')
+ return ns['profile']
def loadTestResults(path):
if os.path.isdir(path):
diff --git a/framework/gleantest.py b/framework/gleantest.py
index 254cfcc3c..fe7c3b722 100644
--- a/framework/gleantest.py
+++ b/framework/gleantest.py
@@ -33,20 +33,20 @@ from exectest import ExecTest
def gleanExecutable():
return testBinDir + 'glean'
-def gleanResultDir():
- return os.path.join('.', 'results', 'glean')
+def gleanResultDir(r_dir):
+ return os.path.join(r_dir, 'results', 'glean')
class GleanTest(ExecTest):
globalParams = []
- def __init__(self, name):
+ def __init__(self, name, resdir):
ExecTest.__init__(self, \
- [gleanExecutable(), "-r", os.path.join(gleanResultDir(), name),
+ [gleanExecutable(), "-r", os.path.join(gleanResultDir(resdir), name),
"-o",
"-v", "-v", "-v",
"-t", "+"+name])
- checkDir(os.path.join(gleanResultDir(), name), False)
+ checkDir(os.path.join(gleanResultDir(resdir), name), False)
self.name = name
diff --git a/piglit-merge-results.py b/piglit-merge-results.py
index eff8d5c61..26d5881c4 100755
--- a/piglit-merge-results.py
+++ b/piglit-merge-results.py
@@ -23,8 +23,9 @@
from getopt import getopt, GetoptError
-import sys
+import sys, os.path
+sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0])))
import framework.core as core
diff --git a/piglit-run.py b/piglit-run.py
index c5f5a4a88..92b554d0d 100755
--- a/piglit-run.py
+++ b/piglit-run.py
@@ -29,6 +29,7 @@ import sys, os
import time
import traceback
+sys.path.append(path.dirname(path.realpath(sys.argv[0])))
import framework.core as core
from framework.threads import synchronized_self
@@ -106,6 +107,10 @@ def main():
profileFilename = args[0]
resultsDir = args[1]
+ # Change to the piglit's path
+ piglit_dir = path.dirname(path.realpath(sys.argv[0]))
+ os.chdir(piglit_dir)
+
core.checkDir(resultsDir, False)
results = core.TestrunResult()
@@ -126,7 +131,7 @@ def main():
for (key, value) in env.collectData().items():
json_writer.write_dict_item(key, value)
- profile = core.loadTestProfile(profileFilename)
+ profile = core.loadTestProfile(profileFilename, resultsDir)
time_start = time.time()
profile.run(env, json_writer)
diff --git a/piglit-summary-html.py b/piglit-summary-html.py
index a255a153a..56e4449b0 100755
--- a/piglit-summary-html.py
+++ b/piglit-summary-html.py
@@ -23,9 +23,10 @@
from getopt import getopt, GetoptError
import cgi
-import os
+import os, os.path
import sys
+sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0])))
import framework.core as core
import framework.summary
@@ -53,7 +54,7 @@ def writefile(filename, text):
f.write(text.encode('utf-8'))
f.close()
-templatedir = os.path.join(os.path.dirname(__file__), 'templates')
+templatedir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'templates')
Result = readfile(os.path.join(templatedir, 'result.html'))
ResultDetail = readfile(os.path.join(templatedir, 'result_detail.html'))
ResultList = readfile(os.path.join(templatedir, 'result_list.html'))
diff --git a/tests/all.tests b/tests/all.tests
index d7dcd5c62..4362a3321 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -59,65 +59,65 @@ def add_fbo_depthstencil_tests(group, format):
group[prefix + 'depthstencil-' + format + '-blit'] = PlainExecTest(['fbo-depthstencil', '-auto', 'blit', format])
glean = Group()
-glean['basic'] = GleanTest('basic')
-glean['api2'] = GleanTest('api2')
-glean['makeCurrent'] = GleanTest('makeCurrent')
-glean['blendFunc'] = GleanTest('blendFunc')
-glean['bufferObject'] = GleanTest('bufferObject')
-glean['clipFlat'] = GleanTest('clipFlat')
-glean['depthStencil'] = GleanTest('depthStencil')
-glean['fbo'] = GleanTest('fbo')
-glean['fpexceptions'] = GleanTest('fpexceptions')
-glean['getString'] = GleanTest('getString')
-glean['logicOp'] = GleanTest('logicOp')
-glean['maskedClear'] = GleanTest('maskedClear')
-glean['occluquery'] = GleanTest('occluQry')
-glean['orthoPosRandTris'] = GleanTest('orthoPosRandTris')
-glean['orthoPosRandRects'] = GleanTest('orthoPosRandRects')
-glean['orthoPosTinyQuads'] = GleanTest('orthoPosTinyQuads')
-glean['orthoPosHLines'] = GleanTest('orthoPosHLines')
-glean['orthoPosVLines'] = GleanTest('orthoPosVLines')
-glean['orthoPosPoints'] = GleanTest('orthoPosPoints')
-glean['paths'] = GleanTest('paths')
-glean['pbo'] = GleanTest('pbo')
-glean['polygonOffset'] = GleanTest('polygonOffset')
-glean['pixelFormats'] = GleanTest('pixelFormats')
-glean['pointAtten'] = GleanTest('pointAtten')
-glean['pointSprite'] = GleanTest('pointSprite')
-glean['exactRGBA'] = GleanTest('exactRGBA')
-glean['readPixSanity'] = GleanTest('readPixSanity')
-glean['rgbTriStrip'] = GleanTest('rgbTriStrip')
-glean['scissor'] = GleanTest('scissor')
-glean['shaderAPI'] = GleanTest('shaderAPI')
-glean['stencil2'] = GleanTest('stencil2')
-glean['teapot'] = GleanTest('teapot')
-glean['texCombine'] = GleanTest('texCombine')
-glean['texCube'] = GleanTest('texCube')
-glean['texEnv'] = GleanTest('texEnv')
-glean['texgen'] = GleanTest('texgen')
-glean['texRect'] = GleanTest('texRect')
-glean['texCombine4'] = GleanTest('texCombine4')
-glean['texSwizzle'] = GleanTest('texSwizzle')
-glean['texture_srgb'] = GleanTest('texture_srgb')
-glean['texUnits'] = GleanTest('texUnits')
-glean['vertArrayBGRA'] = GleanTest('vertArrayBGRA')
-glean['vertattrib'] = GleanTest('vertattrib')
+glean['basic'] = GleanTest('basic', res_dir)
+glean['api2'] = GleanTest('api2', res_dir)
+glean['makeCurrent'] = GleanTest('makeCurrent', res_dir)
+glean['blendFunc'] = GleanTest('blendFunc', res_dir)
+glean['bufferObject'] = GleanTest('bufferObject', res_dir)
+glean['clipFlat'] = GleanTest('clipFlat', res_dir)
+glean['depthStencil'] = GleanTest('depthStencil', res_dir)
+glean['fbo'] = GleanTest('fbo', res_dir)
+glean['fpexceptions'] = GleanTest('fpexceptions', res_dir)
+glean['getString'] = GleanTest('getString', res_dir)
+glean['logicOp'] = GleanTest('logicOp', res_dir)
+glean['maskedClear'] = GleanTest('maskedClear', res_dir)
+glean['occluquery'] = GleanTest('occluQry', res_dir)
+glean['orthoPosRandTris'] = GleanTest('orthoPosRandTris', res_dir)
+glean['orthoPosRandRects'] = GleanTest('orthoPosRandRects', res_dir)
+glean['orthoPosTinyQuads'] = GleanTest('orthoPosTinyQuads', res_dir)
+glean['orthoPosHLines'] = GleanTest('orthoPosHLines', res_dir)
+glean['orthoPosVLines'] = GleanTest('orthoPosVLines', res_dir)
+glean['orthoPosPoints'] = GleanTest('orthoPosPoints', res_dir)
+glean['paths'] = GleanTest('paths', res_dir)
+glean['pbo'] = GleanTest('pbo', res_dir)
+glean['polygonOffset'] = GleanTest('polygonOffset', res_dir)
+glean['pixelFormats'] = GleanTest('pixelFormats', res_dir)
+glean['pointAtten'] = GleanTest('pointAtten', res_dir)
+glean['pointSprite'] = GleanTest('pointSprite', res_dir)
+glean['exactRGBA'] = GleanTest('exactRGBA', res_dir)
+glean['readPixSanity'] = GleanTest('readPixSanity', res_dir)
+glean['rgbTriStrip'] = GleanTest('rgbTriStrip', res_dir)
+glean['scissor'] = GleanTest('scissor', res_dir)
+glean['shaderAPI'] = GleanTest('shaderAPI', res_dir)
+glean['stencil2'] = GleanTest('stencil2', res_dir)
+glean['teapot'] = GleanTest('teapot', res_dir)
+glean['texCombine'] = GleanTest('texCombine', res_dir)
+glean['texCube'] = GleanTest('texCube', res_dir)
+glean['texEnv'] = GleanTest('texEnv', res_dir)
+glean['texgen'] = GleanTest('texgen', res_dir)
+glean['texRect'] = GleanTest('texRect', res_dir)
+glean['texCombine4'] = GleanTest('texCombine4', res_dir)
+glean['texSwizzle'] = GleanTest('texSwizzle', res_dir)
+glean['texture_srgb'] = GleanTest('texture_srgb', res_dir)
+glean['texUnits'] = GleanTest('texUnits', res_dir)
+glean['vertArrayBGRA'] = GleanTest('vertArrayBGRA', res_dir)
+glean['vertattrib'] = GleanTest('vertattrib', res_dir)
def add_glsl1(name):
testname = 'glsl1-' + name
- glean[testname] = GleanTest('glsl1')
+ glean[testname] = GleanTest('glsl1', res_dir)
glean[testname].env['PIGLIT_TEST'] = name
execfile(os.path.dirname(__file__) + '/glean-glsl1.tests')
def add_fp1(name):
testname = 'fp1-' + name
- glean[testname] = GleanTest('fragProg1')
+ glean[testname] = GleanTest('fragProg1', res_dir)
glean[testname].env['PIGLIT_TEST'] = name
execfile(os.path.dirname(__file__) + '/glean-fragProg1.tests')
def add_vp1(name):
testname = 'vp1-' + name
- glean[testname] = GleanTest('vertProg1')
+ glean[testname] = GleanTest('vertProg1', res_dir)
glean[testname].env['PIGLIT_TEST'] = name
execfile(os.path.dirname(__file__) + '/glean-vertProg1.tests')
diff --git a/tests/sanity.tests b/tests/sanity.tests
index 13c65b777..bcab60673 100644
--- a/tests/sanity.tests
+++ b/tests/sanity.tests
@@ -7,8 +7,8 @@ from framework.core import *
from framework.gleantest import *
glean = Group()
-glean['basic'] = GleanTest('basic')
-glean['readPixSanity'] = GleanTest('readPixSanity')
+glean['basic'] = GleanTest('basic', res_dir)
+glean['readPixSanity'] = GleanTest('readPixSanity', res_dir)
profile = TestProfile()
profile.tests['glean'] = glean