diff options
| author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-03-04 12:32:42 +0530 |
|---|---|---|
| committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-03-04 09:12:51 -0500 |
| commit | 9ccbe72509d58cda02d2630925dc8a92e8e5b4f9 (patch) | |
| tree | 11b9c362ba3fdd8ccb2bead6b3a98f8eed336749 | |
| parent | a24651f33a925c5860a58c3fb8e7b5ec2efbccbd (diff) | |
| download | meson-9ccbe72509d58cda02d2630925dc8a92e8e5b4f9.tar.gz | |
Add manual-linking tests to Linux and Windows
In this test, we try to manually link against the generated library to
create an executable and then run it to verify that it works.
Also test for all possible library versioning in the versioning tests on
Windows. Even though they yield the same dll naming, we should still
test it.
8 files changed, 122 insertions, 9 deletions
diff --git a/test cases/linuxlike/7 library versions/exe.orig.c b/test cases/linuxlike/7 library versions/exe.orig.c new file mode 100644 index 000000000..1599ebd76 --- /dev/null +++ b/test cases/linuxlike/7 library versions/exe.orig.c @@ -0,0 +1,5 @@ +int +main (int argc, char *argv[]) +{ + return 0; +} diff --git a/test cases/linuxlike/7 library versions/meson.build b/test cases/linuxlike/7 library versions/meson.build index 504aa4e22..c02bbeda2 100644 --- a/test cases/linuxlike/7 library versions/meson.build +++ b/test cases/linuxlike/7 library versions/meson.build @@ -1,18 +1,43 @@ project('library versions', 'c') -shared_library('some', 'lib.c', +some = shared_library('some', 'lib.c', version : '1.2.3', soversion : '0', install : true) -shared_library('noversion', 'lib.c', +noversion = shared_library('noversion', 'lib.c', install : true) -shared_library('onlyversion', 'lib.c', +onlyversion = shared_library('onlyversion', 'lib.c', version : '1.4.5', install : true) -shared_library('onlysoversion', 'lib.c', +onlysoversion = shared_library('onlysoversion', 'lib.c', # Also test that int soversion is acceptable soversion : 5, install : true) + +# Hack to make the executables below depend on the shared libraries above +# without actually adding them as `link_with` dependencies since we want to try +# linking to them with -lfoo linker arguments. +out = custom_target('library-dependency-hack', + input : 'exe.orig.c', + output : 'exe.c', + depends : [some, noversion, onlyversion, onlysoversion], + command : ['cp', '@INPUT@', '@OUTPUT@']) + +rpath_arg = '-Wl,-rpath,' + meson.current_build_dir() + +# Manually test if the linker can find the above libraries +# i.e., whether they were generated with the right naming scheme +test('manually linked 1', executable('manuallink1', out, + link_args : ['-L.', '-lsome', rpath_arg])) + +test('manually linked 2', executable('manuallink2', out, + link_args : ['-L.', '-lnoversion', rpath_arg])) + +test('manually linked 3', executable('manuallink3', out, + link_args : ['-L.', '-lonlyversion', rpath_arg])) + +test('manually linked 4', executable('manuallink4', out, + link_args : ['-L.', '-lonlysoversion', rpath_arg])) diff --git a/test cases/windows/7 mingw dll versioning/exe.orig.c b/test cases/windows/7 mingw dll versioning/exe.orig.c new file mode 100644 index 000000000..1599ebd76 --- /dev/null +++ b/test cases/windows/7 mingw dll versioning/exe.orig.c @@ -0,0 +1,5 @@ +int +main (int argc, char *argv[]) +{ + return 0; +} diff --git a/test cases/windows/7 mingw dll versioning/installed_files.txt b/test cases/windows/7 mingw dll versioning/installed_files.txt index 8c2a8f296..ebad9e422 100644 --- a/test cases/windows/7 mingw dll versioning/installed_files.txt +++ b/test cases/windows/7 mingw dll versioning/installed_files.txt @@ -2,3 +2,7 @@ usr/bin/libsome-0.dll usr/lib/libsome.dll.a usr/bin/libnoversion.dll usr/lib/libnoversion.dll.a +usr/bin/libonlyversion-1.dll +usr/lib/libonlyversion.dll.a +usr/bin/libonlysoversion-5.dll +usr/lib/libonlysoversion.dll.a diff --git a/test cases/windows/7 mingw dll versioning/meson.build b/test cases/windows/7 mingw dll versioning/meson.build index 2f6035eca..d1fe73a9c 100644 --- a/test cases/windows/7 mingw dll versioning/meson.build +++ b/test cases/windows/7 mingw dll versioning/meson.build @@ -8,10 +8,42 @@ endif # Test that MinGW/GCC creates correctly-named dll files and dll.a files, # and also installs them in the right place -shared_library('some', 'lib.c', +some = shared_library('some', 'lib.c', version : '1.2.3', soversion : '0', install : true) -shared_library('noversion', 'lib.c', +noversion = shared_library('noversion', 'lib.c', install : true) + +onlyversion = shared_library('onlyversion', 'lib.c', + version : '1.4.5', + install : true) + +onlysoversion = shared_library('onlysoversion', 'lib.c', + # Also test that int soversion is acceptable + soversion : 5, + install : true) + +# Hack to make the executables below depend on the shared libraries above +# without actually adding them as `link_with` dependencies since we want to try +# linking to them with -lfoo linker arguments. +out = custom_target('library-dependency-hack', + input : 'exe.orig.c', + output : 'exe.c', + depends : [some, noversion, onlyversion, onlysoversion], + command : ['cp', '@INPUT@', '@OUTPUT@']) + +# Manually test if the linker can find the above libraries +# i.e., whether they were generated with the right naming scheme +test('manually linked 1', executable('manuallink1', out, + link_args : ['-L.', '-lsome'])) + +test('manually linked 2', executable('manuallink2', out, + link_args : ['-L.', '-lnoversion'])) + +test('manually linked 3', executable('manuallink3', out, + link_args : ['-L.', '-lonlyversion'])) + +test('manually linked 4', executable('manuallink4', out, + link_args : ['-L.', '-lonlysoversion'])) diff --git a/test cases/windows/8 msvc dll versioning/exe.orig.c b/test cases/windows/8 msvc dll versioning/exe.orig.c new file mode 100644 index 000000000..1599ebd76 --- /dev/null +++ b/test cases/windows/8 msvc dll versioning/exe.orig.c @@ -0,0 +1,5 @@ +int +main (int argc, char *argv[]) +{ + return 0; +} diff --git a/test cases/windows/8 msvc dll versioning/installed_files.txt b/test cases/windows/8 msvc dll versioning/installed_files.txt index e3f72bca3..ae0fa1f67 100644 --- a/test cases/windows/8 msvc dll versioning/installed_files.txt +++ b/test cases/windows/8 msvc dll versioning/installed_files.txt @@ -4,3 +4,7 @@ usr/lib/some.lib usr/bin/noversion.dll usr/bin/noversion.pdb usr/lib/noversion.lib +usr/bin/onlyversion-1.dll +usr/lib/onlyversion.lib +usr/bin/onlysoversion-5.dll +usr/lib/onlysoversion.lib diff --git a/test cases/windows/8 msvc dll versioning/meson.build b/test cases/windows/8 msvc dll versioning/meson.build index d6aecb60a..3f15e766b 100644 --- a/test cases/windows/8 msvc dll versioning/meson.build +++ b/test cases/windows/8 msvc dll versioning/meson.build @@ -6,11 +6,44 @@ if cc.get_id() != 'msvc' error('MESON_SKIP_TEST: test is only for msvc') endif -# Test that MSVC creates foo-0.dll and bar.dll -shared_library('some', 'lib.c', +# Test that MSVC creates correctly-named dll files and .lib files, +# and also installs them in the right place +some = shared_library('some', 'lib.c', version : '1.2.3', soversion : '0', install : true) -shared_library('noversion', 'lib.c', +noversion = shared_library('noversion', 'lib.c', install : true) + +onlyversion = shared_library('onlyversion', 'lib.c', + version : '1.4.5', + install : true) + +onlysoversion = shared_library('onlysoversion', 'lib.c', + # Also test that int soversion is acceptable + soversion : 5, + install : true) + +# Hack to make the executables below depend on the shared libraries above +# without actually adding them as `link_with` dependencies since we want to try +# linking to them with -lfoo linker arguments. +out = custom_target('library-dependency-hack', + input : 'exe.orig.c', + output : 'exe.c', + depends : [some, noversion, onlyversion, onlysoversion], + command : ['cp', '@INPUT@', '@OUTPUT@']) + +# Manually test if the linker can find the above libraries +# i.e., whether they were generated with the right naming scheme +test('manually linked 1', executable('manuallink1', out, + link_args : ['-L.', '-lsome'])) + +test('manually linked 2', executable('manuallink2', out, + link_args : ['-L.', '-lnoversion'])) + +test('manually linked 3', executable('manuallink3', out, + link_args : ['-L.', '-lonlyversion'])) + +test('manually linked 4', executable('manuallink4', out, + link_args : ['-L.', '-lonlysoversion'])) |
