Chromium Code Reviews| Index: testing/tools/common.py |
| diff --git a/testing/tools/common.py b/testing/tools/common.py |
| index d45404b4d4dd2a3f7d7094ab903002efa0d411e0..60b842af5ee51f66dabeddad2b90cab87d2eb9fe 100755 |
| --- a/testing/tools/common.py |
| +++ b/testing/tools/common.py |
| @@ -6,6 +6,7 @@ |
| import os |
| import subprocess |
| import sys |
| +import glob |
|
Lei Zhang
2015/11/20 00:17:47
alphabetical order
zhaoqin1
2015/11/21 04:20:45
Done.
|
| def os_name(): |
| if sys.platform.startswith('linux'): |
| @@ -27,6 +28,35 @@ 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): |
|
Lei Zhang
2015/11/20 00:17:47
From reading the code, it looks like |pdf_name| is
zhaoqin1
2015/11/21 04:20:45
handle it in run_corpus_tests.py now.
|
| + # convert string to list |
| + cmd_to_run = wrapper.split() |
| + |
| + # 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") |
|
Lei Zhang
2015/11/20 00:17:47
Can you check this does not return the sentinel va
zhaoqin1
2015/11/21 04:20:45
it raise exception on "not found", add check
|
| + old_logdir = cmd_to_run[logdir_idx + 1] |
| + wrapper_pid = str(os.getpid()) |
| + |
| + # On Windows, there is a chance of PID collision. We avoid it by appending the |
|
Lei Zhang
2015/11/20 00:17:47
Oh boy oh boy oh boy.
zhaoqin1
2015/11/21 04:20:45
It gets worse here.
Originally, this function is
|
| + # number of entries in the logdir at the end of wrapper_pid. |
| + # This number is monotonic and we can't have two simultaneously running wrappers |
|
Lei Zhang
2015/11/20 00:17:47
80 chars
zhaoqin1
2015/11/21 04:20:45
Done.
|
| + # with the same PID. |
| + 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 |