[Piglit] [PATCH 1/6] framework/environment.py: Adds new module
Dylan Baker
baker.dylan.c at gmail.com
Wed Dec 18 13:58:16 PST 2013
This module contains the testBinDir variable and the Environemnt class,
and is meant to hold environment settings for piglit
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
framework/core.py | 81 +-------------------------------
framework/environment.py | 105 ++++++++++++++++++++++++++++++++++++++++++
framework/exectest.py | 3 +-
framework/gleantest.py | 3 +-
framework/glsl_parser_test.py | 3 +-
framework/shader_test.py | 3 +-
piglit-print-commands.py | 5 +-
piglit-resume.py | 16 ++++---
piglit-run.py | 13 +++---
tests/es3conform.tests | 3 +-
tests/igt.tests | 3 +-
tests/oglconform.tests | 3 +-
12 files changed, 140 insertions(+), 101 deletions(-)
create mode 100644 framework/environment.py
diff --git a/framework/core.py b/framework/core.py
index 5a9e8b0..713efd1 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -47,16 +47,14 @@ from threadpool import ThreadPool
import status
-__all__ = ['Environment',
- 'checkDir',
+__all__ = ['checkDir',
'loadTestProfile',
'TestrunResult',
'GroupResult',
'TestResult',
'TestProfile',
'Group',
- 'Test',
- 'testBinDir']
+ 'Test']
class PiglitJSONEncoder(json.JSONEncoder):
def default(self, o):
@@ -211,26 +209,6 @@ def checkDir(dirname, failifexists):
if e.errno != errno.EEXIST:
raise
-if 'PIGLIT_BUILD_DIR' in os.environ:
- testBinDir = os.path.join(os.environ['PIGLIT_BUILD_DIR'], 'bin')
-else:
- testBinDir = os.path.normpath(os.path.join(os.path.dirname(__file__),
- '../bin'))
-
-if 'PIGLIT_SOURCE_DIR' not in os.environ:
- p = os.path
- os.environ['PIGLIT_SOURCE_DIR'] = p.abspath(p.join(p.dirname(__file__),
- '..'))
-
-# In debug builds, Mesa will by default log GL API errors to stderr.
-# This is useful for application developers or driver developers
-# trying to debug applications that should execute correctly. But for
-# piglit we expect to generate errors regularly as part of testing,
-# and for exhaustive error-generation tests (particularly some in
-# khronos's conformance suite), it can end up ooming your system
-# trying to parse the strings.
-if 'MESA_DEBUG' not in os.environ:
- os.environ['MESA_DEBUG'] = 'silent'
class TestResult(dict):
def __init__(self, *args):
@@ -394,61 +372,6 @@ class TestrunResult:
json.dump(raw_dict, file, indent=JSONWriter.INDENT)
-class Environment:
- def __init__(self, concurrent=True, execute=True, include_filter=[],
- exclude_filter=[], valgrind=False, dmesg=False):
- self.concurrent = concurrent
- self.execute = execute
- self.filter = []
- self.exclude_filter = []
- self.exclude_tests = set()
- self.valgrind = valgrind
- self.dmesg = dmesg
-
- """
- The filter lists that are read in should be a list of string objects,
- however, the filters need to be a list or regex object.
-
- This code uses re.compile to rebuild the lists and set self.filter
- """
- for each in include_filter:
- self.filter.append(re.compile(each))
- for each in exclude_filter:
- self.exclude_filter.append(re.compile(each))
-
- def __iter__(self):
- for key, values in self.__dict__.iteritems():
- # If the values are regex compiled then yield their pattern
- # attribute, which is the original plaintext they were compiled
- # from, otherwise yield them normally.
- if key in ['filter', 'exclude_filter']:
- yield (key, [x.pattern for x in values])
- else:
- yield (key, values)
-
- def run(self, command):
- try:
- p = subprocess.Popen(command,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- universal_newlines=True)
- (stdout, stderr) = p.communicate()
- except:
- return "Failed to run " + command
- return stderr+stdout
-
- def collectData(self):
- result = {}
- system = platform.system()
- if (system == 'Windows' or system.find("CYGWIN_NT") == 0):
- result['wglinfo'] = self.run('wglinfo')
- else:
- result['glxinfo'] = self.run('glxinfo')
- if system == 'Linux':
- result['lspci'] = self.run('lspci')
- return result
-
-
class Test:
def __init__(self, runConcurrent=False):
'''
diff --git a/framework/environment.py b/framework/environment.py
new file mode 100644
index 0000000..a28992b
--- /dev/null
+++ b/framework/environment.py
@@ -0,0 +1,105 @@
+
+# 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:
+#
+# This permission notice 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 AUTHOR(S) 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 os
+import re
+import subprocess
+import platform
+
+__all__ = ['Environment',
+ 'testBinDir']
+
+if 'PIGLIT_BUILD_DIR' in os.environ:
+ testBinDir = os.path.join(os.environ['PIGLIT_BUILD_DIR'], 'bin')
+else:
+ testBinDir = os.path.normpath(os.path.join(os.path.dirname(__file__),
+ '../bin'))
+
+if 'PIGLIT_SOURCE_DIR' not in os.environ:
+ os.environ['PIGLIT_SOURCE_DIR'] = \
+ os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+
+# In debug builds, Mesa will by default log GL API errors to stderr.
+# This is useful for application developers or driver developers
+# trying to debug applications that should execute correctly. But for
+# piglit we expect to generate errors regularly as part of testing,
+# and for exhaustive error-generation tests (particularly some in
+# khronos's conformance suite), it can end up ooming your system
+# trying to parse the strings.
+if 'MESA_DEBUG' not in os.environ:
+ os.environ['MESA_DEBUG'] = 'silent'
+
+
+class Environment:
+ def __init__(self, concurrent=True, execute=True, include_filter=[],
+ exclude_filter=[], valgrind=False, dmesg=False):
+ self.concurrent = concurrent
+ self.execute = execute
+ self.filter = []
+ self.exclude_filter = []
+ self.exclude_tests = set()
+ self.valgrind = valgrind
+ self.dmesg = dmesg
+
+ """
+ The filter lists that are read in should be a list of string objects,
+ however, the filters need to be a list or regex object.
+
+ This code uses re.compile to rebuild the lists and set self.filter
+ """
+ for each in include_filter:
+ self.filter.append(re.compile(each))
+ for each in exclude_filter:
+ self.exclude_filter.append(re.compile(each))
+
+ def __iter__(self):
+ for key, values in self.__dict__.iteritems():
+ # If the values are regex compiled then yield their pattern
+ # attribute, which is the original plaintext they were compiled
+ # from, otherwise yield them normally.
+ if key in ['filter', 'exclude_filter']:
+ yield (key, [x.pattern for x in values])
+ else:
+ yield (key, values)
+
+ def run(self, command):
+ try:
+ p = subprocess.Popen(command,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ universal_newlines=True)
+ (stdout, stderr) = p.communicate()
+ except:
+ return "Failed to run " + command
+ return stderr+stdout
+
+ def collectData(self):
+ result = {}
+ system = platform.system()
+ if (system == 'Windows' or system.find("CYGWIN_NT") == 0):
+ result['wglinfo'] = self.run('wglinfo')
+ else:
+ result['glxinfo'] = self.run('glxinfo')
+ if system == 'Linux':
+ result['lspci'] = self.run('lspci')
+ return result
diff --git a/framework/exectest.py b/framework/exectest.py
index 7b1c058..06e2af7 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -28,7 +28,8 @@ import shlex
import types
import re
-from core import Test, testBinDir, TestResult
+from core import Test, TestResult
+from framework.environment import testBinDir
# Platform global variables
diff --git a/framework/gleantest.py b/framework/gleantest.py
index 88432e0..bddc0ca 100644
--- a/framework/gleantest.py
+++ b/framework/gleantest.py
@@ -24,7 +24,8 @@
import os
import subprocess
-from core import checkDir, testBinDir, Test, TestResult
+from core import checkDir, Test, TestResult
+from framework.environment import testBinDir
from exectest import ExecTest
glean_executable = os.path.join(testBinDir, "glean")
diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py
index 74034e8..fe9ae59 100755
--- a/framework/glsl_parser_test.py
+++ b/framework/glsl_parser_test.py
@@ -39,7 +39,8 @@ import subprocess
import sys
from ConfigParser import SafeConfigParser
-from core import Test, testBinDir, TestResult
+from core import Test, TestResult
+from framework.environment import testBinDir
from cStringIO import StringIO
from exectest import PlainExecTest
diff --git a/framework/shader_test.py b/framework/shader_test.py
index f5a2bf9..ccec613 100755
--- a/framework/shader_test.py
+++ b/framework/shader_test.py
@@ -34,8 +34,9 @@ import re
import sys
import textwrap
-from core import testBinDir, Group, Test, TestResult, Environment
+from core import Group, Test, TestResult
from exectest import PlainExecTest
+from framework.environment import testBinDir, Environment
"""This module enables running shader tests.
diff --git a/piglit-print-commands.py b/piglit-print-commands.py
index c42ea6d..9dab54b 100755
--- a/piglit-print-commands.py
+++ b/piglit-print-commands.py
@@ -31,6 +31,7 @@ import traceback
sys.path.append(path.dirname(path.realpath(sys.argv[0])))
import framework.core as core
+import framework.environment as environment
from framework.exectest import ExecTest
from framework.gleantest import GleanTest
@@ -54,8 +55,8 @@ def main():
args = parser.parse_args()
# Set the environment, pass in the included and excluded tests
- env = core.Environment(exclude_filter=args.exclude_tests,
- include_filter=args.include_tests)
+ env = environment.Environment(exclude_filter=args.exclude_tests,
+ include_filter=args.include_tests)
# Change to the piglit's path
piglit_dir = path.dirname(path.realpath(sys.argv[0]))
diff --git a/piglit-resume.py b/piglit-resume.py
index ae5de9b..43babcf 100755
--- a/piglit-resume.py
+++ b/piglit-resume.py
@@ -27,6 +27,7 @@ import os.path as path
import argparse
import framework.core as core
+import framework.environment as environment
def main():
@@ -38,12 +39,13 @@ def main():
args = parser.parse_args()
results = core.load_results(args.results_path)
- env = core.Environment(concurrent=results.options['concurrent'],
- exclude_filter=results.options['exclude_filter'],
- include_filter=results.options['filter'],
- execute=results.options['execute'],
- valgrind=results.options['valgrind'],
- dmesg=results.options['dmesg'])
+ env = environment.Environment(
+ concurrent=results.options['concurrent'],
+ exclude_filter=results.options['exclude_filter'],
+ include_filter=results.options['filter'],
+ execute=results.options['execute'],
+ valgrind=results.options['valgrind'],
+ dmesg=results.options['dmesg'])
# Change working directory to the piglit directory
os.chdir(path.dirname(path.realpath(sys.argv[0])))
@@ -81,4 +83,4 @@ def main():
"Results have ben wrriten to {0}".format(results_path))
if __name__ == "__main__":
- main()
\ No newline at end of file
+ main()
diff --git a/piglit-run.py b/piglit-run.py
index 0d3d1be..5a25376 100755
--- a/piglit-run.py
+++ b/piglit-run.py
@@ -31,6 +31,7 @@ import traceback
sys.path.append(path.dirname(path.realpath(sys.argv[0])))
import framework.core as core
+import framework.environment as environment
from framework.threads import synchronized_self
@@ -84,12 +85,12 @@ def main():
os.environ['PIGLIT_PLATFORM'] = args.platform
# Pass arguments into Environment
- env = core.Environment(concurrent=args.concurrency,
- exclude_filter=args.exclude_tests,
- include_filter=args.include_tests,
- execute=args.execute,
- valgrind=args.valgrind,
- dmesg=args.dmesg)
+ env = environment.Environment(concurrent=args.concurrency,
+ exclude_filter=args.exclude_tests,
+ include_filter=args.include_tests,
+ execute=args.execute,
+ valgrind=args.valgrind,
+ dmesg=args.dmesg)
# Change working directory to the root of the piglit directory
piglit_dir = path.dirname(path.realpath(sys.argv[0]))
diff --git a/tests/es3conform.tests b/tests/es3conform.tests
index b0e6ef0..177d599 100644
--- a/tests/es3conform.tests
+++ b/tests/es3conform.tests
@@ -26,7 +26,8 @@ import sys
from os import path
from glob import glob
-from framework.core import TestProfile, testBinDir
+from framework.core import TestProfile
+from framework.environment import testBinDir
from framework.exectest import ExecTest
#############################################################################
diff --git a/tests/igt.tests b/tests/igt.tests
index df747e3..cbd28ba 100644
--- a/tests/igt.tests
+++ b/tests/igt.tests
@@ -28,7 +28,8 @@ import sys
import subprocess
from os import path
-from framework.core import testBinDir, TestProfile, TestResult
+from framework.core import TestProfile, TestResult
+from framework.environment import testBinDir
from framework.exectest import ExecTest
#############################################################################
diff --git a/tests/oglconform.tests b/tests/oglconform.tests
index ace2f9c..9233d20 100644
--- a/tests/oglconform.tests
+++ b/tests/oglconform.tests
@@ -26,7 +26,8 @@ import re
import sys
import subprocess
-from framework.core import TestProfile, testBinDir
+from framework.core import TestProfile
+from framework.environment import testBinDir
from framework.exectest import ExecTest
from os import path
--
1.8.5.1
More information about the Piglit
mailing list