Skip to content

Commit

Permalink
Fix WebKit layout Valgrind runner, part 2
Browse files Browse the repository at this point in the history
Get the layout test URL from the DRT stdin
TBR=thestig
BUG=130832
Review URL: https://chromiumcodereview.appspot.com/10539047

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141003 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
[email protected] committed Jun 7, 2012
1 parent 243cac7 commit fa93de6
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions tools/valgrind/valgrind_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def ToolCommand(self):
# Handle --indirect_webkit_layout separately.
if self._options.indirect_webkit_layout:
# Need to create the wrapper before modifying |proc|.
wrapper = self.CreateBrowserWrapper(proc)
wrapper = self.CreateBrowserWrapper(proc, webkit=True)
proc = self._args
proc.append("--wrapper")
proc.append(wrapper)
Expand All @@ -405,7 +405,7 @@ def ToolSpecificFlags(self):
raise NotImplementedError, "This method should be implemented " \
"in the tool-specific subclass"

def CreateBrowserWrapper(self, proc):
def CreateBrowserWrapper(self, proc, webkit=False):
"""The program being run invokes Python or something else that can't stand
to be valgrinded, and also invokes the Chrome browser. In this case, use a
magic wrapper to only valgrind the Chrome browser. Build the wrapper here.
Expand All @@ -424,31 +424,24 @@ def CreateBrowserWrapper(self, proc):
f.write('#!/bin/bash\n'
'echo "Started Valgrind wrapper for this test, PID=$$" >&2\n')

# Try to get the test case name by looking at the program arguments.
# i.e. Chromium ui_tests and friends pass --test-name arg.
f.write('DIR=`dirname $0`\n'
'FOUND_TESTNAME=0\n'
'TESTNAME_FILE=$DIR/testcase.$$.name\n'
'for arg in $@; do\n'
' # TODO(timurrrr): this doesn\'t handle "--test-name Test.Name"\n'
' if [[ "$arg" =~ --test-name=(.*) ]]; then\n'
' echo ${BASH_REMATCH[1]} >$TESTNAME_FILE\n'
' FOUND_TESTNAME=1\n'
' fi\n'
'done\n\n')

f.write('if [ "$FOUND_TESTNAME" = "1" ]; then\n'
' %s "$@"\n'
'else\n' % command)
# Webkit layout_tests print out the test URL as the first line of stdout.
f.write(' %s "$@" | tee $DIR/test.$$.stdout\n'
' EXITCODE=$PIPESTATUS\n' # $? holds the tee's exit code
' head -n 1 $DIR/test.$$.stdout |\n'
' grep URL |\n'
' sed "s/^.*third_party\/WebKit\/LayoutTests\///" '
'>$TESTNAME_FILE\n'
' exit $EXITCODE\n'
'fi\n' % command)
'TESTNAME_FILE=$DIR/testcase.$$.name\n\n')

if webkit:
# Webkit layout_tests pass the URL as the first line of stdin.
f.write('tee $TESTNAME_FILE | %s "$@"\n' % command)
else:
# Try to get the test case name by looking at the program arguments.
# i.e. Chromium ui_tests used --test-name arg.
# TODO(timurrrr): This doesn't handle "--test-name Test.Name"
# TODO(timurrrr): ui_tests are dead. Where do we use the non-webkit
# wrapper now? browser_tests? What do they do?
f.write('for arg in $@\ndo\n'
' if [[ "$arg" =~ --test-name=(.*) ]]\n then\n'
' echo ${BASH_REMATCH[1]} >$TESTNAME_FILE\n'
' fi\n'
'done\n\n'
'%s "$@"\n' % command)

f.close()
os.chmod(indirect_fname, stat.S_IRUSR|stat.S_IXUSR)
Expand Down Expand Up @@ -480,6 +473,10 @@ def GetAnalyzeResults(self, check_sanity=False):
f = open(self.log_dir + ("/testcase.%d.name" % ppid))
testcase_name = f.read().strip()
f.close()
wk_layout_prefix="third_party/WebKit/LayoutTests/"
wk_prefix_at = testcase_name.rfind(wk_layout_prefix)
if wk_prefix_at != -1:
testcase_name = testcase_name[wk_prefix_at + len(wk_layout_prefix):]
except IOError:
pass
print "====================================================="
Expand Down

0 comments on commit fa93de6

Please sign in to comment.