Commit 88ecb306 authored by Matěj Cepl's avatar Matěj Cepl Committed by Paul Berry

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: default avatarMatěj Cepl <mcepl@redhat.com>
Reviewed-by: Paul Berry's avatarPaul Berry <stereotype441@gmail.com>
parent 022cc63c
......@@ -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):
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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'))
......
......@@ -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')
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment