#!/usr/bin/env python # Copyright (c) 2012 The LibYuv Project Authors. All rights reserved. # # Use of this source code is governed by a BSD-style license # that can be found in the LICENSE file in the root of the source # tree. An additional intellectual property rights grant can be found # in the file PATENTS. All contributing project authors may # be found in the AUTHORS file in the root of the source tree. """Runs various libyuv tests through valgrind_test.py. This script inherits the chrome_tests.py in Chrome, but allows running any test instead of only the hard-coded ones. It uses the -t cmdline flag to do this, and only supports specifying a single test for each run. Suppression files: The Chrome valgrind directory we use as a DEPS dependency contains the following suppression files: valgrind/memcheck/suppressions.txt valgrind/memcheck/suppressions_mac.txt valgrind/tsan/suppressions.txt valgrind/tsan/suppressions_mac.txt valgrind/tsan/suppressions_win32.txt Since they're referenced from the chrome_tests.py script, we have similar files below the directory of this script. When executing, this script will setup both Chrome's suppression files and our own, so we can easily maintain libyuv specific suppressions in our own files. """ import logging import optparse import os import sys import logging_utils import path_utils import chrome_tests class LibyuvTest(chrome_tests.ChromeTests): """Class that handles setup of suppressions for libyuv. Everything else is inherited from chrome_tests.ChromeTests. """ def _DefaultCommand(self, tool, exe=None, valgrind_test_args=None): """Override command-building method so we can add more suppressions.""" cmd = chrome_tests.ChromeTests._DefaultCommand(self, tool, exe, valgrind_test_args) # When ChromeTests._DefaultCommand has executed, it has setup suppression # files based on what's found in the memcheck/ or tsan/ subdirectories of # this script's location. If Mac or Windows is executing, additional # platform specific files have also been added. # Since only the ones located below this directory is added, we must also # add the ones maintained by Chrome, located in ../valgrind. # The idea is to look for --suppression arguments in the cmd list and add a # modified copy of each suppression file, for the corresponding file in # ../valgrind. If we would simply replace 'valgrind-libyuv' with 'valgrind' # we may produce invalid paths if other parts of the path contain that # string. That's why the code below only replaces the end of the path. script_dir = path_utils.ScriptDir() old_base, _ = os.path.split(script_dir) new_dir = os.path.join(old_base, 'valgrind') add_suppressions = [] for token in cmd: if '--suppressions' in token: add_suppressions.append(token.replace(script_dir, new_dir)) return add_suppressions + cmd def main(_): parser = optparse.OptionParser('usage: %prog -b