diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2015-03-19 16:06:54 +0100 |
---|---|---|
committer | Thibault Saunier <tsaunier@gnome.org> | 2015-03-20 10:34:49 +0100 |
commit | 271f9f3c8edeedb21fa5d1288b11e98b6d44d572 (patch) | |
tree | 0862655219ee12abd125d47909968ba9b9efb961 | |
parent | 2778e501c4c05bb69227340bbc43e7995c8082b2 (diff) |
launcher: add valgrind support
Add a --valgrind option to gst-validate-launcher to run the tests inside
Valgrind and tune GLib's memory allocator accordingly.
Fix https://bugzilla.gnome.org/show_bug.cgi?id=746465
-rw-r--r-- | validate/launcher/baseclasses.py | 28 | ||||
-rw-r--r-- | validate/launcher/main.py | 4 |
2 files changed, 32 insertions, 0 deletions
diff --git a/validate/launcher/baseclasses.py b/validate/launcher/baseclasses.py index c07b815..2d446e8 100644 --- a/validate/launcher/baseclasses.py +++ b/validate/launcher/baseclasses.py @@ -38,6 +38,10 @@ import xml.etree.cElementTree as ET from utils import mkdir, Result, Colors, printc, DEFAULT_TIMEOUT, GST_SECOND, \ Protocols +# The factor by which we increase the hard timeout when running inside +# Valgrind +VALGRIND_TIMEOUT_FACTOR = 5 + class Test(Loggable): @@ -270,6 +274,27 @@ class Test(Loggable): if self.result is not Result.TIMEOUT: self.queue.put(None) + def use_valgrind(self): + vg_args = [ + ('trace-children', 'yes'), + ('tool', 'memcheck'), + ('leak-check', 'full'), + ('leak-resolution', 'high'), + ('num-callers', '20'), + ] + + self.command = "valgrind %s %s" % (' '.join(map(lambda x: '--%s=%s' % (x[0], x[1]), vg_args)), + self.command) + + # Tune GLib's memory allocator to be more valgrind friendly + self.proc_env['G_DEBUG'] = 'gc-friendly' + self.add_env_variable('G_DEBUG', 'gc-friendly') + + self.proc_env['G_SLICE'] = 'always-malloc' + self.add_env_variable('G_SLICE', 'always-malloc') + + self.hard_timeout *= VALGRIND_TIMEOUT_FACTOR + def test_start(self, queue): self.open_logfile() @@ -279,6 +304,9 @@ class Test(Loggable): self.build_arguments() self.proc_env = self.get_subproc_env() + if self.options.valgrind: + self.use_valgrind() + message = "Launching: %s%s\n" \ " Command: '%s %s'\n" % (Colors.ENDC, self.classname, self._env_variable, self.command) diff --git a/validate/launcher/main.py b/validate/launcher/main.py index 58398c3..6fdf7a4 100644 --- a/validate/launcher/main.py +++ b/validate/launcher/main.py @@ -217,6 +217,7 @@ class LauncherConfig(Loggable): self.generate_info_full = False self.long_limit = utils.LONG_TEST self.config = None + self.valgrind = False self.xunit_file = None self.main_dir = utils.DEFAULT_MAIN_DIR self.output_dir = None @@ -416,6 +417,9 @@ Note that all testsuite should be inside python modules, so the directory should parser.add_argument("-c", "--config", dest="config", help="This is DEPRECATED, prefer using the testsuite format" " to configure testsuites") + parser.add_argument("-vg", "--valgrind", dest="valgrind", + action="store_true", + help="Run the tests inside Valgrind") dir_group = parser.add_argument_group( "Directories and files to be used by the launcher") parser.add_argument('--xunit-file', action='store', |