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