gyptest-link-large-pdb.py 2.3 KB

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