blob: 6cb31cc9003a568ebd295b2750cc2fedc357fe26 [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.
21BENCHDATA_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.coma4443522012-05-17 17:12:38 +000023# 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.coma2b793c2012-05-15 14:58:53 +000028function compare_directories {
epoger@google.coma413a532012-11-12 18:04:51 +000029 if [ $# != 2 ]; then
30 echo "compare_directories requires exactly 2 parameters, got $#"
31 exit 1
32 fi
epoger@google.coma2b793c2012-05-15 14:58:53 +000033 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.coma4443522012-05-17 17:12:38 +000040# 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.
43function skdiff_test {
epoger@google.coma413a532012-11-12 18:04:51 +000044 if [ $# != 2 ]; then
45 echo "skdiff_test requires exactly 2 parameters, got $#"
46 exit 1
47 fi
epoger@google.coma4443522012-05-17 17:12:38 +000048 SKDIFF_ARGS="$1"
49 ACTUAL_OUTPUT_DIR="$2/output-actual"
50 EXPECTED_OUTPUT_DIR="$2/output-expected"
epoger@google.coma2b793c2012-05-15 14:58:53 +000051
epoger@google.coma4443522012-05-17 17:12:38 +000052 rm -rf $ACTUAL_OUTPUT_DIR
53 mkdir -p $ACTUAL_OUTPUT_DIR
epoger@google.com90cb9b32012-05-18 18:25:26 +000054 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.coma4443522012-05-17 17:12:38 +000059 compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
60}
61
62SKDIFF_TESTDIR=tools/tests/skdiff
epoger@google.com8e4e51d2012-05-30 19:12:45 +000063
epoger@google.comdfbf24e2012-07-13 21:22:02 +000064# Run skdiff over a variety of file pair types: identical bits, identical pixels, missing from
65# baseDir, etc.
epoger@google.coma4443522012-05-17 17:12:38 +000066skdiff_test "$SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test1"
epoger@google.com8e4e51d2012-05-30 19:12:45 +000067
epoger@google.comdfbf24e2012-07-13 21:22:02 +000068# 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.com46a45962012-07-12 18:16:02 +000071# - list filenames with each result type to stdout
72# - don't generate HTML output files
bungeman@google.come3c8ddf2012-12-05 20:13:12 +000073skdiff_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 +000074
epoger@google.comdfbf24e2012-07-13 21:22:02 +000075# Run skdiff over just the files that have identical bits.
76skdiff_test "--nodiffs --match identical-bits $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/identical-bits"
epoger@google.com8e4e51d2012-05-30 19:12:45 +000077
epoger@google.comdfbf24e2012-07-13 21:22:02 +000078# Run skdiff over just the files that have identical bits or identical pixels.
79skdiff_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 +000080
epoger@google.comf4eeeab2013-02-14 15:10:24 +000081
epoger@google.com673816c2013-02-15 15:50:23 +000082# 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.
85function 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.comf4eeeab2013-02-14 15:10:24 +0000108# 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.
111function 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.comf4eeeab2013-02-14 15:10:24 +0000119 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.com673816c2013-02-15 15:50:23 +0000123 # Run bench_graph_svg.py .
epoger@google.comf4eeeab2013-02-14 15:10:24 +0000124 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.com673816c2013-02-15 15:50:23 +0000139benchgraph_download_rawdata Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32 7671
140benchgraph_download_rawdata Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32 7679
141benchgraph_download_rawdata Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32 7686
epoger@google.com2459a392013-02-14 18:58:05 +0000142benchgraph_test Skia_Shuttle_Ubuntu12_ATI5770_Float_Bench_32
epoger@google.comf4eeeab2013-02-14 15:10:24 +0000143
epoger@google.coma2b793c2012-05-15 14:58:53 +0000144echo "All tests passed."