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

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

Issue 8537013: Find out the Webkit layout_tests names by reading their stdout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # valgrind_test.py 6 # valgrind_test.py
7 7
8 """Runs an exe through Valgrind and puts the intermediate files in a 8 """Runs an exe through Valgrind and puts the intermediate files in a
9 directory. 9 directory.
10 """ 10 """
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 "in the tool-specific subclass" 383 "in the tool-specific subclass"
384 384
385 def CreateBrowserWrapper(self, proc): 385 def CreateBrowserWrapper(self, proc):
386 """The program being run invokes Python or something else that can't stand 386 """The program being run invokes Python or something else that can't stand
387 to be valgrinded, and also invokes the Chrome browser. In this case, use a 387 to be valgrinded, and also invokes the Chrome browser. In this case, use a
388 magic wrapper to only valgrind the Chrome browser. Build the wrapper here. 388 magic wrapper to only valgrind the Chrome browser. Build the wrapper here.
389 Returns the path to the wrapper. It's up to the caller to use the wrapper 389 Returns the path to the wrapper. It's up to the caller to use the wrapper
390 appropriately. 390 appropriately.
391 """ 391 """
392 command = " ".join(proc) 392 command = " ".join(proc)
393 # Add the PID of the browser wrapper to the logfile names so we can
394 # separate log files for different UI tests at the analyze stage.
393 command = command.replace("%p", "$$.%p") 395 command = command.replace("%p", "$$.%p")
394 396
395 (fd, indirect_fname) = tempfile.mkstemp(dir=self.log_dir, 397 (fd, indirect_fname) = tempfile.mkstemp(dir=self.log_dir,
396 prefix="browser_wrapper.", 398 prefix="browser_wrapper.",
397 text=True) 399 text=True)
398 f = os.fdopen(fd, "w") 400 f = os.fdopen(fd, "w")
399 f.write("#!/bin/bash\n") 401 f.write('#!/bin/bash\n'
400 f.write('echo "Started Valgrind wrapper for this test, PID=$$"\n\n') 402 'echo "Started Valgrind wrapper for this test, PID=$$"\n')
401 f.write('for arg in $@\ndo\n') 403
402 f.write(' if [[ "$arg" =~ --test-name=(.*) ]]\n then\n') 404 # Try to get the test case name by looking at the program arguments.
403 f.write(' TESTCASE=${BASH_REMATCH[1]}\n') 405 # i.e. Chromium ui_tests and friends pass --test-name arg.
404 f.write(' echo $TESTCASE >`dirname $0`/testcase.$$.name\n') 406 f.write('DIR=`dirname $0`\n'
405 f.write(' fi\ndone\n') 407 'FOUND_TESTNAME=0\n'
406 # Add the PID of the browser wrapper to the logfile names so we can 408 'TESTNAME_FILE=$DIR/testcase.$$.name\n'
407 # separate log files for different UI tests at the analyze stage. 409 'for arg in $@; do\n'
Lei Zhang 2011/11/12 00:03:37 FYI, this doesn't handle arguments with spaces, bu
Timur Iskhodzhanov 2011/11/12 19:42:11 True; added a TODO just in case On 2011/11/12 00:
408 f.write(command) 410 ' if [[ "$arg" =~ --test-name=(.*) ]]; then\n'
409 f.write(' "$@"\n') 411 ' echo ${BASH_REMATCH[1]} >$TESTNAME_FILE\n'
412 ' FOUND_TESTNAME=1\n'
413 ' fi\n'
414 'done\n\n')
415
416 f.write('if [ "$FOUND_TESTNAME" == "1" ]; then\n'
Lei Zhang 2011/11/12 00:03:37 nit: == is valid in bash, but can you use = so peo
Timur Iskhodzhanov 2011/11/12 19:42:11 Ok, the C++ part of me is too defensive :) On 201
417 ' %s "$@"\n'
418 'else\n' % command)
419 # Webkit layout_tests print out the test URL as the first line of stdout.
420 f.write(' %s "$@" | tee $DIR/test.$$.stdout\n'
Timur Iskhodzhanov 2011/11/11 15:22:24 pardon: accidentally removed the initial patchset.
421 ' EXITCODE=$PIPESTATUS\n' # $? holds the tee's exit code
422 ' head -n 1 $DIR/test.$$.stdout | \n'
423 ' sed "s/^.*third_party\/WebKit\/LayoutTests\///" '
424 '>$TESTNAME_FILE\n'
425 ' exit $EXITCODE\n'
426 'fi\n' % command)
427
410 f.close() 428 f.close()
411 os.chmod(indirect_fname, stat.S_IRUSR|stat.S_IXUSR) 429 os.chmod(indirect_fname, stat.S_IRUSR|stat.S_IXUSR)
412 return indirect_fname 430 return indirect_fname
413 431
414 def CreateAnalyzer(self): 432 def CreateAnalyzer(self):
415 raise NotImplementedError, "This method should be implemented " \ 433 raise NotImplementedError, "This method should be implemented " \
416 "in the tool-specific subclass" 434 "in the tool-specific subclass"
417 435
418 def GetAnalyzeResults(self, check_sanity=False): 436 def GetAnalyzeResults(self, check_sanity=False):
419 # Glob all the files in the "testing.tmp" directory 437 # Glob all the files in the "testing.tmp" directory
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 platform_name = sys.platform + "(Unknown)" 1134 platform_name = sys.platform + "(Unknown)"
1117 raise RuntimeError, "Unknown tool (tool=%s, platform=%s)" % (tool_name, 1135 raise RuntimeError, "Unknown tool (tool=%s, platform=%s)" % (tool_name,
1118 platform_name) 1136 platform_name)
1119 1137
1120 def CreateTool(tool): 1138 def CreateTool(tool):
1121 return ToolFactory().Create(tool) 1139 return ToolFactory().Create(tool)
1122 1140
1123 if __name__ == '__main__': 1141 if __name__ == '__main__':
1124 logging.error(sys.argv[0] + " can not be run from command line") 1142 logging.error(sys.argv[0] + " can not be run from command line")
1125 sys.exit(1) 1143 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698