Bug 631842 (part 2) - Implement |mach valgrind-test|. r=gps.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 18 Dec 2013 17:36:08 -0800
changeset 161310 7a1445739c077500199a16c7d3b3d64d79ad2078
parent 161309 32430af5d9d4b8f4c0bb2ba7605b17000e9a0ca8
child 161314 78f2c5e0b9fb59bb1da773df3649724da24c6cc3
push id37893
push userkwierso@gmail.com
push dateFri, 20 Dec 2013 03:51:39 +0000
treeherdermozilla-inbound@0db159616654 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs631842
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 631842 (part 2) - Implement |mach valgrind-test|. r=gps.
build/mach_bootstrap.py
build/valgrind/mach_commands.py
testing/mach_commands.py
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -57,16 +57,17 @@ SEARCH_PATHS = [
     'testing/mozbase/moztest',
     'testing/mozbase/manifestdestiny',
     'xpcom/idl-parser',
 ]
 
 # Individual files providing mach commands.
 MACH_MODULES = [
     'addon-sdk/mach_commands.py',
+    'build/valgrind/mach_commands.py',
     'dom/bindings/mach_commands.py',
     'layout/tools/reftest/mach_commands.py',
     'python/mach_commands.py',
     'python/mach/mach/commands/commandinfo.py',
     'python/mozboot/mozboot/mach_commands.py',
     'python/mozbuild/mozbuild/mach_commands.py',
     'python/mozbuild/mozbuild/frontend/mach_commands.py',
     'testing/mach_commands.py',
new file mode 100644
--- /dev/null
+++ b/build/valgrind/mach_commands.py
@@ -0,0 +1,76 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import print_function, unicode_literals
+
+import os
+import subprocess
+
+from mozbuild.base import (
+    MachCommandBase,
+    MachCommandConditions as conditions,
+)
+
+from mach.decorators import (
+    CommandProvider,
+    Command,
+)
+
+
+@CommandProvider
+class MachCommands(MachCommandBase):
+    '''
+    Easily run Valgrind tests.
+    '''
+    def __init__(self, context):
+        MachCommandBase.__init__(self, context)
+
+    @Command('valgrind-test', category='testing',
+        conditions=[conditions.is_firefox],
+        description='Run the Valgrind test job.')
+    def valgrind_test(self):
+        defines = self.config_environment.defines
+        if 'MOZ_VALGRIND' not in defines or 'MOZ_MEMORY' in defines:
+            print("sorry, this command requires a build configured with\n"
+                  "--enable-valgrind and --disable-jemalloc build")
+            return 1
+
+        debugger_args = [
+            '--error-exitcode=1',
+            '--smc-check=all-non-file',
+            '--vex-iropt-register-updates=allregs-at-each-insn',
+            '--gen-suppressions=all',
+            '--num-callers=20',
+            '--leak-check=full',
+            '--show-possibly-lost=no',
+            '--track-origins=yes'
+        ]
+
+        build_dir = os.path.join(self.topsrcdir, 'build')
+        supps_dir = os.path.join(build_dir, 'valgrind')
+        debugger_args.append('--suppressions=' + os.path.join(supps_dir, 'cross-architecture.sup'))
+
+        # MACHTYPE is an odd bash-only environment variable that doesn't show
+        # up in os.environ, so we have to get it another way.
+        machtype = subprocess.check_output(['bash', '-c', 'echo $MACHTYPE']).rstrip()
+        arch_specific_supps_file = os.path.join(supps_dir, machtype + '.sup')
+        if os.path.isfile(arch_specific_supps_file):
+            debugger_args += ' --suppressions=' + os.path.join(supps_dir, arch_specific_supps_file)
+            print('Using platform-specific suppression file: ',
+                  arch_specific_supps_file + '\n')
+        else:
+            print('Warning: could not find a platform-specific suppression file\n')
+
+        env = os.environ.copy()
+        env['G_SLICE'] = 'always-malloc'
+        env['XPCOM_CC_RUN_DURING_SHUTDOWN'] = '1'
+
+        script = os.path.join(build_dir, 'valgrind', 'valgrind_test.py')
+
+
+        return subprocess.call([self.virtualenv_manager.python_path, script,
+                                '--debugger=valgrind',
+                                '--debugger-args=' + ' '.join(debugger_args) + ''],
+                                env=env)
+
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -82,16 +82,21 @@ TEST_SUITES = {
         'mach_command': 'reftest',
         'kwargs': {'test_file': None},
     },
     'reftest-ipc': {
         'aliases': ('Ripc',),
         'mach_command': 'reftest-ipc',
         'kwargs': {'test_file': None},
     },
+    'valgrind': {
+        'aliases': ('V', 'v'),
+        'mach_command': 'valgrind-test',
+        'kwargs': {},
+    },
     'xpcshell': {
         'aliases': ('X', 'x'),
         'mach_command': 'xpcshell-test',
         'kwargs': {'test_file': 'all'},
     },
 }
 
 for i in range(1, MOCHITEST_TOTAL_CHUNKS + 1):