blob: 7fcaf13a45f1c9013bf20bfe6c53019f88193257 [file] [log] [blame]
senorblanco@chromium.org782f3b42012-10-29 18:06:26 +00001#!/usr/bin/python
2
3'''
4Copyright 2012 Google Inc.
5
6Use of this source code is governed by a BSD-style license that can be
7found in the LICENSE file.
8'''
9
10'''
senorblanco@chromium.org123a0b52012-11-29 21:50:34 +000011Rebaselines the given GM tests, on all bots and all configurations.
12Must be run from the gm-expected directory. If run from a git or SVN
13checkout, the files will be added to the staging area for commit.
senorblanco@chromium.org782f3b42012-10-29 18:06:26 +000014'''
15
epoger@google.comec3397b2013-05-29 17:09:43 +000016import os
17import subprocess
18import sys
19import tempfile
senorblanco@chromium.org782f3b42012-10-29 18:06:26 +000020
epoger@google.comec3397b2013-05-29 17:09:43 +000021# Mapping of gm-expectations subdir (under
22# https://skia.googlecode.com/svn/gm-expected/ )
23# to builder name (see list at http://108.170.217.252:10117/builders )
24subdir_mapping = {
25 'base-shuttle-win7-intel-float':
26 'Test-Win7-ShuttleA-HD2000-x86-Release',
27 'base-shuttle-win7-intel-angle':
28 'Test-Win7-ShuttleA-HD2000-x86-Release-ANGLE',
29 'base-shuttle-win7-intel-directwrite':
30 'Test-Win7-ShuttleA-HD2000-x86-Release-DirectWrite',
31 'base-shuttle_ubuntu12_ati5770':
32 'Test-Ubuntu12-ShuttleA-ATI5770-x86_64-Release',
33 'base-macmini':
34 'Test-Mac10.6-MacMini4.1-GeForce320M-x86-Release',
35 'base-macmini-lion-float':
36 'Test-Mac10.7-MacMini4.1-GeForce320M-x86-Release',
37 'base-android-galaxy-nexus':
38 'Test-Android-GalaxyNexus-SGX540-Arm7-Debug',
39 'base-android-nexus-7':
40 'Test-Android-Nexus7-Tegra3-Arm7-Release',
41 'base-android-nexus-s':
42 'Test-Android-NexusS-SGX540-Arm7-Release',
43 'base-android-xoom':
44 'Test-Android-Xoom-Tegra2-Arm7-Release',
45 'base-android-nexus-10':
46 'Test-Android-Nexus10-MaliT604-Arm7-Release',
47}
48
49IS_SVN_CHECKOUT = (os.path.exists('.svn') or
50 os.path.exists(os.path.join('..', '.svn')))
51IS_GIT_CHECKOUT = (os.path.exists('.git') or
52 os.path.exists(os.path.join('..', '.git')))
53
54
55# Rebaseline a single file.
56def RebaselineOneFile(expectations_subdir, builder_name,
57 infilename, outfilename):
58 url = ('http://skia-autogen.googlecode.com/svn/gm-actual/' +
59 expectations_subdir + '/' + builder_name + '/' +
60 expectations_subdir + '/' + infilename)
61 cmd = [ 'curl', '--fail', '--silent', url ]
62 temp = tempfile.NamedTemporaryFile()
63 ret = subprocess.call(cmd, stdout=temp)
64 if ret != 0:
65 print 'Couldn\'t fetch ' + url
66 return
67 cmd = [ 'cp', temp.name, outfilename ]
68 subprocess.call(cmd);
69 if IS_SVN_CHECKOUT:
70 cmd = [ 'svn', 'add', '--quiet', outfilename ]
71 subprocess.call(cmd)
72 cmd = [ 'svn', 'propset', '--quiet', 'svn:mime-type', 'image/png',
73 outfilename ];
74 subprocess.call(cmd)
75 elif IS_GIT_CHECKOUT:
76 cmd = [ 'git', 'add', outfilename ]
77 subprocess.call(cmd)
78
79
80# Rebaseline all testtypes for a single test.
81def RebaselineOneTest(expectations_subdir, builder_name, testname):
82 if (expectations_subdir == 'base-shuttle-win7-intel-angle'):
83 testtypes = [ 'angle', 'anglemsaa16' ]
84 else:
85 testtypes = [ '565', '8888', 'gpu', 'pdf', 'mesa', 'msaa16', 'msaa4' ]
86 print expectations_subdir + ':'
87 for testtype in testtypes:
88 infilename = testname + '_' + testtype + '.png'
89 print infilename
90 outfilename = os.path.join(expectations_subdir, infilename);
91 RebaselineOneFile(expectations_subdir=expectations_subdir,
92 builder_name=builder_name,
93 infilename=infilename,
94 outfilename=outfilename)
95
96
senorblanco@chromium.org782f3b42012-10-29 18:06:26 +000097
senorblanco@chromium.org123a0b52012-11-29 21:50:34 +000098if len(sys.argv) < 2:
epoger@google.comec3397b2013-05-29 17:09:43 +000099 print ('Usage: ' + os.path.basename(sys.argv[0]) +
100 ' <testname> [ <testname> ... ]')
senorblanco@chromium.org782f3b42012-10-29 18:06:26 +0000101 exit(1)
102
senorblanco@chromium.org123a0b52012-11-29 21:50:34 +0000103for testname in sys.argv[1:]:
epoger@google.comec3397b2013-05-29 17:09:43 +0000104 for expectations_subdir in sorted(subdir_mapping.keys()):
105 builder_name = subdir_mapping[expectations_subdir]
106 RebaselineOneTest(expectations_subdir=expectations_subdir,
107 builder_name=builder_name,
108 testname=testname)