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: testing/tools/common.py

Issue 1464453003: Enable Dr. Memory to run javascript, pixel, and corpus tests (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: PTAL Created 5 years, 1 month 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 | « no previous file | testing/tools/run_corpus_tests.py » ('j') | testing/tools/run_corpus_tests.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/tools/common.py
diff --git a/testing/tools/common.py b/testing/tools/common.py
index d45404b4d4dd2a3f7d7094ab903002efa0d411e0..6e9de7c82c67828a012a96b90d800e0152375bd9 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
« no previous file with comments | « no previous file | testing/tools/run_corpus_tests.py » ('j') | testing/tools/run_corpus_tests.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698