Index: tools/valgrind/valgrind_test.py |
=================================================================== |
--- tools/valgrind/valgrind_test.py (revision 109629) |
+++ tools/valgrind/valgrind_test.py (working copy) |
@@ -390,23 +390,41 @@ |
appropriately. |
""" |
command = " ".join(proc) |
+ # Add the PID of the browser wrapper to the logfile names so we can |
+ # separate log files for different UI tests at the analyze stage. |
command = command.replace("%p", "$$.%p") |
(fd, indirect_fname) = tempfile.mkstemp(dir=self.log_dir, |
prefix="browser_wrapper.", |
text=True) |
f = os.fdopen(fd, "w") |
- f.write("#!/bin/bash\n") |
- f.write('echo "Started Valgrind wrapper for this test, PID=$$"\n\n') |
- f.write('for arg in $@\ndo\n') |
- f.write(' if [[ "$arg" =~ --test-name=(.*) ]]\n then\n') |
- f.write(' TESTCASE=${BASH_REMATCH[1]}\n') |
- f.write(' echo $TESTCASE >`dirname $0`/testcase.$$.name\n') |
- f.write(' fi\ndone\n') |
- # Add the PID of the browser wrapper to the logfile names so we can |
- # separate log files for different UI tests at the analyze stage. |
- f.write(command) |
- f.write(' "$@"\n') |
+ f.write('#!/bin/bash\n' |
+ 'echo "Started Valgrind wrapper for this test, PID=$$"\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' |
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:
|
+ ' 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' |
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
|
+ ' %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' |
Timur Iskhodzhanov
2011/11/11 15:22:24
pardon: accidentally removed the initial patchset.
|
+ ' EXITCODE=$PIPESTATUS\n' # $? holds the tee's exit code |
+ ' head -n 1 $DIR/test.$$.stdout | \n' |
+ ' sed "s/^.*third_party\/WebKit\/LayoutTests\///" ' |
+ '>$TESTNAME_FILE\n' |
+ ' exit $EXITCODE\n' |
+ 'fi\n' % command) |
+ |
f.close() |
os.chmod(indirect_fname, stat.S_IRUSR|stat.S_IXUSR) |
return indirect_fname |