Home | History | Annotate | Download | only in win
      1 #!/usr/bin/env python
      2 
      3 # Copyright (c) 2013 Google Inc. All rights reserved.
      4 # Use of this source code is governed by a BSD-style license that can be
      5 # found in the LICENSE file.
      6 
      7 """
      8 Make sure msvs_large_pdb works correctly.
      9 """
     10 
     11 import TestGyp
     12 
     13 import struct
     14 import sys
     15 
     16 if sys.platform == 'win32':
     17   print "This test is currently disabled: https://crbug.com/483696."
     18   sys.exit(0)
     19 
     20 
     21 CHDIR = 'large-pdb'
     22 
     23 
     24 def CheckImageAndPdb(test, image_basename, expected_page_size,
     25                      pdb_basename=None):
     26   if not pdb_basename:
     27     pdb_basename = image_basename + '.pdb'
     28   test.built_file_must_exist(image_basename, chdir=CHDIR)
     29   test.built_file_must_exist(pdb_basename, chdir=CHDIR)
     30 
     31   # We expect the PDB to have the given page size. For full details of the
     32   # header look here: https://code.google.com/p/pdbparser/wiki/MSF_Format
     33   # We read the little-endian 4-byte unsigned integer at position 32 of the
     34   # file.
     35   pdb_path = test.built_file_path(pdb_basename, chdir=CHDIR)
     36   pdb_file = open(pdb_path, 'rb')
     37   pdb_file.seek(32, 0)
     38   page_size = struct.unpack('<I', pdb_file.read(4))[0]
     39   if page_size != expected_page_size:
     40     print "Expected page size of %d, got %d for PDB file `%s'." % (
     41         expected_page_size, page_size, pdb_path)
     42 
     43 
     44 if sys.platform == 'win32':
     45   test = TestGyp.TestGyp(formats=['msvs', 'ninja'])
     46 
     47   test.run_gyp('large-pdb.gyp', chdir=CHDIR)
     48 
     49   test.build('large-pdb.gyp', 'large_pdb_exe', chdir=CHDIR)
     50   CheckImageAndPdb(test, 'large_pdb_exe.exe', 4096)
     51 
     52   test.build('large-pdb.gyp', 'small_pdb_exe', chdir=CHDIR)
     53   CheckImageAndPdb(test, 'small_pdb_exe.exe', 1024)
     54 
     55   test.build('large-pdb.gyp', 'large_pdb_dll', chdir=CHDIR)
     56   CheckImageAndPdb(test, 'large_pdb_dll.dll', 4096)
     57 
     58   test.build('large-pdb.gyp', 'small_pdb_dll', chdir=CHDIR)
     59   CheckImageAndPdb(test, 'small_pdb_dll.dll', 1024)
     60 
     61   test.build('large-pdb.gyp', 'large_pdb_implicit_exe', chdir=CHDIR)
     62   CheckImageAndPdb(test, 'large_pdb_implicit_exe.exe', 4096)
     63 
     64   # This target has a different PDB name because it uses an
     65   # 'msvs_large_pdb_path' variable.
     66   test.build('large-pdb.gyp', 'large_pdb_variable_exe', chdir=CHDIR)
     67   CheckImageAndPdb(test, 'large_pdb_variable_exe.exe', 4096,
     68                    pdb_basename='foo.pdb')
     69 
     70   # This target has a different output name because it uses 'product_name'.
     71   test.build('large-pdb.gyp', 'large_pdb_product_exe', chdir=CHDIR)
     72   CheckImageAndPdb(test, 'bar.exe', 4096)
     73 
     74   test.pass_test()
     75