media/webrtc/trunk/tools/gyp/test/library/gyptest-static.py

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rwxr-xr-x

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 #!/usr/bin/env python
michael@0 2
michael@0 3 # Copyright (c) 2009 Google Inc. All rights reserved.
michael@0 4 # Use of this source code is governed by a BSD-style license that can be
michael@0 5 # found in the LICENSE file.
michael@0 6
michael@0 7 """
michael@0 8 Verifies simple build of a "Hello, world!" program with static libraries,
michael@0 9 including verifying that libraries are rebuilt correctly when functions
michael@0 10 move between libraries.
michael@0 11 """
michael@0 12
michael@0 13 import TestGyp
michael@0 14
michael@0 15 test = TestGyp.TestGyp()
michael@0 16
michael@0 17 test.run_gyp('library.gyp',
michael@0 18 '-Dlibrary=static_library',
michael@0 19 '-Dmoveable_function=lib1',
michael@0 20 chdir='src')
michael@0 21
michael@0 22 test.relocate('src', 'relocate/src')
michael@0 23
michael@0 24 test.build('library.gyp', test.ALL, chdir='relocate/src')
michael@0 25
michael@0 26 expect = """\
michael@0 27 Hello from program.c
michael@0 28 Hello from lib1.c
michael@0 29 Hello from lib2.c
michael@0 30 Hello from lib1_moveable.c
michael@0 31 """
michael@0 32 test.run_built_executable('program', chdir='relocate/src', stdout=expect)
michael@0 33
michael@0 34
michael@0 35 test.run_gyp('library.gyp',
michael@0 36 '-Dlibrary=static_library',
michael@0 37 '-Dmoveable_function=lib2',
michael@0 38 chdir='relocate/src')
michael@0 39
michael@0 40 # Update program.c to force a rebuild.
michael@0 41 test.sleep()
michael@0 42 contents = test.read('relocate/src/program.c')
michael@0 43 contents = contents.replace('Hello', 'Hello again')
michael@0 44 test.write('relocate/src/program.c', contents)
michael@0 45
michael@0 46 test.build('library.gyp', test.ALL, chdir='relocate/src')
michael@0 47
michael@0 48 expect = """\
michael@0 49 Hello again from program.c
michael@0 50 Hello from lib1.c
michael@0 51 Hello from lib2.c
michael@0 52 Hello from lib2_moveable.c
michael@0 53 """
michael@0 54 test.run_built_executable('program', chdir='relocate/src', stdout=expect)
michael@0 55
michael@0 56
michael@0 57 test.run_gyp('library.gyp',
michael@0 58 '-Dlibrary=static_library',
michael@0 59 '-Dmoveable_function=lib1',
michael@0 60 chdir='relocate/src')
michael@0 61
michael@0 62 # Update program.c and lib2.c to force a rebuild.
michael@0 63 test.sleep()
michael@0 64 contents = test.read('relocate/src/program.c')
michael@0 65 contents = contents.replace('again', 'again again')
michael@0 66 test.write('relocate/src/program.c', contents)
michael@0 67
michael@0 68 # TODO(sgk): we have to force a rebuild of lib2 so that it weeds out
michael@0 69 # the "moved" module. This should be done in gyp by adding a dependency
michael@0 70 # on the generated .vcproj file itself.
michael@0 71 test.touch('relocate/src/lib2.c')
michael@0 72
michael@0 73 test.build('library.gyp', test.ALL, chdir='relocate/src')
michael@0 74
michael@0 75 expect = """\
michael@0 76 Hello again again from program.c
michael@0 77 Hello from lib1.c
michael@0 78 Hello from lib2.c
michael@0 79 Hello from lib1_moveable.c
michael@0 80 """
michael@0 81 test.run_built_executable('program', chdir='relocate/src', stdout=expect)
michael@0 82
michael@0 83
michael@0 84 test.pass_test()

mercurial