aboutsummaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2012-03-02 17:07:57 -0800
committerKenneth Graunke <kenneth@whitecape.org>2012-03-12 16:30:08 -0700
commitfefa962e6e373c67570988db264c0664cf71110d (patch)
tree66f7dc219f8e9efbf0aa482c7968c155cbe47fc2 /framework
parent55107415f69101523f105da8db63d65a8bc3c3eb (diff)
Make valgrind testing a command line option rather than extra tests.
Valgrind testing is useful, but really should be done as a separate exercise from the usual regression testing, as it takes way too long. Rather than including it by default in all.tests and making people exclude it with the -x valgrind option (or by using quick.tests), it makes sense to explicitly request valgrind testing with --valgrind. To perform valgrind testing: $ piglit-run.py --valgrind <options> tests/quick.tests results/vg-1 The ExecTest class now handles Valgrind wrapping natively, rather than relying on the tests/valgrind-test/valgrind-test shell script wrapper. This provides a huge benefit: we can leverage the interpretResult() function to make it work properly for any subclass of ExecTest. The old shell script only worked for PlainExecTest (piglit) and GleanTest. Another small benefit is that you can now use --valgrind with any test profile (such as quick.tests). Also, you can use all.tests without having to remember to specify "-x valgrind". Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'framework')
-rw-r--r--framework/core.py3
-rw-r--r--framework/exectest.py20
-rw-r--r--framework/gleantest.py4
3 files changed, 22 insertions, 5 deletions
diff --git a/framework/core.py b/framework/core.py
index 1bc108bc..b85072a1 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -373,6 +373,7 @@ class Environment:
self.filter = []
self.exclude_filter = []
self.exclude_tests = set()
+ self.valgrind = False
def run(self, command):
try:
@@ -432,7 +433,7 @@ class Test:
try:
status("running")
time_start = time.time()
- result = self.run()
+ result = self.run(env.valgrind)
time_end = time.time()
if 'time' not in result:
result['time'] = time_end - time_start
diff --git a/framework/exectest.py b/framework/exectest.py
index d4a2bd85..7877adb8 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -44,14 +44,18 @@ class ExecTest(Test):
raise NotImplementedError
return out
- def run(self):
+ def run(self, valgrind):
fullenv = os.environ.copy()
for e in self.env:
fullenv[e] = str(self.env[e])
if self.command is not None:
+ command = self.command
+ if valgrind:
+ command[:0] = ['valgrind', '--quiet', '--error-exitcode=1', '--tool=memcheck']
+
proc = subprocess.Popen(
- self.command,
+ command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=fullenv,
@@ -98,6 +102,18 @@ class ExecTest(Test):
elif proc.returncode != 0:
results['note'] = 'Returncode was %d' % (proc.returncode)
+ if valgrind:
+ # If the underlying test failed, simply report
+ # 'skip' for this valgrind test.
+ if results['result'] != 'pass':
+ results['result'] = 'skip'
+ elif proc.returncode == 0:
+ # Test passes and is valgrind clean.
+ results['result'] = 'pass'
+ else:
+ # Test passed but has valgrind errors.
+ results['result'] = 'fail'
+
env = ''
for key in self.env:
env = env + key + '="' + self.env[key] + '" '
diff --git a/framework/gleantest.py b/framework/gleantest.py
index 0bab36a0..a90a1017 100644
--- a/framework/gleantest.py
+++ b/framework/gleantest.py
@@ -49,9 +49,9 @@ class GleanTest(ExecTest):
self.name = name
- def run(self):
+ def run(self, valgrind):
self.command += GleanTest.globalParams
- return ExecTest.run(self)
+ return ExecTest.run(self, valgrind)
def interpretResult(self, out, results):
if out.find('FAIL') >= 0: