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

Side by Side Diff: tools/valgrind/browser_wrapper_win.py

Issue 8816017: Fix rare logdir races by adding "_logdirfilecount" to the 'PID' when generating a unique logdir path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/valgrind/valgrind_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import glob
5 import os 6 import os
6 import re 7 import re
7 import sys 8 import sys
8 import subprocess 9 import subprocess
9 10
10 # TODO(timurrrr): we may use it on POSIX too to avoid code duplication once we 11 # TODO(timurrrr): we may use it on POSIX too to avoid code duplication once we
11 # support layout_tests, remove Dr. Memory specific code and verify it works 12 # support layout_tests, remove Dr. Memory specific code and verify it works
12 # on a "clean" Mac. 13 # on a "clean" Mac.
13 14
14 wrapper_pid = os.getpid()
15 testcase_name = None 15 testcase_name = None
16 for arg in sys.argv: 16 for arg in sys.argv:
17 m = re.match("\-\-test\-name=(.*)", arg) 17 m = re.match("\-\-test\-name=(.*)", arg)
18 if m: 18 if m:
19 assert testcase_name is None 19 assert testcase_name is None
20 testcase_name = m.groups()[0] 20 testcase_name = m.groups()[0]
21 21
22 # arg #0 is the path to this python script 22 # arg #0 is the path to this python script
23 cmd_to_run = sys.argv[1:] 23 cmd_to_run = sys.argv[1:]
24 24
25 # TODO(timurrrr): this is Dr. Memory-specific 25 # TODO(timurrrr): this is Dr. Memory-specific
26 # Usually, we pass "-logdir" "foo\bar\spam path" args to Dr. Memory. 26 # Usually, we pass "-logdir" "foo\bar\spam path" args to Dr. Memory.
27 # To group reports per UI test, we want to put the reports for each test into a 27 # To group reports per UI test, we want to put the reports for each test into a
28 # separate directory. This code can be simplified when we have 28 # separate directory. This code can be simplified when we have
29 # http://code.google.com/p/drmemory/issues/detail?id=684 fixed. 29 # http://code.google.com/p/drmemory/issues/detail?id=684 fixed.
30 logdir_idx = cmd_to_run.index("-logdir") 30 logdir_idx = cmd_to_run.index("-logdir")
31 old_logdir = cmd_to_run[logdir_idx + 1] 31 old_logdir = cmd_to_run[logdir_idx + 1]
32 cmd_to_run[logdir_idx + 1] += "\\testcase.%d.logs" % wrapper_pid 32
33 wrapper_pid = str(os.getpid())
34
35 # On Windows, there is a chance of PID collision. We avoid it by appending the
36 # number of entries in the logdir at the end of wrapper_pid.
37 # This number is monotonic and we can't have two simultaneously running wrappers
38 # with the same PID.
39 wrapper_pid += "_%d" % len(glob.glob(old_logdir + "\\*"))
40
41 cmd_to_run[logdir_idx + 1] += "\\testcase.%s.logs" % wrapper_pid
33 os.makedirs(cmd_to_run[logdir_idx + 1]) 42 os.makedirs(cmd_to_run[logdir_idx + 1])
34 43
35 if testcase_name: 44 if testcase_name:
36 f = open(old_logdir + "\\testcase.%d.name" % wrapper_pid, "w") 45 f = open(old_logdir + "\\testcase.%s.name" % wrapper_pid, "w")
37 print >>f, testcase_name 46 print >>f, testcase_name
38 f.close() 47 f.close()
39 48
40 exit(subprocess.call(cmd_to_run)) 49 exit(subprocess.call(cmd_to_run))
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/valgrind_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698