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: because this is written as a shell script (instead of, say, Python) | 8 # TODO: because this is written as a shell script (instead of, say, Python) |
9 # it only runs on Linux and Mac. | 9 # it only runs on Linux and Mac. |
10 # See https://code.google.com/p/skia/issues/detail?id=677 | 10 # See https://code.google.com/p/skia/issues/detail?id=677 |
11 # ('make tools/tests/run.sh work cross-platform') | 11 # ('make tools/tests/run.sh work cross-platform') |
12 # Ideally, these tests should pass on all development platforms... | 12 # Ideally, these tests should pass on all development platforms... |
13 # 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 |
14 # change? | 14 # change? |
15 | 15 |
16 # cd into .../trunk so all the paths will work | 16 # cd into .../trunk so all the paths will work |
17 cd $(dirname $0)/../.. | 17 cd $(dirname $0)/../.. |
18 | 18 |
19 # TODO(epoger): make it look in Release and/or Debug | 19 # TODO(epoger): make it look in Release and/or Debug |
20 GM_BINARY=out/Debug/gm | 20 GM_BINARY=out/Debug/gm |
21 | 21 |
22 OUTPUT_ACTUAL_SUBDIR=output-actual | 22 OUTPUT_ACTUAL_SUBDIR=output-actual |
23 OUTPUT_EXPECTED_SUBDIR=output-expected | 23 OUTPUT_EXPECTED_SUBDIR=output-expected |
24 CONFIGS="--config 8888 --config 565" | 24 CONFIGS="--config 8888 565" |
25 | 25 |
26 # Compare contents of all files within directories $1 and $2, | 26 # Compare contents of all files within directories $1 and $2, |
27 # EXCEPT for any dotfiles. | 27 # EXCEPT for any dotfiles. |
28 # If there are any differences, a description is written to stdout and | 28 # If there are any differences, a description is written to stdout and |
29 # we exit with a nonzero return value. | 29 # we exit with a nonzero return value. |
30 # Otherwise, we write nothing to stdout and return. | 30 # Otherwise, we write nothing to stdout and return. |
31 function compare_directories { | 31 function compare_directories { |
32 if [ $# != 2 ]; then | 32 if [ $# != 2 ]; then |
33 echo "compare_directories requires exactly 2 parameters, got $#" | 33 echo "compare_directories requires exactly 2 parameters, got $#" |
34 exit 1 | 34 exit 1 |
(...skipping 16 matching lines...) Expand all Loading... |
51 echo "gm_test requires exactly 2 parameters, got $#" | 51 echo "gm_test requires exactly 2 parameters, got $#" |
52 exit 1 | 52 exit 1 |
53 fi | 53 fi |
54 GM_ARGS="$1" | 54 GM_ARGS="$1" |
55 ACTUAL_OUTPUT_DIR="$2/$OUTPUT_ACTUAL_SUBDIR" | 55 ACTUAL_OUTPUT_DIR="$2/$OUTPUT_ACTUAL_SUBDIR" |
56 EXPECTED_OUTPUT_DIR="$2/$OUTPUT_EXPECTED_SUBDIR" | 56 EXPECTED_OUTPUT_DIR="$2/$OUTPUT_EXPECTED_SUBDIR" |
57 JSON_SUMMARY_FILE="$ACTUAL_OUTPUT_DIR/json-summary.txt" | 57 JSON_SUMMARY_FILE="$ACTUAL_OUTPUT_DIR/json-summary.txt" |
58 | 58 |
59 rm -rf $ACTUAL_OUTPUT_DIR | 59 rm -rf $ACTUAL_OUTPUT_DIR |
60 mkdir -p $ACTUAL_OUTPUT_DIR | 60 mkdir -p $ACTUAL_OUTPUT_DIR |
61 COMMAND="$GM_BINARY $GM_ARGS --writeJsonSummary $JSON_SUMMARY_FILE" | 61 COMMAND="$GM_BINARY $GM_ARGS --writeJsonSummaryPath $JSON_SUMMARY_FILE" |
62 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line | 62 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
63 $COMMAND >$ACTUAL_OUTPUT_DIR/stdout 2>$ACTUAL_OUTPUT_DIR/stderr | 63 $COMMAND >$ACTUAL_OUTPUT_DIR/stdout 2>$ACTUAL_OUTPUT_DIR/stderr |
64 echo $? >$ACTUAL_OUTPUT_DIR/return_value | 64 echo $? >$ACTUAL_OUTPUT_DIR/return_value |
65 | 65 |
66 # 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 |
67 # 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 . |
68 # | 68 # |
69 # 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 |
70 # Python soon, and make stuff like this more maintainable. | 70 # Python soon, and make stuff like this more maintainable. |
71 grep ^GM: $ACTUAL_OUTPUT_DIR/stdout >$ACTUAL_OUTPUT_DIR/stdout-tmp | 71 grep ^GM: $ACTUAL_OUTPUT_DIR/stdout >$ACTUAL_OUTPUT_DIR/stdout-tmp |
(...skipping 21 matching lines...) Expand all Loading... |
93 JSON_DIR=$INPUTS_DIR/json | 93 JSON_DIR=$INPUTS_DIR/json |
94 mkdir -p $IMAGES_DIR $JSON_DIR | 94 mkdir -p $IMAGES_DIR $JSON_DIR |
95 | 95 |
96 mkdir -p $IMAGES_DIR/identical-bytes | 96 mkdir -p $IMAGES_DIR/identical-bytes |
97 # Run GM to write out the images actually generated. | 97 # Run GM to write out the images actually generated. |
98 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ | 98 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ |
99 -w $IMAGES_DIR/identical-bytes | 99 -w $IMAGES_DIR/identical-bytes |
100 # 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. |
101 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ | 101 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ |
102 -r $IMAGES_DIR/identical-bytes \ | 102 -r $IMAGES_DIR/identical-bytes \ |
103 --writeJsonSummary $JSON_DIR/identical-bytes.json | 103 --writeJsonSummaryPath $JSON_DIR/identical-bytes.json |
104 | 104 |
105 mkdir -p $IMAGES_DIR/identical-pixels | 105 mkdir -p $IMAGES_DIR/identical-pixels |
106 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ | 106 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ |
107 -w $IMAGES_DIR/identical-pixels | 107 -w $IMAGES_DIR/identical-pixels |
108 echo "more bytes that do not change the image pixels" \ | 108 echo "more bytes that do not change the image pixels" \ |
109 >> $IMAGES_DIR/identical-pixels/8888/selftest1.png | 109 >> $IMAGES_DIR/identical-pixels/8888/selftest1.png |
110 echo "more bytes that do not change the image pixels" \ | 110 echo "more bytes that do not change the image pixels" \ |
111 >> $IMAGES_DIR/identical-pixels/565/selftest1.png | 111 >> $IMAGES_DIR/identical-pixels/565/selftest1.png |
112 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ | 112 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ |
113 -r $IMAGES_DIR/identical-pixels \ | 113 -r $IMAGES_DIR/identical-pixels \ |
114 --writeJsonSummary $JSON_DIR/identical-pixels.json | 114 --writeJsonSummaryPath $JSON_DIR/identical-pixels.json |
115 | 115 |
116 mkdir -p $IMAGES_DIR/different-pixels | 116 mkdir -p $IMAGES_DIR/different-pixels |
117 $GM_BINARY --hierarchy --match selftest2 $CONFIGS \ | 117 $GM_BINARY --hierarchy --match selftest2 $CONFIGS \ |
118 -w $IMAGES_DIR/different-pixels | 118 -w $IMAGES_DIR/different-pixels |
119 mv $IMAGES_DIR/different-pixels/8888/selftest2.png \ | 119 mv $IMAGES_DIR/different-pixels/8888/selftest2.png \ |
120 $IMAGES_DIR/different-pixels/8888/selftest1.png | 120 $IMAGES_DIR/different-pixels/8888/selftest1.png |
121 mv $IMAGES_DIR/different-pixels/565/selftest2.png \ | 121 mv $IMAGES_DIR/different-pixels/565/selftest2.png \ |
122 $IMAGES_DIR/different-pixels/565/selftest1.png | 122 $IMAGES_DIR/different-pixels/565/selftest1.png |
123 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ | 123 $GM_BINARY --hierarchy --match selftest1 $CONFIGS \ |
124 -r $IMAGES_DIR/different-pixels \ | 124 -r $IMAGES_DIR/different-pixels \ |
125 --writeJsonSummary $JSON_DIR/different-pixels.json | 125 --writeJsonSummaryPath $JSON_DIR/different-pixels.json |
126 | 126 |
127 mkdir -p $IMAGES_DIR/empty-dir | 127 mkdir -p $IMAGES_DIR/empty-dir |
128 } | 128 } |
129 | 129 |
130 GM_TESTDIR=gm/tests | 130 GM_TESTDIR=gm/tests |
131 GM_INPUTS=$GM_TESTDIR/inputs | 131 GM_INPUTS=$GM_TESTDIR/inputs |
132 GM_OUTPUTS=$GM_TESTDIR/outputs | 132 GM_OUTPUTS=$GM_TESTDIR/outputs |
133 GM_TEMPFILES=$GM_TESTDIR/tempfiles | 133 GM_TEMPFILES=$GM_TESTDIR/tempfiles |
134 | 134 |
135 create_inputs_dir $GM_INPUTS | 135 create_inputs_dir $GM_INPUTS |
(...skipping 12 matching lines...) Expand all Loading... |
148 | 148 |
149 # Compare generated image against an empty "expected image" dir. | 149 # Compare generated image against an empty "expected image" dir. |
150 gm_test "--hierarchy --match selftest1 $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" |
151 | 151 |
152 # 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 |
153 # actual checksums marked as "failure-ignored", but the "expected-results" | 153 # actual checksums marked as "failure-ignored", but the "expected-results" |
154 # section should be empty. | 154 # section should be empty. |
155 gm_test "--hierarchy --match selftest1 $CONFIGS" "$GM_OUTPUTS/no-readpath" | 155 gm_test "--hierarchy --match selftest1 $CONFIGS" "$GM_OUTPUTS/no-readpath" |
156 | 156 |
157 echo "All tests passed." | 157 echo "All tests passed." |
OLD | NEW |