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

Side by Side Diff: gm/tests/run.sh

Issue 15085007: GM self-test: add --writePath and --mismatchPath , but in a way that works cross-platform (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 months 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
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Self-tests for gm, based on tools/tests/run.sh 3 # Self-tests for gm, based on tools/tests/run.sh
4 # 4 #
5 # These tests are run by the Skia_PerCommit_House_Keeping bot at every commit, 5 # These tests are run by the Skia_PerCommit_House_Keeping bot at every commit,
6 # so make sure that they still pass when you make changes to gm! 6 # so make sure that they still pass when you make changes to gm!
7 # 7 #
8 # To generate new baselines when gm behavior changes, run gm/tests/rebaseline.sh 8 # To generate new baselines when gm behavior changes, run gm/tests/rebaseline.sh
9 # 9 #
10 # TODO: because this is written as a shell script (instead of, say, Python) 10 # TODO: because this is written as a shell script (instead of, say, Python)
11 # it only runs on Linux and Mac. 11 # it only runs on Linux and Mac.
12 # See https://code.google.com/p/skia/issues/detail?id=677 12 # See https://code.google.com/p/skia/issues/detail?id=677
13 # ('make tools/tests/run.sh work cross-platform') 13 # ('make tools/tests/run.sh work cross-platform')
14 # Ideally, these tests should pass on all development platforms... 14 # Ideally, these tests should pass on all development platforms...
15 # otherwise, how can developers be expected to test them before committing a 15 # otherwise, how can developers be expected to test them before committing a
16 # change? 16 # change?
17 17
18 # cd into .../trunk so all the paths will work 18 # cd into .../trunk so all the paths will work
19 cd $(dirname $0)/../.. 19 cd $(dirname $0)/../..
20 20
21 # TODO(epoger): make it look in Release and/or Debug 21 # TODO(epoger): make it look in Release and/or Debug
22 GM_BINARY=out/Debug/gm 22 GM_BINARY=out/Debug/gm
23 23
24 # If WRITE_IMAGE_FILES is nonzero, then the self-test will pass --writePath
25 # and --mismatchPath arguments to GM. Currently, for various reasons, we
26 # cannot run these arguments on the production buildbots, so this should
27 # only be set to nonzero for local testing.
28 WRITE_IMAGE_FILES=0
29
30 OUTPUT_ACTUAL_SUBDIR=output-actual 24 OUTPUT_ACTUAL_SUBDIR=output-actual
31 OUTPUT_EXPECTED_SUBDIR=output-expected 25 OUTPUT_EXPECTED_SUBDIR=output-expected
32 CONFIGS="--config 8888 565" 26 CONFIGS="--config 8888 565"
33 27
34 ENCOUNTERED_ANY_ERRORS=0 28 ENCOUNTERED_ANY_ERRORS=0
35 29
36 # Compare contents of all files within directories $1 and $2, 30 # Compare contents of all files within directories $1 and $2,
37 # EXCEPT for any dotfiles. 31 # EXCEPT for any dotfiles.
38 # If there are any differences, a description is written to stdout and 32 # If there are any differences, a description is written to stdout and
39 # we exit with a nonzero return value. 33 # we exit with a nonzero return value.
(...skipping 22 matching lines...) Expand all
62 exit 1 56 exit 1
63 fi 57 fi
64 GM_ARGS="$1" 58 GM_ARGS="$1"
65 ACTUAL_OUTPUT_DIR="$2/$OUTPUT_ACTUAL_SUBDIR" 59 ACTUAL_OUTPUT_DIR="$2/$OUTPUT_ACTUAL_SUBDIR"
66 EXPECTED_OUTPUT_DIR="$2/$OUTPUT_EXPECTED_SUBDIR" 60 EXPECTED_OUTPUT_DIR="$2/$OUTPUT_EXPECTED_SUBDIR"
67 JSON_SUMMARY_FILE="$ACTUAL_OUTPUT_DIR/json-summary.txt" 61 JSON_SUMMARY_FILE="$ACTUAL_OUTPUT_DIR/json-summary.txt"
68 62
69 rm -rf $ACTUAL_OUTPUT_DIR 63 rm -rf $ACTUAL_OUTPUT_DIR
70 mkdir -p $ACTUAL_OUTPUT_DIR 64 mkdir -p $ACTUAL_OUTPUT_DIR
71 65
72 COMMAND="$GM_BINARY $GM_ARGS --writeJsonSummaryPath $JSON_SUMMARY_FILE" 66 COMMAND="$GM_BINARY $GM_ARGS --writeJsonSummaryPath $JSON_SUMMARY_FILE --write Path $ACTUAL_OUTPUT_DIR/writePath --mismatchPath $ACTUAL_OUTPUT_DIR/mismatchPath "
epoger 2013/05/09 17:37:29 The actual scripting change (as opposed to all the
73 if [ $WRITE_IMAGE_FILES != 0 ]; then
74 COMMAND="$COMMAND --writePath $ACTUAL_OUTPUT_DIR/writePath --mismatchPath $A CTUAL_OUTPUT_DIR/mismatchPath"
75 fi
76 67
77 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line 68 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line
78 $COMMAND >$ACTUAL_OUTPUT_DIR/stdout 2>$ACTUAL_OUTPUT_DIR/stderr 69 $COMMAND >$ACTUAL_OUTPUT_DIR/stdout 2>$ACTUAL_OUTPUT_DIR/stderr
79 echo $? >$ACTUAL_OUTPUT_DIR/return_value 70 echo $? >$ACTUAL_OUTPUT_DIR/return_value
80 71
81 # Only compare selected lines in the stdout, to ignore any spurious lines 72 # Only compare selected lines in the stdout, to ignore any spurious lines
82 # as noted in http://code.google.com/p/skia/issues/detail?id=1068 . 73 # as noted in http://code.google.com/p/skia/issues/detail?id=1068 .
83 # 74 #
84 # TODO(epoger): This is still hacky... we need to rewrite this script in 75 # TODO(epoger): This is still hacky... we need to rewrite this script in
85 # Python soon, and make stuff like this more maintainable. 76 # Python soon, and make stuff like this more maintainable.
86 grep ^GM: $ACTUAL_OUTPUT_DIR/stdout >$ACTUAL_OUTPUT_DIR/stdout-tmp 77 grep ^GM: $ACTUAL_OUTPUT_DIR/stdout >$ACTUAL_OUTPUT_DIR/stdout-tmp
87 mv $ACTUAL_OUTPUT_DIR/stdout-tmp $ACTUAL_OUTPUT_DIR/stdout 78 mv $ACTUAL_OUTPUT_DIR/stdout-tmp $ACTUAL_OUTPUT_DIR/stdout
88 grep ^GM: $ACTUAL_OUTPUT_DIR/stderr >$ACTUAL_OUTPUT_DIR/stderr-tmp 79 grep ^GM: $ACTUAL_OUTPUT_DIR/stderr >$ACTUAL_OUTPUT_DIR/stderr-tmp
89 mv $ACTUAL_OUTPUT_DIR/stderr-tmp $ACTUAL_OUTPUT_DIR/stderr 80 mv $ACTUAL_OUTPUT_DIR/stderr-tmp $ACTUAL_OUTPUT_DIR/stderr
90 81
91 if [ $WRITE_IMAGE_FILES != 0 ]; then 82 # Replace image file contents with just the filename, for two reasons:
92 for IMAGEFILE in $(ls $ACTUAL_OUTPUT_DIR/*/*/*.png); do 83 # 1. Image file encoding may vary by platform
93 SUM=$(sum $IMAGEFILE) 84 # 2. https://code.google.com/p/chromium/issues/detail?id=169600
94 echo "Replaced image bytes with a checksum, because of https://code.google .com/p/chromium/issues/detail?id=169600 ('gcl/upload.py fail to upload binary fi les to rietveld')" >$IMAGEFILE 85 # ('gcl/upload.py fail to upload binary files to rietveld')
95 echo $SUM >> $IMAGEFILE 86 for IMAGEFILE in $(ls $ACTUAL_OUTPUT_DIR/*/*/*.png); do
96 done 87 echo "[contents of $IMAGEFILE]" >$IMAGEFILE
97 for MISMATCHDIR in $(ls -d $ACTUAL_OUTPUT_DIR/mismatchPath/*); do 88 done
98 echo "Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories." >$MISMATCHDIR/bogusfile 89 for MISMATCHDIR in $(ls -d $ACTUAL_OUTPUT_DIR/mismatchPath/*); do
99 done 90 echo "Created additional file to make sure directory isn't empty, because se lf-test cannot handle empty directories." >$MISMATCHDIR/bogusfile
100 fi 91 done
101 92
102 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR 93 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
103 } 94 }
104 95
105 # Create input dir (at path $1) with expectations (both image and json) 96 # Create input dir (at path $1) with expectations (both image and json)
106 # that gm will match or mismatch as appropriate. 97 # that gm will match or mismatch as appropriate.
107 # 98 #
108 # We used to check these files into SVN, but then we needed to rebasline them 99 # We used to check these files into SVN, but then we needed to rebasline them
109 # when our drawing changed at all... so, as proposed in 100 # when our drawing changed at all... so, as proposed in
110 # http://code.google.com/p/skia/issues/detail?id=1068 , we generate them 101 # http://code.google.com/p/skia/issues/detail?id=1068 , we generate them
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 185
195 # Ignore some error types (including ExpectationsMismatch) 186 # Ignore some error types (including ExpectationsMismatch)
196 gm_test "--ignoreErrorTypes ExpectationsMismatch NoGpuContext --verbose --hierar chy --match selftest1 $CONFIGS -r $GM_INPUTS/json/different-pixels.json" "$GM_OU TPUTS/ignore-expectations-mismatch" 187 gm_test "--ignoreErrorTypes ExpectationsMismatch NoGpuContext --verbose --hierar chy --match selftest1 $CONFIGS -r $GM_INPUTS/json/different-pixels.json" "$GM_OU TPUTS/ignore-expectations-mismatch"
197 188
198 if [ $ENCOUNTERED_ANY_ERRORS == 0 ]; then 189 if [ $ENCOUNTERED_ANY_ERRORS == 0 ]; then
199 echo "All tests passed." 190 echo "All tests passed."
200 exit 0 191 exit 0
201 else 192 else
202 exit 1 193 exit 1
203 fi 194 fi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698