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