| OLD | NEW |
| 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 |
| 24 OUTPUT_ACTUAL_SUBDIR=output-actual | 30 OUTPUT_ACTUAL_SUBDIR=output-actual |
| 25 OUTPUT_EXPECTED_SUBDIR=output-expected | 31 OUTPUT_EXPECTED_SUBDIR=output-expected |
| 26 CONFIGS="--config 8888 565" | 32 CONFIGS="--config 8888 565" |
| 27 | 33 |
| 28 ENCOUNTERED_ANY_ERRORS=0 | 34 ENCOUNTERED_ANY_ERRORS=0 |
| 29 | 35 |
| 30 # Compare contents of all files within directories $1 and $2, | 36 # Compare contents of all files within directories $1 and $2, |
| 31 # EXCEPT for any dotfiles. | 37 # EXCEPT for any dotfiles. |
| 32 # If there are any differences, a description is written to stdout and | 38 # If there are any differences, a description is written to stdout and |
| 33 # we exit with a nonzero return value. | 39 # we exit with a nonzero return value. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 55 echo "gm_test requires exactly 2 parameters, got $#" | 61 echo "gm_test requires exactly 2 parameters, got $#" |
| 56 exit 1 | 62 exit 1 |
| 57 fi | 63 fi |
| 58 GM_ARGS="$1" | 64 GM_ARGS="$1" |
| 59 ACTUAL_OUTPUT_DIR="$2/$OUTPUT_ACTUAL_SUBDIR" | 65 ACTUAL_OUTPUT_DIR="$2/$OUTPUT_ACTUAL_SUBDIR" |
| 60 EXPECTED_OUTPUT_DIR="$2/$OUTPUT_EXPECTED_SUBDIR" | 66 EXPECTED_OUTPUT_DIR="$2/$OUTPUT_EXPECTED_SUBDIR" |
| 61 JSON_SUMMARY_FILE="$ACTUAL_OUTPUT_DIR/json-summary.txt" | 67 JSON_SUMMARY_FILE="$ACTUAL_OUTPUT_DIR/json-summary.txt" |
| 62 | 68 |
| 63 rm -rf $ACTUAL_OUTPUT_DIR | 69 rm -rf $ACTUAL_OUTPUT_DIR |
| 64 mkdir -p $ACTUAL_OUTPUT_DIR | 70 mkdir -p $ACTUAL_OUTPUT_DIR |
| 71 |
| 65 COMMAND="$GM_BINARY $GM_ARGS --writeJsonSummaryPath $JSON_SUMMARY_FILE" | 72 COMMAND="$GM_BINARY $GM_ARGS --writeJsonSummaryPath $JSON_SUMMARY_FILE" |
| 73 if [ $WRITE_IMAGE_FILES != 0 ]; then |
| 74 COMMAND="$COMMAND --writePath $ACTUAL_OUTPUT_DIR/writePath --mismatchPath $A
CTUAL_OUTPUT_DIR/mismatchPath" |
| 75 fi |
| 76 |
| 66 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line | 77 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
| 67 $COMMAND >$ACTUAL_OUTPUT_DIR/stdout 2>$ACTUAL_OUTPUT_DIR/stderr | 78 $COMMAND >$ACTUAL_OUTPUT_DIR/stdout 2>$ACTUAL_OUTPUT_DIR/stderr |
| 68 echo $? >$ACTUAL_OUTPUT_DIR/return_value | 79 echo $? >$ACTUAL_OUTPUT_DIR/return_value |
| 69 | 80 |
| 70 # Only compare selected lines in the stdout, to ignore any spurious lines | 81 # Only compare selected lines in the stdout, to ignore any spurious lines |
| 71 # as noted in http://code.google.com/p/skia/issues/detail?id=1068 . | 82 # as noted in http://code.google.com/p/skia/issues/detail?id=1068 . |
| 72 # | 83 # |
| 73 # TODO(epoger): This is still hacky... we need to rewrite this script in | 84 # TODO(epoger): This is still hacky... we need to rewrite this script in |
| 74 # Python soon, and make stuff like this more maintainable. | 85 # Python soon, and make stuff like this more maintainable. |
| 75 grep ^GM: $ACTUAL_OUTPUT_DIR/stdout >$ACTUAL_OUTPUT_DIR/stdout-tmp | 86 grep ^GM: $ACTUAL_OUTPUT_DIR/stdout >$ACTUAL_OUTPUT_DIR/stdout-tmp |
| 76 mv $ACTUAL_OUTPUT_DIR/stdout-tmp $ACTUAL_OUTPUT_DIR/stdout | 87 mv $ACTUAL_OUTPUT_DIR/stdout-tmp $ACTUAL_OUTPUT_DIR/stdout |
| 77 grep ^GM: $ACTUAL_OUTPUT_DIR/stderr >$ACTUAL_OUTPUT_DIR/stderr-tmp | 88 grep ^GM: $ACTUAL_OUTPUT_DIR/stderr >$ACTUAL_OUTPUT_DIR/stderr-tmp |
| 78 mv $ACTUAL_OUTPUT_DIR/stderr-tmp $ACTUAL_OUTPUT_DIR/stderr | 89 mv $ACTUAL_OUTPUT_DIR/stderr-tmp $ACTUAL_OUTPUT_DIR/stderr |
| 79 | 90 |
| 91 if [ $WRITE_IMAGE_FILES != 0 ]; then |
| 92 for IMAGEFILE in $(ls $ACTUAL_OUTPUT_DIR/*/*/*.png); do |
| 93 SUM=$(sum $IMAGEFILE) |
| 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 |
| 95 echo $SUM >> $IMAGEFILE |
| 96 done |
| 97 for MISMATCHDIR in $(ls -d $ACTUAL_OUTPUT_DIR/mismatchPath/*); do |
| 98 echo "Created additional file to make sure directory isn't empty, because
self-test cannot handle empty directories." >$MISMATCHDIR/bogusfile |
| 99 done |
| 100 fi |
| 101 |
| 80 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR | 102 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 81 } | 103 } |
| 82 | 104 |
| 83 # Create input dir (at path $1) with expectations (both image and json) | 105 # Create input dir (at path $1) with expectations (both image and json) |
| 84 # that gm will match or mismatch as appropriate. | 106 # that gm will match or mismatch as appropriate. |
| 85 # | 107 # |
| 86 # We used to check these files into SVN, but then we needed to rebasline them | 108 # We used to check these files into SVN, but then we needed to rebasline them |
| 87 # when our drawing changed at all... so, as proposed in | 109 # when our drawing changed at all... so, as proposed in |
| 88 # http://code.google.com/p/skia/issues/detail?id=1068 , we generate them | 110 # http://code.google.com/p/skia/issues/detail?id=1068 , we generate them |
| 89 # new each time. | 111 # new each time. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 194 |
| 173 # Ignore some error types (including ExpectationsMismatch) | 195 # Ignore some error types (including ExpectationsMismatch) |
| 174 gm_test "--ignoreErrorTypes ExpectationsMismatch NoGpuContext --verbose --hierar
chy --match selftest1 $CONFIGS -r $GM_INPUTS/json/different-pixels.json" "$GM_OU
TPUTS/ignore-expectations-mismatch" | 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" |
| 175 | 197 |
| 176 if [ $ENCOUNTERED_ANY_ERRORS == 0 ]; then | 198 if [ $ENCOUNTERED_ANY_ERRORS == 0 ]; then |
| 177 echo "All tests passed." | 199 echo "All tests passed." |
| 178 exit 0 | 200 exit 0 |
| 179 else | 201 else |
| 180 exit 1 | 202 exit 1 |
| 181 fi | 203 fi |
| OLD | NEW |