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 | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 20 | # Compare contents of all files within directories $1 and $2, |
| 21 | # EXCEPT for any dotfiles. |
| 22 | # If there are any differences, a description is written to stdout and |
| 23 | # we exit with a nonzero return value. |
| 24 | # Otherwise, we write nothing to stdout and return. |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 25 | function compare_directories { |
epoger@google.com | a413a53 | 2012-11-12 18:04:51 +0000 | [diff] [blame] | 26 | if [ $# != 2 ]; then |
| 27 | echo "compare_directories requires exactly 2 parameters, got $#" |
| 28 | exit 1 |
| 29 | fi |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 30 | diff --exclude=.* $1 $2 |
| 31 | if [ $? != 0 ]; then |
| 32 | echo "failed in: compare_directories $1 $2" |
| 33 | exit 1 |
| 34 | fi |
| 35 | } |
| 36 | |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 37 | # Run skdiff with arguments in $1 (plus implicit final argument causing skdiff |
| 38 | # to write its output, if any, to directory $2/output-actual). |
| 39 | # Then compare its results against those in $2/output-expected. |
| 40 | function skdiff_test { |
epoger@google.com | a413a53 | 2012-11-12 18:04:51 +0000 | [diff] [blame] | 41 | if [ $# != 2 ]; then |
| 42 | echo "skdiff_test requires exactly 2 parameters, got $#" |
| 43 | exit 1 |
| 44 | fi |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 45 | SKDIFF_ARGS="$1" |
| 46 | ACTUAL_OUTPUT_DIR="$2/output-actual" |
| 47 | EXPECTED_OUTPUT_DIR="$2/output-expected" |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 48 | |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 49 | rm -rf $ACTUAL_OUTPUT_DIR |
| 50 | mkdir -p $ACTUAL_OUTPUT_DIR |
epoger@google.com | 90cb9b3 | 2012-05-18 18:25:26 +0000 | [diff] [blame] | 51 | COMMAND="$SKDIFF_BINARY $SKDIFF_ARGS $ACTUAL_OUTPUT_DIR" |
| 52 | echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
| 53 | $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
| 54 | echo $? >$ACTUAL_OUTPUT_DIR/return_value |
| 55 | |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 56 | compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 57 | } |
| 58 | |
| 59 | SKDIFF_TESTDIR=tools/tests/skdiff |
epoger@google.com | 8e4e51d | 2012-05-30 19:12:45 +0000 | [diff] [blame] | 60 | |
epoger@google.com | dfbf24e | 2012-07-13 21:22:02 +0000 | [diff] [blame] | 61 | # Run skdiff over a variety of file pair types: identical bits, identical pixels, missing from |
| 62 | # baseDir, etc. |
epoger@google.com | a444352 | 2012-05-17 17:12:38 +0000 | [diff] [blame] | 63 | skdiff_test "$SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test1" |
epoger@google.com | 8e4e51d | 2012-05-30 19:12:45 +0000 | [diff] [blame] | 64 | |
epoger@google.com | dfbf24e | 2012-07-13 21:22:02 +0000 | [diff] [blame] | 65 | # Run skdiff over the same set of files, but with arguments as used by our buildbots: |
| 66 | # - return the number of mismatching file pairs (but ignore any files missing from either |
| 67 | # baseDir or comparisonDir) |
epoger@google.com | 46a4596 | 2012-07-12 18:16:02 +0000 | [diff] [blame] | 68 | # - list filenames with each result type to stdout |
| 69 | # - don't generate HTML output files |
bungeman@google.com | e3c8ddf | 2012-12-05 20:13:12 +0000 | [diff] [blame] | 70 | 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] | 71 | |
epoger@google.com | dfbf24e | 2012-07-13 21:22:02 +0000 | [diff] [blame] | 72 | # Run skdiff over just the files that have identical bits. |
| 73 | 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] | 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 or identical pixels. |
| 76 | 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] | 77 | |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 78 | |
| 79 | # Run bench_graph_svg.py across the data from platform $1, |
| 80 | # writing its output to output-actual and comparing those results against |
| 81 | # output-expected. |
| 82 | function benchgraph_test { |
| 83 | if [ $# != 1 ]; then |
| 84 | echo "benchgraph_test requires exactly 1 parameter, got $#" |
| 85 | exit 1 |
| 86 | fi |
| 87 | PLATFORM="$1" |
| 88 | |
| 89 | PLATFORM_DIR="tools/tests/benchgraphs/$PLATFORM" |
| 90 | TARBALL_DIR="$PLATFORM_DIR/tarballs" |
| 91 | RAW_BENCH_DATA_DIR="$PLATFORM_DIR/raw-bench-data" |
| 92 | ACTUAL_OUTPUT_DIR="$PLATFORM_DIR/output-actual" |
| 93 | EXPECTED_OUTPUT_DIR="$PLATFORM_DIR/output-expected" |
| 94 | |
| 95 | # First, unpack raw bench data from tarballs. |
| 96 | # (The raw bench data files are large, so this saves space in our SVN repo.) |
| 97 | rm -rf $RAW_BENCH_DATA_DIR |
| 98 | mkdir -p $RAW_BENCH_DATA_DIR |
| 99 | for TARBALL in $TARBALL_DIR/*.tgz ; do |
| 100 | tar --extract --gunzip --directory $RAW_BENCH_DATA_DIR --file $TARBALL |
| 101 | done |
| 102 | |
| 103 | # Now that we have the input files we need, run bench_graph_svg.py . |
| 104 | rm -rf $ACTUAL_OUTPUT_DIR |
| 105 | mkdir -p $ACTUAL_OUTPUT_DIR |
| 106 | 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" |
| 107 | echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line |
| 108 | START_TIMESTAMP=$(date +%s) |
| 109 | $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout |
| 110 | echo $? >$ACTUAL_OUTPUT_DIR/return_value |
| 111 | END_TIMESTAMP=$(date +%s) |
| 112 | |
| 113 | SECONDS_RUN=$(expr $END_TIMESTAMP - $START_TIMESTAMP) |
| 114 | echo "bench_graph_svg.py for $PLATFORM took $SECONDS_RUN seconds to complete" |
| 115 | |
| 116 | compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR |
| 117 | } |
| 118 | |
epoger@google.com | 2459a39 | 2013-02-14 18:58:05 +0000 | [diff] [blame] | 119 | benchgraph_test Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32 |
epoger@google.com | f4eeeab | 2013-02-14 15:10:24 +0000 | [diff] [blame] | 120 | |
epoger@google.com | a2b793c | 2012-05-15 14:58:53 +0000 | [diff] [blame] | 121 | echo "All tests passed." |