Mir

Merge lp:~vanvugt/mir/test-pkgconfig into lp:mir

Proposed by Daniel van Vugt
Status: Rejected
Rejected by: Daniel van Vugt
Proposed branch: lp:~vanvugt/mir/test-pkgconfig
Merge into: lp:mir
Diff against target: 172 lines (+140/-0)
5 files modified
tests/CMakeLists.txt (+1/-0)
tests/pkgconfig/CMakeLists.txt (+11/-0)
tests/pkgconfig/standaloneclient/CMakeLists.txt (+45/-0)
tests/pkgconfig/standaloneserver/CMakeLists.txt (+45/-0)
tests/pkgconfig/standaloneserver/server.cpp (+38/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/test-pkgconfig
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Fixing
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Needs Fixing
Review via email: mp+229756@code.launchpad.net

Commit message

Add test coverage to exercise mirclient.pc.in and mirserver.pc.in and to
verify that they will work in external projects for building clients and
servers. (LP: #1352757)

Description of the change

This way we don't have to find out after-the-fact that qtmir/usc/gtk-3 aren't buildable any more.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

50 +set(LIBDIR ${Mir_BINARY_DIR}/lib)
51 +set(INCLUDEDIR ${Mir_SOURCE_DIR}/include/client)
52 +set(COMMON_INCLUDEDIR ${Mir_SOURCE_DIR}/include/shared)
53 +configure_file(${Mir_SOURCE_DIR}/src/client/mirclient.pc.in
54 + ${StandaloneClient_BINARY_DIR}/mirclient.pc)
55 +set(ENV{PKG_CONFIG_PATH} ${StandaloneClient_BINARY_DIR})

This is the code that is tested. Not the code in ${Mir_SOURCE_DIR}/src/client/CMakeLists.txt that generates the real mirclient.pc. Similarly the mirserver.pc code.

I'm not sure what the right way to test is, but cut, paste & edit of the code setting these variables before configure_file() isn't enough.

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Alan,

Yes it's an imperfect build-time test for the pkg-config source files *.pc.in

I think you're asking for a system test of the final released packages files. That's ideal, but also not necessary. I'm still testing real *.pc files here made from the same pc input text. The fact that the paths in the tested pc files are temporary ones isn't a bug but a feature. It allows us to test the correctness of our pkg-config within the build tree, before final installation. Although you could use the real pc files with a fake root into the build tree, the result is the same (albeit more awkward) than what's proposed here.

More importantly at the end of the exercise I came to realize that CMake's insertion of temporary hard-coded search paths (rpath) actually makes any build-time testing of *.pc insufficient either way. Because the build-time search paths are literally hacked out just before packaging (thanks CMake). So the results of final package testing could easily be different.

This proposal is a basic indication of major problems in *.pc.in but it won't catch everything. And for the reason just explained, even using the real *.pc output files in a fake root would be equally insufficient, unfortunately. You either have to test the final released packages (which we do later of course), or accept that what you're testing before packaging is not the same set of binaries with the same search paths as what is about to be released.

lp:~vanvugt/mir/test-pkgconfig updated
1833. By Daniel van Vugt

Merge latest development-branch

1834. By Daniel van Vugt

Merge latest development-branch

1835. By Daniel van Vugt

Add missing mirplatform.pc, which is now a requirement again.

Revision history for this message
Chris Halse Rogers (raof) wrote :

Hm. You actually could do a proper test - invoke “make install DESTDIR=tmp”, then set pkg-config to “pkg-config --define-variable=prefix=/where/we/are/tmp/” and set PKG_CONFIG_PATH appropriately.

CMake would then nicely strip the rpath from the libraries, and you'd be testing the .pc files as-installed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

OK, we're seeing linkage regressions that these tests are failing to notice: bug 1355021

That's probably because of the rpath madness I mentioned. I think this proposal is presently too impotent to be useful...

review: Needs Fixing

Unmerged revisions

1835. By Daniel van Vugt

Add missing mirplatform.pc, which is now a requirement again.

1834. By Daniel van Vugt

Merge latest development-branch

1833. By Daniel van Vugt

Merge latest development-branch

1832. By Daniel van Vugt

Actual working detection of cross-compiling.

1831. By Daniel van Vugt

Don't try testing pkg-config projects when cross compiling. Our cross-compile
environment is a little bit too wacky right now (many include and lib paths
don't exist).

1830. By Daniel van Vugt

Add tests for mirclient.pc

1829. By Daniel van Vugt

Remove old experimental examples/* changes

1828. By Daniel van Vugt

Much improved, and stricter testing of mirserver.pc

1827. By Daniel van Vugt

First working prototype test project that exercises mirserver.pc.in

1826. By Daniel van Vugt

First attempt at getting examples/ to use *.pc(.in)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2014-07-02 06:29:24 +0000
+++ tests/CMakeLists.txt 2014-08-08 06:13:52 +0000
@@ -50,5 +50,6 @@
50add_subdirectory(mir_test_doubles/)50add_subdirectory(mir_test_doubles/)
51add_subdirectory(client-language/)51add_subdirectory(client-language/)
52add_subdirectory(mir-stress/)52add_subdirectory(mir-stress/)
53add_subdirectory(pkgconfig)
5354
54mir_add_memcheck_test()55mir_add_memcheck_test()
5556
=== added directory 'tests/pkgconfig'
=== added file 'tests/pkgconfig/CMakeLists.txt'
--- tests/pkgconfig/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/pkgconfig/CMakeLists.txt 2014-08-08 06:13:52 +0000
@@ -0,0 +1,11 @@
1
2# FIXME: Can't run pkg-config build testing when cross-compiling. It tries
3# to use a bunch of paths under MIR_NDK_PATH that actually don't exist.
4# That probably needs fixing in our cross-compile setup scripts, but
5# so long as these test projects get attempted on native builds,
6# that is sufficient test coverage.
7
8if (NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM MATCHES "NEVER")
9 add_subdirectory(standaloneserver)
10 add_subdirectory(standaloneclient)
11endif()
012
=== added directory 'tests/pkgconfig/standaloneclient'
=== added file 'tests/pkgconfig/standaloneclient/CMakeLists.txt'
--- tests/pkgconfig/standaloneclient/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/pkgconfig/standaloneclient/CMakeLists.txt 2014-08-08 06:13:52 +0000
@@ -0,0 +1,45 @@
1#
2# This project tests the correctness of mirclient.pc.in, ensuring it contains
3# everything an external project needs to successfully compile and link
4# a mir client.
5#
6project(StandaloneClient)
7
8# Forget everything you know about the parent "Mir" project. Pretend you're
9# a distant third-party project. This ensures the directories we do get are
10# coming from mirclient.pc ...
11set_directory_properties(PROPERTIES
12 INCLUDE_DIRECTORIES ""
13 LINK_DIRECTORIES ""
14)
15
16# Generate a temporary mirclient.pc file which points into the build tree ...
17set(LIBDIR ${Mir_BINARY_DIR}/lib)
18set(INCLUDEDIR ${Mir_SOURCE_DIR}/include/client)
19set(COMMON_INCLUDEDIR ${Mir_SOURCE_DIR}/include/shared)
20configure_file(${Mir_SOURCE_DIR}/src/client/mirclient.pc.in
21 ${StandaloneClient_BINARY_DIR}/mirclient.pc)
22set(ENV{PKG_CONFIG_PATH} ${StandaloneClient_BINARY_DIR})
23
24# Now use mirclient.pc like real projects do, verifying it provides all
25# the necessary information to build...
26find_package(PkgConfig)
27pkg_check_modules(LOCALMIRCLIENT REQUIRED mirclient)
28
29include_directories(${LOCALMIRCLIENT_INCLUDE_DIRS})
30link_directories(${LOCALMIRCLIENT_LIBRARY_DIRS})
31add_compile_options(${LOCALMIRCLIENT_CFLAGS})
32
33set(CLIENT_SRC "${Mir_SOURCE_DIR}/examples/flicker.c")
34add_compile_options("-std=c99")
35
36# Test CMake-style explicit linkage: "foo/libbar.so"
37add_executable(test_standaloneclient_directlink ${CLIENT_SRC})
38add_dependencies(test_standaloneclient_directlink mirclient)
39target_link_libraries(test_standaloneclient_directlink ${LOCALMIRCLIENT_LIBRARIES})
40
41# Test traditional linkage: "-Lfoo -lbar"
42add_executable(test_standaloneclient_searchlink ${CLIENT_SRC})
43add_dependencies(test_standaloneclient_searchlink mirclient)
44target_link_libraries(test_standaloneclient_searchlink ${LOCALMIRCLIENT_LDFLAGS})
45
046
=== added directory 'tests/pkgconfig/standaloneserver'
=== added file 'tests/pkgconfig/standaloneserver/CMakeLists.txt'
--- tests/pkgconfig/standaloneserver/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/pkgconfig/standaloneserver/CMakeLists.txt 2014-08-08 06:13:52 +0000
@@ -0,0 +1,45 @@
1#
2# This project tests the correctness of mirserver.pc.in, ensuring it contains
3# everything an external project needs to successfully compile and link
4# a mir server.
5#
6project(StandaloneServer)
7
8# Forget everything you know about the parent "Mir" project. Pretend you're
9# a distant third-party project. This ensures the directories we do get are
10# coming from mirserver.pc ...
11set_directory_properties(PROPERTIES
12 INCLUDE_DIRECTORIES ""
13 LINK_DIRECTORIES ""
14)
15
16# Generate a temporary mirserver.pc file which points into the build tree ...
17set(LIBDIR ${Mir_BINARY_DIR}/lib)
18set(INCLUDEDIR ${Mir_SOURCE_DIR}/include/server)
19set(PLATFORM_INCLUDEDIR ${Mir_SOURCE_DIR}/include/platform)
20set(COMMON_INCLUDEDIR ${Mir_SOURCE_DIR}/include/shared)
21configure_file(${Mir_SOURCE_DIR}/src/platform/mirplatform.pc.in
22 ${StandaloneServer_BINARY_DIR}/mirplatform.pc)
23configure_file(${Mir_SOURCE_DIR}/src/server/mirserver.pc.in
24 ${StandaloneServer_BINARY_DIR}/mirserver.pc)
25set(ENV{PKG_CONFIG_PATH} ${StandaloneServer_BINARY_DIR})
26
27# Now use mirserver.pc like real projects do, verifying it provides all
28# the necessary information to build...
29find_package(PkgConfig)
30pkg_check_modules(LOCALMIRSERVER REQUIRED mirserver)
31
32include_directories(${LOCALMIRSERVER_INCLUDE_DIRS})
33link_directories(${LOCALMIRSERVER_LIBRARY_DIRS})
34add_compile_options(${LOCALMIRSERVER_CFLAGS})
35
36# Test CMake-style explicit linkage: "foo/libbar.so"
37add_executable(test_standaloneserver_directlink server.cpp)
38add_dependencies(test_standaloneserver_directlink mirserver)
39target_link_libraries(test_standaloneserver_directlink ${LOCALMIRSERVER_LIBRARIES})
40
41# Test traditional linkage: "-Lfoo -lbar"
42add_executable(test_standaloneserver_searchlink server.cpp)
43add_dependencies(test_standaloneserver_searchlink mirserver)
44target_link_libraries(test_standaloneserver_searchlink ${LOCALMIRSERVER_LDFLAGS})
45
046
=== added file 'tests/pkgconfig/standaloneserver/server.cpp'
--- tests/pkgconfig/standaloneserver/server.cpp 1970-01-01 00:00:00 +0000
+++ tests/pkgconfig/standaloneserver/server.cpp 2014-08-08 06:13:52 +0000
@@ -0,0 +1,38 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */
18
19#include "mir/default_server_configuration.h"
20#include "mir/run_mir.h"
21#include "mir/geometry/rectangle.h"
22
23using namespace mir;
24using namespace mir::geometry;
25
26int main(int argc, char const* argv[])
27{
28 // Exercise some symbols from libmircommon. Make sure users of
29 // mirserver.pc get these automatically in their link lines...
30 Rectangle a;
31 (void)a.bottom_right();
32 Rectangle b;
33 (void)a.contains(b);
34
35 DefaultServerConfiguration config(argc, argv);
36 run_mir(config, [](mir::DisplayServer&){} );
37 return 0;
38}

Subscribers

People subscribed via source and target branches