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 # TODO: currently, this only passes on Linux (which is the platform that | 8 # TODO: because this is written as a shell script (instead of, say, Python) |
9 # the housekeeper bot runs on, e.g. | 9 # it only runs on Linux and Mac. |
10 # http://70.32.156.51:10117/builders/Skia_PerCommit_House_Keeping/builds/1417/st
eps/RunGmSelfTests/logs/stdio ) | |
11 # See https://code.google.com/p/skia/issues/detail?id=677 | 10 # See https://code.google.com/p/skia/issues/detail?id=677 |
12 # ('make tools/tests/run.sh work cross-platform') | 11 # ('make tools/tests/run.sh work cross-platform') |
13 # Ideally, these tests should pass on all development platforms... | 12 # Ideally, these tests should pass on all development platforms... |
14 # otherwise, how can developers be expected to test them before committing a | 13 # otherwise, how can developers be expected to test them before committing a |
15 # change? | 14 # change? |
16 | 15 |
17 # cd into .../trunk so all the paths will work | 16 # cd into .../trunk so all the paths will work |
18 cd $(dirname $0)/../.. | 17 cd $(dirname $0)/../.. |
19 | 18 |
20 # TODO(epoger): make it look in Release and/or Debug | 19 # TODO(epoger): make it look in Release and/or Debug |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 # Only compare selected lines in the stdout, to ignore any spurious lines | 66 # Only compare selected lines in the stdout, to ignore any spurious lines |
68 # as noted in http://code.google.com/p/skia/issues/detail?id=1068 . | 67 # as noted in http://code.google.com/p/skia/issues/detail?id=1068 . |
69 # | 68 # |
70 # TODO(epoger): This is still hacky... we need to rewrite this script in | 69 # TODO(epoger): This is still hacky... we need to rewrite this script in |
71 # Python soon, and make stuff like this more maintainable. | 70 # Python soon, and make stuff like this more maintainable. |
72 grep --regexp=^reading --regexp=^writing --regexp=^drawing \ | 71 grep --regexp=^reading --regexp=^writing --regexp=^drawing \ |
73 --regexp=^FAILED --regexp=^Ran $ACTUAL_OUTPUT_DIR/stdout \ | 72 --regexp=^FAILED --regexp=^Ran $ACTUAL_OUTPUT_DIR/stdout \ |
74 >$ACTUAL_OUTPUT_DIR/stdout-tmp | 73 >$ACTUAL_OUTPUT_DIR/stdout-tmp |
75 mv $ACTUAL_OUTPUT_DIR/stdout-tmp $ACTUAL_OUTPUT_DIR/stdout | 74 mv $ACTUAL_OUTPUT_DIR/stdout-tmp $ACTUAL_OUTPUT_DIR/stdout |
76 | 75 |
77 # Replace particular checksums in json summary with a placeholder, so | |
78 # we don't need to rebaseline these json files when our drawing routines | |
79 # change. | |
80 sed -e 's/"checksum" : [0-9]*/"checksum" : FAKE/g' \ | |
81 --in-place $JSON_SUMMARY_FILE | |
82 sed -e 's/"checksums" : \[ [0-9]* \]/"checksums" : [ FAKE ]/g' \ | |
83 --in-place $JSON_SUMMARY_FILE | |
84 | |
85 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR | 76 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
86 } | 77 } |
87 | 78 |
88 # Create input dir (at path $1) with expectations (both image and json) | 79 # Create input dir (at path $1) with expectations (both image and json) |
89 # that gm will match or mismatch as appropriate. | 80 # that gm will match or mismatch as appropriate. |
90 # | 81 # |
91 # We used to check these files into SVN, but then we needed to rebasline them | 82 # We used to check these files into SVN, but then we needed to rebasline them |
92 # when our drawing changed at all... so, as proposed in | 83 # when our drawing changed at all... so, as proposed in |
93 # http://code.google.com/p/skia/issues/detail?id=1068 , we generate them | 84 # http://code.google.com/p/skia/issues/detail?id=1068 , we generate them |
94 # new each time. | 85 # new each time. |
95 function create_inputs_dir { | 86 function create_inputs_dir { |
96 if [ $# != 1 ]; then | 87 if [ $# != 1 ]; then |
97 echo "create_inputs_dir requires exactly 1 parameter, got $#" | 88 echo "create_inputs_dir requires exactly 1 parameter, got $#" |
98 exit 1 | 89 exit 1 |
99 fi | 90 fi |
100 INPUTS_DIR="$1" | 91 INPUTS_DIR="$1" |
101 IMAGES_DIR=$INPUTS_DIR/images | 92 IMAGES_DIR=$INPUTS_DIR/images |
102 JSON_DIR=$INPUTS_DIR/json | 93 JSON_DIR=$INPUTS_DIR/json |
103 mkdir -p $IMAGES_DIR $JSON_DIR | 94 mkdir -p $IMAGES_DIR $JSON_DIR |
104 | 95 |
105 mkdir -p $IMAGES_DIR/identical-bytes | 96 mkdir -p $IMAGES_DIR/identical-bytes |
106 # Run GM to write out the images actually generated. | 97 # Run GM to write out the images actually generated. |
107 $GM_BINARY --hierarchy --match dashing2 $CONFIGS \ | 98 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ |
108 -w $IMAGES_DIR/identical-bytes | 99 -w $IMAGES_DIR/identical-bytes |
109 # Run GM again to read in those images and write them out as a JSON summary. | 100 # Run GM again to read in those images and write them out as a JSON summary. |
110 $GM_BINARY --hierarchy --match dashing2 $CONFIGS \ | 101 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ |
111 -r $IMAGES_DIR/identical-bytes \ | 102 -r $IMAGES_DIR/identical-bytes \ |
112 --writeJsonSummary $JSON_DIR/identical-bytes.json | 103 --writeJsonSummary $JSON_DIR/identical-bytes.json |
113 | 104 |
114 mkdir -p $IMAGES_DIR/identical-pixels | 105 mkdir -p $IMAGES_DIR/identical-pixels |
115 $GM_BINARY --hierarchy --match dashing2 $CONFIGS \ | 106 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ |
116 -w $IMAGES_DIR/identical-pixels | 107 -w $IMAGES_DIR/identical-pixels |
117 echo "more bytes that do not change the image pixels" \ | 108 echo "more bytes that do not change the image pixels" \ |
118 >> $IMAGES_DIR/identical-pixels/8888/dashing2.png | 109 >> $IMAGES_DIR/identical-pixels/8888/selftest1.png |
119 echo "more bytes that do not change the image pixels" \ | 110 echo "more bytes that do not change the image pixels" \ |
120 >> $IMAGES_DIR/identical-pixels/565/dashing2.png | 111 >> $IMAGES_DIR/identical-pixels/565/selftest1.png |
121 $GM_BINARY --hierarchy --match dashing2 $CONFIGS \ | 112 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ |
122 -r $IMAGES_DIR/identical-pixels \ | 113 -r $IMAGES_DIR/identical-pixels \ |
123 --writeJsonSummary $JSON_DIR/identical-pixels.json | 114 --writeJsonSummary $JSON_DIR/identical-pixels.json |
124 | 115 |
125 mkdir -p $IMAGES_DIR/different-pixels | 116 mkdir -p $IMAGES_DIR/different-pixels |
126 $GM_BINARY --hierarchy --match dashing3 $CONFIGS \ | 117 $GM_BINARY --hierarchy --match selftest2 $CONFIGS \ |
127 -w $IMAGES_DIR/different-pixels | 118 -w $IMAGES_DIR/different-pixels |
128 mv $IMAGES_DIR/different-pixels/8888/dashing3.png \ | 119 mv $IMAGES_DIR/different-pixels/8888/selftest2.png \ |
129 $IMAGES_DIR/different-pixels/8888/dashing2.png | 120 $IMAGES_DIR/different-pixels/8888/selftest1.png |
130 mv $IMAGES_DIR/different-pixels/565/dashing3.png \ | 121 mv $IMAGES_DIR/different-pixels/565/selftest2.png \ |
131 $IMAGES_DIR/different-pixels/565/dashing2.png | 122 $IMAGES_DIR/different-pixels/565/selftest1.png |
132 $GM_BINARY --hierarchy --match dashing2 $CONFIGS \ | 123 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ |
133 -r $IMAGES_DIR/different-pixels \ | 124 -r $IMAGES_DIR/different-pixels \ |
134 --writeJsonSummary $JSON_DIR/different-pixels.json | 125 --writeJsonSummary $JSON_DIR/different-pixels.json |
135 | 126 |
136 mkdir -p $IMAGES_DIR/empty-dir | 127 mkdir -p $IMAGES_DIR/empty-dir |
137 } | 128 } |
138 | 129 |
139 GM_TESTDIR=gm/tests | 130 GM_TESTDIR=gm/tests |
140 GM_INPUTS=$GM_TESTDIR/inputs | 131 GM_INPUTS=$GM_TESTDIR/inputs |
141 GM_OUTPUTS=$GM_TESTDIR/outputs | 132 GM_OUTPUTS=$GM_TESTDIR/outputs |
142 GM_TEMPFILES=$GM_TESTDIR/tempfiles | 133 GM_TEMPFILES=$GM_TESTDIR/tempfiles |
143 | 134 |
144 create_inputs_dir $GM_INPUTS | 135 create_inputs_dir $GM_INPUTS |
145 | 136 |
146 # Compare generated image against an input image file with identical bytes. | 137 # Compare generated image against an input image file with identical bytes. |
147 gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/images/identical-by
tes" "$GM_OUTPUTS/compared-against-identical-bytes-images" | 138 gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/identical-b
ytes" "$GM_OUTPUTS/compared-against-identical-bytes-images" |
148 gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/json/identical-byte
s.json" "$GM_OUTPUTS/compared-against-identical-bytes-json" | 139 gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/identical-byt
es.json" "$GM_OUTPUTS/compared-against-identical-bytes-json" |
149 | 140 |
150 # Compare generated image against an input image file with identical pixels but
different PNG encoding. | 141 # Compare generated image against an input image file with identical pixels but
different PNG encoding. |
151 gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/images/identical-pi
xels" "$GM_OUTPUTS/compared-against-identical-pixels-images" | 142 gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/identical-p
ixels" "$GM_OUTPUTS/compared-against-identical-pixels-images" |
152 gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/json/identical-pixe
ls.json" "$GM_OUTPUTS/compared-against-identical-pixels-json" | 143 gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/identical-pix
els.json" "$GM_OUTPUTS/compared-against-identical-pixels-json" |
153 | 144 |
154 # Compare generated image against an input image file with different pixels. | 145 # Compare generated image against an input image file with different pixels. |
155 gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/images/different-pi
xels" "$GM_OUTPUTS/compared-against-different-pixels-images" | 146 gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/different-p
ixels" "$GM_OUTPUTS/compared-against-different-pixels-images" |
156 gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/json/different-pixe
ls.json" "$GM_OUTPUTS/compared-against-different-pixels-json" | 147 gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/different-pix
els.json" "$GM_OUTPUTS/compared-against-different-pixels-json" |
157 | 148 |
158 # Compare generated image against an empty "expected image" dir. | 149 # Compare generated image against an empty "expected image" dir. |
159 gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/images/empty-dir" "
$GM_OUTPUTS/compared-against-empty-dir" | 150 gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/empty-dir"
"$GM_OUTPUTS/compared-against-empty-dir" |
160 | 151 |
161 # If run without "-r", the JSON's "actual-results" section should contain | 152 # If run without "-r", the JSON's "actual-results" section should contain |
162 # actual checksums marked as "failure-ignored", but the "expected-results" | 153 # actual checksums marked as "failure-ignored", but the "expected-results" |
163 # section should be empty. | 154 # section should be empty. |
164 gm_test "--hierarchy --match dashing2 $CONFIGS" "$GM_OUTPUTS/no-readpath" | 155 gm_test "--hierarchy --match selftest1 $CONFIGS" "$GM_OUTPUTS/no-readpath" |
165 | 156 |
166 # Run a test which generates partially transparent images, write out those | 157 # Run a test which generates partially transparent images, write out those |
167 # images, and read them back in. | 158 # images, and read them back in. |
168 # | 159 # |
169 # This test would have caught | 160 # This test would have caught |
170 # http://code.google.com/p/skia/issues/detail?id=1079 ('gm generating | 161 # http://code.google.com/p/skia/issues/detail?id=1079 ('gm generating |
171 # spurious pixel_error messages as of r7258'). | 162 # spurious pixel_error messages as of r7258'). |
172 IMAGEDIR=$GM_TEMPFILES/aaclip-images | 163 IMAGEDIR=$GM_TEMPFILES/aaclip-images |
173 rm -rf $IMAGEDIR | 164 rm -rf $IMAGEDIR |
174 mkdir -p $IMAGEDIR | 165 mkdir -p $IMAGEDIR |
175 gm_test "--match simpleaaclip_path $CONFIGS -w $IMAGEDIR" "$GM_OUTPUTS/aaclip-wr
ite" | 166 gm_test "--match simpleaaclip_path $CONFIGS -w $IMAGEDIR" "$GM_OUTPUTS/aaclip-wr
ite" |
176 gm_test "--match simpleaaclip_path $CONFIGS -r $IMAGEDIR" "$GM_OUTPUTS/aaclip-re
adback" | 167 gm_test "--match simpleaaclip_path $CONFIGS -r $IMAGEDIR" "$GM_OUTPUTS/aaclip-re
adback" |
177 | 168 |
178 echo "All tests passed." | 169 echo "All tests passed." |
OLD | NEW |