gyptest-shared.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/usr/bin/env python
  2. # Copyright (c) 2009 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. Verifies simple build of a "Hello, world!" program with shared libraries,
  7. including verifying that libraries are rebuilt correctly when functions
  8. move between libraries.
  9. """
  10. import TestGyp
  11. test = TestGyp.TestGyp()
  12. if test.format == 'android':
  13. # This test currently fails on android. Investigate why, fix the issues
  14. # responsible, and reenable this test on android. See bug:
  15. # https://code.google.com/p/gyp/issues/detail?id=436
  16. test.skip_test(message='Test fails on android. Fix and reenable.\n')
  17. test.run_gyp('library.gyp',
  18. '-Dlibrary=shared_library',
  19. '-Dmoveable_function=lib1',
  20. chdir='src')
  21. test.relocate('src', 'relocate/src')
  22. test.build('library.gyp', test.ALL, chdir='relocate/src')
  23. expect = """\
  24. Hello from program.c
  25. Hello from lib1.c
  26. Hello from lib2.c
  27. Hello from lib1_moveable.c
  28. """
  29. test.run_built_executable('program', chdir='relocate/src', stdout=expect)
  30. test.run_gyp('library.gyp',
  31. '-Dlibrary=shared_library',
  32. '-Dmoveable_function=lib2',
  33. chdir='relocate/src')
  34. # Update program.c to force a rebuild.
  35. test.sleep()
  36. contents = test.read('relocate/src/program.c')
  37. contents = contents.replace('Hello', 'Hello again')
  38. test.write('relocate/src/program.c', contents)
  39. test.build('library.gyp', test.ALL, chdir='relocate/src')
  40. expect = """\
  41. Hello again from program.c
  42. Hello from lib1.c
  43. Hello from lib2.c
  44. Hello from lib2_moveable.c
  45. """
  46. test.run_built_executable('program', chdir='relocate/src', stdout=expect)
  47. test.run_gyp('library.gyp',
  48. '-Dlibrary=shared_library',
  49. '-Dmoveable_function=lib1',
  50. chdir='relocate/src')
  51. # Update program.c to force a rebuild.
  52. test.sleep()
  53. contents = test.read('relocate/src/program.c')
  54. contents = contents.replace('again', 'again again')
  55. test.write('relocate/src/program.c', contents)
  56. # TODO(sgk): we have to force a rebuild of lib2 so that it weeds out
  57. # the "moved" module. This should be done in gyp by adding a dependency
  58. # on the generated .vcproj file itself.
  59. test.touch('relocate/src/lib2.c')
  60. test.build('library.gyp', test.ALL, chdir='relocate/src')
  61. expect = """\
  62. Hello again again from program.c
  63. Hello from lib1.c
  64. Hello from lib2.c
  65. Hello from lib1_moveable.c
  66. """
  67. test.run_built_executable('program', chdir='relocate/src', stdout=expect)
  68. test.pass_test()