senorblanco@chromium.org | 782f3b4 | 2012-10-29 18:06:26 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | ''' |
| 4 | Copyright 2012 Google Inc. |
| 5 | |
| 6 | Use of this source code is governed by a BSD-style license that can be |
| 7 | found in the LICENSE file. |
| 8 | ''' |
| 9 | |
| 10 | ''' |
senorblanco@chromium.org | 123a0b5 | 2012-11-29 21:50:34 +0000 | [diff] [blame] | 11 | Rebaselines the given GM tests, on all bots and all configurations. |
| 12 | Must be run from the gm-expected directory. If run from a git or SVN |
| 13 | checkout, the files will be added to the staging area for commit. |
senorblanco@chromium.org | 782f3b4 | 2012-10-29 18:06:26 +0000 | [diff] [blame] | 14 | ''' |
| 15 | |
epoger@google.com | ec3397b | 2013-05-29 17:09:43 +0000 | [diff] [blame] | 16 | import os |
| 17 | import subprocess |
| 18 | import sys |
| 19 | import tempfile |
senorblanco@chromium.org | 782f3b4 | 2012-10-29 18:06:26 +0000 | [diff] [blame] | 20 | |
epoger@google.com | ec3397b | 2013-05-29 17:09:43 +0000 | [diff] [blame] | 21 | # 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 ) |
| 24 | subdir_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 | |
| 49 | IS_SVN_CHECKOUT = (os.path.exists('.svn') or |
| 50 | os.path.exists(os.path.join('..', '.svn'))) |
| 51 | IS_GIT_CHECKOUT = (os.path.exists('.git') or |
| 52 | os.path.exists(os.path.join('..', '.git'))) |
| 53 | |
| 54 | |
| 55 | # Rebaseline a single file. |
| 56 | def 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. |
| 81 | def 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.org | 782f3b4 | 2012-10-29 18:06:26 +0000 | [diff] [blame] | 97 | |
senorblanco@chromium.org | 123a0b5 | 2012-11-29 21:50:34 +0000 | [diff] [blame] | 98 | if len(sys.argv) < 2: |
epoger@google.com | ec3397b | 2013-05-29 17:09:43 +0000 | [diff] [blame] | 99 | print ('Usage: ' + os.path.basename(sys.argv[0]) + |
| 100 | ' <testname> [ <testname> ... ]') |
senorblanco@chromium.org | 782f3b4 | 2012-10-29 18:06:26 +0000 | [diff] [blame] | 101 | exit(1) |
| 102 | |
senorblanco@chromium.org | 123a0b5 | 2012-11-29 21:50:34 +0000 | [diff] [blame] | 103 | for testname in sys.argv[1:]: |
epoger@google.com | ec3397b | 2013-05-29 17:09:43 +0000 | [diff] [blame] | 104 | 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) |