Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: tools/valgrind/chrome_tests.py

Issue 624533003: Check that the user doesn't try to run ASan-built binaries under Valgrind etc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/valgrind/asan/asan_wrapper.sh ('k') | tools/valgrind/valgrind_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/valgrind/chrome_tests.py
diff --git a/tools/valgrind/chrome_tests.py b/tools/valgrind/chrome_tests.py
index c90b60d4d6dce8288c67b2d38e8564c632b96c5b..d5f3d18540e0811681d16c74b57147050afdcd39 100755
--- a/tools/valgrind/chrome_tests.py
+++ b/tools/valgrind/chrome_tests.py
@@ -11,6 +11,7 @@ import multiprocessing
import optparse
import os
import stat
+import subprocess
import sys
import logging_utils
@@ -27,6 +28,10 @@ class BuildDirNotFound(Exception): pass
class BuildDirAmbiguous(Exception): pass
+class ExecutableNotFound(Exception): pass
+
+class BadBinary(Exception): pass
+
class ChromeTests:
SLOW_TOOLS = ["memcheck", "tsan", "tsan_rv", "drmemory"]
LAYOUT_TESTS_DEFAULT_CHUNK_SIZE = 300
@@ -115,7 +120,24 @@ class ChromeTests:
cmd.append(arg)
if exe:
self._EnsureBuildDirFound()
- cmd.append(os.path.join(self._options.build_dir, exe))
+ exe_path = os.path.join(self._options.build_dir, exe)
+ if not os.path.exists(exe_path):
+ raise ExecutableNotFound("Couldn't find '%s'" % exe_path)
+
+ # Make sure we don't try to test ASan-built binaries
+ # with other dynamic instrumentation-based tools.
+ # TODO(timurrrr): also check TSan and MSan?
+ # `nm` might not be available, so use try-except.
+ try:
+ nm_output = subprocess.check_output(["nm", exe_path])
+ if nm_output.find("__asan_init") != -1:
+ raise BadBinary("You're trying to run an executable instrumented "
+ "with AddressSanitizer under %s. Please provide "
+ "an uninstrumented executable." % tool_name)
+ except OSError:
+ pass
+
+ cmd.append(exe_path)
# Valgrind runs tests slowly, so slow tests hurt more; show elapased time
# so we can find the slowpokes.
cmd.append("--gtest_print_time")
« no previous file with comments | « tools/valgrind/asan/asan_wrapper.sh ('k') | tools/valgrind/valgrind_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698