def __init__(self, options, args, test): if ':' in test: (self._test, self._gtest_filter) = test.split(':', 1) else: self._test = test self._gtest_filter = options.gtest_filter if self._test not in self._test_list: raise TestNotFound("Unknown test: %s" % test) if options.gtest_filter and options.gtest_filter != self._gtest_filter: raise MultipleGTestFiltersSpecified( "Can not specify both --gtest_filter " "and --test %s" % test) self._options = options self._args = args # Compute the top of the tree (the "source dir") from the script dir # (where this script lives). We assume that the script dir is in # tools/drmemory/scripts relative to the top of the tree. script_dir = os.path.dirname(path_utils.ScriptDir()) self._source_dir = os.path.dirname(os.path.dirname(script_dir)) # Setup Dr. Memory if it's not set up yet. drmem_cmd = os.getenv("DRMEMORY_COMMAND") if not drmem_cmd: drmem_sfx = os.path.join(script_dir, "drmemory-windows-sfx.exe") if not os.path.isfile(drmem_sfx): raise RuntimeError, "Cannot find drmemory-windows-sfx.exe" drmem_dir = os.path.join(script_dir, "unpacked") subprocess.call([drmem_sfx, "-o" + drmem_dir, "-y"], 0) drmem_cmd = os.path.join(drmem_dir, "bin", "drmemory.exe") os.environ["DRMEMORY_COMMAND"] = drmem_cmd # since this path is used for string matching, make sure it's always # an absolute Unix-style path self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/') self._command_preamble = ["--source-dir=%s" % (self._source_dir)] if not self._options.build_dir: dirs = [ os.path.join(self._source_dir, "xcodebuild", "Debug"), os.path.join(self._source_dir, "out", "Debug"), os.path.join(self._source_dir, "build", "Debug"), ] build_dir = [d for d in dirs if os.path.isdir(d)] if len(build_dir) > 1: raise BuildDirAmbiguous( "Found more than one suitable build dir:\n" "%s\nPlease specify just one " "using --build-dir" % ", ".join(build_dir)) elif build_dir: self._options.build_dir = build_dir[0] else: self._options.build_dir = None if self._options.build_dir: build_dir = os.path.abspath(self._options.build_dir) self._command_preamble += [ "--build-dir=%s" % (self._options.build_dir) ]
def GetSuppressions(): suppressions_root = path_utils.ScriptDir() JOIN = os.path.join result = {} supp_filename = JOIN(suppressions_root, "memcheck", "suppressions.txt") vg_common = ReadSuppressionsFromFile(supp_filename) supp_filename = JOIN(suppressions_root, "tsan", "suppressions.txt") tsan_common = ReadSuppressionsFromFile(supp_filename) result['common_suppressions'] = vg_common + tsan_common supp_filename = JOIN(suppressions_root, "memcheck", "suppressions_mac.txt") vg_mac = ReadSuppressionsFromFile(supp_filename) supp_filename = JOIN(suppressions_root, "tsan", "suppressions_mac.txt") tsan_mac = ReadSuppressionsFromFile(supp_filename) result['mac_suppressions'] = vg_mac + tsan_mac supp_filename = JOIN(suppressions_root, "tsan", "suppressions_win32.txt") tsan_win = ReadSuppressionsFromFile(supp_filename) result['win_suppressions'] = tsan_win supp_filename = JOIN(suppressions_root, "..", "heapcheck", "suppressions.txt") result['heapcheck_suppressions'] = ReadSuppressionsFromFile(supp_filename) supp_filename = JOIN(suppressions_root, "drmemory", "suppressions.txt") result['drmem_suppressions'] = ReadSuppressionsFromFile(supp_filename) supp_filename = JOIN(suppressions_root, "drmemory", "suppressions_full.txt") result['drmem_full_suppressions'] = ReadSuppressionsFromFile(supp_filename) return result
def GetSuppressions(): suppressions_root = path_utils.ScriptDir() JOIN = os.path.join result = {} supp_filename = JOIN(suppressions_root, "memcheck", "suppressions.txt") vg_common = ReadSuppressionsFromFile(supp_filename) result['common_suppressions'] = vg_common supp_filename = JOIN(suppressions_root, "memcheck", "suppressions_linux.txt") vg_linux = ReadSuppressionsFromFile(supp_filename) result['linux_suppressions'] = vg_linux supp_filename = JOIN(suppressions_root, "memcheck", "suppressions_mac.txt") vg_mac = ReadSuppressionsFromFile(supp_filename) result['mac_suppressions'] = vg_mac supp_filename = JOIN(suppressions_root, "drmemory", "suppressions.txt") result['drmem_suppressions'] = ReadSuppressionsFromFile(supp_filename) supp_filename = JOIN(suppressions_root, "drmemory", "suppressions_full.txt") result['drmem_full_suppressions'] = ReadSuppressionsFromFile(supp_filename) return result
def __init__(self, options, args, test): if ':' in test: (self._test, self._gtest_filter) = test.split(':', 1) else: self._test = test self._gtest_filter = options.gtest_filter if self._test not in self._test_list: raise TestNotFound("Unknown test: %s" % test) if options.gtest_filter and options.gtest_filter != self._gtest_filter: raise MultipleGTestFiltersSpecified("Can not specify both --gtest_filter " "and --test %s" % test) self._options = options self._args = args script_dir = path_utils.ScriptDir() # Compute the top of the tree (the "source dir") from the script dir (where # this script lives). We assume that the script dir is in tools/valgrind/ # relative to the top of the tree. self._source_dir = os.path.dirname(os.path.dirname(script_dir)) # since this path is used for string matching, make sure it's always # an absolute Unix-style path self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/') valgrind_test_script = os.path.join(script_dir, "valgrind_test.py") self._command_preamble = ["--source_dir=%s" % (self._source_dir)]
def __init__(self, options, args, test): # The known list of tests. # Recognise the original abbreviations as well as full executable names. self._test_list = { "app_list": self.TestAppList, "app_list_unittests": self.TestAppList, "ash": self.TestAsh, "ash_unittests": self.TestAsh, "aura": self.TestAura, "aura_unittests": self.TestAura, "base": self.TestBase, "base_unittests": self.TestBase, "browser": self.TestBrowser, "browser_tests": self.TestBrowser, "chromeos": self.TestChromeOS, "chromeos_unittests": self.TestChromeOS, "components": self.TestComponents, "components_unittests": self.TestComponents, "compositor": self.TestCompositor, "compositor_unittests": self.TestCompositor, "content": self.TestContent, "content_unittests": self.TestContent, "content_browsertests": self.TestContentBrowser, "courgette": self.TestCourgette, "courgette_unittests": self.TestCourgette, "crypto": self.TestCrypto, "crypto_unittests": self.TestCrypto, "device": self.TestDevice, "device_unittests": self.TestDevice, "gpu": self.TestGPU, "gpu_unittests": self.TestGPU, "ipc": self.TestIpc, "ipc_tests": self.TestIpc, "jingle": self.TestJingle, "jingle_unittests": self.TestJingle, "layout": self.TestLayout, "layout_tests": self.TestLayout, "media": self.TestMedia, "media_unittests": self.TestMedia, "message_center": self.TestMessageCenter, "message_center_unittests" : self.TestMessageCenter, "net": self.TestNet, "net_unittests": self.TestNet, "ppapi": self.TestPPAPI, "ppapi_unittests": self.TestPPAPI, "printing": self.TestPrinting, "printing_unittests": self.TestPrinting, "remoting": self.TestRemoting, "remoting_unittests": self.TestRemoting, "sql": self.TestSql, "sql_unittests": self.TestSql, "startup": self.TestStartup, "startup_tests": self.TestStartup, "sync": self.TestSync, "sync_unit_tests": self.TestSync, "ui_unit": self.TestUIUnit, "ui_unittests": self.TestUIUnit, "unit": self.TestUnit, "unit_tests": self.TestUnit, "url": self.TestURL, "url_unittests": self.TestURL, "views": self.TestViews, "views_unittests": self.TestViews, } if test not in self._test_list: raise TestNotFound("Unknown test: %s" % test) self._options = options self._args = args self._test = test script_dir = path_utils.ScriptDir() # Compute the top of the tree (the "source dir") from the script dir (where # this script lives). We assume that the script dir is in tools/heapcheck/ # relative to the top of the tree. self._source_dir = os.path.dirname(os.path.dirname(script_dir)) # Since this path is used for string matching, make sure it's always # an absolute Unix-style path. self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/') heapcheck_test_script = os.path.join(script_dir, "heapcheck_test.py") self._command_preamble = [heapcheck_test_script]
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) # Add gtest filters, if found. chrome_tests.ChromeTests._AppendGtestFilter(self, tool, self._test_name, cmd) # When ChromeTests._DefaultCommand has executed, it has setup suppression # files based on what's found in the memcheck/ subdirectory 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 are 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. 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 __init__(self, options, args, test): # The known list of tests. # Recognise the original abbreviations as well as full executable names. self._test_list = { "base": self.TestBase, "base_unittests": self.TestBase, "browser": self.TestBrowser, "browser_tests": self.TestBrowser, "googleurl": self.TestGURL, "googleurl_unittests": self.TestGURL, "courgette": self.TestCourgette, "courgette_unittests": self.TestCourgette, "ipc": self.TestIpc, "ipc_tests": self.TestIpc, "layout": self.TestLayout, "layout_tests": self.TestLayout, "media": self.TestMedia, "media_unittests": self.TestMedia, "net": self.TestNet, "net_unittests": self.TestNet, "printing": self.TestPrinting, "printing_unittests": self.TestPrinting, "remoting": self.TestRemoting, "remoting_unittests": self.TestRemoting, "startup": self.TestStartup, "startup_tests": self.TestStartup, "sync": self.TestSync, "sync_unit_tests": self.TestSync, "test_shell": self.TestTestShell, "test_shell_tests": self.TestTestShell, "ui": self.TestUI, "ui_tests": self.TestUI, "unit": self.TestUnit, "unit_tests": self.TestUnit, "app": self.TestApp, "app_unittests": self.TestApp, } if test not in self._test_list: raise TestNotFound("Unknown test: %s" % test) self._options = options self._args = args self._test = test script_dir = path_utils.ScriptDir() # Compute the top of the tree (the "source dir") from the script dir (where # this script lives). We assume that the script dir is in tools/heapcheck/ # relative to the top of the tree. self._source_dir = os.path.dirname(os.path.dirname(script_dir)) # Since this path is used for string matching, make sure it's always # an absolute Unix-style path. self._source_dir = os.path.abspath(self._source_dir).replace('\\', '/') heapcheck_test_script = os.path.join(script_dir, "heapcheck_test.py") self._command_preamble = [heapcheck_test_script]
def TestLayoutChunk(self, chunk_num, chunk_size): '''Runs tests [chunk_num*chunk_size .. (chunk_num+1)*chunk_size). Wrap around to beginning of list at end. If chunk_size is zero, run all tests in the list once. If a text file is given as argument, it is used as the list of tests. ''' # Build the ginormous commandline in 'cmd'. # It's going to be roughly # python heapcheck_test.py ... python run_webkit_tests.py ... # but we'll use the --indirect flag to heapcheck_test.py # to avoid heapchecking python. # Start by building the heapcheck_test.py commandline. cmd = self._DefaultCommand("webkit") # Now build script_cmd, the run_webkits_tests.py commandline # Store each chunk in its own directory so that we can find the data later chunk_dir = os.path.join("layout", "chunk_%05d" % chunk_num) test_shell = os.path.join(self._options.build_dir, "test_shell") out_dir = os.path.join(path_utils.ScriptDir(), "latest") out_dir = os.path.join(out_dir, chunk_dir) if os.path.exists(out_dir): old_files = glob.glob(os.path.join(out_dir, "*.txt")) for f in old_files: os.remove(f) else: os.makedirs(out_dir) script = os.path.join(self._source_dir, "webkit", "tools", "layout_tests", "run_webkit_tests.py") script_cmd = [ "python", script, "--run-singly", "-v", "--noshow-results", "--time-out-ms=200000", "--nocheck-sys-deps" ] # Pass build mode to run_webkit_tests.py. We aren't passed it directly, # so parse it out of build_dir. run_webkit_tests.py can only handle # the two values "Release" and "Debug". # TODO(Hercules): unify how all our scripts pass around build mode # (--mode / --target / --build_dir / --debug) if self._options.build_dir.endswith("Debug"): script_cmd.append("--debug") if (chunk_size > 0): script_cmd.append("--run-chunk=%d:%d" % (chunk_num, chunk_size)) if len(self._args): # if the arg is a txt file, then treat it as a list of tests if os.path.isfile(self._args[0]) and self._args[0][-4:] == ".txt": script_cmd.append("--test-list=%s" % self._args[0]) else: script_cmd.extend(self._args) self._ReadGtestFilterFile("layout", script_cmd) # Now run script_cmd with the wrapper in cmd cmd.extend(["--"]) cmd.extend(script_cmd) supp = self.Suppressions() return heapcheck_test.RunTool(cmd, supp, "layout")
def _DefaultCommand(self, tool, exe=None, valgrind_test_args=None): '''Generates the default command array that most tests will use.''' if exe and common.IsWindows(): exe += '.exe' cmd = list(self._command_preamble) # Find all suppressions matching the following pattern: # tools/valgrind/TOOL/suppressions[_PLATFORM].txt # and list them with --suppressions= prefix. script_dir = path_utils.ScriptDir() suppression_file = os.path.join(script_dir, "..", "suppressions.txt") if os.path.exists(suppression_file): cmd.append("--suppressions=%s" % suppression_file) # Platform-specific suppression for platform in common.PlatformNames(): platform_suppression_file = \ os.path.join(script_dir, "..", 'suppressions_%s.txt' % platform) if os.path.exists(platform_suppression_file): cmd.append("--suppressions=%s" % platform_suppression_file) if self._options.valgrind_tool_flags: cmd += self._options.valgrind_tool_flags.split(" ") if self._options.keep_logs: cmd += ["--keep_logs"] if valgrind_test_args != None: for arg in valgrind_test_args: cmd.append(arg) if exe: self._EnsureBuildDirFound() 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) 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") # Built-in test launcher for gtest-based executables runs tests using # multiple process by default. Force the single-process mode back. cmd.append("--single-process-tests") if self._options.gtest_repeat: cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) if self._options.gtest_shuffle: cmd.append("--gtest_shuffle") if self._options.gtest_break_on_failure: cmd.append("--gtest_break_on_failure") if self._options.test_launcher_bot_mode: cmd.append("--test-launcher-bot-mode") if self._options.test_launcher_total_shards is not None: cmd.append("--test-launcher-total-shards=%d" % self._options.test_launcher_total_shards) if self._options.test_launcher_shard_index is not None: cmd.append("--test-launcher-shard-index=%d" % self._options.test_launcher_shard_index) return cmd
def Execute(self): """Executes the app to be tested.""" logging.info('starting execution...') proc = ['sh', path_utils.ScriptDir() + '/heapcheck_std.sh'] proc += self._args self.PutEnvAndLog('G_SLICE', 'always-malloc') self.PutEnvAndLog('NSS_DISABLE_ARENA_FREE_LIST', '1') self.PutEnvAndLog('NSS_DISABLE_UNLOAD', '1') self.PutEnvAndLog('GTEST_DEATH_TEST_USE_FORK', '1') self.PutEnvAndLog('HEAPCHECK', self._mode) self.PutEnvAndLog('HEAP_CHECK_ERROR_EXIT_CODE', '0') self.PutEnvAndLog('HEAP_CHECK_MAX_LEAKS', '-1') self.PutEnvAndLog('KEEP_SHADOW_STACKS', '1') self.PutEnvAndLog( 'PPROF_PATH', path_utils.ScriptDir() + '/../../third_party/tcmalloc/chromium/src/pprof') self.PutEnvAndLog('LD_LIBRARY_PATH', '/usr/lib/debug/:/usr/lib32/debug/') return common.RunSubprocess(proc, self._timeout)
def _DefaultCommand(self, tool, module, exe=None, valgrind_test_args=None): '''Generates the default command array that most tests will use.''' if exe and common.IsWindows(): exe = exe + '.exe' if not self._options.build_dir: if common.IsWine(): self._options.build_dir = os.path.join( self._source_dir, "chrome", "Debug") else: dirs = [ os.path.join(self._source_dir, "xcodebuild", "Debug"), os.path.join(self._source_dir, "out", "Debug"), os.path.join(self._source_dir, "build", "Debug"), ] if exe: self._options.build_dir = FindDirContainingNewestFile(dirs, exe) else: self._options.build_dir = FindNewestDir(dirs) cmd = list(self._command_preamble) # Find all suppressions matching the following pattern: # tools/valgrind/TOOL/suppressions[_PLATFORM].txt # and list them with --suppressions= prefix. script_dir = path_utils.ScriptDir() tool_name = tool.ToolName(); suppression_file = os.path.join(script_dir, tool_name, "suppressions.txt") if os.path.exists(suppression_file): cmd.append("--suppressions=%s" % suppression_file) # Platform-specific suppression for platform in common.PlatformNames(): platform_suppression_file = \ os.path.join(script_dir, tool_name, 'suppressions_%s.txt' % platform) if os.path.exists(platform_suppression_file): cmd.append("--suppressions=%s" % platform_suppression_file) if self._options.valgrind_tool_flags: cmd += self._options.valgrind_tool_flags.split(" ") if valgrind_test_args != None: for arg in valgrind_test_args: cmd.append(arg) if exe: if common.IsWine(): cmd.append(os.environ.get('WINE')) exe = exe + '.exe' cmd.append(os.path.join(self._options.build_dir, exe)) # Valgrind runs tests slowly, so slow tests hurt more; show elapased time # so we can find the slowpokes. cmd.append("--gtest_print_time") if self._options.gtest_repeat: cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) return cmd
def _DefaultCommand(self, module, exe=None, heapcheck_test_args=None): '''Generates the default command array that most tests will use. Args: module: The module name (corresponds to the dir in src/ where the test data resides). exe: The executable name. heapcheck_test_args: additional arguments to append to the command line. Returns: A string with the command to run the test. ''' module_dir = os.path.join(self._source_dir, module) # We need multiple data dirs, the current script directory and a module # specific one. The global suppression file lives in our directory, and the # module specific suppression file lives with the module. self._data_dirs = [path_utils.ScriptDir()] if module == "chrome": # Unfortunately, not all modules have the same directory structure. self._data_dirs.append( os.path.join(module_dir, "test", "data", "heapcheck")) else: self._data_dirs.append( os.path.join(module_dir, "data", "heapcheck")) if not self._options.build_dir: dirs = [ os.path.join(self._source_dir, "xcodebuild", "Debug"), os.path.join(self._source_dir, "out", "Debug"), ] if exe: self._options.build_dir = FindDirContainingNewestFile( dirs, exe) else: self._options.build_dir = FindNewestDir(dirs) cmd = list(self._command_preamble) if heapcheck_test_args != None: for arg in heapcheck_test_args: cmd.append(arg) if exe: cmd.append(os.path.join(self._options.build_dir, exe)) # Heapcheck runs tests slowly, so slow tests hurt more; show elapased time # so we can find the slowpokes. cmd.append("--gtest_print_time") if self._options.gtest_repeat: cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) return cmd
def Execute(self): """Executes the app to be tested.""" logging.info('starting execution...') proc = ['sh', path_utils.ScriptDir() + '/heapcheck_std.sh'] proc += self._args self.PutEnvAndLog('G_SLICE', 'always-malloc') self.PutEnvAndLog('NSS_DISABLE_ARENA_FREE_LIST', '1') self.PutEnvAndLog('GTEST_DEATH_TEST_USE_FORK', '1') self.PutEnvAndLog('HEAPCHECK', self._mode) self.PutEnvAndLog('HEAP_CHECK_MAX_LEAKS', '-1') self.PutEnvAndLog('KEEP_SHADOW_STACKS', '1') self.PutEnvAndLog( 'PPROF_PATH', path_utils.ScriptDir() + '/../../third_party/tcmalloc/chromium/src/pprof') self.PutEnvAndLog('LD_PRELOAD', '/usr/lib/debug/libstdc++.so') common.RunSubprocess(proc, self._timeout) # Always return true, even if running the subprocess failed. We depend on # Analyze to determine if the run was valid. (This behaviour copied from # the purify_test.py script.) return True
def _ReadGtestFilterFile(self, tool, name, cmd): '''Read a file which is a list of tests to filter out with --gtest_filter and append the command-line option to cmd. ''' filters = [] gtest_files_dir = os.path.join(path_utils.ScriptDir(), "gtest_exclude") gtest_filter_files = [ os.path.join(gtest_files_dir, name + ".gtest.txt"), os.path.join(gtest_files_dir, name + ".gtest-%s.txt" % tool.ToolName())] for platform_suffix in common.PlatformNames(): gtest_filter_files += [ os.path.join(gtest_files_dir, name + ".gtest_%s.txt" % platform_suffix), os.path.join(gtest_files_dir, name + ".gtest-%s_%s.txt" % \ (tool.ToolName(), platform_suffix))] for filename in gtest_filter_files: if not os.path.exists(filename): logging.info("gtest filter file %s not found - skipping" % filename) continue logging.info("Reading gtest filters from %s" % filename) f = open(filename, 'r') for line in f.readlines(): if line.startswith("#") or line.startswith("//") or line.isspace(): continue line = line.rstrip() test_prefixes = ["FLAKY", "FAILS"] for p in test_prefixes: # Strip prefixes from the test names. line = line.replace(".%s_" % p, ".") # Exclude the original test name. filters.append(line) if line[-2:] != ".*": # List all possible prefixes if line doesn't end with ".*". for p in test_prefixes: filters.append(line.replace(".", ".%s_" % p)) # Get rid of duplicates. filters = set(filters) gtest_filter = self._gtest_filter if len(filters): if gtest_filter: gtest_filter += ":" if gtest_filter.find("-") < 0: gtest_filter += "-" else: gtest_filter = "-" gtest_filter += ":".join(filters) if gtest_filter: cmd.append("--gtest_filter=%s" % gtest_filter)
def _ReadGtestFilterFile(self, name, cmd): '''Reads files which contain lists of tests to filter out with --gtest_filter and appends the command-line option to |cmd|. Args: name: the test executable name. cmd: the test running command line to be modified. ''' filters = [] directory = path_utils.ScriptDir() gtest_filter_files = [ os.path.join(directory, name + ".gtest-heapcheck.txt"), # TODO(glider): Linux vs. CrOS? ] logging.info("Reading gtest exclude filter files:") for filename in gtest_filter_files: # strip the leading absolute path (may be very long on the bot) # and the following / or \. readable_filename = filename.replace(self._source_dir, "")[1:] if not os.path.exists(filename): logging.info(" \"%s\" - not found" % readable_filename) continue logging.info(" \"%s\" - OK" % readable_filename) f = open(filename, 'r') for line in f.readlines(): if line.startswith("#") or line.startswith( "//") or line.isspace(): continue line = line.rstrip() filters.append(line) gtest_filter = self._options.gtest_filter if len(filters): if gtest_filter: gtest_filter += ":" if gtest_filter.find("-") < 0: gtest_filter += "-" else: gtest_filter = "-" gtest_filter += ":".join(filters) if gtest_filter: cmd.append("--gtest_filter=%s" % gtest_filter)
def main(argv): suppressions_root = path_utils.ScriptDir() JOIN = os.path.join supp_filename = JOIN(suppressions_root, "memcheck", "suppressions.txt") vg_common = suppressions.ReadSuppressionsFromFile(supp_filename) supp_filename = JOIN(suppressions_root, "tsan", "suppressions.txt") tsan_common = suppressions.ReadSuppressionsFromFile(supp_filename) common_suppressions = vg_common + tsan_common supp_filename = JOIN(suppressions_root, "memcheck", "suppressions_mac.txt") vg_mac = suppressions.ReadSuppressionsFromFile(supp_filename) supp_filename = JOIN(suppressions_root, "tsan", "suppressions_mac.txt") tsan_mac = suppressions.ReadSuppressionsFromFile(supp_filename) mac_suppressions = vg_mac + tsan_mac supp_filename = JOIN(suppressions_root, "tsan", "suppressions_win32.txt") tsan_win = suppressions.ReadSuppressionsFromFile(supp_filename) win_suppressions = tsan_win supp_filename = JOIN(suppressions_root, "..", "heapcheck", "suppressions.txt") heapcheck_suppressions = suppressions.ReadSuppressionsFromFile( supp_filename) supp_filename = JOIN(suppressions_root, "drmemory", "suppressions.txt") drmem_suppressions = suppressions.ReadSuppressionsFromFile(supp_filename) supp_filename = JOIN(suppressions_root, "drmemory", "suppressions_full.txt") drmem_full_suppressions = suppressions.ReadSuppressionsFromFile( supp_filename) # all_reports is a map {report: list of urls containing this report} all_reports = defaultdict(list) report_hashes = {} for f in argv: f_reports, url = ReadReportsFromFile(f) for (hash, report) in f_reports: all_reports[report] += [url] report_hashes[report] = hash reports_count = 0 for r in all_reports: cur_supp = common_suppressions if all([ re.search("%20Mac%20|mac_valgrind", url) for url in all_reports[r] ]): # Include mac suppressions if the report is only present on Mac cur_supp += mac_suppressions elif all([re.search("Windows%20", url) for url in all_reports[r]]): # Include win32 suppressions if the report is only present on Windows cur_supp += win_suppressions elif all([re.search("%20Heapcheck", url) for url in all_reports[r]]): cur_supp += heapcheck_suppressions elif all(["DrMemory%20full" in url for url in all_reports[r]]): cur_supp += drmem_suppressions + drmem_full_suppressions elif all(["DrMemory" in url for url in all_reports[r]]): cur_supp += drmem_suppressions match = False for s in cur_supp: if s.Match(r.split("\n")): match = True break if not match: reports_count += 1 print "===================================" print "This report observed at" for url in all_reports[r]: print " %s" % url print "didn't match any suppressions:" print "Suppression (error hash=#%s#):" % (report_hashes[r]) print r print "===================================" if reports_count > 0: print("%d unique reports don't match any of the suppressions" % reports_count) else: print "Congratulations! All reports are suppressed!"
def TestLayoutChunk(self, chunk_num, chunk_size): '''Runs tests [chunk_num*chunk_size .. (chunk_num+1)*chunk_size). Wrap around to beginning of list at end. If chunk_size is zero, run all tests in the list once. If a text file is given as argument, it is used as the list of tests. ''' # Build the ginormous commandline in 'cmd'. # It's going to be roughly # python heapcheck_test.py ... python run_webkit_tests.py ... # but we'll use the --indirect flag to heapcheck_test.py # to avoid heapchecking python. # Start by building the heapcheck_test.py commandline. cmd = self._DefaultCommand("webkit") # Now build script_cmd, the run_webkits_tests.py commandline # Store each chunk in its own directory so that we can find the data later chunk_dir = os.path.join("layout", "chunk_%05d" % chunk_num) out_dir = os.path.join(path_utils.ScriptDir(), "latest") out_dir = os.path.join(out_dir, chunk_dir) if os.path.exists(out_dir): old_files = glob.glob(os.path.join(out_dir, "*.txt")) for f in old_files: os.remove(f) else: os.makedirs(out_dir) script = os.path.join(self._source_dir, "webkit", "tools", "layout_tests", "run_webkit_tests.py") # While Heapcheck is not memory bound like Valgrind for running layout tests # in parallel, it is still CPU bound. Many machines have hyper-threading # turned on, so the real number of cores is actually half. jobs = max(1, int(multiprocessing.cpu_count() * 0.5)) script_cmd = [ "python", script, "-v", "--run-singly", # run a separate DumpRenderTree for each test "--fully-parallel", "--child-processes=%d" % jobs, "--time-out-ms=200000", "--no-retry-failures", # retrying takes too much time # http://crbug.com/176908: Don't launch a browser when done. "--no-show-results", "--nocheck-sys-deps" ] # Pass build mode to run_webkit_tests.py. We aren't passed it directly, # so parse it out of build_dir. run_webkit_tests.py can only handle # the two values "Release" and "Debug". # TODO(Hercules): unify how all our scripts pass around build mode # (--mode / --target / --build-dir / --debug) if self._options.build_dir.endswith("Debug"): script_cmd.append("--debug") if (chunk_size > 0): script_cmd.append("--run-chunk=%d:%d" % (chunk_num, chunk_size)) if len(self._args): # if the arg is a txt file, then treat it as a list of tests if os.path.isfile(self._args[0]) and self._args[0][-4:] == ".txt": script_cmd.append("--test-list=%s" % self._args[0]) else: script_cmd.extend(self._args) self._ReadGtestFilterFile("layout", script_cmd) # Now run script_cmd with the wrapper in cmd cmd.extend(["--"]) cmd.extend(script_cmd) supp = self.Suppressions() return heapcheck_test.RunTool(cmd, supp, "layout")
def TestLayoutChunk(self, chunk_num, chunk_size): # Run tests [chunk_num*chunk_size .. (chunk_num+1)*chunk_size) from the # list of tests. Wrap around to beginning of list at end. # If chunk_size is zero, run all tests in the list once. # If a text file is given as argument, it is used as the list of tests. # # Build the ginormous commandline in 'cmd'. # It's going to be roughly # python valgrind_test.py ... python run_webkit_tests.py ... # but we'll use the --indirect flag to valgrind_test.py # to avoid valgrinding python. # Start by building the valgrind_test.py commandline. tool = valgrind_test.CreateTool(self._options.valgrind_tool) cmd = self._DefaultCommand(tool) cmd.append("--trace_children") cmd.append("--indirect_webkit_layout") cmd.append("--ignore_exit_code") # Now build script_cmd, the run_webkits_tests.py commandline # Store each chunk in its own directory so that we can find the data later chunk_dir = os.path.join("layout", "chunk_%05d" % chunk_num) test_shell = os.path.join(self._options.build_dir, "test_shell") out_dir = os.path.join(path_utils.ScriptDir(), "latest") out_dir = os.path.join(out_dir, chunk_dir) if os.path.exists(out_dir): old_files = glob.glob(os.path.join(out_dir, "*.txt")) for f in old_files: os.remove(f) else: os.makedirs(out_dir) script = os.path.join(self._source_dir, "webkit", "tools", "layout_tests", "run_webkit_tests.py") script_cmd = ["python", script, "-v", "--run-singly", # run a separate DumpRenderTree for each test "--fully-parallel", "--time-out-ms=200000", "--noshow-results", "--nocheck-sys-deps"] # Pass build mode to run_webkit_tests.py. We aren't passed it directly, # so parse it out of build_dir. run_webkit_tests.py can only handle # the two values "Release" and "Debug". # TODO(Hercules): unify how all our scripts pass around build mode # (--mode / --target / --build_dir / --debug) if self._options.build_dir.endswith("Debug"): script_cmd.append("--debug"); if (chunk_size > 0): script_cmd.append("--run-chunk=%d:%d" % (chunk_num, chunk_size)) if len(self._args): # if the arg is a txt file, then treat it as a list of tests if os.path.isfile(self._args[0]) and self._args[0][-4:] == ".txt": script_cmd.append("--test-list=%s" % self._args[0]) else: script_cmd.extend(self._args) self._AppendGtestFilter(tool, "layout", script_cmd) # Now run script_cmd with the wrapper in cmd cmd.extend(["--"]) cmd.extend(script_cmd) # Layout tests often times fail quickly, but the buildbot remains green. # Detect this situation when running with the default chunk size. if chunk_size == self.LAYOUT_TESTS_DEFAULT_CHUNK_SIZE: min_runtime_in_seconds=120 else: min_runtime_in_seconds=0 ret = tool.Run(cmd, "layout", min_runtime_in_seconds=min_runtime_in_seconds) return ret
reports += [[last_hash, "\n".join(cur_supp)]] in_suppression = False cur_supp = [] last_hash = "" else: cur_supp += [" " * 3 + line] elif line == "{": in_suppression = True cur_supp = ["{"] elif line.find("Suppression (error hash=#") == 0: last_hash = line[25:41] # The line at the end of the file is assumed to store the URL of the report. return reports, line suppressions_root = path_utils.ScriptDir() supp_filename = os.path.join(suppressions_root, "memcheck", "suppressions.txt") common_suppressions = suppressions.ReadSuppressionsFromFile(supp_filename) supp_filename = os.path.join(suppressions_root, "memcheck", "suppressions_mac.txt") mac_suppressions = suppressions.ReadSuppressionsFromFile(supp_filename) # all_reports is a map {report: list of urls containing this report} all_reports = defaultdict(list) report_hashes = {} for f in sys.argv[1:]: f_reports, url = ReadReportsFromFile(f) for (hash, report) in f_reports: