2017-02-02 14:02:37 +00:00
|
|
|
# Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
|
2018-05-24 13:14:18 +00:00
|
|
|
from . import default
|
2017-02-02 14:02:37 +00:00
|
|
|
|
|
|
|
|
2018-05-24 13:14:18 +00:00
|
|
|
"""Valgrind flavor, used for running code through Valgrind."""
|
2017-02-02 14:02:37 +00:00
|
|
|
|
|
|
|
|
2018-05-24 13:14:18 +00:00
|
|
|
class ValgrindFlavor(default.DefaultFlavor):
|
2017-02-02 14:02:37 +00:00
|
|
|
def __init__(self, m):
|
2018-05-24 13:14:18 +00:00
|
|
|
super(ValgrindFlavor, self).__init__(m)
|
2018-05-18 11:36:55 +00:00
|
|
|
self._suppressions_file = self.m.path['start_dir'].join(
|
|
|
|
'skia', 'tools', 'valgrind.supp')
|
2017-05-31 19:09:10 +00:00
|
|
|
self._valgrind_cipd_dir = self.m.vars.slave_dir.join('valgrind')
|
|
|
|
self._valgrind_fake_dir = self._valgrind_cipd_dir
|
|
|
|
self._valgrind = self._valgrind_fake_dir.join('bin', 'valgrind')
|
|
|
|
self._lib_dir = self._valgrind_fake_dir.join('lib', 'valgrind')
|
2017-02-02 14:02:37 +00:00
|
|
|
|
|
|
|
def step(self, name, cmd, **kwargs):
|
2017-05-31 19:09:10 +00:00
|
|
|
new_cmd = [self._valgrind, '--gen-suppressions=all', '--leak-check=full',
|
2017-02-02 14:02:37 +00:00
|
|
|
'--track-origins=yes', '--error-exitcode=1', '--num-callers=40',
|
|
|
|
'--suppressions=%s' % self._suppressions_file]
|
2018-06-01 14:08:53 +00:00
|
|
|
path_to_app = self.host_dirs.bin_dir.join(cmd[0])
|
2017-02-02 14:02:37 +00:00
|
|
|
new_cmd.append(path_to_app)
|
|
|
|
new_cmd.extend(cmd[1:])
|
2017-05-31 19:09:10 +00:00
|
|
|
with self.m.env({'VALGRIND_LIB': self._lib_dir}):
|
|
|
|
return self.m.run(self.m.step, name, cmd=new_cmd, **kwargs)
|