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 | aa6470a | 2013-02-15 16:42:21 +0000 | [diff] [blame^] | 21 | BENCHDATA_FILE_SUFFIXES=\ |
| 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 | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 26 | |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 27 | # Compare contents of all files within directories $1 and $2, |
| 28 | # EXCEPT for any dotfiles. |
| 29 | # If there are any differences, a description is written to stdout and |
| 30 | # we exit with a nonzero return value. |
| 31 | # Otherwise, we write nothing to stdout and return. |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 32 | function compare_directories { |
epoger@google.com | a413a53 | 2012-11-12 18:04:51 +0000 | [diff] [blame] | 33 | if [ $# != 2 ]; then |
| 34 | echo "compare_directories requires exactly 2 parameters, got $#" |
| 35 | exit 1 |
| 36 | fi |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 37 | diff --exclude=.* $1 $2 |
| 38 | if [ $? != 0 ]; then |
| 39 | echo "failed in: compare_directories $1 $2" |
| 40 | exit 1 |
| 41 | fi |
| 42 | } |
| 43 | |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 44 | # Run skdiff with arguments in $1 (plus implicit final argument causing skdiff |
| 45 | # to write its output, if any, to directory $2/output-actual). |
| 46 | # Then compare its results against those in $2/output-expected. |
| 47 | function skdiff_test { |
epoger@google.com | a413a53 | 2012-11-12 18:04:51 +0000 | [diff] [blame] | 48 | if [ $# != 2 ]; then |
| 49 | echo "skdiff_test requires exactly 2 parameters, got $#" |
| 50 | exit 1 |
| 51 | fi |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 52 | SKDIFF_ARGS="$1" |
| 53 | ACTUAL_OUTPUT_DIR="$2/output-actual" |
| 54 | EXPECTED_OUTPUT_DIR="$2/output-expected" |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 55 | |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 56 | rm -rf $ACTUAL_OUTPUT_DIR |
| 57 | mkdir -p $ACTUAL_OUTPUT_DIR |
epoger@google.com | 90cb9b3 | 2012-05-18 18:25:26 +0000 | [diff] [blame] | 58 | COMMAND="$SKDIFF_BINARY $SKDIFF_ARGS $ACTUAL_OUTPUT_DIR" |
| 59 | echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
| 60 | $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
| 61 | echo $? >$ACTUAL_OUTPUT_DIR/return_value |
| 62 | |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 63 | compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 64 | } |
| 65 | |
| 66 | SKDIFF_TESTDIR=tools/tests/skdiff |
epoger@google.com | 8e4e51d | 2012-05-30 19:12:45 +0000 | [diff] [blame] | 67 | |
epoger@google.com | dfbf24e | 2012-07-13 21:22:02 +0000 | [diff] [blame] | 68 | # Run skdiff over a variety of file pair types: identical bits, identical pixels, missing from |
| 69 | # baseDir, etc. |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 70 | skdiff_test "$SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test1" |
epoger@google.com | 8e4e51d | 2012-05-30 19:12:45 +0000 | [diff] [blame] | 71 | |
epoger@google.com | dfbf24e | 2012-07-13 21:22:02 +0000 | [diff] [blame] | 72 | # Run skdiff over the same set of files, but with arguments as used by our buildbots: |
| 73 | # - return the number of mismatching file pairs (but ignore any files missing from either |
| 74 | # baseDir or comparisonDir) |
epoger@google.com | 46a4596 | 2012-07-12 18:16:02 +0000 | [diff] [blame] | 75 | # - list filenames with each result type to stdout |
| 76 | # - don't generate HTML output files |
bungeman@google.com | e3c8ddf | 2012-12-05 20:13:12 +0000 | [diff] [blame] | 77 | 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" |
epoger@google.com | 8e4e51d | 2012-05-30 19:12:45 +0000 | [diff] [blame] | 78 | |
epoger@google.com | dfbf24e | 2012-07-13 21:22:02 +0000 | [diff] [blame] | 79 | # Run skdiff over just the files that have identical bits. |
| 80 | skdiff_test "--nodiffs --match identical-bits $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits" |
epoger@google.com | 8e4e51d | 2012-05-30 19:12:45 +0000 | [diff] [blame] | 81 | |
epoger@google.com | dfbf24e | 2012-07-13 21:22:02 +0000 | [diff] [blame] | 82 | # Run skdiff over just the files that have identical bits or identical pixels. |
| 83 | skdiff_test "--nodiffs --match identical-bits --match identical-pixels $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits-or-pixels" |
epoger@google.com | 8e4e51d | 2012-05-30 19:12:45 +0000 | [diff] [blame] | 84 | |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 85 | |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 86 | # Download a subset of the raw bench data for platform $1 at revision $2. |
| 87 | # If any of those files already exist locally, we assume that they are |
| 88 | # correct and up to date, and we don't download them again. |
| 89 | function benchgraph_download_rawdata { |
| 90 | if [ $# != 2 ]; then |
| 91 | echo "benchgraph_download_rawdata requires exactly 2 parameters, got $#" |
| 92 | exit 1 |
| 93 | fi |
| 94 | PLATFORM="$1" |
| 95 | REV="$2" |
| 96 | |
| 97 | PLATFORM_DIR="tools/tests/benchgraphs/$PLATFORM" |
| 98 | RAW_BENCH_DATA_DIR="$PLATFORM_DIR/raw-bench-data" |
| 99 | mkdir -p $RAW_BENCH_DATA_DIR |
| 100 | |
| 101 | for FILE_SUFFIX in $BENCHDATA_FILE_SUFFIXES; do |
| 102 | FILE=bench_r${REV}_${FILE_SUFFIX} |
| 103 | DESTFILE=$RAW_BENCH_DATA_DIR/$FILE |
| 104 | if [ ! -f $DESTFILE ]; |
| 105 | then |
| 106 | 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^] | 107 | echo Downloading $URL ... |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 108 | curl $URL --output $DESTFILE |
| 109 | fi |
| 110 | done |
| 111 | } |
| 112 | |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 113 | # Run bench_graph_svg.py across the data from platform $1, |
| 114 | # writing its output to output-actual and comparing those results against |
| 115 | # output-expected. |
| 116 | function benchgraph_test { |
| 117 | if [ $# != 1 ]; then |
| 118 | echo "benchgraph_test requires exactly 1 parameter, got $#" |
| 119 | exit 1 |
| 120 | fi |
| 121 | PLATFORM="$1" |
| 122 | |
| 123 | PLATFORM_DIR="tools/tests/benchgraphs/$PLATFORM" |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 124 | RAW_BENCH_DATA_DIR="$PLATFORM_DIR/raw-bench-data" |
| 125 | ACTUAL_OUTPUT_DIR="$PLATFORM_DIR/output-actual" |
| 126 | EXPECTED_OUTPUT_DIR="$PLATFORM_DIR/output-expected" |
| 127 | |
epoger@google.com | 673816c | 2013-02-15 15:50:23 +0000 | [diff] [blame] | 128 | # Run bench_graph_svg.py . |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 129 | rm -rf $ACTUAL_OUTPUT_DIR |
| 130 | mkdir -p $ACTUAL_OUTPUT_DIR |
| 131 | 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" |
| 132 | echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
| 133 | START_TIMESTAMP=$(date +%s) |
| 134 | $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
| 135 | echo $? >$ACTUAL_OUTPUT_DIR/return_value |
| 136 | END_TIMESTAMP=$(date +%s) |
| 137 | |
| 138 | SECONDS_RUN=$(expr $END_TIMESTAMP - $START_TIMESTAMP) |
| 139 | echo "bench_graph_svg.py for $PLATFORM took $SECONDS_RUN seconds to complete" |
| 140 | |
| 141 | compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 142 | } |
| 143 | |
epoger@google.com | aa6470a | 2013-02-15 16:42:21 +0000 | [diff] [blame^] | 144 | # Parse a collection of bench data leading up to |
| 145 | # http://70.32.156.53:10117/builders/Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32/builds/878/steps/GenerateWebpagePictureBenchGraphs/logs/stdio |
| 146 | # (this was during the period when the bench data included a ton of per-tile, |
| 147 | # per-iteration data) |
| 148 | PLATFORM=Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32 |
| 149 | benchgraph_download_rawdata $PLATFORM 7671 |
| 150 | benchgraph_download_rawdata $PLATFORM 7679 |
| 151 | benchgraph_download_rawdata $PLATFORM 7686 |
| 152 | benchgraph_test $PLATFORM |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 153 | |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 154 | echo "All tests passed." |