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 | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 42 | diff --exclude=.* $1 $2 |
| 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 | db29a31 | 2013-06-04 14:58:47 +0000 | [diff] [blame] | 132 | # 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. |
| 134 | function rebaseline_test { |
| 135 | if [ $# != 2 ]; then |
| 136 | echo "rebaseline_test requires exactly 2 parameters, got $#" |
| 137 | exit 1 |
| 138 | fi |
| 139 | ARGS="$1" |
| 140 | ACTUAL_OUTPUT_DIR="$2/output-actual" |
| 141 | EXPECTED_OUTPUT_DIR="$2/output-expected" |
| 142 | |
| 143 | rm -rf $ACTUAL_OUTPUT_DIR |
| 144 | mkdir -p $ACTUAL_OUTPUT_DIR |
| 145 | COMMAND="python tools/rebaseline.py --dry_run $ARGS" |
| 146 | echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
| 147 | $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
| 148 | echo $? >$ACTUAL_OUTPUT_DIR/return_value |
| 149 | |
| 150 | compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 151 | } |
| 152 | |
| 153 | |
| 154 | |
| 155 | # |
| 156 | # Run skdiff tests... |
| 157 | # |
| 158 | |
| 159 | SKDIFF_TESTDIR=tools/tests/skdiff |
| 160 | |
| 161 | # Run skdiff over a variety of file pair types: identical bits, identical pixels, missing from |
| 162 | # baseDir, etc. |
| 163 | skdiff_test "$SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test1" |
| 164 | |
| 165 | # Run skdiff over the same set of files, but with arguments as used by our buildbots: |
| 166 | # - return the number of mismatching file pairs (but ignore any files missing from either |
| 167 | # baseDir or comparisonDir) |
| 168 | # - list filenames with each result type to stdout |
| 169 | # - don't generate HTML output files |
| 170 | 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" |
| 171 | |
| 172 | # Run skdiff over just the files that have identical bits. |
| 173 | skdiff_test "--nodiffs --match identical-bits $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits" |
| 174 | |
| 175 | # Run skdiff over just the files that have identical bits or identical pixels. |
| 176 | skdiff_test "--nodiffs --match identical-bits --match identical-pixels $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits-or-pixels" |
| 177 | |
| 178 | # |
| 179 | # Run benchgraph tests... |
| 180 | # |
| 181 | |
epoger@google.com | aa6470a | 2013-02-15 16:42:21 +0000 | [diff] [blame] | 182 | # Parse a collection of bench data leading up to |
| 183 | # http://70.32.156.53:10117/builders/Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32/builds/878/steps/GenerateWebpagePictureBenchGraphs/logs/stdio |
| 184 | # (this was during the period when the bench data included a ton of per-tile, |
| 185 | # per-iteration data) |
| 186 | PLATFORM=Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32 |
epoger@google.com | bd9669a | 2013-02-17 08:33:27 +0000 | [diff] [blame] | 187 | benchgraph_download_rawdata $PLATFORM 7618 "$BENCHDATA_FILE_SUFFIXES_NO_INDIVIDUAL_TILES" |
| 188 | benchgraph_download_rawdata $PLATFORM 7671 "$BENCHDATA_FILE_SUFFIXES_YES_INDIVIDUAL_TILES" |
| 189 | benchgraph_download_rawdata $PLATFORM 7679 "$BENCHDATA_FILE_SUFFIXES_YES_INDIVIDUAL_TILES" |
| 190 | benchgraph_download_rawdata $PLATFORM 7686 "$BENCHDATA_FILE_SUFFIXES_YES_INDIVIDUAL_TILES" |
epoger@google.com | aa6470a | 2013-02-15 16:42:21 +0000 | [diff] [blame] | 191 | benchgraph_test $PLATFORM |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 192 | |
epoger@google.com | db29a31 | 2013-06-04 14:58:47 +0000 | [diff] [blame] | 193 | # |
scroggo@google.com | e762dad | 2013-06-07 12:40:35 +0000 | [diff] [blame^] | 194 | # Run self test for skimage ... |
| 195 | # |
| 196 | |
| 197 | COMMAND="python tools/tests/skimage_self_test.py" |
| 198 | echo "$COMMAND" |
| 199 | $COMMAND |
| 200 | ret=$? |
| 201 | if [ $ret -ne 0 ]; then |
| 202 | echo "skimage self tests failed." |
| 203 | exit 1 |
| 204 | fi |
| 205 | |
| 206 | # |
epoger@google.com | db29a31 | 2013-06-04 14:58:47 +0000 | [diff] [blame] | 207 | # Test rebaseline.py ... |
| 208 | # |
| 209 | |
epoger@google.com | 19e80c1 | 2013-06-06 15:11:11 +0000 | [diff] [blame] | 210 | REBASELINE_INPUT=tools/tests/rebaseline/input |
| 211 | REBASELINE_OUTPUT=tools/tests/rebaseline/output |
| 212 | rebaseline_test "--tests test1 test2 --configs 565 8888 --subdirs base-android-galaxy-nexus base-shuttle-win7-intel-float" "$REBASELINE_OUTPUT/subset" |
| 213 | rebaseline_test "--tests test1 test2" "$REBASELINE_OUTPUT/all" |
| 214 | rebaseline_test "--json_base_url file:$REBASELINE_INPUT/json1 --subdirs base-android-galaxy-nexus base-shuttle-win7-intel-float" "$REBASELINE_OUTPUT/using-json1" |
epoger@google.com | db29a31 | 2013-06-04 14:58:47 +0000 | [diff] [blame] | 215 | |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 216 | echo "All tests passed." |