diff options
author | Qin Zhao <zhaoqin@google.com> | 2015-11-23 16:50:49 -0500 |
---|---|---|
committer | Qin Zhao <zhaoqin@google.com> | 2015-11-23 16:50:49 -0500 |
commit | fba46da798abae8c8cc0e9329e14bca860c2afc6 (patch) | |
tree | 976fd4425cf7bf3099cf4657d64059adaa827b37 /testing/tools/common.py | |
parent | 65db985775e032463cf9ae93ba4c6f7b01961bf0 (diff) | |
download | pdfium-fba46da798abae8c8cc0e9329e14bca860c2afc6.tar.xz |
Merge to XFA: Enable Dr. Memory to run javascript, pixel, and corpus tests
- add DrMemoryWrapper in common.py to adjust Dr. Memory wrapper
- add --wrapper option to run_*_tests.py for Dr. Mempry wrapper
- update run_*_tests.py to handle Dr. Memory wrapper
- add TestPDFiumTest in pdfium_tests.py to support run_*_tests.py
- remove ValgrindTool in valgrind_tests.py
R=thestig@chromium.org
BUG=pdfium:238
Review URL: https://codereview.chromium.org/1464453003 .
(cherry picked from commit 36476923ae5eb8e9283e605f3c85ee8811c86014)
Review URL: https://codereview.chromium.org/1465333002 .
Diffstat (limited to 'testing/tools/common.py')
-rwxr-xr-x | testing/tools/common.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/testing/tools/common.py b/testing/tools/common.py index d45404b4d4..6e9de7c82c 100755 --- a/testing/tools/common.py +++ b/testing/tools/common.py @@ -3,6 +3,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import glob import os import subprocess import sys @@ -27,6 +28,38 @@ def RunCommand(cmd, redirect_output=False): except subprocess.CalledProcessError as e: return e +# Adjust Dr. Memory wrapper to have separate log directory for each test +# for better error reporting. +def DrMemoryWrapper(wrapper, pdf_name): + if not wrapper: + return [] + # convert string to list + cmd_to_run = wrapper.split() + + # Do nothing if using default log directory. + if cmd_to_run.count("-logdir") == 0: + return cmd_to_run + # Usually, we pass "-logdir" "foo\bar\spam path" args to Dr. Memory. + # To group reports per test, we want to put the reports for each test into a + # separate directory. This code can be simplified when we have + # https://github.com/DynamoRIO/drmemory/issues/684 fixed. + logdir_idx = cmd_to_run.index("-logdir") + old_logdir = cmd_to_run[logdir_idx + 1] + wrapper_pid = str(os.getpid()) + + # We are using the same pid of the same python process, so append the number + # of entries in the logdir at the end of wrapper_pid to avoid conflict. + wrapper_pid += "_%d" % len(glob.glob(old_logdir + "\\*")) + + cmd_to_run[logdir_idx + 1] += "\\testcase.%s.logs" % wrapper_pid + os.makedirs(cmd_to_run[logdir_idx + 1]) + + f = open(old_logdir + "\\testcase.%s.name" % wrapper_pid, "w") + print >>f, pdf_name + ".pdf" + f.close() + + return cmd_to_run + class DirectoryFinder: '''A class for finding directories and paths under either a standalone |