blob: 30a7882e5d4d418746ea22dc3579edeb09e15d0e [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.combd9669a2013-02-17 08:33:27 +000021BENCHDATA_FILE_SUFFIXES_YES_INDIVIDUAL_TILES=\
epoger@google.comaa6470a2013-02-15 16:42:21 +000022"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.combd9669a2013-02-17 08:33:27 +000026BENCHDATA_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.com673816c2013-02-15 15:50:23 +000031
epoger@google.coma4443522012-05-17 17:12:38 +000032# 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.coma2b793c2012-05-15 14:58:53 +000037function compare_directories {
epoger@google.coma413a532012-11-12 18:04:51 +000038 if [ $# != 2 ]; then
39 echo "compare_directories requires exactly 2 parameters, got $#"
40 exit 1
41 fi
epoger@google.coma2b793c2012-05-15 14:58:53 +000042 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.coma4443522012-05-17 17:12:38 +000049# 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.
52function skdiff_test {
epoger@google.coma413a532012-11-12 18:04:51 +000053 if [ $# != 2 ]; then
54 echo "skdiff_test requires exactly 2 parameters, got $#"
55 exit 1
56 fi
epoger@google.coma4443522012-05-17 17:12:38 +000057 SKDIFF_ARGS="$1"
58 ACTUAL_OUTPUT_DIR="$2/output-actual"
59 EXPECTED_OUTPUT_DIR="$2/output-expected"
epoger@google.coma2b793c2012-05-15 14:58:53 +000060
epoger@google.coma4443522012-05-17 17:12:38 +000061 rm -rf $ACTUAL_OUTPUT_DIR
62 mkdir -p $ACTUAL_OUTPUT_DIR
epoger@google.com90cb9b32012-05-18 18:25:26 +000063 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.coma4443522012-05-17 17:12:38 +000068 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
69}
70
71SKDIFF_TESTDIR=tools/tests/skdiff
epoger@google.com8e4e51d2012-05-30 19:12:45 +000072
epoger@google.comdfbf24e2012-07-13 21:22:02 +000073# Run skdiff over a variety of file pair types: identical bits, identical pixels, missing from
74# baseDir, etc.
epoger@google.coma4443522012-05-17 17:12:38 +000075skdiff_test "$SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test1"
epoger@google.com8e4e51d2012-05-30 19:12:45 +000076
epoger@google.comdfbf24e2012-07-13 21:22:02 +000077# Run skdiff over the same set of files, but with arguments as used by our buildbots:
78# - return the number of mismatching file pairs (but ignore any files missing from either
79# baseDir or comparisonDir)
epoger@google.com46a45962012-07-12 18:16:02 +000080# - list filenames with each result type to stdout
81# - don't generate HTML output files
bungeman@google.come3c8ddf2012-12-05 20:13:12 +000082skdiff_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 +000083
epoger@google.comdfbf24e2012-07-13 21:22:02 +000084# Run skdiff over just the files that have identical bits.
85skdiff_test "--nodiffs --match identical-bits $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits"
epoger@google.com8e4e51d2012-05-30 19:12:45 +000086
epoger@google.comdfbf24e2012-07-13 21:22:02 +000087# Run skdiff over just the files that have identical bits or identical pixels.
88skdiff_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 +000089
epoger@google.comf4eeeab2013-02-14 15:10:24 +000090
epoger@google.com673816c2013-02-15 15:50:23 +000091# Download a subset of the raw bench data for platform $1 at revision $2.
epoger@google.combd9669a2013-02-17 08:33:27 +000092# (For the subset, download all files matching any of the suffixes in
93# whitespace-separated list $3.)
epoger@google.com673816c2013-02-15 15:50:23 +000094# If any of those files already exist locally, we assume that they are
95# correct and up to date, and we don't download them again.
96function benchgraph_download_rawdata {
epoger@google.combd9669a2013-02-17 08:33:27 +000097 if [ $# != 3 ]; then
98 echo "benchgraph_download_rawdata requires exactly 3 parameters, got $#"
epoger@google.com673816c2013-02-15 15:50:23 +000099 exit 1
100 fi
101 PLATFORM="$1"
102 REV="$2"
epoger@google.combd9669a2013-02-17 08:33:27 +0000103 FILE_SUFFIXES="$3"
epoger@google.com673816c2013-02-15 15:50:23 +0000104
105 PLATFORM_DIR="tools/tests/benchgraphs/$PLATFORM"
106 RAW_BENCH_DATA_DIR="$PLATFORM_DIR/raw-bench-data"
107 mkdir -p $RAW_BENCH_DATA_DIR
108
epoger@google.combd9669a2013-02-17 08:33:27 +0000109 for FILE_SUFFIX in $FILE_SUFFIXES; do
epoger@google.com673816c2013-02-15 15:50:23 +0000110 FILE=bench_r${REV}_${FILE_SUFFIX}
111 DESTFILE=$RAW_BENCH_DATA_DIR/$FILE
112 if [ ! -f $DESTFILE ];
113 then
114 URL=http://chromium-skia-gm.commondatastorage.googleapis.com/playback/perfdata/${PLATFORM}/data/${FILE}
epoger@google.comaa6470a2013-02-15 16:42:21 +0000115 echo Downloading $URL ...
epoger@google.com673816c2013-02-15 15:50:23 +0000116 curl $URL --output $DESTFILE
117 fi
118 done
119}
120
epoger@google.comf4eeeab2013-02-14 15:10:24 +0000121# Run bench_graph_svg.py across the data from platform $1,
122# writing its output to output-actual and comparing those results against
123# output-expected.
124function benchgraph_test {
125 if [ $# != 1 ]; then
126 echo "benchgraph_test requires exactly 1 parameter, got $#"
127 exit 1
128 fi
129 PLATFORM="$1"
130
131 PLATFORM_DIR="tools/tests/benchgraphs/$PLATFORM"
epoger@google.comf4eeeab2013-02-14 15:10:24 +0000132 RAW_BENCH_DATA_DIR="$PLATFORM_DIR/raw-bench-data"
133 ACTUAL_OUTPUT_DIR="$PLATFORM_DIR/output-actual"
134 EXPECTED_OUTPUT_DIR="$PLATFORM_DIR/output-expected"
135
epoger@google.com673816c2013-02-15 15:50:23 +0000136 # Run bench_graph_svg.py .
epoger@google.comf4eeeab2013-02-14 15:10:24 +0000137 rm -rf $ACTUAL_OUTPUT_DIR
138 mkdir -p $ACTUAL_OUTPUT_DIR
139 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"
140 echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line
141 START_TIMESTAMP=$(date +%s)
142 $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout
143 echo $? >$ACTUAL_OUTPUT_DIR/return_value
144 END_TIMESTAMP=$(date +%s)
145
146 SECONDS_RUN=$(expr $END_TIMESTAMP - $START_TIMESTAMP)
147 echo "bench_graph_svg.py for $PLATFORM took $SECONDS_RUN seconds to complete"
148
149 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
150}
151
epoger@google.comaa6470a2013-02-15 16:42:21 +0000152# Parse a collection of bench data leading up to
153# http://70.32.156.53:10117/builders/Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32/builds/878/steps/GenerateWebpagePictureBenchGraphs/logs/stdio
154# (this was during the period when the bench data included a ton of per-tile,
155# per-iteration data)
156PLATFORM=Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32
epoger@google.combd9669a2013-02-17 08:33:27 +0000157benchgraph_download_rawdata $PLATFORM 7618 "$BENCHDATA_FILE_SUFFIXES_NO_INDIVIDUAL_TILES"
158benchgraph_download_rawdata $PLATFORM 7671 "$BENCHDATA_FILE_SUFFIXES_YES_INDIVIDUAL_TILES"
159benchgraph_download_rawdata $PLATFORM 7679 "$BENCHDATA_FILE_SUFFIXES_YES_INDIVIDUAL_TILES"
160benchgraph_download_rawdata $PLATFORM 7686 "$BENCHDATA_FILE_SUFFIXES_YES_INDIVIDUAL_TILES"
epoger@google.comaa6470a2013-02-15 16:42:21 +0000161benchgraph_test $PLATFORM
epoger@google.comf4eeeab2013-02-14 15:10:24 +0000162
epoger@google.coma2b793c2012-05-15 14:58:53 +0000163echo "All tests passed."