This removes the need to pass the results directory to each test instance, but still gives the guarantee that each instance will write it's results to a unique location, since that guarantee is made by python's tempfile.mkdtemp.
cc: Eric Anholt <[email protected]> Signed-off-by: Dylan Baker <[email protected]> --- Eric, I'm not quite sure how this is plugged into X's make check, does this work correctly and not race, or is there something I've missed? tests/xts.py | 57 ++++++++++++++++++----------------------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/tests/xts.py b/tests/xts.py index d2f1e30..20f6531 100644 --- a/tests/xts.py +++ b/tests/xts.py @@ -27,10 +27,11 @@ from __future__ import ( absolute_import, division, print_function, unicode_literals ) import base64 +import itertools import os import re import subprocess -import itertools +import tempfile from framework import grouptools, exceptions, core from framework.profile import TestProfile, Test @@ -39,17 +40,9 @@ __all__ = ['profile'] X_TEST_SUITE = core.PIGLIT_CONFIG.required_get('xts', 'path') - -class XTSProfile(TestProfile): # pylint: disable=too-few-public-methods - """ A subclass of TestProfile that provides a setup hook for XTS """ - - def setup(self): - """This hook sets the XTSTest.results_path variable. - - Setting this variable allows images created by XTS to moved into the - results directory. - """ - XTSTest.RESULTS_PATH = self.results_dir +# This directory is gauranteed to be unique, ensureing that even if multiple +# copies of this profile run at the same time they won't clobber each other. +OUTDIR = tempfile.mkdtemp() class XTSTest(Test): # pylint: disable=too-few-public-methods @@ -63,36 +56,26 @@ class XTSTest(Test): # pylint: disable=too-few-public-methods testnum -- the number of the test file """ - RESULTS_PATH = None def __init__(self, name, testname, testdir, testnum): super(XTSTest, self).__init__( ['./' + os.path.basename(name), '-i', str(testnum)]) - # Path relative to XTSTest.RESULTS_PATH (which is not - # initialized at init time) to store any test-specific files. - # We need to store into the results directory to protect - # against races when multiple piglit-run.py -t xts commands - # are running (as in the X Server's make check). self.testdir = testdir self.testname = '{0}-{1}'.format(testname, testnum) self.cwd = os.path.dirname(os.path.realpath(name)) - self.env.update( - {"XT_RESET_DELAY": '0', - "XT_FONTPATH_GOOD": '/usr/share/fonts/X11/misc', - "XT_FONTPATH": os.path.join(X_TEST_SUITE, 'xts5', 'fonts'), - # XXX: Are the next 3 necissary? - "XT_LOCAL": 'Yes', - "XT_TCP": 'No', - "XT_DISPLAYHOST": ''}) - - def run(self): - # We only get the RESULTS_PATH after the profile has been set - # up, so we can't do it in init. - self.test_results_file = os.path.join(XTSTest.RESULTS_PATH, + self.test_results_file = os.path.join(OUTDIR, self.testdir, self.testname) - self.env.update({"TET_RESFILE": self.test_results_file}) - super(XTSTest, self).run() + self.env.update({ + "XT_RESET_DELAY": '0', + "XT_FONTPATH_GOOD": '/usr/share/fonts/X11/misc', + "XT_FONTPATH": os.path.join(X_TEST_SUITE, 'xts5', 'fonts'), + # XXX: Are the next 3 necissary? + "XT_LOCAL": 'Yes', + "XT_TCP": 'No', + "XT_DISPLAYHOST": '', + "TET_RESFILE": self.test_results_file, + }) def _process_log_for_images(self, log): """ Parse the image logfile """ @@ -110,7 +93,7 @@ class XTSTest(Test): # pylint: disable=too-few-public-methods # and depth, then run-length-encoded pixel values (in # hexadecimal). Use xtsttopng to convert the error log to a # pair of PNGs so we can put them in the summary. - command = ['xtsttopng', os.path.join(XTSTest.RESULTS_PATH, + command = ['xtsttopng', os.path.join(OUTDIR, self.testdir, match.group(1))] try: @@ -128,10 +111,10 @@ class XTSTest(Test): # pylint: disable=too-few-public-methods # subtest with an error would overwrite the previous test's # images). ref_path = os.path.join( - self.RESULTS_PATH, 'images', '{1}-{2}-ref.png'.format( + OUTDIR, 'images', '{1}-{2}-ref.png'.format( self.testname, match.group(1))) render_path = os.path.join( - self.RESULTS_PATH, 'images', '{1}-{2}-render.png'.format( + OUTDIR, 'images', '{1}-{2}-render.png'.format( self.testname, match.group(1))) with open(ref_path, 'rb') as f: @@ -260,7 +243,7 @@ def _populate_profile_rendercheck(profile): def _populate_profile(): """ Populate the profile attribute """ # Add all tests to the profile - profile = XTSProfile() # pylint: disable=redefined-outer-name + profile = TestProfile() # pylint: disable=redefined-outer-name _populate_profile_xts(profile) _populate_profile_rendercheck(profile) return profile -- git-series 0.8.10 _______________________________________________ Piglit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/piglit
