blob: 4fe044dbbeb4eb3aeec975e70e07237247d0fedf [file] [log] [blame]
rmistry@google.comee5a5ee2013-01-03 19:23:22 +00001#!/bin/bash
2
3# Rebaseline the skdiff/*/output-expected/ subdirectories used by the skdiff
epoger@google.comf4eeeab2013-02-14 15:10:24 +00004# self-tests, and similar for benchgraphs/*/output-expected.
5#
rmistry@google.comee5a5ee2013-01-03 19:23:22 +00006# Use with caution: are you sure the new results are actually correct?
7#
8# YOU MUST RE-RUN THIS UNTIL THE SELF-TESTS SUCCEED!
9#
10# TODO: currently, this must be run on Linux to generate baselines that match
11# the ones on the housekeeper bot (which runs on Linux... see
12# http://70.32.156.51:10117/builders/Skia_PerCommit_House_Keeping/builds/1417/steps/RunGmSelfTests/logs/stdio )
13# See https://code.google.com/p/skia/issues/detail?id=677
14# ('make tools/tests/run.sh work cross-platform')
15
epoger@google.com19e80c12013-06-06 15:11:11 +000016# Replace expected output with actual output, within subdir $1.
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000017function replace_expected_with_actual {
epoger@google.com19e80c12013-06-06 15:11:11 +000018 if [ $# != 1 ]; then
19 echo "replace_expected_with_actual requires exactly 1 parameter, got $#"
20 exit 1
21 fi
22
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000023 # Delete all the expected output files
epoger@google.com19e80c12013-06-06 15:11:11 +000024 EXPECTED_FILES=$(find $1/*/output-expected -type f | grep -v /\.svn/)
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000025 for EXPECTED_FILE in $EXPECTED_FILES; do
26 rm $EXPECTED_FILE
27 done
28
29 # Copy all the actual output files into the "expected" directories,
30 # creating new subdirs as we go.
epoger@google.com19e80c12013-06-06 15:11:11 +000031 ACTUAL_FILES=$(find $1/*/output-actual -type f | grep -v /\.svn/)
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000032 for ACTUAL_FILE in $ACTUAL_FILES; do
33 EXPECTED_FILE=${ACTUAL_FILE//actual/expected}
34 mkdir -p $(dirname $EXPECTED_FILE)
35 cp $ACTUAL_FILE $EXPECTED_FILE
36 done
37}
38
epoger@google.com19e80c12013-06-06 15:11:11 +000039# Add all new files to SVN control, within subdir $1.
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000040function svn_add_new_files {
epoger@google.com19e80c12013-06-06 15:11:11 +000041 if [ $# != 1 ]; then
42 echo "svn_add_new_files requires exactly 1 parameter, got $#"
43 exit 1
44 fi
45
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000046 # Delete all the "actual" directories, so we can svn-add any new "expected"
47 # directories without adding the "actual" ones.
epoger@google.com19e80c12013-06-06 15:11:11 +000048 rm -rf $1/*/output-actual $1/*/raw-bench-data
49 FILES=$(svn stat $1/* | grep ^\? | awk '{print $2}')
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000050 for FILE in $FILES; do
51 svn add $FILE
52 done
epoger@google.com19e80c12013-06-06 15:11:11 +000053 FILES=$(svn stat $1/*/output-expected | grep ^\? | awk '{print $2}')
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000054 for FILE in $FILES; do
55 svn add $FILE
56 done
57}
58
epoger@google.com19e80c12013-06-06 15:11:11 +000059# For any files that have been removed from subdir $1, remove them from
60# SVN control.
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000061function svn_delete_old_files {
epoger@google.com19e80c12013-06-06 15:11:11 +000062 if [ $# != 1 ]; then
63 echo "svn_delete_old_files requires exactly 1 parameter, got $#"
64 exit 1
65 fi
66
67 FILES=$(svn stat $1/*/output-expected | grep ^\! | awk '{print $2}')
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000068 for FILE in $FILES; do
69 svn rm $FILE
70 done
epoger@google.com19e80c12013-06-06 15:11:11 +000071 FILES=$(svn stat $1/* | grep ^\! | awk '{print $2}')
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000072 for FILE in $FILES; do
73 svn rm $FILE
74 done
75}
76
77
78# cd into the gm self-test dir
79cd $(dirname $0)
80
81./run.sh
82SELFTEST_RESULT=$?
epoger@google.com53953b42013-07-02 20:22:27 +000083SUBDIRS="skdiff benchgraphs rebaseline/output jsondiff/output"
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000084echo
85if [ "$SELFTEST_RESULT" != "0" ]; then
epoger@google.com19e80c12013-06-06 15:11:11 +000086 for SUBDIR in $SUBDIRS; do
87 replace_expected_with_actual $SUBDIR
epoger@google.comdb29a312013-06-04 14:58:47 +000088 done
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000089 echo "Self-tests still failing, you should probably run this again..."
90else
epoger@google.com19e80c12013-06-06 15:11:11 +000091 for SUBDIR in $SUBDIRS; do
92 svn_add_new_files $SUBDIR
93 svn_delete_old_files $SUBDIR
epoger@google.comdb29a312013-06-04 14:58:47 +000094 done
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000095 echo "Self-tests succeeded this time, you should be done!"
96fi
97exit $SELFTEST_RESULT
98