epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Tests for our tools. |
epoger@google.com | 3aa3358 | 2013-01-02 15:53:25 +0000 | [diff] [blame] | 4 | # |
epoger@google.com | 3aa3358 | 2013-01-02 15:53:25 +0000 | [diff] [blame] | 5 | # TODO: currently, this only passes on Linux (which is the platform that |
| 6 | # the housekeeper bot runs on, e.g. |
| 7 | # http://70.32.156.51:10117/builders/Skia_PerCommit_House_Keeping/builds/1415/steps/RunToolSelfTests/logs/stdio ) |
| 8 | # See https://code.google.com/p/skia/issues/detail?id=677 |
| 9 | # ('make tools/tests/run.sh work cross-platform') |
| 10 | # Ideally, these tests should pass on all development platforms... |
| 11 | # otherwise, how can developers be expected to test them before committing a |
| 12 | # change? |
epoger@google.com | a413a53 | 2012-11-12 18:04:51 +0000 | [diff] [blame] | 13 | |
| 14 | # cd into .../trunk so all the paths will work |
| 15 | cd $(dirname $0)/../.. |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 16 | |
| 17 | # TODO: make it look in Release and/or Debug |
| 18 | SKDIFF_BINARY=out/Debug/skdiff |
| 19 | |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 20 | # Suffixes of all the raw bench data files we want to process. |
epoger@google.com | bd9669a | 2013-02-17 08:33:27 +0000 | [diff] [blame] | 21 | BENCHDATA_FILE_SUFFIXES_YES_INDIVIDUAL_TILES=\ |
epoger@google.com | aa6470a | 2013-02-15 16:42:21 +0000 | [diff] [blame] | 22 | "data_skp_device_bitmap_multi_2_mode_tile_256_256_timeIndividualTiles "\ |
| 23 | "data_skp_device_bitmap_multi_3_mode_tile_256_256_timeIndividualTiles "\ |
| 24 | "data_skp_device_bitmap_multi_4_mode_tile_256_256_timeIndividualTiles "\ |
| 25 | "data_skp_device_bitmap_mode_record_bbh_rtree" |
epoger@google.com | bd9669a | 2013-02-17 08:33:27 +0000 | [diff] [blame] | 26 | BENCHDATA_FILE_SUFFIXES_NO_INDIVIDUAL_TILES=\ |
| 27 | "data_skp_device_bitmap_multi_2_mode_tile_256_256 "\ |
| 28 | "data_skp_device_bitmap_multi_3_mode_tile_256_256 "\ |
| 29 | "data_skp_device_bitmap_multi_4_mode_tile_256_256 "\ |
| 30 | "data_skp_device_bitmap_mode_record_bbh_rtree" |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 31 | |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 32 | # Compare contents of all files within directories $1 and $2, |
| 33 | # EXCEPT for any dotfiles. |
| 34 | # If there are any differences, a description is written to stdout and |
| 35 | # we exit with a nonzero return value. |
| 36 | # Otherwise, we write nothing to stdout and return. |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 37 | function compare_directories { |
epoger@google.com | a413a53 | 2012-11-12 18:04:51 +0000 | [diff] [blame] | 38 | if [ $# != 2 ]; then |
| 39 | echo "compare_directories requires exactly 2 parameters, got $#" |
| 40 | exit 1 |
| 41 | fi |
epoger@google.com | 34b73a2 | 2013-07-03 17:43:11 +0000 | [diff] [blame] | 42 | diff --recursive --exclude=.* $1 $2 |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 43 | if [ $? != 0 ]; then |
| 44 | echo "failed in: compare_directories $1 $2" |
| 45 | exit 1 |
| 46 | fi |
| 47 | } |
| 48 | |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 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). |
| 51 | # Then compare its results against those in $2/output-expected. |
| 52 | function skdiff_test { |
epoger@google.com | a413a53 | 2012-11-12 18:04:51 +0000 | [diff] [blame] | 53 | if [ $# != 2 ]; then |
| 54 | echo "skdiff_test requires exactly 2 parameters, got $#" |
| 55 | exit 1 |
| 56 | fi |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 57 | SKDIFF_ARGS="$1" |
| 58 | ACTUAL_OUTPUT_DIR="$2/output-actual" |
| 59 | EXPECTED_OUTPUT_DIR="$2/output-expected" |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 60 | |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 61 | rm -rf $ACTUAL_OUTPUT_DIR |
| 62 | mkdir -p $ACTUAL_OUTPUT_DIR |
epoger@google.com | 90cb9b3 | 2012-05-18 18:25:26 +0000 | [diff] [blame] | 63 | COMMAND="$SKDIFF_BINARY $SKDIFF_ARGS $ACTUAL_OUTPUT_DIR" |
| 64 | echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
| 65 | $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
| 66 | echo $? >$ACTUAL_OUTPUT_DIR/return_value |
| 67 | |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 68 | compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 69 | } |
| 70 | |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 71 | # Download a subset of the raw bench data for platform $1 at revision $2. |
epoger@google.com | bd9669a | 2013-02-17 08:33:27 +0000 | [diff] [blame] | 72 | # (For the subset, download all files matching any of the suffixes in |
| 73 | # whitespace-separated list $3.) |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 74 | # If any of those files already exist locally, we assume that they are |
| 75 | # correct and up to date, and we don't download them again. |
| 76 | function benchgraph_download_rawdata { |
epoger@google.com | bd9669a | 2013-02-17 08:33:27 +0000 | [diff] [blame] | 77 | if [ $# != 3 ]; then |
| 78 | echo "benchgraph_download_rawdata requires exactly 3 parameters, got $#" |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 79 | exit 1 |
| 80 | fi |
| 81 | PLATFORM="$1" |
| 82 | REV="$2" |
epoger@google.com | bd9669a | 2013-02-17 08:33:27 +0000 | [diff] [blame] | 83 | FILE_SUFFIXES="$3" |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 84 | |
| 85 | PLATFORM_DIR="tools/tests/benchgraphs/$PLATFORM" |
| 86 | RAW_BENCH_DATA_DIR="$PLATFORM_DIR/raw-bench-data" |
| 87 | mkdir -p $RAW_BENCH_DATA_DIR |
| 88 | |
epoger@google.com | bd9669a | 2013-02-17 08:33:27 +0000 | [diff] [blame] | 89 | for FILE_SUFFIX in $FILE_SUFFIXES; do |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 90 | FILE=bench_r${REV}_${FILE_SUFFIX} |
| 91 | DESTFILE=$RAW_BENCH_DATA_DIR/$FILE |
| 92 | if [ ! -f $DESTFILE ]; |
| 93 | then |
| 94 | URL=http://chromium-skia-gm.commondatastorage.googleapis.com/playback/perfdata/${PLATFORM}/data/${FILE} |
epoger@google.com | aa6470a | 2013-02-15 16:42:21 +0000 | [diff] [blame] | 95 | echo Downloading $URL ... |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 96 | curl $URL --output $DESTFILE |
| 97 | fi |
| 98 | done |
| 99 | } |
| 100 | |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 101 | # Run bench_graph_svg.py across the data from platform $1, |
| 102 | # writing its output to output-actual and comparing those results against |
| 103 | # output-expected. |
| 104 | function benchgraph_test { |
| 105 | if [ $# != 1 ]; then |
| 106 | echo "benchgraph_test requires exactly 1 parameter, got $#" |
| 107 | exit 1 |
| 108 | fi |
| 109 | PLATFORM="$1" |
| 110 | |
| 111 | PLATFORM_DIR="tools/tests/benchgraphs/$PLATFORM" |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 112 | RAW_BENCH_DATA_DIR="$PLATFORM_DIR/raw-bench-data" |
| 113 | ACTUAL_OUTPUT_DIR="$PLATFORM_DIR/output-actual" |
| 114 | EXPECTED_OUTPUT_DIR="$PLATFORM_DIR/output-expected" |
| 115 | |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 116 | # Run bench_graph_svg.py . |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 117 | rm -rf $ACTUAL_OUTPUT_DIR |
| 118 | mkdir -p $ACTUAL_OUTPUT_DIR |
| 119 | COMMAND="python bench/bench_graph_svg.py -d $RAW_BENCH_DATA_DIR -r -150 -f -150 -x 1024 -y 768 -l Title -m 25th -o $ACTUAL_OUTPUT_DIR/graph.xhtml" |
| 120 | echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
| 121 | START_TIMESTAMP=$(date +%s) |
| 122 | $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
| 123 | echo $? >$ACTUAL_OUTPUT_DIR/return_value |
| 124 | END_TIMESTAMP=$(date +%s) |
| 125 | |
| 126 | SECONDS_RUN=$(expr $END_TIMESTAMP - $START_TIMESTAMP) |
| 127 | echo "bench_graph_svg.py for $PLATFORM took $SECONDS_RUN seconds to complete" |
| 128 | |
| 129 | compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 130 | } |
| 131 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 132 | # Test rebaseline.py's JSON-format expectations rebaselining capability. |
epoger@google.com | 34b73a2 | 2013-07-03 17:43:11 +0000 | [diff] [blame] | 133 | # |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame] | 134 | # Copy expected-results.json files from $1 into a dir where they can be modified. |
epoger@google.com | 34b73a2 | 2013-07-03 17:43:11 +0000 | [diff] [blame] | 135 | # Run rebaseline.py with arguments in $2, recording its output. |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame] | 136 | # Then compare the output (and modified expected-results.json files) to the |
epoger@google.com | 34b73a2 | 2013-07-03 17:43:11 +0000 | [diff] [blame] | 137 | # content of $2/output-expected. |
| 138 | function rebaseline_test { |
| 139 | if [ $# != 3 ]; then |
| 140 | echo "rebaseline_test requires exactly 3 parameters, got $#" |
| 141 | exit 1 |
| 142 | fi |
| 143 | COPY_EXPECTATIONS_FROM_DIR="$1" |
| 144 | ARGS="$2" |
| 145 | ACTUAL_OUTPUT_DIR="$3/output-actual" |
| 146 | EXPECTED_OUTPUT_DIR="$3/output-expected" |
| 147 | |
| 148 | rm -rf $ACTUAL_OUTPUT_DIR |
| 149 | mkdir -p $ACTUAL_OUTPUT_DIR |
| 150 | EXPECTATIONS_TO_MODIFY_DIR="$ACTUAL_OUTPUT_DIR/gm-expectations" |
epoger@google.com | 3f0a108 | 2013-08-28 19:04:05 +0000 | [diff] [blame] | 151 | BUILDERS=$(ls $COPY_EXPECTATIONS_FROM_DIR) |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame] | 152 | for BUILDER in $BUILDERS; do |
| 153 | mkdir -p $EXPECTATIONS_TO_MODIFY_DIR/$BUILDER |
| 154 | cp $COPY_EXPECTATIONS_FROM_DIR/$BUILDER/expected-results.json \ |
| 155 | $EXPECTATIONS_TO_MODIFY_DIR/$BUILDER |
epoger@google.com | 34b73a2 | 2013-07-03 17:43:11 +0000 | [diff] [blame] | 156 | done |
| 157 | COMMAND="python tools/rebaseline.py --expectations-root $EXPECTATIONS_TO_MODIFY_DIR $ARGS" |
| 158 | echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
| 159 | $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
| 160 | echo $? >$ACTUAL_OUTPUT_DIR/return_value |
| 161 | |
epoger@google.com | 3f0a108 | 2013-08-28 19:04:05 +0000 | [diff] [blame] | 162 | compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
epoger@google.com | 34b73a2 | 2013-07-03 17:43:11 +0000 | [diff] [blame] | 163 | } |
| 164 | |
epoger@google.com | 53953b4 | 2013-07-02 20:22:27 +0000 | [diff] [blame] | 165 | # Run jsondiff.py with arguments in $1, recording its output. |
| 166 | # Then compare that output to the content of $2/output-expected. |
| 167 | function jsondiff_test { |
| 168 | if [ $# != 2 ]; then |
| 169 | echo "jsondiff_test requires exactly 2 parameters, got $#" |
| 170 | exit 1 |
| 171 | fi |
| 172 | ARGS="$1" |
| 173 | ACTUAL_OUTPUT_DIR="$2/output-actual" |
| 174 | EXPECTED_OUTPUT_DIR="$2/output-expected" |
| 175 | |
| 176 | rm -rf $ACTUAL_OUTPUT_DIR |
| 177 | mkdir -p $ACTUAL_OUTPUT_DIR |
| 178 | COMMAND="python tools/jsondiff.py $ARGS" |
| 179 | echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
| 180 | $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
| 181 | echo $? >$ACTUAL_OUTPUT_DIR/return_value |
| 182 | |
| 183 | compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 184 | } |
| 185 | |
epoger@google.com | db29a31 | 2013-06-04 14:58:47 +0000 | [diff] [blame] | 186 | |
| 187 | |
| 188 | # |
| 189 | # Run skdiff tests... |
| 190 | # |
| 191 | |
| 192 | SKDIFF_TESTDIR=tools/tests/skdiff |
| 193 | |
| 194 | # Run skdiff over a variety of file pair types: identical bits, identical pixels, missing from |
| 195 | # baseDir, etc. |
| 196 | skdiff_test "$SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test1" |
| 197 | |
| 198 | # Run skdiff over the same set of files, but with arguments as used by our buildbots: |
| 199 | # - return the number of mismatching file pairs (but ignore any files missing from either |
| 200 | # baseDir or comparisonDir) |
| 201 | # - list filenames with each result type to stdout |
| 202 | # - don't generate HTML output files |
| 203 | skdiff_test "--failonresult DifferentPixels --failonresult DifferentSizes --failonresult Unknown --failonstatus CouldNotDecode,CouldNotRead any --failonstatus any CouldNotDecode,CouldNotRead --listfilenames --nodiffs $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test2" |
| 204 | |
| 205 | # Run skdiff over just the files that have identical bits. |
| 206 | skdiff_test "--nodiffs --match identical-bits $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits" |
| 207 | |
| 208 | # Run skdiff over just the files that have identical bits or identical pixels. |
| 209 | skdiff_test "--nodiffs --match identical-bits --match identical-pixels $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits-or-pixels" |
| 210 | |
| 211 | # |
| 212 | # Run benchgraph tests... |
| 213 | # |
| 214 | |
epoger@google.com | aa6470a | 2013-02-15 16:42:21 +0000 | [diff] [blame] | 215 | # Parse a collection of bench data leading up to |
| 216 | # http://70.32.156.53:10117/builders/Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32/builds/878/steps/GenerateWebpagePictureBenchGraphs/logs/stdio |
| 217 | # (this was during the period when the bench data included a ton of per-tile, |
| 218 | # per-iteration data) |
| 219 | PLATFORM=Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32 |
epoger@google.com | bd9669a | 2013-02-17 08:33:27 +0000 | [diff] [blame] | 220 | benchgraph_download_rawdata $PLATFORM 7618 "$BENCHDATA_FILE_SUFFIXES_NO_INDIVIDUAL_TILES" |
| 221 | benchgraph_download_rawdata $PLATFORM 7671 "$BENCHDATA_FILE_SUFFIXES_YES_INDIVIDUAL_TILES" |
| 222 | benchgraph_download_rawdata $PLATFORM 7679 "$BENCHDATA_FILE_SUFFIXES_YES_INDIVIDUAL_TILES" |
| 223 | benchgraph_download_rawdata $PLATFORM 7686 "$BENCHDATA_FILE_SUFFIXES_YES_INDIVIDUAL_TILES" |
epoger@google.com | aa6470a | 2013-02-15 16:42:21 +0000 | [diff] [blame] | 224 | benchgraph_test $PLATFORM |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 225 | |
epoger@google.com | db29a31 | 2013-06-04 14:58:47 +0000 | [diff] [blame] | 226 | # |
scroggo@google.com | e762dad | 2013-06-07 12:40:35 +0000 | [diff] [blame] | 227 | # Run self test for skimage ... |
| 228 | # |
| 229 | |
| 230 | COMMAND="python tools/tests/skimage_self_test.py" |
| 231 | echo "$COMMAND" |
| 232 | $COMMAND |
| 233 | ret=$? |
| 234 | if [ $ret -ne 0 ]; then |
| 235 | echo "skimage self tests failed." |
| 236 | exit 1 |
| 237 | fi |
| 238 | |
| 239 | # |
epoger@google.com | db29a31 | 2013-06-04 14:58:47 +0000 | [diff] [blame] | 240 | # Test rebaseline.py ... |
| 241 | # |
| 242 | |
epoger@google.com | 19e80c1 | 2013-06-06 15:11:11 +0000 | [diff] [blame] | 243 | REBASELINE_INPUT=tools/tests/rebaseline/input |
| 244 | REBASELINE_OUTPUT=tools/tests/rebaseline/output |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame] | 245 | rebaseline_test "$REBASELINE_INPUT/json1" "--actuals-base-url $REBASELINE_INPUT/json1 --builders Test-Android-GalaxyNexus-SGX540-Arm7-Debug Test-Win7-ShuttleA-HD2000-x86-Release" "$REBASELINE_OUTPUT/using-json1-expectations" |
epoger@google.com | 06e626d | 2013-09-03 17:32:15 +0000 | [diff] [blame^] | 246 | rebaseline_test "$REBASELINE_INPUT/json1" "--actuals-base-url $REBASELINE_INPUT/json1 --bugs 1234 5678 --builders Test-Android-GalaxyNexus-SGX540-Arm7-Debug Test-Win7-ShuttleA-HD2000-x86-Release --notes notes_content --unreviewed" "$REBASELINE_OUTPUT/marked-unreviewed" |
epoger@google.com | db29a31 | 2013-06-04 14:58:47 +0000 | [diff] [blame] | 247 | |
epoger@google.com | 53953b4 | 2013-07-02 20:22:27 +0000 | [diff] [blame] | 248 | # |
| 249 | # Test jsondiff.py ... |
| 250 | # |
| 251 | |
| 252 | JSONDIFF_INPUT=tools/tests/jsondiff/input |
| 253 | JSONDIFF_OUTPUT=tools/tests/jsondiff/output |
| 254 | jsondiff_test "$JSONDIFF_INPUT/old.json $JSONDIFF_INPUT/new.json" "$JSONDIFF_OUTPUT/old-vs-new" |
| 255 | |
| 256 | |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 257 | echo "All tests passed." |