Home | History | Annotate | Download | only in tools
      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 '''
     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.
     14 '''
     15 
     16 import os, subprocess, sys, tempfile
     17 
     18 pairs = [ 
     19    ['base-shuttle-win7-intel-float',
     20     'Skia_Shuttle_Win7_Intel_Float_Release_32'],
     21    ['base-shuttle-win7-intel-angle',
     22     'Skia_Shuttle_Win7_Intel_Float_ANGLE_Release_32'],
     23    ['base-shuttle-win7-intel-directwrite',
     24     'Skia_Shuttle_Win7_Intel_Float_DirectWrite_Release_32'],
     25    ['base-shuttle_ubuntu12_ati5770',
     26     'Skia_Shuttle_Ubuntu12_ATI5770_Float_Release_64'],
     27    ['base-macmini',
     28     'Skia_Mac_Float_Release_32'],
     29    ['base-macmini-lion-float',
     30     'Skia_MacMiniLion_Float_Release_32'],
     31    ['base-android-galaxy-nexus',
     32     'Skia_GalaxyNexus_4-1_Float_Release_32'],
     33    ['base-android-nexus-7',
     34     'Skia_Nexus7_4-1_Float_Release_32'],
     35    ['base-android-nexus-s',
     36     'Skia_NexusS_4-1_Float_Release_32'],
     37    ['base-android-xoom',
     38     'Skia_Xoom_4-1_Float_Release_32'],
     39 ]
     40 
     41 if len(sys.argv) < 2:
     42     print 'Usage:  ' + os.path.basename(sys.argv[0]) + ' <testname> '
     43     '[ <testname> ... ]'
     44     exit(1)
     45 
     46 is_svn_checkout = os.path.exists('.svn') or os.path.exists(os.path.join('..', '.svn') )
     47 is_git_checkout = os.path.exists('.git') or os.path.exists(os.path.join('..', '.git'))
     48 
     49 for testname in sys.argv[1:]:
     50     for pair in pairs:
     51         if (pair[0] == 'base-shuttle-win7-intel-angle'):
     52             testtypes = [ 'angle' ]
     53         else:
     54             testtypes = [ '565', '8888', 'gpu', 'pdf', 'mesa' ]
     55         print pair[0] + ':'
     56         for testtype in testtypes:
     57             infilename = testname + '_' + testtype + '.png'
     58             print infilename
     59 
     60             url = 'http://skia-autogen.googlecode.com/svn/gm-actual/' + pair[0] + '/' + pair[1] + '/' + pair[0] + '/' + 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                 continue
     67             outfilename = os.path.join(pair[0], infilename);
     68             cmd = [ 'cp', temp.name, outfilename ]
     69             subprocess.call(cmd);
     70             if is_svn_checkout:
     71                 cmd = [ 'svn', 'add', '--quiet', outfilename ]
     72                 subprocess.call(cmd)
     73                 cmd = [ 'svn', 'propset', '--quiet', 'svn:mime-type', 'image/png', outfilename ];
     74                 subprocess.call(cmd)
     75             elif is_git_checkout:
     76                 cmd = [ 'git', 'add', outfilename ]
     77                 subprocess.call(cmd)
     78