validate:launcher: Add a way to specify a set of tests to run under the leak tracer

https://bugzilla.gnome.org/show_bug.cgi?id=767856
This commit is contained in:
Thibault Saunier 2017-02-08 17:46:23 -03:00
parent e4f05cb577
commit 7773ca7765
3 changed files with 38 additions and 8 deletions

View file

@ -18,6 +18,7 @@
# Boston, MA 02110-1301, USA.
import argparse
import os
import re
import pickle
import platform
import shutil
@ -31,7 +32,7 @@ from launcher.utils import printc, Colors
class MesonTest(Test):
def __init__(self, name, options, reporter, test, child_env=None):
ref_env = os.environ
ref_env = os.environ.copy()
if child_env is None:
child_env = {}
else:
@ -80,14 +81,14 @@ class MesonTestsManager(TestsManager):
if self.arggroup:
return
MesonTestsManager.arggroup = parser.add_argument_group(
arggroup = MesonTestsManager.arggroup = parser.add_argument_group(
"meson tests specific options and behaviours")
parser.add_argument("--meson-build-dir",
arggroup.add_argument("--meson-build-dir",
action="append",
dest='meson_build_dirs',
default=[config.BUILDDIR],
help="defines the paths to look for GstValidate tools.")
parser.add_argument("--meson-no-rebuild",
arggroup.add_argument("--meson-no-rebuild",
action="store_true",
default=False,
help="Whether to avoid to rebuild tests before running them.")
@ -228,6 +229,28 @@ class GstCheckTestsManager(MesonTestsManager):
with open(dumpfile, 'wb') as f:
pickle.dump(self.tests_info, f)
def add_options(self, parser):
super().add_options(parser)
arggroup = parser.add_argument_group("gstcheck specific options")
arggroup.add_argument("--gst-check-leak-trace-testnames",
default=None,
help="A regex to specifying testsnames of the test"
"to run with the leak tracer activated, if 'known-not-leaky'"
" is specified, the testsuite will automatically activate"
" leak tracers on tests known to be not leaky.")
def get_child_env(self, testname, check_name=None):
child_env = {}
if check_name:
child_env['GST_CHECKS'] = check_name
if self.options.gst_check_leak_trace_testnames:
if re.findall(self.options.gst_check_leak_trace_testnames, testname):
tracers = set(os.environ.get('GST_TRACERS', '').split(';')) | set(['leaks'])
child_env['GST_TRACERS'] = ';'.join(tracers)
return child_env
def list_tests(self):
if self.tests:
return self.tests
@ -266,12 +289,15 @@ class GstCheckTestsManager(MesonTestsManager):
for test in mesontests:
gst_tests = self.tests_info[test.fname[0]][1]
if not gst_tests:
self.add_test(MesonTest(self.get_test_name(test),
self.options, self.reporter, test))
name = self.get_test_name(test)
child_env = self.get_child_env(name)
self.add_test(MesonTest(name, self.options, self.reporter, test,
child_env))
else:
for ltest in gst_tests:
name = self.get_test_name(test) + '.' + ltest
child_env = self.get_child_env(name, ltest)
self.add_test(MesonTest(name, self.options, self.reporter, test,
{'GST_CHECKS': ltest}))
child_env))
self.save_tests_info()
return self.tests

View file

@ -876,7 +876,7 @@ class GstValidateTest(Test):
result = super(GstValidateTest, self).get_valgrind_suppressions()
gst_sup = self.get_valgrind_suppression_file('common', 'gst.supp')
if gst_sup:
resut.append(gst_sup)
result.append(gst_sup)
return result

View file

@ -23,6 +23,10 @@ GStreamer unit tests
TEST_MANAGER = "check"
KNOWN_NOT_LEAKY = r'^check.gst-devtools.*|^check.gstreamer.*|^check-gst-plugins-base|^check.gst-plugins-ugly|^check.gst-plugins-good'
def setup_tests(test_manager, options):
if options.gst_check_leak_trace_testnames == 'known-not-leaky':
options.gst_check_leak_trace_testnames = KNOWN_NOT_LEAKY
return True