blob: 0f900036130aad6f025cb8e82e6601f03d4af29d [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
16function replace_expected_with_actual {
17 # Delete all the expected output files
epoger@google.comf4eeeab2013-02-14 15:10:24 +000018 EXPECTED_FILES=$(find $WHICHTOOL/*/output-expected -type f | grep -v /\.svn/)
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000019 for EXPECTED_FILE in $EXPECTED_FILES; do
20 rm $EXPECTED_FILE
21 done
22
23 # Copy all the actual output files into the "expected" directories,
24 # creating new subdirs as we go.
epoger@google.comf4eeeab2013-02-14 15:10:24 +000025 ACTUAL_FILES=$(find $WHICHTOOL/*/output-actual -type f | grep -v /\.svn/)
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000026 for ACTUAL_FILE in $ACTUAL_FILES; do
27 EXPECTED_FILE=${ACTUAL_FILE//actual/expected}
28 mkdir -p $(dirname $EXPECTED_FILE)
29 cp $ACTUAL_FILE $EXPECTED_FILE
30 done
31}
32
33function svn_add_new_files {
34 # Delete all the "actual" directories, so we can svn-add any new "expected"
35 # directories without adding the "actual" ones.
epoger@google.comf4eeeab2013-02-14 15:10:24 +000036 rm -rf $WHICHTOOL/*/output-actual $WHICHTOOL/*/raw-bench-data
37 FILES=$(svn stat $WHICHTOOL/* | grep ^\? | awk '{print $2}')
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000038 for FILE in $FILES; do
39 svn add $FILE
40 done
epoger@google.comf4eeeab2013-02-14 15:10:24 +000041 FILES=$(svn stat $WHICHTOOL/*/output-expected | grep ^\? | awk '{print $2}')
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000042 for FILE in $FILES; do
43 svn add $FILE
44 done
45}
46
47function svn_delete_old_files {
epoger@google.comf4eeeab2013-02-14 15:10:24 +000048 FILES=$(svn stat $WHICHTOOL/*/output-expected | grep ^\! | awk '{print $2}')
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000049 for FILE in $FILES; do
50 svn rm $FILE
51 done
epoger@google.comf4eeeab2013-02-14 15:10:24 +000052 FILES=$(svn stat $WHICHTOOL/* | grep ^\! | awk '{print $2}')
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000053 for FILE in $FILES; do
54 svn rm $FILE
55 done
56}
57
58
59# cd into the gm self-test dir
60cd $(dirname $0)
61
62./run.sh
63SELFTEST_RESULT=$?
64echo
65if [ "$SELFTEST_RESULT" != "0" ]; then
epoger@google.comf4eeeab2013-02-14 15:10:24 +000066 WHICHTOOL=skdiff
67 replace_expected_with_actual
68 WHICHTOOL=benchgraphs
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000069 replace_expected_with_actual
70 echo "Self-tests still failing, you should probably run this again..."
71else
epoger@google.comf4eeeab2013-02-14 15:10:24 +000072 WHICHTOOL=skdiff
73 svn_add_new_files
74 svn_delete_old_files
75 WHICHTOOL=benchgraphs
rmistry@google.comee5a5ee2013-01-03 19:23:22 +000076 svn_add_new_files
77 svn_delete_old_files
78 echo "Self-tests succeeded this time, you should be done!"
79fi
80exit $SELFTEST_RESULT
81