| 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) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 done | 113 done |
| 114 | 114 |
| 115 # Add a file to any empty subdirectories. | 115 # Add a file to any empty subdirectories. |
| 116 for DIR in $(find $ACTUAL_OUTPUT_DIR -mindepth 1 -type d); do | 116 for DIR in $(find $ACTUAL_OUTPUT_DIR -mindepth 1 -type d); do |
| 117 echo "Created additional file to make sure directory isn't empty, because se
lf-test cannot handle empty directories." >$DIR/bogusfile | 117 echo "Created additional file to make sure directory isn't empty, because se
lf-test cannot handle empty directories." >$DIR/bogusfile |
| 118 done | 118 done |
| 119 | 119 |
| 120 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR | 120 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 121 } | 121 } |
| 122 | 122 |
| 123 # Swap contents of two files at paths $1 and $2. |
| 124 function swap_files { |
| 125 if [ $# != 2 ]; then |
| 126 echo "swap_files requires exactly 2 parameters, got $#" |
| 127 exit 1 |
| 128 fi |
| 129 mv "$1" "$1.tmp" |
| 130 mv "$2" "$1" |
| 131 mv "$1.tmp" "$2" |
| 132 } |
| 133 |
| 123 # Create input dir (at path $1) with expectations (both image and json) | 134 # Create input dir (at path $1) with expectations (both image and json) |
| 124 # that gm will match or mismatch as appropriate. | 135 # that gm will match or mismatch as appropriate. |
| 125 # | 136 # |
| 126 # We used to check these files into SVN, but then we needed to rebaseline them | 137 # We used to check these files into SVN, but then we needed to rebaseline them |
| 127 # when our drawing changed at all... so, as proposed in | 138 # when our drawing changed at all... so, as proposed in |
| 128 # http://code.google.com/p/skia/issues/detail?id=1068 , we generate them | 139 # http://code.google.com/p/skia/issues/detail?id=1068 , we generate them |
| 129 # new each time. | 140 # new each time. |
| 130 function create_inputs_dir { | 141 function create_inputs_dir { |
| 131 if [ $# != 1 ]; then | 142 if [ $# != 1 ]; then |
| 132 echo "create_inputs_dir requires exactly 1 parameter, got $#" | 143 echo "create_inputs_dir requires exactly 1 parameter, got $#" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 150 $GM_BINARY --hierarchy --match selftest1 $CONFIGS -w $THIS_IMAGE_DIR | 161 $GM_BINARY --hierarchy --match selftest1 $CONFIGS -w $THIS_IMAGE_DIR |
| 151 echo "more bytes that do not change the image pixels" \ | 162 echo "more bytes that do not change the image pixels" \ |
| 152 >> $THIS_IMAGE_DIR/8888/selftest1.png | 163 >> $THIS_IMAGE_DIR/8888/selftest1.png |
| 153 echo "more bytes that do not change the image pixels" \ | 164 echo "more bytes that do not change the image pixels" \ |
| 154 >> $THIS_IMAGE_DIR/565/selftest1.png | 165 >> $THIS_IMAGE_DIR/565/selftest1.png |
| 155 $GM_BINARY --hierarchy --match selftest1 $CONFIGS -r $THIS_IMAGE_DIR \ | 166 $GM_BINARY --hierarchy --match selftest1 $CONFIGS -r $THIS_IMAGE_DIR \ |
| 156 --writeJsonSummaryPath $JSON_DIR/identical-pixels.json | 167 --writeJsonSummaryPath $JSON_DIR/identical-pixels.json |
| 157 | 168 |
| 158 THIS_IMAGE_DIR=$IMAGES_DIR/different-pixels | 169 THIS_IMAGE_DIR=$IMAGES_DIR/different-pixels |
| 159 mkdir -p $THIS_IMAGE_DIR | 170 mkdir -p $THIS_IMAGE_DIR |
| 160 $GM_BINARY --hierarchy --match selftest2 $CONFIGS -w $THIS_IMAGE_DIR | 171 $GM_BINARY --hierarchy --match selftest $CONFIGS -w $THIS_IMAGE_DIR |
| 161 mv $THIS_IMAGE_DIR/8888/selftest2.png $THIS_IMAGE_DIR/8888/selftest1.png | 172 swap_files $THIS_IMAGE_DIR/8888/selftest2.png $THIS_IMAGE_DIR/8888/selftest1.p
ng |
| 162 mv $THIS_IMAGE_DIR/565/selftest2.png $THIS_IMAGE_DIR/565/selftest1.png | 173 swap_files $THIS_IMAGE_DIR/565/selftest2.png $THIS_IMAGE_DIR/565/selftest1.pn
g |
| 163 $GM_BINARY --hierarchy --match selftest1 $CONFIGS -r $THIS_IMAGE_DIR \ | 174 $GM_BINARY --hierarchy --match selftest $CONFIGS -r $THIS_IMAGE_DIR \ |
| 164 --writeJsonSummaryPath $JSON_DIR/different-pixels.json | 175 --writeJsonSummaryPath $JSON_DIR/different-pixels.json |
| 165 | 176 |
| 166 # Create another JSON expectations file which is identical to | 177 # Create another JSON expectations file which is identical to |
| 167 # different-pixels.json, but in which the *first* ignore-failure is changed | 178 # different-pixels.json, but in which the *first* ignore-failure is changed |
| 168 # from false to true. | 179 # from false to true. |
| 169 OLD='"ignore-failure" : false' | 180 OLD='"ignore-failure" : false' |
| 170 NEW='"ignore-failure" : true' | 181 NEW='"ignore-failure" : true' |
| 171 sed -e "0,/$OLD/{s/$OLD/$NEW/}" $JSON_DIR/different-pixels.json \ | 182 sed -e "0,/$OLD/{s/$OLD/$NEW/}" $JSON_DIR/different-pixels.json \ |
| 172 >$JSON_DIR/different-pixels-ignore-some-failures.json | 183 >$JSON_DIR/different-pixels-ignore-some-failures.json |
| 173 | 184 |
| 174 THIS_IMAGE_DIR=$IMAGES_DIR/different-pixels-no-hierarchy | 185 THIS_IMAGE_DIR=$IMAGES_DIR/different-pixels-no-hierarchy |
| 175 mkdir -p $THIS_IMAGE_DIR | 186 mkdir -p $THIS_IMAGE_DIR |
| 176 $GM_BINARY --match selftest2 $CONFIGS -w $THIS_IMAGE_DIR | 187 $GM_BINARY --match selftest2 $CONFIGS -w $THIS_IMAGE_DIR |
| 177 mv $THIS_IMAGE_DIR/selftest2_8888.png $THIS_IMAGE_DIR/selftest1_8888.png | 188 mv $THIS_IMAGE_DIR/selftest2_8888.png $THIS_IMAGE_DIR/selftest1_8888.png |
| 178 mv $THIS_IMAGE_DIR/selftest2_565.png $THIS_IMAGE_DIR/selftest1_565.png | 189 mv $THIS_IMAGE_DIR/selftest2_565.png $THIS_IMAGE_DIR/selftest1_565.png |
| 179 $GM_BINARY --match selftest1 $CONFIGS -r $THIS_IMAGE_DIR \ | 190 $GM_BINARY --match selftest1 $CONFIGS -r $THIS_IMAGE_DIR \ |
| 180 --writeJsonSummaryPath $JSON_DIR/different-pixels-no-hierarchy.json | 191 --writeJsonSummaryPath $JSON_DIR/different-pixels-no-hierarchy.json |
| 181 | 192 |
| 182 mkdir -p $IMAGES_DIR/empty-dir | 193 mkdir -p $IMAGES_DIR/empty-dir |
| 183 | 194 |
| 184 echo "# Comment line" >$GM_IGNORE_FAILURES_FILE | 195 echo "# Comment line" >$GM_IGNORE_FAILURES_FILE |
| 185 echo "" >>$GM_IGNORE_FAILURES_FILE | 196 echo "" >>$GM_IGNORE_FAILURES_FILE |
| 186 echo "# ignore any test runs whose filename contains '8888/selfte'" >>$GM_IGNO
RE_FAILURES_FILE | 197 echo "# ignore any runs of the 'selftest1' test" >>$GM_IGNORE_FAILURES_FILE |
| 187 echo "# (in other words, config is 8888 and test name starts with 'selfte')"
>>$GM_IGNORE_FAILURES_FILE | 198 echo "selftest1" >>$GM_IGNORE_FAILURES_FILE |
| 188 echo "8888/selfte" >>$GM_IGNORE_FAILURES_FILE | 199 echo "" >>$GM_IGNORE_FAILURES_FILE |
| 200 echo "# make sure we don't do partial matches (should NOT ignore 'selftest2' r
uns)" >>$GM_IGNORE_FAILURES_FILE |
| 201 echo "selftest" >>$GM_IGNORE_FAILURES_FILE |
| 189 } | 202 } |
| 190 | 203 |
| 191 GM_TESTDIR=gm/tests | 204 GM_TESTDIR=gm/tests |
| 192 GM_INPUTS=$GM_TESTDIR/inputs | 205 GM_INPUTS=$GM_TESTDIR/inputs |
| 193 GM_OUTPUTS=$GM_TESTDIR/outputs | 206 GM_OUTPUTS=$GM_TESTDIR/outputs |
| 194 GM_TEMPFILES=$GM_TESTDIR/tempfiles | 207 GM_TEMPFILES=$GM_TESTDIR/tempfiles |
| 195 GM_IGNORE_FAILURES_FILE=$GM_INPUTS/ignored-tests.txt | 208 GM_IGNORE_FAILURES_FILE=$GM_INPUTS/ignored-tests.txt |
| 196 | 209 |
| 197 create_inputs_dir $GM_INPUTS | 210 create_inputs_dir $GM_INPUTS |
| 198 | 211 |
| 199 # Compare generated image against an input image file with identical bytes. | 212 # Compare generated image against an input image file with identical bytes. |
| 200 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/i
dentical-bytes" "$GM_OUTPUTS/compared-against-identical-bytes-images" | 213 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/i
dentical-bytes" "$GM_OUTPUTS/compared-against-identical-bytes-images" |
| 201 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/ide
ntical-bytes.json" "$GM_OUTPUTS/compared-against-identical-bytes-json" | 214 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/ide
ntical-bytes.json" "$GM_OUTPUTS/compared-against-identical-bytes-json" |
| 202 | 215 |
| 203 # Compare generated image against an input image file with identical pixels but
different PNG encoding. | 216 # Compare generated image against an input image file with identical pixels but
different PNG encoding. |
| 204 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/i
dentical-pixels" "$GM_OUTPUTS/compared-against-identical-pixels-images" | 217 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/i
dentical-pixels" "$GM_OUTPUTS/compared-against-identical-pixels-images" |
| 205 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/ide
ntical-pixels.json" "$GM_OUTPUTS/compared-against-identical-pixels-json" | 218 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/ide
ntical-pixels.json" "$GM_OUTPUTS/compared-against-identical-pixels-json" |
| 206 | 219 |
| 207 # Compare generated image against an input image file with different pixels. | 220 # Compare generated image against an input image file with different pixels. |
| 208 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/d
ifferent-pixels" "$GM_OUTPUTS/compared-against-different-pixels-images" | 221 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/d
ifferent-pixels" "$GM_OUTPUTS/compared-against-different-pixels-images" |
| 209 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/dif
ferent-pixels.json" "$GM_OUTPUTS/compared-against-different-pixels-json" | 222 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/dif
ferent-pixels.json" "$GM_OUTPUTS/compared-against-different-pixels-json" |
| 210 | 223 |
| 211 # Exercise --ignoreFailuresFile flag. | 224 # Exercise --ignoreFailuresFile flag. |
| 212 gm_test "--verbose --hierarchy --match selftest1 --ignoreFailuresFile $GM_IGNORE
_FAILURES_FILE $CONFIGS -r $GM_INPUTS/json/different-pixels.json" "$GM_OUTPUTS/i
gnoring-one-test" | 225 # This should run two GM tests: selftest1 and selftest2. |
| 226 # Failures in selftest1 should be ignored, but failures in selftest2 should not. |
| 227 gm_test "--verbose --hierarchy --match selftest --ignoreFailuresFile $GM_IGNORE_
FAILURES_FILE $CONFIGS -r $GM_INPUTS/json/different-pixels.json" "$GM_OUTPUTS/ig
noring-one-test" |
| 213 | 228 |
| 214 # Compare different pixels, but with a SUBSET of the expectations marked as | 229 # Compare different pixels, but with a SUBSET of the expectations marked as |
| 215 # ignore-failure. | 230 # ignore-failure. |
| 216 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/dif
ferent-pixels-ignore-some-failures.json" "$GM_OUTPUTS/ignoring-some-failures" | 231 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/dif
ferent-pixels-ignore-some-failures.json" "$GM_OUTPUTS/ignoring-some-failures" |
| 217 | 232 |
| 218 # Compare generated image against an empty "expected image" dir. | 233 # Compare generated image against an empty "expected image" dir. |
| 219 # Even the tests that have been marked as ignore-failure should show up as | 234 # Even the tests that have been marked as ignore-failure (selftest1) should |
| 220 # no-comparison. | 235 # show up as no-comparison. |
| 221 gm_test "--verbose --hierarchy --match selftest1 --ignoreFailuresFile $GM_IGNORE
_FAILURES_FILE $CONFIGS -r $GM_INPUTS/images/empty-dir" "$GM_OUTPUTS/compared-ag
ainst-empty-dir" | 236 gm_test "--verbose --hierarchy --match selftest --ignoreFailuresFile $GM_IGNORE_
FAILURES_FILE $CONFIGS -r $GM_INPUTS/images/empty-dir" "$GM_OUTPUTS/compared-aga
inst-empty-dir" |
| 222 | 237 |
| 223 # Compare generated image against a nonexistent "expected image" dir. | 238 # Compare generated image against a nonexistent "expected image" dir. |
| 224 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r ../path/to/nowhere"
"$GM_OUTPUTS/compared-against-nonexistent-dir" | 239 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS -r ../path/to/nowhere"
"$GM_OUTPUTS/compared-against-nonexistent-dir" |
| 225 | 240 |
| 226 # Compare generated image against an empty "expected image" dir, but NOT in verb
ose mode. | 241 # Compare generated image against an empty "expected image" dir, but NOT in verb
ose mode. |
| 227 gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/empty-dir"
"$GM_OUTPUTS/nonverbose" | 242 gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/empty-dir"
"$GM_OUTPUTS/nonverbose" |
| 228 | 243 |
| 229 # Add pdf to the list of configs. | 244 # Add pdf to the list of configs. |
| 230 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS pdf -r $GM_INPUTS/json
/identical-bytes.json" "$GM_OUTPUTS/add-config-pdf" | 245 gm_test "--verbose --hierarchy --match selftest1 $CONFIGS pdf -r $GM_INPUTS/json
/identical-bytes.json" "$GM_OUTPUTS/add-config-pdf" |
| 231 | 246 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 258 for CASE in $FAILING_CASES; do | 273 for CASE in $FAILING_CASES; do |
| 259 assert_fails "python gm/display_json_results.py $GM_OUTPUTS/$CASE/$OUTPUT_EXPE
CTED_SUBDIR/json-summary.txt" | 274 assert_fails "python gm/display_json_results.py $GM_OUTPUTS/$CASE/$OUTPUT_EXPE
CTED_SUBDIR/json-summary.txt" |
| 260 done | 275 done |
| 261 | 276 |
| 262 if [ $ENCOUNTERED_ANY_ERRORS == 0 ]; then | 277 if [ $ENCOUNTERED_ANY_ERRORS == 0 ]; then |
| 263 echo "All tests passed." | 278 echo "All tests passed." |
| 264 exit 0 | 279 exit 0 |
| 265 else | 280 else |
| 266 exit 1 | 281 exit 1 |
| 267 fi | 282 fi |
| OLD | NEW |