webrtc/tools/valgrind-webrtc/webrtc_tests.py

119 lines
5.1 KiB
Python
Raw Normal View History

This CL introduces a new directory for WebRTC utility scripts for Valgrind: tools/valgrind-webrtc To be able to re-use as much as possible from Chromium's scripts, I've created two customized scripts for running tests: - webrtc_tests.py: a customized version of chrome_tests.py with WebRTC tests instead. - webrtc_tests.sh: a customized version of the chrome_tests.sh wrapper script, to launch the above script. The webrtc_tests.sh script is setting up PYTHONPATH so that tools/valgrind is available for the webrtc_tests.py script. The webrtc_tests.py script inherits the chrome_tests.py script as much as possible, to minimize maintenance and maximize readability. Having this mirrored setup of directories, allows us to use the same directory hierarchy for suppression files too. This CL only adds suppression files for memcheck, but we can add files for tsan later easily. The suppression file is currently empty for Linux. For Mac I copied all the Chromium third-party suppressions. We will need a lot more added for Mac before Valgrind runs becomes usable for that platform. The platform specific naming of the suppression files are handled automatically when webrtc_tests.sh is used to launch the tests. Example: Plain memcheck (default tool): tools/valgrind-webrtc/webrtc_tests.sh -t system_wrappers Run ThreadSanitizer: tools/valgrind-webrtc/webrtc_tests.sh --tool=tsan -t system_wrappers Previously mentioned AddressSanitizer requires additional scripts to be added and it not covered in this CL. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/322010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1240 4adac7df-926f-26a2-2b94-8c16560cd09d
2011-12-20 09:53:41 +01:00
#!/usr/bin/env python
# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
This CL introduces a new directory for WebRTC utility scripts for Valgrind: tools/valgrind-webrtc To be able to re-use as much as possible from Chromium's scripts, I've created two customized scripts for running tests: - webrtc_tests.py: a customized version of chrome_tests.py with WebRTC tests instead. - webrtc_tests.sh: a customized version of the chrome_tests.sh wrapper script, to launch the above script. The webrtc_tests.sh script is setting up PYTHONPATH so that tools/valgrind is available for the webrtc_tests.py script. The webrtc_tests.py script inherits the chrome_tests.py script as much as possible, to minimize maintenance and maximize readability. Having this mirrored setup of directories, allows us to use the same directory hierarchy for suppression files too. This CL only adds suppression files for memcheck, but we can add files for tsan later easily. The suppression file is currently empty for Linux. For Mac I copied all the Chromium third-party suppressions. We will need a lot more added for Mac before Valgrind runs becomes usable for that platform. The platform specific naming of the suppression files are handled automatically when webrtc_tests.sh is used to launch the tests. Example: Plain memcheck (default tool): tools/valgrind-webrtc/webrtc_tests.sh -t system_wrappers Run ThreadSanitizer: tools/valgrind-webrtc/webrtc_tests.sh --tool=tsan -t system_wrappers Previously mentioned AddressSanitizer requires additional scripts to be added and it not covered in this CL. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/322010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1240 4adac7df-926f-26a2-2b94-8c16560cd09d
2011-12-20 09:53:41 +01:00
#
# 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.
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
"""Runs various WebRTC tests through valgrind_test.py.
This CL introduces a new directory for WebRTC utility scripts for Valgrind: tools/valgrind-webrtc To be able to re-use as much as possible from Chromium's scripts, I've created two customized scripts for running tests: - webrtc_tests.py: a customized version of chrome_tests.py with WebRTC tests instead. - webrtc_tests.sh: a customized version of the chrome_tests.sh wrapper script, to launch the above script. The webrtc_tests.sh script is setting up PYTHONPATH so that tools/valgrind is available for the webrtc_tests.py script. The webrtc_tests.py script inherits the chrome_tests.py script as much as possible, to minimize maintenance and maximize readability. Having this mirrored setup of directories, allows us to use the same directory hierarchy for suppression files too. This CL only adds suppression files for memcheck, but we can add files for tsan later easily. The suppression file is currently empty for Linux. For Mac I copied all the Chromium third-party suppressions. We will need a lot more added for Mac before Valgrind runs becomes usable for that platform. The platform specific naming of the suppression files are handled automatically when webrtc_tests.sh is used to launch the tests. Example: Plain memcheck (default tool): tools/valgrind-webrtc/webrtc_tests.sh -t system_wrappers Run ThreadSanitizer: tools/valgrind-webrtc/webrtc_tests.sh --tool=tsan -t system_wrappers Previously mentioned AddressSanitizer requires additional scripts to be added and it not covered in this CL. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/322010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1240 4adac7df-926f-26a2-2b94-8c16560cd09d
2011-12-20 09:53:41 +01:00
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
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 WebRTC
specific suppressions in our own files.
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
"""
This CL introduces a new directory for WebRTC utility scripts for Valgrind: tools/valgrind-webrtc To be able to re-use as much as possible from Chromium's scripts, I've created two customized scripts for running tests: - webrtc_tests.py: a customized version of chrome_tests.py with WebRTC tests instead. - webrtc_tests.sh: a customized version of the chrome_tests.sh wrapper script, to launch the above script. The webrtc_tests.sh script is setting up PYTHONPATH so that tools/valgrind is available for the webrtc_tests.py script. The webrtc_tests.py script inherits the chrome_tests.py script as much as possible, to minimize maintenance and maximize readability. Having this mirrored setup of directories, allows us to use the same directory hierarchy for suppression files too. This CL only adds suppression files for memcheck, but we can add files for tsan later easily. The suppression file is currently empty for Linux. For Mac I copied all the Chromium third-party suppressions. We will need a lot more added for Mac before Valgrind runs becomes usable for that platform. The platform specific naming of the suppression files are handled automatically when webrtc_tests.sh is used to launch the tests. Example: Plain memcheck (default tool): tools/valgrind-webrtc/webrtc_tests.sh -t system_wrappers Run ThreadSanitizer: tools/valgrind-webrtc/webrtc_tests.sh --tool=tsan -t system_wrappers Previously mentioned AddressSanitizer requires additional scripts to be added and it not covered in this CL. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/322010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1240 4adac7df-926f-26a2-2b94-8c16560cd09d
2011-12-20 09:53:41 +01:00
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
import logging
This CL introduces a new directory for WebRTC utility scripts for Valgrind: tools/valgrind-webrtc To be able to re-use as much as possible from Chromium's scripts, I've created two customized scripts for running tests: - webrtc_tests.py: a customized version of chrome_tests.py with WebRTC tests instead. - webrtc_tests.sh: a customized version of the chrome_tests.sh wrapper script, to launch the above script. The webrtc_tests.sh script is setting up PYTHONPATH so that tools/valgrind is available for the webrtc_tests.py script. The webrtc_tests.py script inherits the chrome_tests.py script as much as possible, to minimize maintenance and maximize readability. Having this mirrored setup of directories, allows us to use the same directory hierarchy for suppression files too. This CL only adds suppression files for memcheck, but we can add files for tsan later easily. The suppression file is currently empty for Linux. For Mac I copied all the Chromium third-party suppressions. We will need a lot more added for Mac before Valgrind runs becomes usable for that platform. The platform specific naming of the suppression files are handled automatically when webrtc_tests.sh is used to launch the tests. Example: Plain memcheck (default tool): tools/valgrind-webrtc/webrtc_tests.sh -t system_wrappers Run ThreadSanitizer: tools/valgrind-webrtc/webrtc_tests.sh --tool=tsan -t system_wrappers Previously mentioned AddressSanitizer requires additional scripts to be added and it not covered in this CL. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/322010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1240 4adac7df-926f-26a2-2b94-8c16560cd09d
2011-12-20 09:53:41 +01:00
import optparse
import os
This CL introduces a new directory for WebRTC utility scripts for Valgrind: tools/valgrind-webrtc To be able to re-use as much as possible from Chromium's scripts, I've created two customized scripts for running tests: - webrtc_tests.py: a customized version of chrome_tests.py with WebRTC tests instead. - webrtc_tests.sh: a customized version of the chrome_tests.sh wrapper script, to launch the above script. The webrtc_tests.sh script is setting up PYTHONPATH so that tools/valgrind is available for the webrtc_tests.py script. The webrtc_tests.py script inherits the chrome_tests.py script as much as possible, to minimize maintenance and maximize readability. Having this mirrored setup of directories, allows us to use the same directory hierarchy for suppression files too. This CL only adds suppression files for memcheck, but we can add files for tsan later easily. The suppression file is currently empty for Linux. For Mac I copied all the Chromium third-party suppressions. We will need a lot more added for Mac before Valgrind runs becomes usable for that platform. The platform specific naming of the suppression files are handled automatically when webrtc_tests.sh is used to launch the tests. Example: Plain memcheck (default tool): tools/valgrind-webrtc/webrtc_tests.sh -t system_wrappers Run ThreadSanitizer: tools/valgrind-webrtc/webrtc_tests.sh --tool=tsan -t system_wrappers Previously mentioned AddressSanitizer requires additional scripts to be added and it not covered in this CL. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/322010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1240 4adac7df-926f-26a2-2b94-8c16560cd09d
2011-12-20 09:53:41 +01:00
import sys
import logging_utils
import path_utils
This CL introduces a new directory for WebRTC utility scripts for Valgrind: tools/valgrind-webrtc To be able to re-use as much as possible from Chromium's scripts, I've created two customized scripts for running tests: - webrtc_tests.py: a customized version of chrome_tests.py with WebRTC tests instead. - webrtc_tests.sh: a customized version of the chrome_tests.sh wrapper script, to launch the above script. The webrtc_tests.sh script is setting up PYTHONPATH so that tools/valgrind is available for the webrtc_tests.py script. The webrtc_tests.py script inherits the chrome_tests.py script as much as possible, to minimize maintenance and maximize readability. Having this mirrored setup of directories, allows us to use the same directory hierarchy for suppression files too. This CL only adds suppression files for memcheck, but we can add files for tsan later easily. The suppression file is currently empty for Linux. For Mac I copied all the Chromium third-party suppressions. We will need a lot more added for Mac before Valgrind runs becomes usable for that platform. The platform specific naming of the suppression files are handled automatically when webrtc_tests.sh is used to launch the tests. Example: Plain memcheck (default tool): tools/valgrind-webrtc/webrtc_tests.sh -t system_wrappers Run ThreadSanitizer: tools/valgrind-webrtc/webrtc_tests.sh --tool=tsan -t system_wrappers Previously mentioned AddressSanitizer requires additional scripts to be added and it not covered in this CL. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/322010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1240 4adac7df-926f-26a2-2b94-8c16560cd09d
2011-12-20 09:53:41 +01:00
import chrome_tests
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
class WebRTCTest(chrome_tests.ChromeTests):
"""Class that handles setup of suppressions for WebRTC.
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-webrtc' 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.
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
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:
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
add_suppressions.append(token.replace(script_dir, new_dir))
return add_suppressions + cmd
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
def main(_):
parser = optparse.OptionParser('usage: %prog -b <dir> -t <test> <test args>')
parser.disable_interspersed_args()
parser.add_option('-b', '--build_dir',
help=('Location of the compiler output. Can only be used '
'when the test argument does not contain this path.'))
parser.add_option('-t', '--test', help='Test to run.')
parser.add_option('', '--baseline', action='store_true', default=False,
help='Generate baseline data instead of validating')
parser.add_option('', '--gtest_filter',
help='Additional arguments to --gtest_filter')
parser.add_option('', '--gtest_repeat',
help='Argument for --gtest_repeat')
parser.add_option('-v', '--verbose', action='store_true', default=False,
help='Verbose output - enable debug log messages')
parser.add_option('', '--tool', dest='valgrind_tool', default='memcheck',
help='Specify a valgrind tool to run the tests under')
parser.add_option('', '--tool_flags', dest='valgrind_tool_flags', default='',
help='Specify custom flags for the selected valgrind tool')
parser.add_option('', '--keep_logs', action='store_true', default=False,
help=('Store memory tool logs in the <tool>.logs directory '
'instead of /tmp.\nThis can be useful for tool '
'developers/maintainers.\nPlease note that the <tool>'
'.logs directory will be clobbered on tool startup.'))
This CL introduces a new directory for WebRTC utility scripts for Valgrind: tools/valgrind-webrtc To be able to re-use as much as possible from Chromium's scripts, I've created two customized scripts for running tests: - webrtc_tests.py: a customized version of chrome_tests.py with WebRTC tests instead. - webrtc_tests.sh: a customized version of the chrome_tests.sh wrapper script, to launch the above script. The webrtc_tests.sh script is setting up PYTHONPATH so that tools/valgrind is available for the webrtc_tests.py script. The webrtc_tests.py script inherits the chrome_tests.py script as much as possible, to minimize maintenance and maximize readability. Having this mirrored setup of directories, allows us to use the same directory hierarchy for suppression files too. This CL only adds suppression files for memcheck, but we can add files for tsan later easily. The suppression file is currently empty for Linux. For Mac I copied all the Chromium third-party suppressions. We will need a lot more added for Mac before Valgrind runs becomes usable for that platform. The platform specific naming of the suppression files are handled automatically when webrtc_tests.sh is used to launch the tests. Example: Plain memcheck (default tool): tools/valgrind-webrtc/webrtc_tests.sh -t system_wrappers Run ThreadSanitizer: tools/valgrind-webrtc/webrtc_tests.sh --tool=tsan -t system_wrappers Previously mentioned AddressSanitizer requires additional scripts to be added and it not covered in this CL. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/322010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1240 4adac7df-926f-26a2-2b94-8c16560cd09d
2011-12-20 09:53:41 +01:00
options, args = parser.parse_args()
if options.verbose:
logging_utils.config_root(logging.DEBUG)
else:
logging_utils.config_root()
if not options.test:
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
parser.error('--test not specified')
This CL introduces a new directory for WebRTC utility scripts for Valgrind: tools/valgrind-webrtc To be able to re-use as much as possible from Chromium's scripts, I've created two customized scripts for running tests: - webrtc_tests.py: a customized version of chrome_tests.py with WebRTC tests instead. - webrtc_tests.sh: a customized version of the chrome_tests.sh wrapper script, to launch the above script. The webrtc_tests.sh script is setting up PYTHONPATH so that tools/valgrind is available for the webrtc_tests.py script. The webrtc_tests.py script inherits the chrome_tests.py script as much as possible, to minimize maintenance and maximize readability. Having this mirrored setup of directories, allows us to use the same directory hierarchy for suppression files too. This CL only adds suppression files for memcheck, but we can add files for tsan later easily. The suppression file is currently empty for Linux. For Mac I copied all the Chromium third-party suppressions. We will need a lot more added for Mac before Valgrind runs becomes usable for that platform. The platform specific naming of the suppression files are handled automatically when webrtc_tests.sh is used to launch the tests. Example: Plain memcheck (default tool): tools/valgrind-webrtc/webrtc_tests.sh -t system_wrappers Run ThreadSanitizer: tools/valgrind-webrtc/webrtc_tests.sh --tool=tsan -t system_wrappers Previously mentioned AddressSanitizer requires additional scripts to be added and it not covered in this CL. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/322010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1240 4adac7df-926f-26a2-2b94-8c16560cd09d
2011-12-20 09:53:41 +01:00
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
# If --build_dir is provided, prepend it to the test executable if needed.
test_executable = options.test
if options.build_dir and not test_executable.startswith(options.build_dir):
test_executable = os.path.join(options.build_dir, test_executable)
args = [test_executable] + args
test = WebRTCTest(options, args, 'cmdline')
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
return test.Run()
Improved memory tool test wrapper script * Clarified that the test only supports specifying a single test (multiple didn't work before, so better not claim to support it). * No longer needs test executable arguments to use ++ instead of -- * Only appends the build_dir path to the test executable if not already present. * Simplified suppression path handling. * Fixed crash when -v was used (import logging was missing) * Style fixes. * Thorougly tested with all the supported flags. I noted that the --gtest_filter flag does not work as expected (it's only for 'additional gtest_filter arguments', which seems to mean additional arguments to the gtest filter text files that are used by Chrome. I left it in here anyway. If --gtest_filter is given after the test executable it will work, since those arguments are added straight to the test executable the test BUG=none TEST=I ran the following commands and verified that the suppressions and flags were handled correct: tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -t out/Debug/test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t test_support_unittests --foo --bar tools/valgrind-webrtc/webrtc_tests.sh -v --tool=tsan --gtest_repeat=2 --keep_logs --tool_flags=--trace-children=yes -b out/Debug -t out/Debug/test_support_unittests --foo --bar Review URL: https://webrtc-codereview.appspot.com/1029005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3354 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-10 09:13:52 +01:00
if __name__ == '__main__':
return_code = main(sys.argv)
sys.exit(return_code)