michael@0: #!/usr/bin/env python michael@0: michael@0: # Copyright (c) 2009 Google Inc. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: """ michael@0: Verifies simple build of a "Hello, world!" program with shared libraries, michael@0: including verifying that libraries are rebuilt correctly when functions michael@0: move between libraries. michael@0: """ michael@0: michael@0: import TestGyp michael@0: michael@0: test = TestGyp.TestGyp() michael@0: michael@0: test.run_gyp('library.gyp', michael@0: '-Dlibrary=shared_library', michael@0: '-Dmoveable_function=lib1', michael@0: chdir='src') michael@0: michael@0: test.relocate('src', 'relocate/src') michael@0: michael@0: test.build('library.gyp', test.ALL, chdir='relocate/src') michael@0: michael@0: expect = """\ michael@0: Hello from program.c michael@0: Hello from lib1.c michael@0: Hello from lib2.c michael@0: Hello from lib1_moveable.c michael@0: """ michael@0: test.run_built_executable('program', chdir='relocate/src', stdout=expect) michael@0: michael@0: michael@0: test.run_gyp('library.gyp', michael@0: '-Dlibrary=shared_library', michael@0: '-Dmoveable_function=lib2', michael@0: chdir='relocate/src') michael@0: michael@0: # Update program.c to force a rebuild. michael@0: test.sleep() michael@0: contents = test.read('relocate/src/program.c') michael@0: contents = contents.replace('Hello', 'Hello again') michael@0: test.write('relocate/src/program.c', contents) michael@0: michael@0: test.build('library.gyp', test.ALL, chdir='relocate/src') michael@0: michael@0: expect = """\ michael@0: Hello again from program.c michael@0: Hello from lib1.c michael@0: Hello from lib2.c michael@0: Hello from lib2_moveable.c michael@0: """ michael@0: test.run_built_executable('program', chdir='relocate/src', stdout=expect) michael@0: michael@0: michael@0: test.run_gyp('library.gyp', michael@0: '-Dlibrary=shared_library', michael@0: '-Dmoveable_function=lib1', michael@0: chdir='relocate/src') michael@0: michael@0: # Update program.c to force a rebuild. michael@0: test.sleep() michael@0: contents = test.read('relocate/src/program.c') michael@0: contents = contents.replace('again', 'again again') michael@0: test.write('relocate/src/program.c', contents) michael@0: michael@0: # TODO(sgk): we have to force a rebuild of lib2 so that it weeds out michael@0: # the "moved" module. This should be done in gyp by adding a dependency michael@0: # on the generated .vcproj file itself. michael@0: test.touch('relocate/src/lib2.c') michael@0: michael@0: test.build('library.gyp', test.ALL, chdir='relocate/src') michael@0: michael@0: expect = """\ michael@0: Hello again again from program.c michael@0: Hello from lib1.c michael@0: Hello from lib2.c michael@0: Hello from lib1_moveable.c michael@0: """ michael@0: test.run_built_executable('program', chdir='relocate/src', stdout=expect) michael@0: michael@0: michael@0: test.pass_test()