Note: We no longer publish the latest version of our code here. We primarily use a kumc-bmi github organization. The heron ETL repository, in particular, is not public. Peers in the informatics community should see MultiSiteDev for details on requesting access.

source: webrtc/tools/valgrind-webrtc/ @ 0:4bda6873e34c

pub_scrub_3792 tip
Last change on this file since 0:4bda6873e34c was 0:4bda6873e34c, checked in by Michael Prittie <mprittie@…>, 6 years ago

Scrubbed password for publication.

  • Property exe set to *
File size: 6.2 KB
1#!/usr/bin/env python
2# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
4# Use of this source code is governed by a BSD-style license
5# that can be found in the LICENSE file in the root of the source
6# tree. An additional intellectual property rights grant can be found
7# in the file PATENTS.  All contributing project authors may
8# be found in the AUTHORS file in the root of the source tree.
10"""Runs various WebRTC tests through
12This script inherits the in Chrome, but allows running any test
13instead of only the hard-coded ones. It uses the -t cmdline flag to do this, and
14only supports specifying a single test for each run.
16Suppression files:
17The Chrome valgrind directory we use as a DEPS dependency contains the following
18suppression files:
19  valgrind/memcheck/suppressions.txt
20  valgrind/memcheck/suppressions_mac.txt
21  valgrind/tsan/suppressions.txt
22  valgrind/tsan/suppressions_mac.txt
23  valgrind/tsan/suppressions_win32.txt
24Since they're referenced from the script, we have similar files
25below the directory of this script. When executing, this script will setup both
26Chrome's suppression files and our own, so we can easily maintain WebRTC
27specific suppressions in our own files.
30import logging
31import optparse
32import os
33import sys
35import logging_utils
36import path_utils
38import chrome_tests
41class WebRTCTest(chrome_tests.ChromeTests):
42  """Class that handles setup of suppressions for WebRTC.
44  Everything else is inherited from chrome_tests.ChromeTests.
45  """
47  def __init__(self, test_name, options, args, test_in_chrome_tests):
48    """Create a WebRTC test.
49    Args:
50      test_name: Short name for the test executable (no path).
51      options: options to pass to ChromeTests.
52      args: args to pass to ChromeTests.
53      test_in_chrome_tests: The name of the test configuration in ChromeTests.
54    """
55    self._test_name = test_name
56    chrome_tests.ChromeTests.__init__(self, options, args, test_in_chrome_tests)
58  def _DefaultCommand(self, tool, exe=None, valgrind_test_args=None):
59    """Override command-building method so we can add more suppressions."""
60    cmd = chrome_tests.ChromeTests._DefaultCommand(self, tool, exe,
61                                                   valgrind_test_args)
63    # Add gtest filters, if found.
64    chrome_tests.ChromeTests._AppendGtestFilter(self, tool, self._test_name,
65                                                cmd)
67    # When ChromeTests._DefaultCommand has executed, it has setup suppression
68    # files based on what's found in the memcheck/ or tsan/ subdirectories of
69    # this script's location. If Mac or Windows is executing, additional
70    # platform specific files have also been added.
71    # Since only the ones located below this directory are added, we must also
72    # add the ones maintained by Chrome, located in ../valgrind.
74    # The idea is to look for --suppression arguments in the cmd list and add a
75    # modified copy of each suppression file, for the corresponding file in
76    # ../valgrind. If we would simply replace 'valgrind-webrtc' with 'valgrind'
77    # we may produce invalid paths if other parts of the path contain that
78    # string. That's why the code below only replaces the end of the path.
79    script_dir = path_utils.ScriptDir()
80    old_base, _ = os.path.split(script_dir)
81    new_dir = os.path.join(old_base, 'valgrind')
82    add_suppressions = []
83    for token in cmd:
84      if '--suppressions' in token:
85        add_suppressions.append(token.replace(script_dir, new_dir))
86    return add_suppressions + cmd
89def main(_):
90  parser = optparse.OptionParser(
91      'usage: %prog -b <dir> -t <test> -- <test args>')
92  parser.disable_interspersed_args()
93  parser.add_option('-b', '--build-dir',
94                    help=('Location of the compiler output. Can only be used '
95                          'when the test argument does not contain this path.'))
96  parser.add_option("--target", help="Debug or Release")
97  parser.add_option('-t', '--test', help='Test to run.')
98  parser.add_option('', '--baseline', action='store_true', default=False,
99                    help='Generate baseline data instead of validating')
100  parser.add_option('', '--gtest_filter',
101                    help='Additional arguments to --gtest_filter')
102  parser.add_option('', '--gtest_repeat',
103                    help='Argument for --gtest_repeat')
104  parser.add_option("--gtest_shuffle", action="store_true", default=False,
105                    help="Randomize tests' orders on every iteration.")
106  parser.add_option('-v', '--verbose', action='store_true', default=False,
107                    help='Verbose output - enable debug log messages')
108  parser.add_option('', '--tool', dest='valgrind_tool', default='memcheck',
109                    help='Specify a valgrind tool to run the tests under')
110  parser.add_option('', '--tool_flags', dest='valgrind_tool_flags', default='',
111                    help='Specify custom flags for the selected valgrind tool')
112  parser.add_option('', '--keep_logs', action='store_true', default=False,
113                    help=('Store memory tool logs in the <tool>.logs directory '
114                          'instead of /tmp.\nThis can be useful for tool '
115                          'developers/maintainers.\nPlease note that the <tool>'
116                          '.logs directory will be clobbered on tool startup.'))
117  options, args = parser.parse_args()
119  if options.verbose:
120    logging_utils.config_root(logging.DEBUG)
121  else:
122    logging_utils.config_root()
124  if not options.test:
125    parser.error('--test not specified')
127  # Support build dir both with and without the target.
128  if ( and options.build_dir and
129      not options.build_dir.endswith(
130    options.build_dir = os.path.join(options.build_dir,
132  # If --build_dir is provided, prepend it to the test executable if needed.
133  test_executable = options.test
134  if options.build_dir and not test_executable.startswith(options.build_dir):
135    test_executable = os.path.join(options.build_dir, test_executable)
136  args = [test_executable] + args
138  test = WebRTCTest(options.test, options, args, 'cmdline')
139  return test.Run()
141if __name__ == '__main__':
142  return_code = main(sys.argv)
143  sys.exit(return_code)
Note: See TracBrowser for help on using the repository browser.