OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Tests for our tools. | 3 # Tests for our tools. |
4 # | 4 # |
5 # TODO: currently, this only passes on Linux (which is the platform that | 5 # TODO: currently, this only passes on Linux (which is the platform that |
6 # the housekeeper bot runs on, e.g. | 6 # the housekeeper bot runs on, e.g. |
7 # http://70.32.156.51:10117/builders/Skia_PerCommit_House_Keeping/builds/1415/st
eps/RunToolSelfTests/logs/stdio ) | 7 # http://70.32.156.51:10117/builders/Skia_PerCommit_House_Keeping/builds/1415/st
eps/RunToolSelfTests/logs/stdio ) |
8 # See https://code.google.com/p/skia/issues/detail?id=677 | 8 # See https://code.google.com/p/skia/issues/detail?id=677 |
9 # ('make tools/tests/run.sh work cross-platform') | 9 # ('make tools/tests/run.sh work cross-platform') |
10 # Ideally, these tests should pass on all development platforms... | 10 # Ideally, these tests should pass on all development platforms... |
(...skipping 21 matching lines...) Expand all Loading... |
32 # Compare contents of all files within directories $1 and $2, | 32 # Compare contents of all files within directories $1 and $2, |
33 # EXCEPT for any dotfiles. | 33 # EXCEPT for any dotfiles. |
34 # If there are any differences, a description is written to stdout and | 34 # If there are any differences, a description is written to stdout and |
35 # we exit with a nonzero return value. | 35 # we exit with a nonzero return value. |
36 # Otherwise, we write nothing to stdout and return. | 36 # Otherwise, we write nothing to stdout and return. |
37 function compare_directories { | 37 function compare_directories { |
38 if [ $# != 2 ]; then | 38 if [ $# != 2 ]; then |
39 echo "compare_directories requires exactly 2 parameters, got $#" | 39 echo "compare_directories requires exactly 2 parameters, got $#" |
40 exit 1 | 40 exit 1 |
41 fi | 41 fi |
42 diff --exclude=.* $1 $2 | 42 diff --recursive --exclude=.* $1 $2 |
43 if [ $? != 0 ]; then | 43 if [ $? != 0 ]; then |
44 echo "failed in: compare_directories $1 $2" | 44 echo "failed in: compare_directories $1 $2" |
45 exit 1 | 45 exit 1 |
46 fi | 46 fi |
47 } | 47 } |
48 | 48 |
49 # Run skdiff with arguments in $1 (plus implicit final argument causing skdiff | 49 # Run skdiff with arguments in $1 (plus implicit final argument causing skdiff |
50 # to write its output, if any, to directory $2/output-actual). | 50 # to write its output, if any, to directory $2/output-actual). |
51 # Then compare its results against those in $2/output-expected. | 51 # Then compare its results against those in $2/output-expected. |
52 function skdiff_test { | 52 function skdiff_test { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout | 122 $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
123 echo $? >$ACTUAL_OUTPUT_DIR/return_value | 123 echo $? >$ACTUAL_OUTPUT_DIR/return_value |
124 END_TIMESTAMP=$(date +%s) | 124 END_TIMESTAMP=$(date +%s) |
125 | 125 |
126 SECONDS_RUN=$(expr $END_TIMESTAMP - $START_TIMESTAMP) | 126 SECONDS_RUN=$(expr $END_TIMESTAMP - $START_TIMESTAMP) |
127 echo "bench_graph_svg.py for $PLATFORM took $SECONDS_RUN seconds to complete" | 127 echo "bench_graph_svg.py for $PLATFORM took $SECONDS_RUN seconds to complete" |
128 | 128 |
129 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR | 129 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
130 } | 130 } |
131 | 131 |
| 132 # Test rebaseline.py's soon-to-disappear image file rebaselining capability. |
| 133 # |
132 # Run rebaseline.py with arguments in $1, recording its dry-run output. | 134 # Run rebaseline.py with arguments in $1, recording its dry-run output. |
133 # Then compare that dry-run output to the content of $2/output-expected. | 135 # Then compare that dry-run output to the content of $2/output-expected. |
134 function rebaseline_test { | 136 function rebaseline_images_test { |
135 if [ $# != 2 ]; then | 137 if [ $# != 2 ]; then |
136 echo "rebaseline_test requires exactly 2 parameters, got $#" | 138 echo "rebaseline_test requires exactly 2 parameters, got $#" |
137 exit 1 | 139 exit 1 |
138 fi | 140 fi |
139 ARGS="$1" | 141 ARGS="$1" |
140 ACTUAL_OUTPUT_DIR="$2/output-actual" | 142 ACTUAL_OUTPUT_DIR="$2/output-actual" |
141 EXPECTED_OUTPUT_DIR="$2/output-expected" | 143 EXPECTED_OUTPUT_DIR="$2/output-expected" |
142 | 144 |
143 rm -rf $ACTUAL_OUTPUT_DIR | 145 rm -rf $ACTUAL_OUTPUT_DIR |
144 mkdir -p $ACTUAL_OUTPUT_DIR | 146 mkdir -p $ACTUAL_OUTPUT_DIR |
145 COMMAND="python tools/rebaseline.py --dry-run $ARGS" | 147 COMMAND="python tools/rebaseline.py --dry-run $ARGS" |
146 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line | 148 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
147 $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout | 149 $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
148 echo $? >$ACTUAL_OUTPUT_DIR/return_value | 150 echo $? >$ACTUAL_OUTPUT_DIR/return_value |
149 | 151 |
150 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR | 152 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
151 } | 153 } |
152 | 154 |
| 155 # Test rebaseline.py's new JSON-format expectations rebaselining capability. |
| 156 # |
| 157 # Copy expected-result.json files from $1 into a dir where they can be modified. |
| 158 # Run rebaseline.py with arguments in $2, recording its output. |
| 159 # Then compare the output (and modified expected-result.json files) to the |
| 160 # content of $2/output-expected. |
| 161 function rebaseline_test { |
| 162 if [ $# != 3 ]; then |
| 163 echo "rebaseline_test requires exactly 3 parameters, got $#" |
| 164 exit 1 |
| 165 fi |
| 166 COPY_EXPECTATIONS_FROM_DIR="$1" |
| 167 ARGS="$2" |
| 168 ACTUAL_OUTPUT_DIR="$3/output-actual" |
| 169 EXPECTED_OUTPUT_DIR="$3/output-expected" |
| 170 |
| 171 rm -rf $ACTUAL_OUTPUT_DIR |
| 172 mkdir -p $ACTUAL_OUTPUT_DIR |
| 173 EXPECTATIONS_TO_MODIFY_DIR="$ACTUAL_OUTPUT_DIR/gm-expectations" |
| 174 SUBDIRS=$(ls $COPY_EXPECTATIONS_FROM_DIR) |
| 175 for SUBDIR in $SUBDIRS; do |
| 176 mkdir -p $EXPECTATIONS_TO_MODIFY_DIR/$SUBDIR |
| 177 cp $COPY_EXPECTATIONS_FROM_DIR/$SUBDIR/expected-results.json \ |
| 178 $EXPECTATIONS_TO_MODIFY_DIR/$SUBDIR |
| 179 done |
| 180 COMMAND="python tools/rebaseline.py --expectations-root $EXPECTATIONS_TO_MODIF
Y_DIR $ARGS" |
| 181 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
| 182 $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
| 183 echo $? >$ACTUAL_OUTPUT_DIR/return_value |
| 184 |
| 185 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 186 } |
| 187 |
153 # Run jsondiff.py with arguments in $1, recording its output. | 188 # Run jsondiff.py with arguments in $1, recording its output. |
154 # Then compare that output to the content of $2/output-expected. | 189 # Then compare that output to the content of $2/output-expected. |
155 function jsondiff_test { | 190 function jsondiff_test { |
156 if [ $# != 2 ]; then | 191 if [ $# != 2 ]; then |
157 echo "jsondiff_test requires exactly 2 parameters, got $#" | 192 echo "jsondiff_test requires exactly 2 parameters, got $#" |
158 exit 1 | 193 exit 1 |
159 fi | 194 fi |
160 ARGS="$1" | 195 ARGS="$1" |
161 ACTUAL_OUTPUT_DIR="$2/output-actual" | 196 ACTUAL_OUTPUT_DIR="$2/output-actual" |
162 EXPECTED_OUTPUT_DIR="$2/output-expected" | 197 EXPECTED_OUTPUT_DIR="$2/output-expected" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 echo "skimage self tests failed." | 258 echo "skimage self tests failed." |
224 exit 1 | 259 exit 1 |
225 fi | 260 fi |
226 | 261 |
227 # | 262 # |
228 # Test rebaseline.py ... | 263 # Test rebaseline.py ... |
229 # | 264 # |
230 | 265 |
231 REBASELINE_INPUT=tools/tests/rebaseline/input | 266 REBASELINE_INPUT=tools/tests/rebaseline/input |
232 REBASELINE_OUTPUT=tools/tests/rebaseline/output | 267 REBASELINE_OUTPUT=tools/tests/rebaseline/output |
233 rebaseline_test "--expectations-root fake/expectations/path --json-base-url file
:$REBASELINE_INPUT/json1 --tests test1 test2 --configs 565 8888 --subdirs base-a
ndroid-galaxy-nexus base-shuttle-win7-intel-float" "$REBASELINE_OUTPUT/subset" | 268 |
234 rebaseline_test "--json-base-url file:nonexistent-path --tests test1 test2" "$RE
BASELINE_OUTPUT/all" | 269 # These test the old image-file expectations. |
235 rebaseline_test "--json-base-url file:$REBASELINE_INPUT/json1 --subdirs base-and
roid-galaxy-nexus base-shuttle-win7-intel-float" "$REBASELINE_OUTPUT/using-json1
" | 270 rebaseline_images_test "--expectations-root fake/expectations/path --json-base-u
rl file:$REBASELINE_INPUT/json1 --tests test1 test2 --configs 565 8888 --subdirs
base-android-galaxy-nexus base-shuttle-win7-intel-float" "$REBASELINE_OUTPUT/su
bset" |
236 rebaseline_test "--json-base-url file:$REBASELINE_INPUT/json1 --subdirs base-and
roid-galaxy-nexus base-shuttle-win7-intel-float --add-new" "$REBASELINE_OUTPUT/u
sing-json1-add-new" | 271 rebaseline_images_test "--json-base-url file:nonexistent-path --tests test1 test
2" "$REBASELINE_OUTPUT/all" |
237 rebaseline_test "--json-base-url file:$REBASELINE_INPUT/json1 --subdirs base-and
roid-galaxy-nexus base-shuttle-win7-intel-float --expectations-root $REBASELINE_
INPUT/json1" "$REBASELINE_OUTPUT/using-json1-expectations" | 272 rebaseline_images_test "--json-base-url file:$REBASELINE_INPUT/json1 --subdirs b
ase-android-galaxy-nexus base-shuttle-win7-intel-float" "$REBASELINE_OUTPUT/usin
g-json1" |
| 273 rebaseline_images_test "--json-base-url file:$REBASELINE_INPUT/json1 --subdirs b
ase-android-galaxy-nexus base-shuttle-win7-intel-float --add-new" "$REBASELINE_O
UTPUT/using-json1-add-new" |
| 274 |
| 275 # These test the new JSON-format expectations. |
| 276 rebaseline_test "$REBASELINE_INPUT/json1" "--json-base-url file:$REBASELINE_INPU
T/json1 --subdirs base-android-galaxy-nexus base-shuttle-win7-intel-float" "$REB
ASELINE_OUTPUT/using-json1-expectations" |
238 | 277 |
239 # | 278 # |
240 # Test jsondiff.py ... | 279 # Test jsondiff.py ... |
241 # | 280 # |
242 | 281 |
243 JSONDIFF_INPUT=tools/tests/jsondiff/input | 282 JSONDIFF_INPUT=tools/tests/jsondiff/input |
244 JSONDIFF_OUTPUT=tools/tests/jsondiff/output | 283 JSONDIFF_OUTPUT=tools/tests/jsondiff/output |
245 jsondiff_test "$JSONDIFF_INPUT/old.json $JSONDIFF_INPUT/new.json" "$JSONDIFF_OUT
PUT/old-vs-new" | 284 jsondiff_test "$JSONDIFF_INPUT/old.json $JSONDIFF_INPUT/new.json" "$JSONDIFF_OUT
PUT/old-vs-new" |
246 | 285 |
247 | 286 |
248 echo "All tests passed." | 287 echo "All tests passed." |
OLD | NEW |