[Piglit] [PATCH piglit] Make Python scripts independent of the place of start.
Matěj Cepl
mcepl at redhat.com
Fri Oct 7 16:57:13 PDT 2011
This patch allowed me to make a package of piglit
(http://mcepl.fedorapeople.org/rpms/piglit*), which is severely non-compliant
with Fedora packaging rules, but at least I have now all tests and data RO on
/usr/lib*/piglit directory, executables (i.e., piglit-*.py scripts) symlinked
to /usr/bin and the results could go to some third place.
So I am now able 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.
Please, comment and explain me why I am crazy.
Matěj
---------------------------------------------------------
- also replace execfile with subprocess.call and setting results_dir.
- still needs more debugging, but hopefully could start to work
- fix also piglit-summary-html
Signed-off-by: Matěj Cepl <mcepl at redhat.com>
---
framework/core.py | 16 ++++--
framework/gleantest.py | 10 ++--
piglit-merge-results.py | 3 +-
piglit-run.py | 11 ++++-
piglit-summary-html.py | 5 +-
tests/all.tests | 100 +++++++++++++++++++--------------------
tests/external-glslparser.tests | 1 -
tests/quick-driver.tests | 7 +--
tests/quick.tests | 6 +--
tests/r300.tests | 2 +-
tests/r500.tests | 3 +-
tests/r600.tests | 3 +-
tests/sanity.tests | 5 +-
13 files changed, 88 insertions(+), 84 deletions(-)
diff --git a/framework/core.py b/framework/core.py
index 5c583c7..2a00415 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -25,7 +25,7 @@
import errno
import json
-import os
+import os, os.path
import platform
import stat
import subprocess
@@ -200,6 +200,7 @@ def checkDir(dirname, failifexists):
os.makedirs(dirname)
except OSError, e:
if e.errno != errno.EEXIST:
+ print >>sys.stderr, "Exception: %s" % e
raise
if 'PIGLIT_BUILD_DIR' in os.environ:
@@ -572,16 +573,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):
@@ -599,3 +601,5 @@ def loadTestResults(path):
assert(testrun.name is not None)
return testrun
+
+#vi:noet sw=4 ts=8
diff --git a/framework/gleantest.py b/framework/gleantest.py
index 254cfcc..32409bd 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 eff8d5c..26d5881 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 c5f5a4a..4218b75 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,11 @@ def main():
profileFilename = args[0]
resultsDir = args[1]
+ # Change to the piglit's path
+ start_dir = os.getcwd()
+ piglit_dir = path.dirname(path.realpath(sys.argv[0]))
+ os.chdir(piglit_dir)
+
core.checkDir(resultsDir, False)
results = core.TestrunResult()
@@ -126,7 +132,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)
@@ -143,5 +149,8 @@ def main():
print 'Thank you for running Piglit!'
print 'Results have been written to ' + result_filepath
+ # Return back to the original path
+ os.chdir(start_dir)
+
if __name__ == "__main__":
main()
diff --git a/piglit-summary-html.py b/piglit-summary-html.py
index a255a15..56e4449 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 40bc92c..3fcc4d0 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2,14 +2,12 @@
# -*- coding: utf-8 -*-
# All tests that come with piglit, using default settings
-import os
+import os, re, sys
import os.path as path
-import re
-import subprocess
-from framework.core import *
+from framework.core import Group, TestProfile
from framework.exectest import *
-from framework.gleantest import *
+from framework.gleantest import GleanTest
from framework.glsl_parser_test import GLSLParserTest, add_glsl_parser_test, import_glsl_parser_tests
# Blacklisted tests are removed from the test profile.
@@ -59,65 +57,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/external-glslparser.tests b/tests/external-glslparser.tests
index f8ea1ac..81f5ae4 100644
--- a/tests/external-glslparser.tests
+++ b/tests/external-glslparser.tests
@@ -4,7 +4,6 @@
import os
import re
-import subprocess
from framework.core import *
from framework.exectest import *
diff --git a/tests/quick-driver.tests b/tests/quick-driver.tests
index 8d05ee3..0e5f8c1 100644
--- a/tests/quick-driver.tests
+++ b/tests/quick-driver.tests
@@ -1,12 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import re
-import subprocess
-
-from framework.core import *
-from framework.exectest import *
-from framework.gleantest import *
+import re, sys, os
execfile(os.path.dirname(__file__) + '/quick.tests')
diff --git a/tests/quick.tests b/tests/quick.tests
index b2c3212..702a69f 100644
--- a/tests/quick.tests
+++ b/tests/quick.tests
@@ -4,14 +4,10 @@
# Testing drivers for Radeon hardware
#
-import os
-import re
+import os.path
execfile(os.path.dirname(__file__) + '/all.tests')
-from framework.core import *
-from framework.gleantest import *
-
GleanTest.globalParams += [ "--quick" ]
del profile.tests['valgrind']
diff --git a/tests/r300.tests b/tests/r300.tests
index ac8096a..fb93d6a 100644
--- a/tests/r300.tests
+++ b/tests/r300.tests
@@ -3,7 +3,7 @@
# Testing the r300 DRI driver
#
-import os
+import os, sys
import re
execfile(os.path.dirname(__file__) + '/quick-driver.tests')
diff --git a/tests/r500.tests b/tests/r500.tests
index 32c8d5b..7276ac2 100644
--- a/tests/r500.tests
+++ b/tests/r500.tests
@@ -3,8 +3,7 @@
# Testing the r500 DRI driver
#
-import os
-import re
+import os.path
execfile(os.path.dirname(__file__) + '/quick-driver.tests')
diff --git a/tests/r600.tests b/tests/r600.tests
index 1b7bc7f..0bf21fa 100644
--- a/tests/r600.tests
+++ b/tests/r600.tests
@@ -1,7 +1,8 @@
#!/usr/bin/env python
-import os
+import os.path
import re
+import os, re, sys
execfile(os.path.dirname(__file__) + '/quick-driver.tests')
diff --git a/tests/sanity.tests b/tests/sanity.tests
index 13c65b7..c134685 100644
--- a/tests/sanity.tests
+++ b/tests/sanity.tests
@@ -5,10 +5,11 @@
from framework.core import *
from framework.gleantest import *
+import sys
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
--
1.7.1
More information about the Piglit
mailing list