blob: 1ce11f36e4a807939b5eb1d43000e7b81334bc6f [file] [log] [blame]
epoger@google.coma2b793c2012-05-15 14:58:53 +00001#!/bin/bash
2
3# Tests for our tools.
epoger@google.com3aa33582013-01-02 15:53:25 +00004#
epoger@google.com3aa33582013-01-02 15:53:25 +00005# 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.coma413a532012-11-12 18:04:51 +000013
14# cd into .../trunk so all the paths will work
15cd $(dirname $0)/../..
epoger@google.coma2b793c2012-05-15 14:58:53 +000016
17# TODO: make it look in Release and/or Debug
18SKDIFF_BINARY=out/Debug/skdiff
19
epoger@google.com673816c2013-02-15 15:50:23 +000020# Suffixes of all the raw bench data files we want to process.
epoger@google.comaa6470a2013-02-15 16:42:21 +000021BENCHDATA_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.com673816c2013-02-15 15:50:23 +000026
epoger@google.coma4443522012-05-17 17:12:38 +000027# 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.coma2b793c2012-05-15 14:58:53 +000032function compare_directories {
epoger@google.coma413a532012-11-12 18:04:51 +000033 if [ $# != 2 ]; then
34 echo "compare_directories requires exactly 2 parameters, got $#"
35 exit 1
36 fi
epoger@google.coma2b793c2012-05-15 14:58:53 +000037 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.coma4443522012-05-17 17:12:38 +000044# 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.
47function skdiff_test {
epoger@google.coma413a532012-11-12 18:04:51 +000048 if [ $# != 2 ]; then
49 echo "skdiff_test requires exactly 2 parameters, got $#"
50 exit 1
51 fi
epoger@google.coma4443522012-05-17 17:12:38 +000052 SKDIFF_ARGS="$1"
53 ACTUAL_OUTPUT_DIR="$2/output-actual"
54 EXPECTED_OUTPUT_DIR="$2/output-expected"
epoger@google.coma2b793c2012-05-15 14:58:53 +000055
epoger@google.coma4443522012-05-17 17:12:38 +000056 rm -rf $ACTUAL_OUTPUT_DIR
57 mkdir -p $ACTUAL_OUTPUT_DIR
epoger@google.com90cb9b32012-05-18 18:25:26 +000058 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.coma4443522012-05-17 17:12:38 +000063 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
64}
65
66SKDIFF_TESTDIR=tools/tests/skdiff
epoger@google.com8e4e51d2012-05-30 19:12:45 +000067
epoger@google.comdfbf24e2012-07-13 21:22:02 +000068# Run skdiff over a variety of file pair types: identical bits, identical pixels, missing from
69# baseDir, etc.
epoger@google.coma4443522012-05-17 17:12:38 +000070skdiff_test "$SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test1"
epoger@google.com8e4e51d2012-05-30 19:12:45 +000071
epoger@google.comdfbf24e2012-07-13 21:22:02 +000072# 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.com46a45962012-07-12 18:16:02 +000075# - list filenames with each result type to stdout
76# - don't generate HTML output files
bungeman@google.come3c8ddf2012-12-05 20:13:12 +000077skdiff_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.com8e4e51d2012-05-30 19:12:45 +000078
epoger@google.comdfbf24e2012-07-13 21:22:02 +000079# Run skdiff over just the files that have identical bits.
80skdiff_test "--nodiffs --match identical-bits $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits"
epoger@google.com8e4e51d2012-05-30 19:12:45 +000081
epoger@google.comdfbf24e2012-07-13 21:22:02 +000082# Run skdiff over just the files that have identical bits or identical pixels.
83skdiff_test "--nodiffs --match identical-bits --match identical-pixels $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits-or-pixels"
epoger@google.com8e4e51d2012-05-30 19:12:45 +000084
epoger@google.comf4eeeab2013-02-14 15:10:24 +000085
epoger@google.com673816c2013-02-15 15:50:23 +000086# 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.
89function 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.comaa6470a2013-02-15 16:42:21 +0000107 echo Downloading $URL ...
epoger@google.com673816c2013-02-15 15:50:23 +0000108 curl $URL --output $DESTFILE
109 fi
110 done
111}
112
epoger@google.comf4eeeab2013-02-14 15:10:24 +0000113# 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.
116function 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.comf4eeeab2013-02-14 15:10:24 +0000124 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.com673816c2013-02-15 15:50:23 +0000128 # Run bench_graph_svg.py .
epoger@google.comf4eeeab2013-02-14 15:10:24 +0000129 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.comaa6470a2013-02-15 16:42:21 +0000144# 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)
148PLATFORM=Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32
149benchgraph_download_rawdata $PLATFORM 7671
150benchgraph_download_rawdata $PLATFORM 7679
151benchgraph_download_rawdata $PLATFORM 7686
152benchgraph_test $PLATFORM
epoger@google.comf4eeeab2013-02-14 15:10:24 +0000153
epoger@google.coma2b793c2012-05-15 14:58:53 +0000154echo "All tests passed."