Mir

Merge lp:~raof/mir/privatise-all-the-things into lp:mir

Proposed by Chris Halse Rogers
Status: Superseded
Proposed branch: lp:~raof/mir/privatise-all-the-things
Merge into: lp:mir
Prerequisite: lp:~raof/mir/shared-library-prober
Diff against target: 4356 lines (+1981/-593)
116 files modified
CMakeLists.txt (+3/-1)
client-ABI-sha1sums (+1/-1)
common-ABI-sha1sums (+3/-1)
debian/control (+6/-10)
debian/create_postinst_prerm_scripts.sh (+0/-39)
debian/install_ld_so_conf.sh (+0/-26)
debian/mir-client-platform-android-1.install (+1/-1)
debian/mir-client-platform-mesa-1.install (+1/-1)
debian/mir-platform-graphics-android-1.install (+1/-1)
debian/mir-platform-graphics-mesa-1.install (+1/-1)
debian/rules (+0/-11)
debian/update-alternatives.postinst.in (+0/-18)
debian/update-alternatives.prerm.in (+0/-16)
include.private/common/mir/shared_library.h (+9/-0)
include.private/platform/mir/graphics/platform.h (+36/-0)
include.private/platform/mir/shared_library_loader.h (+0/-28)
include/common/mir_toolkit/mesa/native_display.h (+3/-3)
include/platform/mir/options/configuration.h (+2/-0)
include/server/mir/default_server_configuration.h (+3/-0)
platform-ABI-sha1sums (+4/-2)
server-ABI-sha1sums (+5/-3)
src/client/CMakeLists.txt (+15/-11)
src/client/android/CMakeLists.txt (+6/-22)
src/client/android/android_native_display_container.cpp (+16/-4)
src/client/android/android_native_display_container.h (+8/-1)
src/client/android/client_platform_factory.cpp (+21/-5)
src/client/android/client_platform_factory.h (+2/-5)
src/client/android/symbols.map (+2/-1)
src/client/client_platform_factory.h (+5/-2)
src/client/connection_configuration.h (+0/-3)
src/client/default_connection_configuration.cpp (+23/-18)
src/client/default_connection_configuration.h (+0/-4)
src/client/egl_native_display_container.h (+3/-1)
src/client/mesa/CMakeLists.txt (+5/-22)
src/client/mesa/client_platform.cpp (+1/-1)
src/client/mesa/client_platform_factory.cpp (+19/-5)
src/client/mesa/client_platform_factory.h (+0/-5)
src/client/mesa/mesa_native_display_container.cpp (+5/-5)
src/client/mesa/mesa_native_display_container.h (+1/-1)
src/client/mesa/native_surface.cpp (+0/-1)
src/client/mesa/symbols.map (+4/-2)
src/client/mir_connection.cpp (+7/-4)
src/client/mir_connection.h (+3/-1)
src/client/probing_client_platform_factory.cpp (+36/-0)
src/client/probing_client_platform_factory.h (+27/-0)
src/common/graphics/android/mir_native_window.cpp (+0/-1)
src/common/logging/CMakeLists.txt (+1/-1)
src/common/sharedlibrary/CMakeLists.txt (+4/-1)
src/common/sharedlibrary/shared_library.cpp (+12/-0)
src/platform/CMakeLists.txt (+19/-6)
src/platform/graphics/CMakeLists.txt (+1/-0)
src/platform/graphics/android/CMakeLists.txt (+15/-25)
src/platform/graphics/android/android_platform.cpp (+23/-0)
src/platform/graphics/android/symbols.map (+8/-0)
src/platform/graphics/mesa/CMakeLists.txt (+18/-27)
src/platform/graphics/mesa/platform.cpp (+28/-0)
src/platform/graphics/mesa/symbols.map (+8/-0)
src/platform/graphics/platform_probe.cpp (+50/-0)
src/platform/graphics/platform_probe.h (+37/-0)
src/platform/options/default_configuration.cpp (+70/-20)
src/platform/shared_library_loader.cpp (+0/-38)
src/platform/symbols.map (+3/-0)
src/server/CMakeLists.txt (+5/-1)
src/server/graphics/CMakeLists.txt (+1/-1)
src/server/graphics/default_configuration.cpp (+39/-6)
src/server/logging/CMakeLists.txt (+0/-1)
src/server/report/default_server_configuration.cpp (+9/-0)
src/server/report/logging/CMakeLists.txt (+0/-1)
src/server/report/logging/logging_report_factory.cpp (+5/-1)
src/server/report/logging_report_factory.h (+2/-0)
src/server/report/lttng/CMakeLists.txt (+1/-0)
src/server/report/lttng/lttng_report_factory.cpp (+5/-0)
src/server/report/lttng/shared_library_prober_report.cpp (+48/-0)
src/server/report/lttng/shared_library_prober_report.h (+52/-0)
src/server/report/lttng/shared_library_prober_report_tp.h (+71/-0)
src/server/report/lttng_report_factory.h (+1/-0)
src/server/report/null/CMakeLists.txt (+1/-0)
src/server/report/null/null_report_factory.cpp (+11/-0)
src/server/report/null/shared_library_prober_report.cpp (+35/-0)
src/server/report/null/shared_library_prober_report.h (+43/-0)
src/server/report/null_report_factory.h (+2/-1)
src/server/report/report_factory.h (+3/-0)
src/server/symbols.map (+2/-0)
tests/acceptance-tests/CMakeLists.txt (+3/-1)
tests/acceptance-tests/test_symbols_required_by_mesa.cpp (+3/-3)
tests/include/mir_test_doubles/mock_android_alloc_device.h (+5/-0)
tests/include/mir_test_doubles/mock_android_hw.h (+5/-0)
tests/include/mir_test_doubles/mock_hwc_composer_device_1.h (+5/-0)
tests/include/mir_test_framework/client_platform_factory.h (+72/-0)
tests/include/mir_test_framework/executable_path.h (+2/-0)
tests/include/mir_test_framework/stub_client_platform_factory.h (+33/-0)
tests/integration-tests/CMakeLists.txt (+21/-2)
tests/mir_test_doubles/CMakeLists.txt (+13/-10)
tests/mir_test_framework/CMakeLists.txt (+39/-0)
tests/mir_test_framework/executable_path.cpp (+5/-0)
tests/mir_test_framework/platform_graphics_dummy.cpp (+33/-0)
tests/mir_test_framework/stub_client_platform_factory.cpp (+143/-0)
tests/mir_test_framework/stub_client_platform_module.cpp (+35/-0)
tests/mir_test_framework/symbols-client.map (+7/-0)
tests/mir_test_framework/symbols-server.map (+10/-0)
tests/mir_test_framework/testing_client_options.cpp (+2/-102)
tests/unit-tests/CMakeLists.txt (+35/-3)
tests/unit-tests/client/CMakeLists.txt (+1/-0)
tests/unit-tests/client/android/test_android_client_platform.cpp (+4/-7)
tests/unit-tests/client/mesa/test_client_platform.cpp (+7/-6)
tests/unit-tests/client/mesa/test_mesa_native_display_container.cpp (+1/-1)
tests/unit-tests/client/test_client_platform.cpp (+109/-29)
tests/unit-tests/client/test_probing_client_platform_factory.cpp (+140/-0)
tests/unit-tests/graphics/CMakeLists.txt (+1/-0)
tests/unit-tests/graphics/android/test_android_platform.cpp (+24/-0)
tests/unit-tests/graphics/android/test_output_builder.cpp (+1/-0)
tests/unit-tests/graphics/mesa/test_platform.cpp (+22/-0)
tests/unit-tests/graphics/test_platform_prober.cpp (+212/-0)
tests/unit-tests/shared_library_test.cpp (+56/-11)
tests/unit-tests/test_shared_library_prober.cpp (+2/-0)
tools/valgrind_suppressions_armhf (+9/-0)
To merge this branch: bzr merge lp:~raof/mir/privatise-all-the-things
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Kevin DuBois Pending
Alan Griffiths Pending
Alexandros Frantzis Pending
Mir development team Pending
Review via email: mp+232664@code.launchpad.net

This proposal supersedes a proposal from 2014-07-30.

This proposal has been superseded by a proposal from 2014-09-10.

Commit message

Move the platform plugins into a private directory, versioned with the relevant ABI.

Together with Alan's versioning of libmirplatform, makes different versions of Mir parallel installable again.

Fixes: https://bugs.launchpad.net/mir/+bug/1293944

Description of the change

Move the platform plugins into a private directory, versioned with the relevant ABI.

There are some obvious TODOs here, but none seem super-urgent:
*) Actually managing the lifetime of our platform plugins rather than just keeping them around indefinitely
*) Defining an ABI we expose to platform plugins and then sticking them in an unversioned directory.
*) Loading the specific version of the ABI we expect via dlvsym.

Things that I'll do as an immediate follow-on branch:
*) Logging for platform module probing

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

How does removing libmirplatform fits with our "platform" story?

AIUI libmirplatform is the LGPL foundation (establishing common interfaces & types) that both a propitiatory platform implementation and the GPL libmirserver link against.

How is that seen to work after these changes?

review: Needs Information
Revision history for this message
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal

Besides the conflicts:

42 +Package: libmirplatformgraphics-mesa-24

Debian packaging guidelines mandate lib<name><version>, so e.g. libmirclientplatform-mesa8 for the package names. The extra dash before the version is only used if the name ends with a number.

225 -override_dh_install:
231 -override_dh_installdeb:
787 + // TODO: Some sort of probe so we have some guarantee that

We need to check if removing alternatives support breaks the emulator use case (which was the driving force behing it). In general, until we have a smart enough probe, we either need to allow setting a sensible system-wide default (that's what the current alternatives system does), or disallow installing the mesa/android packages at the same time (which somewhat defeats the purpose of this MP).

2173 +std::list<std::shared_ptr<mir::SharedLibrary>>

Prefer vector<> by default (not that it will makes any performance different in this case).

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal

the define MIR_SERVER_PLATFORM_PLUGIN_PATH makes me a little leary (esp with the various cross compiling methods floating around. Could we use a some default paths instead?

review: Needs Information
Revision history for this message
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal

> How does removing libmirplatform fits with our "platform" story?
>
> AIUI libmirplatform is the LGPL foundation (establishing common interfaces &
> types) that both a propitiatory platform implementation and the GPL
> libmirserver link against.
>
> How is that seen to work after these changes?

Roughly the same as it was working before these changes - if, for example, you check out libmirplatform in trunk then you'll see it exports a single symbol - mir::load_library - which I removed and then noticed that nothing was actually linked against libmirplatform (because we pass the linker flag to only link against things that we use symbols from).

Thinking of which, have we checked with our lawyers and/or NVIDIA's/AMD's lawyers about this? The situation is more like loadable modules in the kernel rather than traditional dynamic linking, and it'd be nice to be clearer about our expectations than the kernel is.

> Besides the conflicts:
>
> 42 +Package: libmirplatformgraphics-mesa-24
>
> Debian packaging guidelines mandate lib<name><version>, so e.g.
> libmirclientplatform-mesa8 for the package names. The extra dash before the
> version is only used if the name ends with a number.

Ah, yeah. I'll actually go the other way - this isn't a shared library, it's a module, so I'll rename it mir-platform-graphics-mesa-24 (see also: Xserver versioning)

> 787 + // TODO: Some sort of probe so we have some guarantee that
>
> We need to check if removing alternatives support breaks the emulator use case
> (which was the driving force behing it). In general, until we have a smart
> enough probe, we either need to allow setting a sensible system-wide default
> (that's what the current alternatives system does), or disallow installing the
> mesa/android packages at the same time (which somewhat defeats the purpose of
> this MP).

It shouldn't be too hard to get a basic probe up and running. I'll do so.

>
> 2173 +std::list<std::shared_ptr<mir::SharedLibrary>>
>
> Prefer vector<> by default (not that it will makes any performance different
> in this case).

Ah, yeah. This was a holdover of trying to use raw mir::SharedLibrary which isn't default-constructible.

> the define MIR_SERVER_PLATFORM_PLUGIN_PATH makes me a little leary (esp with
> the various cross compiling methods floating around. Could we use a some
> default paths instead?

I'm not entirely clear what you're concerned about here. Is your concern about testability? That should be mitigated by the MIR_CLIENT_PLATFORM_LIBRARY and MIR_SERVER_PLATFORM_LIBRARY environment overrides, which we need to use in the tests anyway?

Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> > How does removing libmirplatform fits with our "platform" story?
> >
> > AIUI libmirplatform is the LGPL foundation (establishing common interfaces &
> > types) that both a propitiatory platform implementation and the GPL
> > libmirserver link against.
> >
> > How is that seen to work after these changes?
>
> Roughly the same as it was working before these changes - if, for example, you
> check out libmirplatform in trunk then you'll see it exports a single symbol -
> mir::load_library - which I removed and then noticed that nothing was actually
> linked against libmirplatform (because we pass the linker flag to only link
> against things that we use symbols from).
>
> Thinking of which, have we checked with our lawyers and/or NVIDIA's/AMD's
> lawyers about this? The situation is more like loadable modules in the kernel
> rather than traditional dynamic linking, and it'd be nice to be clearer about
> our expectations than the kernel is.

I wasn't party to the conversations with lawyers, I'm going on what kgunn told us.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> Roughly the same as it was working before these changes - if, for example, you
> check out libmirplatform in trunk then you'll see it exports a single symbol -
> mir::load_library - which I removed and then noticed that nothing was actually
> linked against libmirplatform (because we pass the linker flag to only link
> against things that we use symbols from).

That bug and has been fixed on development-branch (-r 1786)

Revision history for this message
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal

Moving to WIP: probing is taking a little longer than expected. Hah!

Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Interesting approach. Not a complete review but:

1607 +#include <iostream>

Not needed

~~~~

3961 -#ifdef ANDROID
3962 #include "mir_test_doubles/mock_android_hw.h"
3963 -#include "src/client/android/client_platform_factory.h"

Causes FTBFS for me on desktop:

include/test/mir_test_doubles/mock_android_alloc_device.h:26:30: fatal error: hardware/gralloc.h: No such file or directory
 #include <hardware/gralloc.h>
                              ^
compilation terminated.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) : Posted in a previous version of this proposal
review: Abstain
Revision history for this message
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal

Didn't get a chance to review properly.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> [ RUN ] SurfaceLoop.all_created_buffers_are_destroyed
> Build timed out (after 60 minutes). Marking the build as failed.

Sometimes tests hang. Sometimes CI is this slow. Who knows?!

~~~~

1204 +std::shared_ptr<mcl::ProbingClientPlatformFactory> the_platform_prober;

Having recently tracked down several problems caused by namespace scoped objects with state I'm concerned that this may be fragile.

~~~~

Triggering rebuild to see if it it gets through CI - will come back for a closer look later.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Minor suggestion: Try reverting all the blank line changes. That will get the diff size down to below the 5000 line limit so Launchpad will display it all.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal

Ok. I don't know what's going on with CI.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I suggest trying to shrink the diff down to 5000 lines so LP will not truncate it. Also resubmit because the above CI madness is making things confusing.

review: Needs Resubmitting
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1851. By Chris Halse Rogers

Remerge prerequisite

1852. By Chris Halse Rogers

♪ Merge merge merge your prereq gently down the stream ♫

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

As always, I have no idea what's going wrong in CI; it works fine locally in an i386 chroot...

Maybe pressing the rebuild button will work this time??

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Mark as WIP until the prerequisites land.

1853. By Chris Halse Rogers

Stub client library doesn't need to link to mir-test-framework

Fixes failure to build on i386-android-cross-compile

1854. By Chris Halse Rogers

Merge versioned-shared-library work

1855. By Chris Halse Rogers

Make ProbingClientFactory ignore non-client-platform modules.

You shouldn't be installing non-client platform modules in the client platform path,
but that's no reason not to be robust against it

1856. By Chris Halse Rogers

Remove some detritus

1857. By Chris Halse Rogers

Define CLIENT_PLATFORM_API instead of the client module path

1858. By Chris Halse Rogers

Also make module_for_device ignore non-server-platform modules.

Again, there's no reason not to be robust against this

1859. By Chris Halse Rogers

Load the specific platform version we're expecting.

There's no particular reason not to do this now, and it's a bit of safety for when we
*do* have a different platform ABI

1860. By Chris Halse Rogers

Merge prereq

1861. By Chris Halse Rogers

Merge prereq

1862. By Chris Halse Rogers

Merged versioned-loader into private-library-loading.

1863. By Chris Halse Rogers

Merged versioned-loader into private-library-loading.

1864. By Chris Halse Rogers

Use a dummy library rather than something that might actually have side-effects

1865. By Chris Halse Rogers

Merged versioned-loader into private-library-loading.

1866. By Chris Halse Rogers

Timeouts for everyone!

This was reliably timing out for me under valgrind. 50 seconds should be enough for everyone!

1867. By Chris Halse Rogers

Merge trunk. Conflicts!

1868. By Chris Halse Rogers

Fix cross-building of client-platform-dummy

1869. By Chris Halse Rogers

Aww, yeah. Don't load libmirplatform twice

1870. By Chris Halse Rogers

Merge trunk, reverting version-drivers branch as this subsumes it

1871. By Chris Halse Rogers

Merge trunk, resolving conflicts

1872. By Chris Halse Rogers

Merge trunk

1873. By Chris Halse Rogers

Merge trunk

1874. By Chris Halse Rogers

Drop numbering from driver packages.

Looking through what's involved in that ABI, we haven't changed anything in there for a while.

We should be able to handle not breaking the driver interface, and when we do we should
be able to invest the effort to handle backwards compatibility.

1875. By Chris Halse Rogers

Use MIR_CLIENT_PLATFORM_2.

We load the platform libraries from an entirely new path, so it's not actually
necessary for the purposes of disambiguation, but it's also harmless.

1876. By Chris Halse Rogers

Install and load platform libraries in unadorned path.

1877. By Chris Halse Rogers

Merge trunk

1878. By Chris Halse Rogers

Drop duplicated prefixes from platform libraries

1879. By Chris Halse Rogers

Merge trunk

1880. By Chris Halse Rogers

Remove resolved hw_get_module question-comment

1881. By Chris Halse Rogers

Remove spurious whitespace changes

1882. By Chris Halse Rogers

Use BOOST_THROW_EXCEPTION to decorate the exceptions

1883. By Chris Halse Rogers

Clarify MIR_GRAPHICS_PLATFORM_1 CMake comment

1884. By Chris Halse Rogers

Fix android platform module install

1885. By Chris Halse Rogers

Merge trunk

1886. By Chris Halse Rogers

Fix android graphics platform linking post-merge

1887. By Chris Halse Rogers

Link Mesa platform graphics module against libmirplatform, to pick up symbol versions

1888. By Chris Halse Rogers

Move client and server modules into an appropriate directory in the build tree

1889. By Chris Halse Rogers

Fix remaining Android module load failure in tests

1890. By Chris Halse Rogers

Merge trunk

1891. By Chris Halse Rogers

Turn libplatformstub into platform-graphics-dummy.so and fix the tests

1892. By Chris Halse Rogers

Add a set of helpers to find the various platform plugins

1893. By Chris Halse Rogers

Don't throw exception pointers; just throw the exception.

1894. By Chris Halse Rogers

Fix name for platform-graphics-dummy.so

1895. By Chris Halse Rogers

Coalesce all hardcoded platform module strings into {client,server}_platform_() calls

1896. By Chris Halse Rogers

Rename, and install client & server stub platforms into mir-test-tools

1897. By Chris Halse Rogers

Merge trunk, updating the RendererFactory cludge for graphics-stub.so

1898. By Chris Halse Rogers

Fix random tab character

1899. By Chris Halse Rogers

Fix stub server platform build on armhf

1900. By Chris Halse Rogers

Fix unnecessary symbol leakage from server platform modules

1901. By Chris Halse Rogers

Merge trunk

Unmerged revisions

1901. By Chris Halse Rogers

Merge trunk

1900. By Chris Halse Rogers

Fix unnecessary symbol leakage from server platform modules

1899. By Chris Halse Rogers

Fix stub server platform build on armhf

1898. By Chris Halse Rogers

Fix random tab character

1897. By Chris Halse Rogers

Merge trunk, updating the RendererFactory cludge for graphics-stub.so

1896. By Chris Halse Rogers

Rename, and install client & server stub platforms into mir-test-tools

1895. By Chris Halse Rogers

Coalesce all hardcoded platform module strings into {client,server}_platform_() calls

1894. By Chris Halse Rogers

Fix name for platform-graphics-dummy.so

1893. By Chris Halse Rogers

Don't throw exception pointers; just throw the exception.

1892. By Chris Halse Rogers

Add a set of helpers to find the various platform plugins

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-09-09 14:04:48 +0000
3+++ CMakeLists.txt 2014-09-10 08:00:52 +0000
4@@ -159,13 +159,15 @@
5 include_directories (${EGL_INCLUDE_DIRS})
6 include_directories (${GLM_INCLUDE_DIRS})
7
8+find_package( PkgConfig )
9+
10 if (MIR_BUILD_PLATFORM_ANDROID)
11 find_package(AndroidProperties REQUIRED)
12 find_package(LibHardware REQUIRED)
13+ pkg_check_modules( ANDROID_HEADERS REQUIRED android-headers )
14 endif()
15
16 if (MIR_BUILD_PLATFORM_MESA)
17- find_package( PkgConfig )
18 pkg_check_modules( GBM REQUIRED gbm>=9.0.0)
19 pkg_check_modules( DRM REQUIRED libdrm )
20 endif()
21
22=== modified file 'client-ABI-sha1sums'
23--- client-ABI-sha1sums 2014-09-09 14:04:48 +0000
24+++ client-ABI-sha1sums 2014-09-10 08:00:52 +0000
25@@ -11,5 +11,5 @@
26 183d9e5e6cfe48b3d9145a28541dd4202ff6137b include/common/mir_toolkit/common.h
27 fce4c1a9e0d037244f7e9e96ea2d8eaab4fc404c include/common/mir_toolkit/cursors.h
28 bdaceadd56e41d2cb708f7c4da97acf84dfc75b7 include/common/mir_toolkit/event.h
29-99ef5f3bf548508fae24c60f74be1dea018a6e8c include/common/mir_toolkit/mesa/native_display.h
30+4975998aa1056ed0d39dcc538127453e516ad8e9 include/common/mir_toolkit/mesa/native_display.h
31 101017c17714a57db57d79b7b5e7df40a3568236 include/common/mir_toolkit/mir_native_buffer.h
32
33=== modified file 'common-ABI-sha1sums'
34--- common-ABI-sha1sums 2014-09-09 14:04:48 +0000
35+++ common-ABI-sha1sums 2014-09-10 08:00:52 +0000
36@@ -7,10 +7,12 @@
37 42646c2367b9821e3aa71feff6e31cf50526acaa include/common/mir/geometry/size.h
38 e1be9faee8b844ca2ce617f8fd82c9ee08d56bed include/common/mir/graphics/native_buffer.h
39 be7d58c9fde2ce91cc66dd6144b76e08b536266b include/common/mir/int_wrapper.h
40+4d80544bf59ef452979b934d664ac592aff58c82 include/common/mir/shared_library_prober.h
41+53e4159f2a0b564cb39a7785b4e229f6f7424779 include/common/mir/shared_library_prober_report.h
42 6bb8715336020864626cc8355a0d130db6613ff4 include/common/mir/time/clock.h
43 9907751d046e4aea81881cf19e5df52c7a6a813e include/common/mir_toolkit/client_types.h
44 183d9e5e6cfe48b3d9145a28541dd4202ff6137b include/common/mir_toolkit/common.h
45 fce4c1a9e0d037244f7e9e96ea2d8eaab4fc404c include/common/mir_toolkit/cursors.h
46 bdaceadd56e41d2cb708f7c4da97acf84dfc75b7 include/common/mir_toolkit/event.h
47-99ef5f3bf548508fae24c60f74be1dea018a6e8c include/common/mir_toolkit/mesa/native_display.h
48+4975998aa1056ed0d39dcc538127453e516ad8e9 include/common/mir_toolkit/mesa/native_display.h
49 101017c17714a57db57d79b7b5e7df40a3568236 include/common/mir_toolkit/mir_native_buffer.h
50
51=== modified file 'debian/control'
52--- debian/control 2014-09-09 11:19:01 +0000
53+++ debian/control 2014-09-10 08:00:52 +0000
54@@ -52,8 +52,7 @@
55 Pre-Depends: ${misc:Pre-Depends}
56 Depends: ${misc:Depends},
57 ${shlibs:Depends},
58- libmirplatformgraphics-mesa (= ${binary:Version}) |
59- libmirplatformgraphics-android (= ${binary:Version}),
60+ mir-platform-graphics-mesa-1 | mir-platform-graphics-android-1,
61 Description: Display server for Ubuntu - server library
62 Mir is a display server running on linux systems, with a focus on efficiency,
63 robust operation and a well-defined driver model.
64@@ -74,7 +73,7 @@
65 Contains the shared libraries required for the Mir server to interact with
66 the underlying hardware platform.
67
68-Package: libmirplatformgraphics-mesa
69+Package: mir-platform-graphics-mesa-1
70 Section: libs
71 Architecture: i386 amd64 armhf arm64
72 Multi-Arch: same
73@@ -88,7 +87,7 @@
74 Contains the shared libraries required for the Mir server to interact with
75 the hardware platform using the Mesa drivers.
76
77-Package: libmirplatformgraphics-android
78+Package: mir-platform-graphics-android-1
79 Section: libs
80 Architecture: i386 amd64 armhf
81 Multi-Arch: same
82@@ -158,8 +157,7 @@
83 Pre-Depends: ${misc:Pre-Depends}
84 Depends: ${misc:Depends},
85 ${shlibs:Depends},
86- libmirclientplatform-mesa (= ${binary:Version}) |
87- libmirclientplatform-android (= ${binary:Version}),
88+ mir-client-platform-mesa-1 | mir-client-platform-android-1,
89 Description: Display server for Ubuntu - client library
90 Mir is a display server running on linux systems, with a focus on efficiency,
91 robust operation and a well-defined driver model.
92@@ -181,14 +179,13 @@
93 .
94 Contains header files required to develop against Mir.
95
96-Package: libmirclientplatform-mesa
97+Package: mir-client-platform-mesa-1
98 Section: libs
99 Architecture: i386 amd64 armhf arm64
100 Multi-Arch: same
101 Pre-Depends: ${misc:Pre-Depends}
102 Depends: ${misc:Depends},
103 ${shlibs:Depends}
104-Replaces: libmirclientplatform
105 Description: Display server for Ubuntu - client platform library for Mesa
106 Mir is a display server running on linux systems, with a focus on efficiency,
107 robust operation and a well-defined driver model.
108@@ -196,14 +193,13 @@
109 Contains the shared libraries required for the Mir clients to interact with
110 the underlying hardware platform using the Mesa drivers.
111
112-Package: libmirclientplatform-android
113+Package: mir-client-platform-android-1
114 Section: libs
115 Architecture: i386 amd64 armhf
116 Multi-Arch: same
117 Pre-Depends: ${misc:Pre-Depends}
118 Depends: ${misc:Depends},
119 ${shlibs:Depends}
120-Replaces: libmirclientplatform
121 Description: Display server for Ubuntu - client platform library for Android
122 Mir is a display server running on linux systems, with a focus on efficiency,
123 robust operation and a well-defined driver model.
124
125=== removed file 'debian/create_postinst_prerm_scripts.sh'
126--- debian/create_postinst_prerm_scripts.sh 2014-04-15 15:02:05 +0000
127+++ debian/create_postinst_prerm_scripts.sh 1970-01-01 00:00:00 +0000
128@@ -1,39 +0,0 @@
129-#!/bin/sh
130-
131-set -e
132-
133-dpkg_alternatives_priority=500
134-deb_host_arch=$1
135-deb_host_multiarch=$2
136-
137-mir_platform_types="platformgraphics clientplatform"
138-case $deb_host_arch in
139- arm64)
140- mir_platforms="mesa"
141- ;;
142- *)
143- mir_platforms="android mesa"
144- ;;
145-esac
146-
147-create_script()
148-{
149- local script=$1
150- local platform_type=$2
151- local platform=$3
152-
153- sed -e "s/@DEB_HOST_MULTIARCH@/$deb_host_multiarch/" \
154- -e "s/@MIR_PLATFORM_TYPE@/$platform_type/" \
155- -e "s/@MIR_PLATFORM@/$platform/" \
156- -e "s/@DPKG_ALTERNATIVES_PRIORITY@/$dpkg_alternatives_priority/" \
157- debian/update-alternatives.${script}.in > debian/libmir$platform_type-$platform.${script}
158-}
159-
160-for platform_type in $mir_platform_types;
161-do
162- for platform in $mir_platforms;
163- do
164- create_script postinst $platform_type $platform
165- create_script prerm $platform_type $platform
166- done
167-done
168
169=== removed file 'debian/install_ld_so_conf.sh'
170--- debian/install_ld_so_conf.sh 2014-04-15 15:02:05 +0000
171+++ debian/install_ld_so_conf.sh 1970-01-01 00:00:00 +0000
172@@ -1,26 +0,0 @@
173-#!/bin/sh
174-
175-set -e
176-
177-DEB_HOST_ARCH=$1
178-DEB_HOST_MULTIARCH=$2
179-
180-mir_platform_types="platformgraphics clientplatform"
181-case $DEB_HOST_ARCH in
182- arm64)
183- mir_platforms="mesa"
184- ;;
185- *)
186- mir_platforms="android mesa"
187- ;;
188-esac
189-
190-for platform_type in $mir_platform_types;
191-do
192- for platform in $mir_platforms;
193- do
194- platform_dir="/usr/lib/$DEB_HOST_MULTIARCH/mir/$platform_type/$platform"
195- package_dir="debian/libmir$platform_type-$platform/$platform_dir"
196- echo "$platform_dir" > $package_dir/ld.so.conf
197- done
198-done
199
200=== renamed file 'debian/libmirclientplatform-android.install' => 'debian/mir-client-platform-android-1.install'
201--- debian/libmirclientplatform-android.install 2014-02-14 08:43:47 +0000
202+++ debian/mir-client-platform-android-1.install 2014-09-10 08:00:52 +0000
203@@ -1,1 +1,1 @@
204-usr/lib/*/mir/clientplatform/android/*
205+usr/lib/*/mir/client-platform-1/client-platform-android.so
206
207=== renamed file 'debian/libmirclientplatform-mesa.install' => 'debian/mir-client-platform-mesa-1.install'
208--- debian/libmirclientplatform-mesa.install 2014-02-14 08:43:47 +0000
209+++ debian/mir-client-platform-mesa-1.install 2014-09-10 08:00:52 +0000
210@@ -1,1 +1,1 @@
211-usr/lib/*/mir/clientplatform/mesa/*
212+usr/lib/*/mir/client-platform-1/client-platform-mesa.so
213
214=== renamed file 'debian/libmirplatformgraphics-android.install' => 'debian/mir-platform-graphics-android-1.install'
215--- debian/libmirplatformgraphics-android.install 2014-02-14 08:43:47 +0000
216+++ debian/mir-platform-graphics-android-1.install 2014-09-10 08:00:52 +0000
217@@ -1,1 +1,1 @@
218-usr/lib/*/mir/platformgraphics/android/*
219+usr/lib/*/mir/server-platform-1/platform-graphics-android.so
220
221=== renamed file 'debian/libmirplatformgraphics-mesa.install' => 'debian/mir-platform-graphics-mesa-1.install'
222--- debian/libmirplatformgraphics-mesa.install 2014-02-14 08:43:47 +0000
223+++ debian/mir-platform-graphics-mesa-1.install 2014-09-10 08:00:52 +0000
224@@ -1,1 +1,1 @@
225-usr/lib/*/mir/platformgraphics/mesa/*
226+usr/lib/*/mir/server-platform-1/platform-graphics-mesa.so
227
228=== modified file 'debian/rules'
229--- debian/rules 2014-09-08 04:12:17 +0000
230+++ debian/rules 2014-09-10 08:00:52 +0000
231@@ -46,14 +46,3 @@
232 # TODO: we'll use a symbol file once mir is abi stable
233 override_dh_makeshlibs:
234 dh_makeshlibs -V
235-
236-override_dh_install:
237- dh_install --fail-missing \
238- -Xusr/lib/$(DEB_HOST_MULTIARCH)/libmirplatformgraphics.so \
239- -Xusr/lib/$(DEB_HOST_MULTIARCH)/libmirclientplatform.so
240- sh debian/install_ld_so_conf.sh $(DEB_HOST_ARCH) $(DEB_HOST_MULTIARCH)
241-
242-override_dh_installdeb:
243- sh debian/create_postinst_prerm_scripts.sh \
244- $(DEB_HOST_ARCH) $(DEB_HOST_MULTIARCH)
245- dh_installdeb
246
247=== removed file 'debian/update-alternatives.postinst.in'
248--- debian/update-alternatives.postinst.in 2014-02-14 09:20:28 +0000
249+++ debian/update-alternatives.postinst.in 1970-01-01 00:00:00 +0000
250@@ -1,18 +0,0 @@
251-#!/bin/sh
252-
253-set -e
254-
255-if [ "$1" = "configure" ];
256-then
257- update-alternatives --force --install \
258- /etc/ld.so.conf.d/@DEB_HOST_MULTIARCH@_mir@MIR_PLATFORM_TYPE@.conf \
259- @DEB_HOST_MULTIARCH@_mir@MIR_PLATFORM_TYPE@_conf \
260- /usr/lib/@DEB_HOST_MULTIARCH@/mir/@MIR_PLATFORM_TYPE@/@MIR_PLATFORM@/ld.so.conf \
261- @DPKG_ALTERNATIVES_PRIORITY@
262-
263- LDCONFIG_NOTRIGGER=y ldconfig
264-fi
265-
266-#DEBHELPER#
267-
268-exit 0
269
270=== removed file 'debian/update-alternatives.prerm.in'
271--- debian/update-alternatives.prerm.in 2014-02-14 09:20:28 +0000
272+++ debian/update-alternatives.prerm.in 1970-01-01 00:00:00 +0000
273@@ -1,16 +0,0 @@
274-#!/bin/sh
275-
276-set -e
277-
278-if [ "$1" = "remove" ];
279-then
280- update-alternatives --remove \
281- @DEB_HOST_MULTIARCH@_mir@MIR_PLATFORM_TYPE@_conf \
282- /usr/lib/@DEB_HOST_MULTIARCH@/mir/@MIR_PLATFORM_TYPE@/@MIR_PLATFORM@/ld.so.conf
283-
284- ldconfig
285-fi
286-
287-#DEBHELPER#
288-
289-exit 0
290
291=== modified file 'include.private/common/mir/shared_library.h'
292--- include.private/common/mir/shared_library.h 2014-09-08 04:12:17 +0000
293+++ include.private/common/mir/shared_library.h 2014-09-10 08:00:52 +0000
294@@ -43,9 +43,18 @@
295 {
296 return load_function<FunctionPtr>(function_name.c_str());
297 }
298+
299+ template<typename FunctionPtr>
300+ FunctionPtr load_function(std::string const& function_name, std::string const& version) const
301+ {
302+ FunctionPtr result{};
303+ (void*&)result = load_symbol(function_name.c_str(), version.c_str());
304+ return result;
305+ }
306 private:
307 void* const so;
308 void* load_symbol(char const* function_name) const;
309+ void* load_symbol(char const* function_name, char const* version) const;
310 SharedLibrary(SharedLibrary const&) = delete;
311 SharedLibrary& operator=(SharedLibrary const&) = delete;
312 };
313
314=== modified file 'include.private/platform/mir/graphics/platform.h'
315--- include.private/platform/mir/graphics/platform.h 2014-09-09 14:04:48 +0000
316+++ include.private/platform/mir/graphics/platform.h 2014-09-10 08:00:52 +0000
317@@ -126,6 +126,33 @@
318 };
319
320 /**
321+ * A measure of how good this module is at supporting the current device
322+ *
323+ * \note This is compared as an integer; best + 1 is a valid PlatformPriority that
324+ * will be used in preference to a module that reports best.
325+ * Platform modules distributed with Mir will never use a priority higher
326+ * than best.
327+ */
328+enum PlatformPriority : uint32_t
329+{
330+ unsupported = 0, /**< Unable to function at all on this device */
331+ supported = 128, /**< Capable of providing a functioning Platform on this device,
332+ * possibly with degraded performance or features.
333+ */
334+ best = 256 /**< Capable of providing a Platform with the best features and
335+ * performance this device is capable of.
336+ */
337+};
338+
339+/**
340+ * Describes a platform module
341+ */
342+struct ModuleProperties
343+{
344+ char const* name;
345+};
346+
347+/**
348 * Function prototype used to return a new graphics platform.
349 *
350 * \param [in] options options to use for this platform
351@@ -148,6 +175,15 @@
352 boost::program_options::options_description& config);
353 extern "C" void add_platform_options(
354 boost::program_options::options_description& config);
355+
356+// TODO: We actually need to be more granular here; on a device with more
357+// than one graphics system we may need a different platform per GPU,
358+// so we should be associating platforms with graphics devices in some way
359+extern "C" typedef PlatformPriority(*PlatformProbe)();
360+extern "C" PlatformPriority probe_platform();
361+
362+extern "C" typedef ModuleProperties const*(*DescribeModule)();
363+extern "C" ModuleProperties const* describe_module();
364 }
365 }
366
367
368=== removed file 'include.private/platform/mir/shared_library_loader.h'
369--- include.private/platform/mir/shared_library_loader.h 2014-09-08 04:12:17 +0000
370+++ include.private/platform/mir/shared_library_loader.h 1970-01-01 00:00:00 +0000
371@@ -1,28 +0,0 @@
372-/*
373- * Copyright © 2013 Canonical Ltd.
374- *
375- * This program is free software: you can redistribute it and/or modify it
376- * under the terms of the GNU Lesser General Public License version 3,
377- * as published by the Free Software Foundation.
378- *
379- * This program is distributed in the hope that it will be useful,
380- * but WITHOUT ANY WARRANTY; without even the implied warranty of
381- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
382- * GNU Lesser General Public License for more details.
383- *
384- * You should have received a copy of the GNU Lesser General Public License
385- * along with this program. If not, see <http://www.gnu.org/licenses/>.
386- *
387- * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
388- */
389-
390-#ifndef MIR_SHARED_LIBRARY_LOADER_H_
391-#define MIR_SHARED_LIBRARY_LOADER_H_
392-
393-#include <string>
394-namespace mir
395-{
396-class SharedLibrary;
397-SharedLibrary const* load_library(std::string const& libname);
398-}
399-#endif
400
401=== modified file 'include/common/mir_toolkit/mesa/native_display.h'
402--- include/common/mir_toolkit/mesa/native_display.h 2013-08-28 03:41:48 +0000
403+++ include/common/mir_toolkit/mesa/native_display.h 2014-09-10 08:00:52 +0000
404@@ -39,7 +39,7 @@
405 struct MirMesaEGLNativeDisplay
406 {
407 int (*display_get_platform)(MirMesaEGLNativeDisplay* display,
408- MirPlatformPackage* package);
409+ MirPlatformPackage* package);
410 void *context;
411 };
412
413@@ -47,9 +47,9 @@
414 {
415 int (*surface_set_swapinterval)(MirMesaEGLNativeSurface* surface, int interval);
416 int (*surface_advance_buffer)(MirMesaEGLNativeSurface* surface,
417- MirBufferPackage* buffer_package);
418+ MirBufferPackage* buffer_package);
419 int (*surface_get_parameters)(MirMesaEGLNativeSurface* surface,
420- MirSurfaceParameters* surface_parameters);
421+ MirSurfaceParameters* surface_parameters);
422 };
423
424 typedef int (*MirMesaEGLNativeDisplayIsValidFunc)(MirMesaEGLNativeDisplay* display);
425
426=== modified file 'include/platform/mir/options/configuration.h'
427--- include/platform/mir/options/configuration.h 2014-09-08 04:12:17 +0000
428+++ include/platform/mir/options/configuration.h 2014-09-10 08:00:52 +0000
429@@ -39,6 +39,7 @@
430 extern char const* const connector_report_opt;
431 extern char const* const scene_report_opt;
432 extern char const* const input_report_opt;
433+extern char const* const shared_library_prober_report_opt;
434 extern char const* const host_socket_opt;
435 extern char const* const frontend_threads_opt;
436 extern char const* const fatal_abort_opt;
437@@ -56,6 +57,7 @@
438 extern char const* const lttng_opt_value;
439
440 extern char const* const platform_graphics_lib;
441+extern char const* const platform_graphics_path;
442
443 class Configuration
444 {
445
446=== modified file 'include/server/mir/default_server_configuration.h'
447--- include/server/mir/default_server_configuration.h 2014-09-08 04:12:17 +0000
448+++ include/server/mir/default_server_configuration.h 2014-09-10 08:00:52 +0000
449@@ -35,6 +35,7 @@
450 namespace mir
451 {
452 class ServerActionQueue;
453+class SharedLibraryProberReport;
454
455 namespace compositor
456 {
457@@ -307,6 +308,7 @@
458
459 virtual std::shared_ptr<time::Clock> the_clock();
460 virtual std::shared_ptr<ServerActionQueue> the_server_action_queue();
461+ virtual std::shared_ptr<SharedLibraryProberReport> the_shared_library_prober_report();
462
463 protected:
464 std::shared_ptr<options::Option> the_options() const;
465@@ -407,6 +409,7 @@
466 CachedPtr<scene::SessionCoordinator> session_coordinator;
467 CachedPtr<EmergencyCleanup> emergency_cleanup;
468 CachedPtr<shell::HostLifecycleEventListener> host_lifecycle_event_listener;
469+ CachedPtr<SharedLibraryProberReport> shared_library_prober_report;
470
471 private:
472 std::shared_ptr<options::Configuration> const configuration_options;
473
474=== modified file 'platform-ABI-sha1sums'
475--- platform-ABI-sha1sums 2014-09-09 14:04:48 +0000
476+++ platform-ABI-sha1sums 2014-09-10 08:00:52 +0000
477@@ -7,12 +7,14 @@
478 42646c2367b9821e3aa71feff6e31cf50526acaa include/common/mir/geometry/size.h
479 e1be9faee8b844ca2ce617f8fd82c9ee08d56bed include/common/mir/graphics/native_buffer.h
480 be7d58c9fde2ce91cc66dd6144b76e08b536266b include/common/mir/int_wrapper.h
481+4d80544bf59ef452979b934d664ac592aff58c82 include/common/mir/shared_library_prober.h
482+53e4159f2a0b564cb39a7785b4e229f6f7424779 include/common/mir/shared_library_prober_report.h
483 6bb8715336020864626cc8355a0d130db6613ff4 include/common/mir/time/clock.h
484 9907751d046e4aea81881cf19e5df52c7a6a813e include/common/mir_toolkit/client_types.h
485 183d9e5e6cfe48b3d9145a28541dd4202ff6137b include/common/mir_toolkit/common.h
486 fce4c1a9e0d037244f7e9e96ea2d8eaab4fc404c include/common/mir_toolkit/cursors.h
487 bdaceadd56e41d2cb708f7c4da97acf84dfc75b7 include/common/mir_toolkit/event.h
488-99ef5f3bf548508fae24c60f74be1dea018a6e8c include/common/mir_toolkit/mesa/native_display.h
489+4975998aa1056ed0d39dcc538127453e516ad8e9 include/common/mir_toolkit/mesa/native_display.h
490 101017c17714a57db57d79b7b5e7df40a3568236 include/common/mir_toolkit/mir_native_buffer.h
491 871e609c0fed0d566ddbaaa8ac2d7cd5c06dd09a include/platform/mir/abnormal_exit.h
492 54328767ca330ba166160a486bd0688406ab0222 include/platform/mir/graphics/buffer.h
493@@ -25,7 +27,7 @@
494 5dc095474ef3e294c0aa4008e9ed997bdb21d34c include/platform/mir/graphics/gl_config.h
495 d0442a5d5d88a4be6e3e1f99e433c1c43a86bfce include/platform/mir/graphics/gl_context.h
496 15f201741a465de33e55ffc1ea775b507a5be950 include/platform/mir/graphics/renderable.h
497-b0014e8c4f44f831c9d178f995efb172417aaee4 include/platform/mir/options/configuration.h
498+df61c1168b1798c628d087fc17900d58d608a6fa include/platform/mir/options/configuration.h
499 47007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h
500 b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h
501 3c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h
502
503=== modified file 'server-ABI-sha1sums'
504--- server-ABI-sha1sums 2014-09-09 14:04:48 +0000
505+++ server-ABI-sha1sums 2014-09-10 08:00:52 +0000
506@@ -7,12 +7,14 @@
507 42646c2367b9821e3aa71feff6e31cf50526acaa include/common/mir/geometry/size.h
508 e1be9faee8b844ca2ce617f8fd82c9ee08d56bed include/common/mir/graphics/native_buffer.h
509 be7d58c9fde2ce91cc66dd6144b76e08b536266b include/common/mir/int_wrapper.h
510+4d80544bf59ef452979b934d664ac592aff58c82 include/common/mir/shared_library_prober.h
511+53e4159f2a0b564cb39a7785b4e229f6f7424779 include/common/mir/shared_library_prober_report.h
512 6bb8715336020864626cc8355a0d130db6613ff4 include/common/mir/time/clock.h
513 9907751d046e4aea81881cf19e5df52c7a6a813e include/common/mir_toolkit/client_types.h
514 183d9e5e6cfe48b3d9145a28541dd4202ff6137b include/common/mir_toolkit/common.h
515 fce4c1a9e0d037244f7e9e96ea2d8eaab4fc404c include/common/mir_toolkit/cursors.h
516 bdaceadd56e41d2cb708f7c4da97acf84dfc75b7 include/common/mir_toolkit/event.h
517-99ef5f3bf548508fae24c60f74be1dea018a6e8c include/common/mir_toolkit/mesa/native_display.h
518+4975998aa1056ed0d39dcc538127453e516ad8e9 include/common/mir_toolkit/mesa/native_display.h
519 101017c17714a57db57d79b7b5e7df40a3568236 include/common/mir_toolkit/mir_native_buffer.h
520 871e609c0fed0d566ddbaaa8ac2d7cd5c06dd09a include/platform/mir/abnormal_exit.h
521 54328767ca330ba166160a486bd0688406ab0222 include/platform/mir/graphics/buffer.h
522@@ -25,12 +27,12 @@
523 5dc095474ef3e294c0aa4008e9ed997bdb21d34c include/platform/mir/graphics/gl_config.h
524 d0442a5d5d88a4be6e3e1f99e433c1c43a86bfce include/platform/mir/graphics/gl_context.h
525 15f201741a465de33e55ffc1ea775b507a5be950 include/platform/mir/graphics/renderable.h
526-b0014e8c4f44f831c9d178f995efb172417aaee4 include/platform/mir/options/configuration.h
527+df61c1168b1798c628d087fc17900d58d608a6fa include/platform/mir/options/configuration.h
528 47007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h
529 b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h
530 3c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h
531 f4030e400baf8baa9c38e7c6ec6b4a5ad7134aeb include/server/mir/compositor/compositor.h
532-f102d38fd8afd63b636d76005f9b80f3adda0858 include/server/mir/default_server_configuration.h
533+d69ff1401221ffa9adce7f8d85074a6f8b234baf include/server/mir/default_server_configuration.h
534 af1ff0714be973ac76d56006a2e5991f68cd1dec include/server/mir/display_server.h
535 65db331f1c0e956eced5c9fc73a2b2122dbc8dc7 include/server/mir/frontend/connection_creator.h
536 e6e92642301fc9bb85e1d38087a5dd84e5d30fd7 include/server/mir/frontend/connections.h
537
538=== modified file 'src/client/CMakeLists.txt'
539--- src/client/CMakeLists.txt 2014-09-08 04:12:17 +0000
540+++ src/client/CMakeLists.txt 2014-09-10 08:00:52 +0000
541@@ -17,6 +17,17 @@
542 ${DRM_INCLUDE_DIRS}
543 )
544
545+set(MIRCLIENT_ABI 8)
546+set(CLIENT_PLATFORM_VERSION "MIR_CLIENTPLATFORM_1")
547+set(symbol_map ${CMAKE_SOURCE_DIR}/src/client/symbols.map)
548+
549+set(MIR_CLIENT_PLATFORM_PATH
550+ ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/mir/client-platform-1
551+)
552+
553+add_definitions(-DMIR_CLIENT_PLATFORM_PATH="${MIR_CLIENT_PLATFORM_PATH}/")
554+add_definitions(-DCLIENT_PLATFORM_VERSION="${CLIENT_PLATFORM_VERSION}")
555+
556 add_subdirectory(rpc/)
557 add_subdirectory(lttng/)
558
559@@ -55,6 +66,7 @@
560 mir_prompt_session.cpp
561 mir_prompt_session_api.cpp
562 mir_event_distributor.cpp
563+ probing_client_platform_factory.cpp
564 )
565
566 add_library(
567@@ -63,9 +75,6 @@
568 $<TARGET_OBJECTS:mirclientobjects>
569 )
570
571-set(MIRCLIENT_ABI 8)
572-set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)
573-
574 set_target_properties(
575 mirclient
576
577@@ -74,8 +83,9 @@
578 LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}"
579 )
580
581-set(
582- MIR_CLIENT_LIBRARIES
583+target_link_libraries(
584+ mirclient
585+
586 mirclientrpc
587 mirclientlttngstatic
588 mircommon
589@@ -85,12 +95,6 @@
590 ${XKBCOMMON_LIBRARIES}
591 )
592
593-target_link_libraries(
594- mirclient
595-
596- ${MIR_CLIENT_LIBRARIES}
597-)
598-
599 install(
600 TARGETS mirclient
601 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
602
603=== modified file 'src/client/android/CMakeLists.txt'
604--- src/client/android/CMakeLists.txt 2014-09-08 04:12:17 +0000
605+++ src/client/android/CMakeLists.txt 2014-09-10 08:00:52 +0000
606@@ -15,17 +15,17 @@
607 )
608
609 add_library(
610- mirclientplatformandroid SHARED
611-
612+ mirclientplatformandroid MODULE
613+
614 $<TARGET_OBJECTS:mirclientplatformandroidobjects>
615 $<TARGET_OBJECTS:mirclient_platformimpl>
616 )
617
618 set_target_properties(
619 mirclientplatformandroid PROPERTIES
620- OUTPUT_NAME mirclientplatform
621- LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/android
622- LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}"
623+ OUTPUT_NAME client-platform-android
624+ PREFIX ""
625+ LINK_FLAGS "-Wl,--version-script,${symbol_map}"
626 )
627
628 target_link_libraries(
629@@ -35,20 +35,4 @@
630 ${LIBHARDWARE_LIBRARIES}
631 )
632
633-install(TARGETS mirclientplatformandroid LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/clientplatform/android)
634-
635-if (MIR_TEST_PLATFORM STREQUAL "android")
636- add_custom_command(TARGET mirclientplatformandroid
637- POST_BUILD
638- COMMAND ${CMAKE_COMMAND} -E remove libmirclientplatform.so
639- COMMAND ${CMAKE_COMMAND} -E create_symlink android/$<TARGET_FILE_NAME:mirclientplatformandroid> libmirclientplatform.so
640- WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
641- )
642-
643- install(CODE
644- "execute_process(
645- COMMAND ln -sf mir/clientplatform/android/libmirclientplatform.so
646- WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
647- )"
648- )
649-endif()
650+install(TARGETS mirclientplatformandroid LIBRARY DESTINATION ${MIR_CLIENT_PLATFORM_PATH})
651
652=== modified file 'src/client/android/android_native_display_container.cpp'
653--- src/client/android/android_native_display_container.cpp 2014-09-08 04:12:17 +0000
654+++ src/client/android/android_native_display_container.cpp 2014-09-10 08:00:52 +0000
655@@ -62,16 +62,28 @@
656 bool
657 mcla::AndroidNativeDisplayContainer::validate(MirEGLNativeDisplayType display) const
658 {
659- return mir_connection_is_valid(static_cast<MirConnection*>(display));
660+ std::lock_guard<std::mutex> lg(guard);
661+ return (valid_displays.find(display) != valid_displays.end());
662 }
663
664 MirEGLNativeDisplayType
665-mcla::AndroidNativeDisplayContainer::create(MirConnection* connection)
666+mcla::AndroidNativeDisplayContainer::create(ClientContext* context)
667 {
668- return static_cast<MirEGLNativeDisplayType>(connection);
669+ std::lock_guard<std::mutex> lg(guard);
670+ auto egl_display = static_cast<MirEGLNativeDisplayType>(context);
671+ valid_displays.insert(egl_display);
672+
673+ return egl_display;
674 }
675
676 void
677-mcla::AndroidNativeDisplayContainer::release(MirEGLNativeDisplayType /* display */)
678+mcla::AndroidNativeDisplayContainer::release(MirEGLNativeDisplayType display)
679 {
680+ std::lock_guard<std::mutex> lg(guard);
681+
682+ auto it = valid_displays.find(display);
683+ if (it == valid_displays.end())
684+ return;
685+
686+ valid_displays.erase(it);
687 }
688
689=== modified file 'src/client/android/android_native_display_container.h'
690--- src/client/android/android_native_display_container.h 2013-05-02 00:11:18 +0000
691+++ src/client/android/android_native_display_container.h 2014-09-10 08:00:52 +0000
692@@ -23,6 +23,9 @@
693
694 #include "mir_toolkit/client_types.h"
695
696+#include <unordered_set>
697+#include <mutex>
698+
699 namespace mir
700 {
701 namespace client
702@@ -36,7 +39,7 @@
703 AndroidNativeDisplayContainer();
704 virtual ~AndroidNativeDisplayContainer();
705
706- MirEGLNativeDisplayType create(MirConnection* connection);
707+ MirEGLNativeDisplayType create(ClientContext* context) override;
708 void release(MirEGLNativeDisplayType display);
709
710 bool validate(MirEGLNativeDisplayType display) const;
711@@ -44,6 +47,10 @@
712 protected:
713 AndroidNativeDisplayContainer(AndroidNativeDisplayContainer const&) = delete;
714 AndroidNativeDisplayContainer& operator=(AndroidNativeDisplayContainer const&) = delete;
715+
716+private:
717+ std::mutex mutable guard;
718+ std::unordered_set<MirEGLNativeDisplayType> valid_displays;
719 };
720
721 }
722
723=== modified file 'src/client/android/client_platform_factory.cpp'
724--- src/client/android/client_platform_factory.cpp 2014-02-07 15:43:41 +0000
725+++ src/client/android/client_platform_factory.cpp 2014-09-10 08:00:52 +0000
726@@ -16,19 +16,35 @@
727 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
728 */
729
730-#include "client_platform_factory.h"
731+#include "../client_platform_factory.h"
732+#include "mir_toolkit/client_types.h"
733+#include "../client_context.h"
734 #include "android_client_platform.h"
735
736+#include <stdexcept>
737+
738 namespace mcl = mir::client;
739 namespace mcla = mcl::android;
740
741-std::shared_ptr<mcl::ClientPlatform>
742-mcla::ClientPlatformFactory::create_client_platform(mcl::ClientContext* /*context*/)
743+extern "C" std::shared_ptr<mcl::ClientPlatform>
744+mcl::create_client_platform(mcl::ClientContext* context)
745 {
746+ MirPlatformPackage platform;
747+ context->populate(platform);
748+ if (platform.data_items != 0 || platform.fd_items != 0)
749+ {
750+ throw new std::runtime_error{"Attempted to create Android client platform on non-Android server"};
751+ }
752 return std::make_shared<mcla::AndroidClientPlatform>();
753 }
754
755-extern "C" std::shared_ptr<mcl::ClientPlatformFactory> mcl::create_client_platform_factory()
756+extern "C" bool
757+mcl::is_appropriate_module(mcl::ClientContext* context)
758 {
759- return std::make_shared<mcla::ClientPlatformFactory>();
760+ MirPlatformPackage platform;
761+ context->populate(platform);
762+ // TODO: Actually check what platform we're using, rather than blindly
763+ // hope we can distinguish them from the stuff they've put in the
764+ // PlatformPackage.
765+ return platform.data_items == 0 && platform.fd_items == 0;
766 }
767
768=== modified file 'src/client/android/client_platform_factory.h'
769--- src/client/android/client_platform_factory.h 2014-02-07 15:43:41 +0000
770+++ src/client/android/client_platform_factory.h 2014-09-10 08:00:52 +0000
771@@ -28,11 +28,8 @@
772 namespace android
773 {
774
775-class ClientPlatformFactory : public client::ClientPlatformFactory
776-{
777-public:
778- std::shared_ptr<ClientPlatform> create_client_platform(ClientContext* context) override;
779-};
780+extern "C" std::shared_ptr<ClientPlatform>
781+create_client_platform(ClientContext* context);
782
783 }
784 }
785
786=== modified file 'src/client/android/symbols.map'
787--- src/client/android/symbols.map 2014-09-08 04:12:17 +0000
788+++ src/client/android/symbols.map 2014-09-10 08:00:52 +0000
789@@ -1,5 +1,6 @@
790 MIR_CLIENTPLATFORM_1 {
791 global:
792- create_client_platform_factory;
793+ create_client_platform;
794+ is_appropriate_module;
795 local: *;
796 };
797\ No newline at end of file
798
799=== modified file 'src/client/client_platform_factory.h'
800--- src/client/client_platform_factory.h 2014-03-06 06:05:17 +0000
801+++ src/client/client_platform_factory.h 2014-09-10 08:00:52 +0000
802@@ -41,8 +41,11 @@
803 ClientPlatformFactory& operator=(ClientPlatformFactory const& p) = delete;
804 };
805
806-extern "C" typedef std::shared_ptr<ClientPlatformFactory>(*CreateClientPlatformFactory)();
807-extern "C" std::shared_ptr<ClientPlatformFactory> create_client_platform_factory();
808+extern "C" typedef std::shared_ptr<ClientPlatform>(*CreateClientPlatform)(ClientContext* context);
809+extern "C" std::shared_ptr<ClientPlatform> create_client_platform(ClientContext* context);
810+
811+extern "C" typedef bool (*ClientPlatformProbe)(ClientContext* context);
812+extern "C" bool is_appropriate_module(ClientContext* context);
813
814 }
815 }
816
817=== modified file 'src/client/connection_configuration.h'
818--- src/client/connection_configuration.h 2014-09-08 04:12:17 +0000
819+++ src/client/connection_configuration.h 2014-09-10 08:00:52 +0000
820@@ -39,8 +39,6 @@
821 class Logger;
822 }
823
824-class SharedLibrary;
825-
826 namespace client
827 {
828 class ConnectionSurfaceMap;
829@@ -65,7 +63,6 @@
830 virtual std::shared_ptr<LifecycleControl> the_lifecycle_control() = 0;
831 virtual std::shared_ptr<EventSink> the_event_sink() = 0;
832 virtual std::shared_ptr<EventHandlerRegister> the_event_handler_register() = 0;
833- virtual std::shared_ptr<SharedLibrary> the_platform_library() = 0;
834
835 protected:
836 ConnectionConfiguration() = default;
837
838=== modified file 'src/client/default_connection_configuration.cpp'
839--- src/client/default_connection_configuration.cpp 2014-09-09 09:54:19 +0000
840+++ src/client/default_connection_configuration.cpp 2014-09-10 08:00:52 +0000
841@@ -35,6 +35,7 @@
842 #include "lifecycle_control.h"
843 #include "mir/shared_library.h"
844 #include "client_platform_factory.h"
845+#include "probing_client_platform_factory.h"
846 #include "mir_event_distributor.h"
847 #include "mir/shared_library_prober.h"
848
849@@ -47,7 +48,10 @@
850 std::string const off_opt_val{"off"};
851 std::string const log_opt_val{"log"};
852 std::string const lttng_opt_val{"lttng"};
853-std::string const default_platform_lib{"libmirclientplatform.so"};
854+
855+// Shove this here until we properly manage the lifetime of our
856+// loadable modules
857+std::shared_ptr<mcl::ProbingClientPlatformFactory> the_platform_prober;
858
859 // Hack around the way Qt loads mir:
860 // qtmir and therefore Mir are loaded via dlopen(..., RTLD_LOCAL).
861@@ -108,11 +112,23 @@
862 return client_platform_factory(
863 [this]
864 {
865- auto const create_client_platform_factory =
866- the_platform_library()->load_function<mcl::CreateClientPlatformFactory>(
867- "create_client_platform_factory");
868-
869- return create_client_platform_factory();
870+ ensure_loaded_with_rtld_global();
871+ auto const platform_override = getenv("MIR_CLIENT_PLATFORM_LIB");
872+ std::vector<std::shared_ptr<mir::SharedLibrary>> platform_plugins;
873+ if (platform_override)
874+ {
875+ platform_plugins.push_back(std::make_shared<mir::SharedLibrary>(platform_override));
876+ }
877+ else
878+ {
879+ auto const platform_path_override = getenv("MIR_CLIENT_PLATFORM_PATH");
880+ auto const platform_path = platform_path_override ? platform_path_override : MIR_CLIENT_PLATFORM_PATH;
881+ platform_plugins = mir::libraries_for_path(platform_path, *the_shared_library_prober_report());
882+ }
883+
884+ the_platform_prober = std::make_shared<mcl::ProbingClientPlatformFactory>(platform_plugins);
885+
886+ return the_platform_prober;
887 });
888 }
889
890@@ -211,6 +227,7 @@
891 {
892 auto val_raw = getenv("MIR_CLIENT_SHARED_LIBRARY_PROBER_REPORT");
893 std::string const val{val_raw ? val_raw : off_opt_val};
894+
895 if (val == log_opt_val)
896 return std::make_shared<mir::logging::SharedLibraryProberReport>(the_logger());
897 else if (val == lttng_opt_val)
898@@ -219,15 +236,3 @@
899 return std::make_shared<mir::logging::NullSharedLibraryProberReport>();
900 });
901 }
902-
903-std::shared_ptr<mir::SharedLibrary> mcl::DefaultConnectionConfiguration::the_platform_library()
904-{
905- if (!platform_library)
906- {
907- ensure_loaded_with_rtld_global();
908- auto const val_raw = getenv("MIR_CLIENT_PLATFORM_LIB");
909- std::string const libname{val_raw ? val_raw : default_platform_lib};
910- platform_library = std::make_shared<mir::SharedLibrary>(libname);
911- }
912- return platform_library;
913-}
914
915=== modified file 'src/client/default_connection_configuration.h'
916--- src/client/default_connection_configuration.h 2014-09-09 09:54:19 +0000
917+++ src/client/default_connection_configuration.h 2014-09-10 08:00:52 +0000
918@@ -60,16 +60,12 @@
919 std::shared_ptr<EventSink> the_event_sink();
920 std::shared_ptr<EventHandlerRegister> the_event_handler_register();
921 std::shared_ptr<mir::SharedLibraryProberReport> the_shared_library_prober_report();
922- std::shared_ptr<SharedLibrary> the_platform_library() override;
923
924 virtual std::string the_socket_file();
925 virtual std::shared_ptr<rpc::RpcReport> the_rpc_report();
926 virtual std::shared_ptr<input::receiver::InputReceiverReport> the_input_receiver_report();
927
928 protected:
929- // MUST be first data member so it is destroyed last.
930- std::shared_ptr<mir::SharedLibrary> platform_library;
931-
932 CachedPtr<google::protobuf::RpcChannel> rpc_channel;
933 CachedPtr<mir::logging::Logger> logger;
934 CachedPtr<ClientPlatformFactory> client_platform_factory;
935
936=== modified file 'src/client/egl_native_display_container.h'
937--- src/client/egl_native_display_container.h 2014-03-06 06:05:17 +0000
938+++ src/client/egl_native_display_container.h 2014-09-10 08:00:52 +0000
939@@ -26,12 +26,14 @@
940 namespace client
941 {
942
943+class ClientContext;
944+
945 class EGLNativeDisplayContainer
946 {
947 public:
948 virtual ~EGLNativeDisplayContainer() {}
949
950- virtual MirEGLNativeDisplayType create(MirConnection* connection) = 0;
951+ virtual MirEGLNativeDisplayType create(ClientContext* context) = 0;
952 virtual void release(MirEGLNativeDisplayType display) = 0;
953
954 virtual bool validate(MirEGLNativeDisplayType display) const = 0;
955
956=== modified file 'src/client/mesa/CMakeLists.txt'
957--- src/client/mesa/CMakeLists.txt 2014-09-08 04:12:17 +0000
958+++ src/client/mesa/CMakeLists.txt 2014-09-10 08:00:52 +0000
959@@ -17,7 +17,7 @@
960 )
961
962 add_library(
963- mirclientplatformmesa SHARED
964+ mirclientplatformmesa MODULE
965
966 $<TARGET_OBJECTS:mirclientplatformmesaobjects>
967 $<TARGET_OBJECTS:mirclient_platformimpl>
968@@ -25,9 +25,9 @@
969
970 set_target_properties(
971 mirclientplatformmesa PROPERTIES
972- OUTPUT_NAME mirclientplatform
973- LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/mesa
974- LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}"
975+ OUTPUT_NAME client-platform-mesa
976+ PREFIX ""
977+ LINK_FLAGS "-Wl,--version-script,${symbol_map}"
978 )
979
980 target_link_libraries(
981@@ -36,21 +36,4 @@
982 ${DRM_LDFLAGS} ${DRM_LIBRARIES}
983 )
984
985-install(TARGETS mirclientplatformmesa LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/clientplatform/mesa)
986-
987-if (MIR_TEST_PLATFORM STREQUAL "mesa")
988- add_custom_command(TARGET mirclientplatformmesa
989- POST_BUILD
990- COMMAND ${CMAKE_COMMAND} -E remove libmirclientplatform.so
991- COMMAND ${CMAKE_COMMAND} -E create_symlink mesa/$<TARGET_FILE_NAME:mirclientplatformmesa> libmirclientplatform.so
992- WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
993- )
994-
995- install(CODE
996- "execute_process(
997- COMMAND ln -sf mir/clientplatform/mesa/libmirclientplatform.so
998- WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
999- )"
1000- )
1001-endif()
1002-
1003+install(TARGETS mirclientplatformmesa LIBRARY DESTINATION ${MIR_CLIENT_PLATFORM_PATH})
1004
1005=== modified file 'src/client/mesa/client_platform.cpp'
1006--- src/client/mesa/client_platform.cpp 2014-03-06 06:05:17 +0000
1007+++ src/client/mesa/client_platform.cpp 2014-09-10 08:00:52 +0000
1008@@ -95,7 +95,7 @@
1009 std::shared_ptr<EGLNativeDisplayType> mclm::ClientPlatform::create_egl_native_display()
1010 {
1011 MirEGLNativeDisplayType *mir_native_display = new MirEGLNativeDisplayType;
1012- *mir_native_display = display_container.create(context->mir_connection());
1013+ *mir_native_display = display_container.create(context);
1014 auto egl_native_display = reinterpret_cast<EGLNativeDisplayType*>(mir_native_display);
1015
1016 return std::shared_ptr<EGLNativeDisplayType>(egl_native_display, NativeDisplayDeleter(display_container));
1017
1018=== modified file 'src/client/mesa/client_platform_factory.cpp'
1019--- src/client/mesa/client_platform_factory.cpp 2014-02-07 15:43:41 +0000
1020+++ src/client/mesa/client_platform_factory.cpp 2014-09-10 08:00:52 +0000
1021@@ -16,13 +16,16 @@
1022 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
1023 */
1024
1025-#include "client_platform_factory.h"
1026+#include "../client_platform_factory.h"
1027 #include "client_platform.h"
1028+#include "mir_toolkit/client_types.h"
1029+#include "../client_context.h"
1030 #include "buffer_file_ops.h"
1031 #include "../egl_native_display_container.h"
1032
1033 #include <sys/mman.h>
1034 #include <unistd.h>
1035+#include <stdexcept>
1036
1037 namespace mcl = mir::client;
1038 namespace mclm = mcl::mesa;
1039@@ -57,15 +60,26 @@
1040
1041 }
1042
1043-std::shared_ptr<mcl::ClientPlatform>
1044-mclm::ClientPlatformFactory::create_client_platform(mcl::ClientContext* context)
1045+extern "C" std::shared_ptr<mcl::ClientPlatform> mcl::create_client_platform(mcl::ClientContext* context)
1046 {
1047+ MirPlatformPackage package;
1048+ context->populate(package);
1049+ if (package.data_items != 0 || package.fd_items != 1)
1050+ {
1051+ throw std::runtime_error{"Attempted to create Mesa client platform on non-Mesa server"};
1052+ }
1053 auto buffer_file_ops = std::make_shared<RealBufferFileOps>();
1054 return std::make_shared<mclm::ClientPlatform>(
1055 context, buffer_file_ops, mcl::EGLNativeDisplayContainer::instance());
1056 }
1057
1058-extern "C" std::shared_ptr<mcl::ClientPlatformFactory> mcl::create_client_platform_factory()
1059+extern "C" bool
1060+mcl::is_appropriate_module(mcl::ClientContext* context)
1061 {
1062- return std::make_shared<mclm::ClientPlatformFactory>();
1063+ MirPlatformPackage platform;
1064+ context->populate(platform);
1065+ // TODO: Actually check what platform we're using, rather than blindly
1066+ // hope we can distinguish them from the stuff they've put in the
1067+ // PlatformPackage.
1068+ return platform.data_items == 0 && platform.fd_items == 1;
1069 }
1070
1071=== modified file 'src/client/mesa/client_platform_factory.h'
1072--- src/client/mesa/client_platform_factory.h 2014-02-07 15:43:41 +0000
1073+++ src/client/mesa/client_platform_factory.h 2014-09-10 08:00:52 +0000
1074@@ -28,11 +28,6 @@
1075 namespace mesa
1076 {
1077
1078-class ClientPlatformFactory : public client::ClientPlatformFactory
1079-{
1080-public:
1081- std::shared_ptr<ClientPlatform> create_client_platform(ClientContext* context) override;
1082-};
1083
1084 }
1085 }
1086
1087=== modified file 'src/client/mesa/mesa_native_display_container.cpp'
1088--- src/client/mesa/mesa_native_display_container.cpp 2014-09-08 04:12:17 +0000
1089+++ src/client/mesa/mesa_native_display_container.cpp 2014-09-10 08:00:52 +0000
1090@@ -18,7 +18,7 @@
1091
1092 #include "mesa_native_display_container.h"
1093
1094-#include "mir_toolkit/mir_client_library.h"
1095+#include "../client_context.h"
1096
1097 #include <cstring>
1098 #include <unordered_set>
1099@@ -35,8 +35,8 @@
1100 static int egl_display_get_platform(MirMesaEGLNativeDisplay* display,
1101 MirPlatformPackage* package)
1102 {
1103- auto connection = static_cast<MirConnection*>(display->context);
1104- mir_connection_get_platform(connection, package);
1105+ auto context = static_cast<mcl::ClientContext*>(display->context);
1106+ context->populate(*package);
1107 return MIR_MESA_TRUE;
1108 }
1109
1110@@ -93,11 +93,11 @@
1111 }
1112
1113 MirEGLNativeDisplayType
1114-mclm::MesaNativeDisplayContainer::create(MirConnection* connection)
1115+mclm::MesaNativeDisplayContainer::create(ClientContext* context)
1116 {
1117 MirMesaEGLNativeDisplay* display = new MirMesaEGLNativeDisplay();
1118 display->display_get_platform = egl_display_get_platform;
1119- display->context = connection;
1120+ display->context = context;
1121
1122 std::lock_guard<std::mutex> lg(guard);
1123 auto egl_display = static_cast<MirEGLNativeDisplayType>(display);
1124
1125=== modified file 'src/client/mesa/mesa_native_display_container.h'
1126--- src/client/mesa/mesa_native_display_container.h 2014-03-06 06:05:17 +0000
1127+++ src/client/mesa/mesa_native_display_container.h 2014-09-10 08:00:52 +0000
1128@@ -40,7 +40,7 @@
1129 MesaNativeDisplayContainer();
1130 virtual ~MesaNativeDisplayContainer();
1131
1132- MirEGLNativeDisplayType create(MirConnection* connection);
1133+ MirEGLNativeDisplayType create(ClientContext* context);
1134 void release(MirEGLNativeDisplayType display);
1135
1136 bool validate(MirEGLNativeDisplayType display) const;
1137
1138=== modified file 'src/client/mesa/native_surface.cpp'
1139--- src/client/mesa/native_surface.cpp 2014-09-08 04:12:17 +0000
1140+++ src/client/mesa/native_surface.cpp 2014-09-10 08:00:52 +0000
1141@@ -20,7 +20,6 @@
1142 #include "../client_buffer.h"
1143 #include "native_surface.h"
1144
1145-#include <iostream>
1146 #include <boost/exception/diagnostic_information.hpp>
1147
1148 namespace mclm=mir::client::mesa;
1149
1150=== modified file 'src/client/mesa/symbols.map'
1151--- src/client/mesa/symbols.map 2014-09-08 04:12:17 +0000
1152+++ src/client/mesa/symbols.map 2014-09-10 08:00:52 +0000
1153@@ -1,7 +1,9 @@
1154 MIR_CLIENTPLATFORM_1 {
1155 global:
1156- create_client_platform_factory;
1157+ create_client_platform;
1158+ is_appropriate_module;
1159 # Needed by our Mesa EGL platform
1160 mir_client_mesa_egl_native_display_is_valid;
1161- local: *;
1162+ local:
1163+ *;
1164 };
1165
1166=== modified file 'src/client/mir_connection.cpp'
1167--- src/client/mir_connection.cpp 2014-09-08 04:12:17 +0000
1168+++ src/client/mir_connection.cpp 2014-09-10 08:00:52 +0000
1169@@ -94,10 +94,10 @@
1170 MirConnection::MirConnection(
1171 mir::client::ConnectionConfiguration& conf) :
1172 deregisterer{this},
1173- platform_library{conf.the_platform_library()},
1174 channel(conf.the_rpc_channel()),
1175 server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL),
1176 logger(conf.the_logger()),
1177+ connect_done{false},
1178 client_platform_factory(conf.the_client_platform_factory()),
1179 input_platform(conf.the_input_platform()),
1180 display_configuration(conf.the_display_configuration()),
1181@@ -249,6 +249,9 @@
1182 set_error_message("Connect failed");
1183 }
1184 }
1185+
1186+ connect_done = true;
1187+
1188 /*
1189 * We need to create the client platform after the connection has been
1190 * established, to ensure that the client platform has access to all
1191@@ -353,9 +356,9 @@
1192
1193 void MirConnection::populate(MirPlatformPackage& platform_package)
1194 {
1195- std::lock_guard<decltype(mutex)> lock(mutex);
1196-
1197- if (!connect_result.has_error() && connect_result.has_platform())
1198+ // connect_result is write-once: once it's valid, we don't need to lock
1199+ // to use it.
1200+ if (connect_done && !connect_result.has_error() && connect_result.has_platform())
1201 {
1202 auto const& platform = connect_result.platform();
1203
1204
1205=== modified file 'src/client/mir_connection.h'
1206--- src/client/mir_connection.h 2014-09-08 04:12:17 +0000
1207+++ src/client/mir_connection.h 2014-09-10 08:00:52 +0000
1208@@ -22,6 +22,7 @@
1209 #include <memory>
1210 #include <unordered_set>
1211 #include <unordered_map>
1212+#include <atomic>
1213
1214 #include <mutex>
1215
1216@@ -149,8 +150,9 @@
1217 std::shared_ptr<google::protobuf::RpcChannel> const channel;
1218 mir::protobuf::DisplayServer::Stub server;
1219 std::shared_ptr<mir::logging::Logger> const logger;
1220- mir::protobuf::Void void_response;
1221+ mir::protobuf::Void void_response;
1222 mir::protobuf::Connection connect_result;
1223+ std::atomic<bool> connect_done;
1224 mir::protobuf::Void ignored;
1225 mir::protobuf::ConnectParameters connect_parameters;
1226 mir::protobuf::DRMAuthMagicStatus drm_auth_magic_status;
1227
1228=== added file 'src/client/probing_client_platform_factory.cpp'
1229--- src/client/probing_client_platform_factory.cpp 1970-01-01 00:00:00 +0000
1230+++ src/client/probing_client_platform_factory.cpp 2014-09-10 08:00:52 +0000
1231@@ -0,0 +1,36 @@
1232+#include "probing_client_platform_factory.h"
1233+
1234+#include <stdexcept>
1235+
1236+namespace mcl = mir::client;
1237+
1238+mcl::ProbingClientPlatformFactory::ProbingClientPlatformFactory(std::vector<std::shared_ptr<mir::SharedLibrary>> const& modules)
1239+ : platform_modules{modules}
1240+{
1241+ if (modules.empty())
1242+ {
1243+ throw std::runtime_error{"Attempted to create a ClientPlatformFactory with no platform modules"};
1244+ }
1245+}
1246+
1247+std::shared_ptr<mcl::ClientPlatform>
1248+mcl::ProbingClientPlatformFactory::create_client_platform(mcl::ClientContext* context)
1249+{
1250+ for (auto& module : platform_modules)
1251+ {
1252+ try
1253+ {
1254+ auto probe = module->load_function<mir::client::ClientPlatformProbe>("is_appropriate_module", CLIENT_PLATFORM_VERSION);
1255+ if (probe(context))
1256+ {
1257+ auto factory = module->load_function<mir::client::CreateClientPlatform>("create_client_platform", CLIENT_PLATFORM_VERSION);
1258+ return factory(context);
1259+ }
1260+ }
1261+ catch(std::runtime_error)
1262+ {
1263+ // We were handled a SharedLibrary that's not a client platform module?
1264+ }
1265+ }
1266+ throw std::runtime_error{"No appropriate client platform module found"};
1267+}
1268
1269=== added file 'src/client/probing_client_platform_factory.h'
1270--- src/client/probing_client_platform_factory.h 1970-01-01 00:00:00 +0000
1271+++ src/client/probing_client_platform_factory.h 2014-09-10 08:00:52 +0000
1272@@ -0,0 +1,27 @@
1273+#ifndef MIR_CLIENT_PROBING_CLIENT_PLATFORM_FACTORY_H_
1274+#define MIR_CLIENT_PROBING_CLIENT_PLATFORM_FACTORY_H_
1275+
1276+#include <vector>
1277+
1278+#include "client_platform_factory.h"
1279+#include "mir/shared_library.h"
1280+
1281+namespace mir
1282+{
1283+namespace client
1284+{
1285+class ProbingClientPlatformFactory : public ClientPlatformFactory
1286+{
1287+public:
1288+ ProbingClientPlatformFactory(std::vector<std::shared_ptr<SharedLibrary>> const& modules);
1289+
1290+ std::shared_ptr<ClientPlatform> create_client_platform(ClientContext *context) override;
1291+private:
1292+ std::vector<std::shared_ptr<SharedLibrary>> platform_modules;
1293+};
1294+
1295+
1296+}
1297+}
1298+
1299+#endif // MIR_CLIENT_PROBING_CLIENT_PLATFORM_FACTORY_H_
1300
1301=== modified file 'src/common/graphics/android/mir_native_window.cpp'
1302--- src/common/graphics/android/mir_native_window.cpp 2014-09-08 04:12:17 +0000
1303+++ src/common/graphics/android/mir_native_window.cpp 2014-09-10 08:00:52 +0000
1304@@ -20,7 +20,6 @@
1305 #include "mir/graphics/android/android_driver_interpreter.h"
1306 #include "mir/graphics/android/sync_fence.h"
1307
1308-#include <iostream>
1309 #include <boost/exception/diagnostic_information.hpp>
1310
1311 namespace mg=mir::graphics;
1312
1313=== modified file 'src/common/logging/CMakeLists.txt'
1314--- src/common/logging/CMakeLists.txt 2014-09-09 09:54:19 +0000
1315+++ src/common/logging/CMakeLists.txt 2014-09-10 08:00:52 +0000
1316@@ -18,7 +18,7 @@
1317 dumb_console_logger.cpp
1318 input_timestamp.cpp
1319 shared_library_prober_report.cpp
1320-)
1321+)
1322
1323 list(APPEND MIR_COMMON_SOURCES
1324 $<TARGET_OBJECTS:mirsharedlogging>
1325
1326=== modified file 'src/common/sharedlibrary/CMakeLists.txt'
1327--- src/common/sharedlibrary/CMakeLists.txt 2014-09-09 09:54:19 +0000
1328+++ src/common/sharedlibrary/CMakeLists.txt 2014-09-10 08:00:52 +0000
1329@@ -23,7 +23,10 @@
1330 $<TARGET_OBJECTS:mirsharedsharedlibrary>
1331 )
1332
1333-list(APPEND MIR_COMMON_REFERENCES dl)
1334+list(APPEND MIR_COMMON_REFERENCES
1335+ dl
1336+ ${Boost_LIBRARIES}
1337+)
1338
1339 set(MIR_COMMON_SOURCES ${MIR_COMMON_SOURCES} PARENT_SCOPE)
1340 set(MIR_COMMON_REFERENCES ${MIR_COMMON_REFERENCES} PARENT_SCOPE)
1341
1342=== modified file 'src/common/sharedlibrary/shared_library.cpp'
1343--- src/common/sharedlibrary/shared_library.cpp 2014-03-06 06:05:17 +0000
1344+++ src/common/sharedlibrary/shared_library.cpp 2014-09-10 08:00:52 +0000
1345@@ -53,3 +53,15 @@
1346 BOOST_THROW_EXCEPTION(std::runtime_error(dlerror()));
1347 }
1348 }
1349+
1350+void* mir::SharedLibrary::load_symbol(char const* function_name, char const* version) const
1351+{
1352+ if (void* result = dlvsym(so, function_name, version))
1353+ {
1354+ return result;
1355+ }
1356+ else
1357+ {
1358+ BOOST_THROW_EXCEPTION(std::runtime_error(dlerror()));
1359+ }
1360+}
1361
1362=== modified file 'src/platform/CMakeLists.txt'
1363--- src/platform/CMakeLists.txt 2014-09-08 04:12:17 +0000
1364+++ src/platform/CMakeLists.txt 2014-09-10 08:00:52 +0000
1365@@ -7,12 +7,23 @@
1366
1367 set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)
1368
1369-add_library(mirplatformobjects OBJECT
1370- shared_library_loader.cpp
1371-)
1372+# This needs to change whenever the much smaller ABI between the platform
1373+# modules and the server changes in an incompatible way.
1374+set(SERVER_PLATFORM_VERSION "MIR_GRAPHICS_PLATFORM_1")
1375+set(SERVER_PLATFORM_VERSION ${SERVER_PLATFORM_VERSION} PARENT_SCOPE)
1376+
1377+set(MIR_SERVER_PLATFORM_PLUGIN_PATH
1378+ ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/mir/server-platform-1
1379+)
1380+set(MIR_SERVER_PLATFORM_PLUGIN_PATH
1381+ ${MIR_SERVER_PLATFORM_PLUGIN_PATH}
1382+ PARENT_SCOPE
1383+)
1384+
1385+add_definitions(-DMIR_SERVER_PLATFORM_PLUGIN_PATH="${MIR_SERVER_PLATFORM_PLUGIN_PATH}")
1386+add_definitions(-DSERVER_PLATFORM_VERSION="${SERVER_PLATFORM_VERSION}")
1387
1388 set(MIR_PLATFORM_OBJECTS
1389- $<TARGET_OBJECTS:mirplatformobjects>
1390 $<TARGET_OBJECTS:mirplatformgraphicscommon>
1391 $<TARGET_OBJECTS:miroptions>
1392 $<TARGET_OBJECTS:mirfatal>
1393@@ -31,17 +42,19 @@
1394 )
1395
1396 target_link_libraries(mirplatform
1397+
1398 mircommon
1399 ${MIR_PLATFORM_REFERENCES}
1400 )
1401
1402-set_target_properties(mirplatform
1403+set_target_properties(
1404+ mirplatform
1405+
1406 PROPERTIES
1407 SOVERSION ${MIRPLATFORM_ABI}
1408 LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}"
1409 )
1410
1411-
1412 install(TARGETS mirplatform LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
1413
1414 add_subdirectory(graphics/)
1415
1416=== modified file 'src/platform/graphics/CMakeLists.txt'
1417--- src/platform/graphics/CMakeLists.txt 2014-09-08 04:12:17 +0000
1418+++ src/platform/graphics/CMakeLists.txt 2014-09-10 08:00:52 +0000
1419@@ -14,6 +14,7 @@
1420 gl_program.cpp
1421 gl_texture.cpp
1422 tessellation_helpers.cpp
1423+ platform_probe.cpp
1424 )
1425
1426 add_library(mirplatformgraphicscommon OBJECT
1427
1428=== modified file 'src/platform/graphics/android/CMakeLists.txt'
1429--- src/platform/graphics/android/CMakeLists.txt 2014-09-08 04:12:17 +0000
1430+++ src/platform/graphics/android/CMakeLists.txt 2014-09-10 08:00:52 +0000
1431@@ -8,7 +8,9 @@
1432 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
1433 add_definitions( -DANDROID )
1434
1435-add_library(mirplatformgraphicsandroidobjects OBJECT
1436+add_library(
1437+ mirplatformgraphicsandroidobjects OBJECT
1438+
1439 android_platform.cpp
1440 android_buffer_allocator.cpp
1441 buffer.cpp
1442@@ -36,17 +38,12 @@
1443 real_hwc_wrapper.cpp
1444 hwc_fallback_gl_renderer.cpp
1445 )
1446+
1447 add_library(mirplatformgraphicsandroid SHARED
1448+
1449 $<TARGET_OBJECTS:mirplatformgraphicsandroidobjects>
1450 )
1451
1452-set_target_properties(
1453- mirplatformgraphicsandroid PROPERTIES
1454- OUTPUT_NAME mirplatformgraphics
1455- LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/android
1456- LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}"
1457-)
1458-
1459 target_link_libraries(
1460 mirplatformgraphicsandroid
1461
1462@@ -59,20 +56,13 @@
1463 ${ANDROID_PROPERTIES_LDFLAGS}
1464 )
1465
1466-install(TARGETS mirplatformgraphicsandroid LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/platformgraphics/android)
1467-
1468-if (MIR_TEST_PLATFORM STREQUAL "android")
1469- add_custom_command(TARGET mirplatformgraphicsandroid
1470- POST_BUILD
1471- COMMAND ${CMAKE_COMMAND} -E remove libmirplatformgraphics.so
1472- COMMAND ${CMAKE_COMMAND} -E create_symlink android/$<TARGET_FILE_NAME:mirplatformgraphicsandroid> libmirplatformgraphics.so
1473- WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
1474- )
1475-
1476- install(CODE
1477- "execute_process(
1478- COMMAND ln -sf mir/platformgraphics/android/libmirplatformgraphics.so
1479- WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
1480- )"
1481- )
1482-endif()
1483+set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)
1484+
1485+set_target_properties(
1486+ mirplatformgraphicsandroid PROPERTIES
1487+ OUTPUT_NAME platform-graphics-android
1488+ PREFIX ""
1489+ LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}"
1490+)
1491+
1492+install(TARGETS mirplatformgraphicsandroid LIBRARY DESTINATION ${MIR_SERVER_PLATFORM_PLUGIN_PATH})
1493
1494=== modified file 'src/platform/graphics/android/android_platform.cpp'
1495--- src/platform/graphics/android/android_platform.cpp 2014-09-09 12:41:41 +0000
1496+++ src/platform/graphics/android/android_platform.cpp 2014-09-10 08:00:52 +0000
1497@@ -187,3 +187,26 @@
1498 boost::program_options::value<bool>()->default_value(true), //TODO: switch default to false
1499 "[platform-specific] Whether to disable overlay optimizations [{on,off}]");
1500 }
1501+
1502+extern "C" mg::PlatformPriority probe_platform()
1503+{
1504+ int err;
1505+ hw_module_t const* hw_module;
1506+
1507+ err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hw_module);
1508+
1509+ // TODO: Yo! kdub! Is this totally insane?
1510+ // It *looks* like the hw_module_t is global, so we don't leak by
1511+ // not doing anything with it?
1512+
1513+ return err < 0 ? mg::PlatformPriority::unsupported : mg::PlatformPriority::best;
1514+}
1515+
1516+mg::ModuleProperties const description = {
1517+ "android"
1518+};
1519+
1520+extern "C" mg::ModuleProperties const* describe_module()
1521+{
1522+ return &description;
1523+}
1524
1525=== added file 'src/platform/graphics/android/symbols.map'
1526--- src/platform/graphics/android/symbols.map 1970-01-01 00:00:00 +0000
1527+++ src/platform/graphics/android/symbols.map 2014-09-10 08:00:52 +0000
1528@@ -0,0 +1,8 @@
1529+MIR_GRAPHICS_PLATFORM_1 {
1530+ global:
1531+ add_platform_options;
1532+ create_platform;
1533+ create_native_platform;
1534+ probe_platform;
1535+ describe_module;
1536+};
1537
1538=== modified file 'src/platform/graphics/mesa/CMakeLists.txt'
1539--- src/platform/graphics/mesa/CMakeLists.txt 2014-09-08 04:12:17 +0000
1540+++ src/platform/graphics/mesa/CMakeLists.txt 2014-09-10 08:00:52 +0000
1541@@ -11,7 +11,9 @@
1542 string(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
1543 add_definitions(-D__GBM__)
1544
1545-add_library(mirplatformgraphicsmesaobjects OBJECT
1546+add_library(
1547+ mirplatformgraphicsmesaobjects OBJECT
1548+
1549 platform.cpp
1550 buffer_allocator.cpp
1551 gbm_buffer.cpp
1552@@ -35,18 +37,14 @@
1553 bypass.cpp
1554 )
1555
1556-add_library(mirplatformgraphicsmesa SHARED
1557+add_library(
1558+ mirplatformgraphicsmesa MODULE
1559+
1560 $<TARGET_OBJECTS:mirplatformgraphicsmesaobjects>
1561 )
1562
1563-set_target_properties(
1564- mirplatformgraphicsmesa PROPERTIES
1565- OUTPUT_NAME mirplatformgraphics
1566- LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/mesa
1567- LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}"
1568-)
1569-
1570-target_link_libraries(mirplatformgraphicsmesa
1571+target_link_libraries(
1572+ mirplatformgraphicsmesa
1573
1574 ${Boost_PROGRAM_OPTIONS_LIBRARY}
1575 ${DRM_LDFLAGS} ${DRM_LIBRARIES}
1576@@ -55,20 +53,13 @@
1577 ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}
1578 )
1579
1580-install(TARGETS mirplatformgraphicsmesa LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/platformgraphics/mesa)
1581-
1582-if (MIR_TEST_PLATFORM STREQUAL "mesa")
1583- add_custom_command(TARGET mirplatformgraphicsmesa
1584- POST_BUILD
1585- COMMAND ${CMAKE_COMMAND} -E remove libmirplatformgraphics.so
1586- COMMAND ${CMAKE_COMMAND} -E create_symlink mesa/$<TARGET_FILE_NAME:mirplatformgraphicsmesa> libmirplatformgraphics.so
1587- WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
1588- )
1589-
1590- install(CODE
1591- "execute_process(
1592- COMMAND ln -sf mir/platformgraphics/mesa/libmirplatformgraphics.so
1593- WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
1594- )"
1595- )
1596-endif()
1597+set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)
1598+
1599+set_target_properties(
1600+ mirplatformgraphicsmesa PROPERTIES
1601+ OUTPUT_NAME platform-graphics-mesa
1602+ PREFIX ""
1603+ LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}"
1604+)
1605+
1606+install(TARGETS mirplatformgraphicsmesa LIBRARY DESTINATION ${MIR_SERVER_PLATFORM_PLUGIN_PATH})
1607
1608=== modified file 'src/platform/graphics/mesa/platform.cpp'
1609--- src/platform/graphics/mesa/platform.cpp 2014-09-08 04:12:17 +0000
1610+++ src/platform/graphics/mesa/platform.cpp 2014-09-10 08:00:52 +0000
1611@@ -28,6 +28,7 @@
1612 #include "mir/options/option.h"
1613 #include "mir/graphics/native_buffer.h"
1614 #include "mir/emergency_cleanup_registry.h"
1615+#include "mir/udev/wrapper.h"
1616
1617 #include "drm_close_threadsafe.h"
1618
1619@@ -269,3 +270,30 @@
1620 boost::program_options::value<bool>()->default_value(true),
1621 "[platform-specific] utilize the bypass optimization for fullscreen surfaces.");
1622 }
1623+
1624+extern "C" mg::PlatformPriority probe_platform()
1625+{
1626+ auto udev = std::make_shared<mir::udev::Context>();
1627+
1628+ mir::udev::Enumerator drm_devices{udev};
1629+ drm_devices.match_subsystem("drm");
1630+ drm_devices.match_sysname("card[0-9]*");
1631+ drm_devices.scan_devices();
1632+
1633+ for(auto& device : drm_devices)
1634+ {
1635+ static_cast<void>(device);
1636+ return mg::PlatformPriority::best;
1637+ }
1638+
1639+ return mg::PlatformPriority::unsupported;
1640+}
1641+
1642+mg::ModuleProperties const description = {
1643+ "mesa"
1644+};
1645+
1646+extern "C" mg::ModuleProperties const* describe_module()
1647+{
1648+ return &description;
1649+}
1650
1651=== added file 'src/platform/graphics/mesa/symbols.map'
1652--- src/platform/graphics/mesa/symbols.map 1970-01-01 00:00:00 +0000
1653+++ src/platform/graphics/mesa/symbols.map 2014-09-10 08:00:52 +0000
1654@@ -0,0 +1,8 @@
1655+MIR_GRAPHICS_PLATFORM_1 {
1656+ global:
1657+ add_platform_options;
1658+ create_platform;
1659+ create_native_platform;
1660+ probe_platform;
1661+ describe_module;
1662+};
1663
1664=== added file 'src/platform/graphics/platform_probe.cpp'
1665--- src/platform/graphics/platform_probe.cpp 1970-01-01 00:00:00 +0000
1666+++ src/platform/graphics/platform_probe.cpp 2014-09-10 08:00:52 +0000
1667@@ -0,0 +1,50 @@
1668+/*
1669+ * Copyright © 2014 Canonical Ltd.
1670+ *
1671+ * This program is free software: you can redistribute it and/or modify it
1672+ * under the terms of the GNU Lesser General Public License version 3,
1673+ * as published by the Free Software Foundation.
1674+ *
1675+ * This program is distributed in the hope that it will be useful,
1676+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1677+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1678+ * GNU Lesser General Public License for more details.
1679+ *
1680+ * You should have received a copy of the GNU Lesser General Public License
1681+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1682+ *
1683+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
1684+ */
1685+
1686+#include "mir/graphics/platform.h"
1687+#include "platform_probe.h"
1688+
1689+std::shared_ptr<mir::SharedLibrary>
1690+mir::graphics::module_for_device(std::vector<std::shared_ptr<SharedLibrary>> const& modules)
1691+{
1692+ mir::graphics::PlatformPriority best_priority_so_far = mir::graphics::unsupported;
1693+ std::shared_ptr<mir::SharedLibrary> best_module_so_far;
1694+ for(auto& module : modules)
1695+ {
1696+ try
1697+ {
1698+ auto probe = module->load_function<mir::graphics::PlatformProbe>("probe_platform",
1699+ SERVER_PLATFORM_VERSION);
1700+ auto module_priority = probe();
1701+ if (module_priority > best_priority_so_far)
1702+ {
1703+ best_priority_so_far = module_priority;
1704+ best_module_so_far = module;
1705+ }
1706+ }
1707+ catch (std::runtime_error)
1708+ {
1709+ // Tried to probe a SharedLibrary that isn't a platform module?
1710+ }
1711+ }
1712+ if (best_priority_so_far > mir::graphics::unsupported)
1713+ {
1714+ return best_module_so_far;
1715+ }
1716+ throw std::runtime_error{"Failed to find platform for current system"};
1717+}
1718
1719=== added file 'src/platform/graphics/platform_probe.h'
1720--- src/platform/graphics/platform_probe.h 1970-01-01 00:00:00 +0000
1721+++ src/platform/graphics/platform_probe.h 2014-09-10 08:00:52 +0000
1722@@ -0,0 +1,37 @@
1723+/*
1724+ * Copyright © 2014 Canonical Ltd.
1725+ *
1726+ * This program is free software: you can redistribute it and/or modify it
1727+ * under the terms of the GNU Lesser General Public License version 3,
1728+ * as published by the Free Software Foundation.
1729+ *
1730+ * This program is distributed in the hope that it will be useful,
1731+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1732+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1733+ * GNU Lesser General Public License for more details.
1734+ *
1735+ * You should have received a copy of the GNU Lesser General Public License
1736+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1737+ *
1738+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
1739+ */
1740+
1741+#ifndef MIR_GRAPHICS_PLATFORM_PROBE_H_
1742+#define MIR_GRAPHICS_PLATFORM_PROBE_H_
1743+
1744+#include <vector>
1745+#include <memory>
1746+#include "mir/shared_library.h"
1747+
1748+namespace mir
1749+{
1750+namespace graphics
1751+{
1752+class Platform;
1753+
1754+std::shared_ptr<SharedLibrary> module_for_device(std::vector<std::shared_ptr<SharedLibrary>> const& modules);
1755+
1756+}
1757+}
1758+
1759+#endif // MIR_GRAPHICS_PLATFORM_PROBE_H_
1760
1761=== modified file 'src/platform/options/default_configuration.cpp'
1762--- src/platform/options/default_configuration.cpp 2014-09-09 05:49:11 +0000
1763+++ src/platform/options/default_configuration.cpp 2014-09-10 08:00:52 +0000
1764@@ -17,11 +17,12 @@
1765 */
1766
1767 #include "mir/shared_library.h"
1768-#include "mir/shared_library_loader.h"
1769 #include "mir/options/default_configuration.h"
1770 #include "mir/graphics/platform.h"
1771 #include "mir/default_configuration.h"
1772 #include "mir/abnormal_exit.h"
1773+#include "mir/shared_library_prober.h"
1774+#include "../graphics/platform_probe.h"
1775
1776 #include <dlfcn.h>
1777
1778@@ -39,6 +40,7 @@
1779 char const* const mo::connector_report_opt = "connector-report";
1780 char const* const mo::scene_report_opt = "scene-report";
1781 char const* const mo::input_report_opt = "input-report";
1782+char const* const mo::shared_library_prober_report_opt = "shared-library-prober-report";
1783 char const* const mo::host_socket_opt = "host-socket";
1784 char const* const mo::frontend_threads_opt = "ipc-thread-pool";
1785 char const* const mo::name_opt = "name";
1786@@ -55,6 +57,7 @@
1787 char const* const mo::lttng_opt_value = "lttng";
1788
1789 char const* const mo::platform_graphics_lib = "platform-graphics-lib";
1790+char const* const mo::platform_graphics_path = "platform-graphics-path";
1791
1792 namespace
1793 {
1794@@ -63,7 +66,8 @@
1795 int const glog_minloglevel_default = 0;
1796 char const* const glog_log_dir_default = "";
1797 bool const enable_input_default = true;
1798-char const* const default_platform_graphics_lib = "libmirplatformgraphics.so";
1799+
1800+std::shared_ptr<mir::SharedLibrary> graphics_lib;
1801
1802 // Hack around the way Qt loads mir:
1803 // platform_api and therefore Mir are loaded via dlopen(..., RTLD_LOCAL).
1804@@ -120,8 +124,10 @@
1805 "Socket filename [string:default=$XDG_RUNTIME_DIR/mir_socket or /tmp/mir_socket]")
1806 (no_server_socket_opt, "Do not provide a socket filename for client connections")
1807 (prompt_socket_opt, "Provide a \"..._trusted\" filename for prompt helper connections")
1808- (platform_graphics_lib, po::value<std::string>()->default_value(default_platform_graphics_lib),
1809- "Library to use for platform graphics support")
1810+ (platform_graphics_lib, po::value<std::string>(),
1811+ "Library to use for platform graphics support (default: autodetect)")
1812+ (platform_graphics_path, po::value<std::string>()->default_value(MIR_SERVER_PLATFORM_PLUGIN_PATH),
1813+ "Library to use for platform graphics support (default: " MIR_SERVER_PLATFORM_PLUGIN_PATH ")")
1814 (enable_input_opt, po::value<bool>()->default_value(enable_input_default),
1815 "Enable input.")
1816 (compositor_report_opt, po::value<std::string>()->default_value(off_opt_value),
1817@@ -140,6 +146,8 @@
1818 "How to handle the MessageProcessor report. [{log,lttng,off}]")
1819 (scene_report_opt, po::value<std::string>()->default_value(off_opt_value),
1820 "How to handle the scene report. [{log,lttng,off}]")
1821+ (shared_library_prober_report_opt, po::value<std::string>()->default_value(off_opt_value),
1822+ "How to handle the shared library prober report. [{log,lttng,off}]")
1823 (glog,
1824 "Use google::GLog for logging")
1825 (glog_stderrthreshold, po::value<int>()->default_value(glog_stderrthreshold_default),
1826@@ -167,32 +175,74 @@
1827 add_platform_options();
1828 }
1829
1830+namespace
1831+{
1832+class NullSharedLibraryProberReport : public mir::SharedLibraryProberReport
1833+{
1834+public:
1835+ void probing_path(boost::filesystem::path const& /*path*/) override
1836+ {
1837+ }
1838+ void probing_failed(boost::filesystem::path const& /*path*/, std::exception const& /*error*/) override
1839+ {
1840+ }
1841+ void loading_library(boost::filesystem::path const& /*filename*/) override
1842+ {
1843+ }
1844+ void loading_failed(boost::filesystem::path const& /*filename*/, std::exception const& /*error*/) override
1845+ {
1846+ }
1847+};
1848+}
1849+
1850 void mo::DefaultConfiguration::add_platform_options()
1851 {
1852 namespace po = boost::program_options;
1853 po::options_description program_options;
1854 program_options.add_options()
1855 (platform_graphics_lib,
1856- po::value<std::string>()->default_value(default_platform_graphics_lib), "");
1857+ po::value<std::string>(), "");
1858+ program_options.add_options()
1859+ (platform_graphics_path,
1860+ po::value<std::string>()->default_value(MIR_SERVER_PLATFORM_PLUGIN_PATH),
1861+ "");
1862 mo::ProgramOption options;
1863 options.parse_arguments(program_options, argc, argv);
1864
1865- std::string graphics_libname;
1866+ ensure_loaded_with_rtld_global();
1867+
1868+ // TODO: We should just load all the platform plugins we can and present their options.
1869 auto env_libname = ::getenv("MIR_SERVER_PLATFORM_GRAPHICS_LIB");
1870- if (!options.is_set(platform_graphics_lib) && env_libname)
1871- {
1872- graphics_libname = std::string{env_libname};
1873- }
1874- else
1875- {
1876- graphics_libname = options.get<std::string>(platform_graphics_lib);
1877- }
1878-
1879- ensure_loaded_with_rtld_global();
1880-
1881- auto graphics_lib = load_library(graphics_libname);
1882- auto add_platform_options = graphics_lib->load_function<mir::graphics::AddPlatformOptions>(std::string("add_platform_options"));
1883- add_platform_options(*this->program_options);
1884+ auto env_libpath = ::getenv("MIR_SERVER_PLATFORM_GRAPHICS_PATH");
1885+ try
1886+ {
1887+ if (options.is_set(platform_graphics_lib))
1888+ {
1889+ graphics_lib = std::make_shared<mir::SharedLibrary>(options.get<std::string>(platform_graphics_lib));
1890+ }
1891+ else if (env_libname)
1892+ {
1893+ graphics_lib = std::make_shared<mir::SharedLibrary>(std::string{env_libname});
1894+ }
1895+ else
1896+ {
1897+ auto const plugin_path = env_libpath ? env_libpath : options.get<std::string>(platform_graphics_path);
1898+ NullSharedLibraryProberReport nuller;
1899+ auto plugins = mir::libraries_for_path(plugin_path, nuller);
1900+ graphics_lib = mir::graphics::module_for_device(plugins);
1901+ }
1902+
1903+ auto add_platform_options = graphics_lib->load_function<mir::graphics::AddPlatformOptions>(std::string("add_platform_options"));
1904+ add_platform_options(*this->program_options);
1905+ }
1906+ catch(...)
1907+ {
1908+ // We don't actually care at this point if this failed.
1909+ // Maybe we've been pointed at the wrong place. Maybe this platform doesn't actually
1910+ // *have* platform-specific options.
1911+ // Regardless, if we need a platform and can't find one then we'll bail later
1912+ // in startup with a useful error.
1913+ }
1914 }
1915
1916 boost::program_options::options_description_easy_init mo::DefaultConfiguration::add_options()
1917
1918=== removed file 'src/platform/shared_library_loader.cpp'
1919--- src/platform/shared_library_loader.cpp 2014-03-20 16:49:52 +0000
1920+++ src/platform/shared_library_loader.cpp 1970-01-01 00:00:00 +0000
1921@@ -1,38 +0,0 @@
1922-/*
1923- * Copyright © 2013 Canonical Ltd.
1924- *
1925- * This program is free software: you can redistribute it and/or modify it
1926- * under the terms of the GNU Lesser General Public License version 3,
1927- * as published by the Free Software Foundation.
1928- *
1929- * This program is distributed in the hope that it will be useful,
1930- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1931- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1932- * GNU Lesser General Public License for more details.
1933- *
1934- * You should have received a copy of the GNU Lesser General Public License
1935- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1936- *
1937- * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
1938- */
1939-
1940-#include "mir/shared_library_loader.h"
1941-#include "mir/shared_library.h"
1942-#include <memory>
1943-#include <map>
1944-
1945-mir::SharedLibrary const* mir::load_library(std::string const& libname)
1946-{
1947- // There's no point in loading twice, and it isn't safe to unload...
1948- static std::map<std::string, std::shared_ptr<mir::SharedLibrary>> libraries_cache;
1949-
1950- if (auto& ptr = libraries_cache[libname])
1951- {
1952- return ptr.get();
1953- }
1954- else
1955- {
1956- ptr = std::make_shared<mir::SharedLibrary>(libname);
1957- return ptr.get();
1958- }
1959-}
1960
1961=== modified file 'src/platform/symbols.map'
1962--- src/platform/symbols.map 2014-09-08 04:12:17 +0000
1963+++ src/platform/symbols.map 2014-09-10 08:00:52 +0000
1964@@ -155,6 +155,7 @@
1965 mir::graphics::InternalSurface::pixel_format*;
1966 mir::graphics::InternalSurface::size*;
1967 mir::graphics::InternalSurface::swap_buffers*;
1968+ mir::graphics::module_for_device*;
1969 mir::graphics::NativePlatform::create_buffer_allocator*;
1970 mir::graphics::NativePlatform::create_internal_client*;
1971 mir::graphics::NativePlatform::fill_buffer_package*;
1972@@ -225,6 +226,7 @@
1973 mir::options::glog_log_dir*;
1974 mir::options::glog_minloglevel*;
1975 mir::options::glog_stderrthreshold*;
1976+ mir::options::platform_graphics_path*;
1977 mir::options::host_socket_opt*;
1978 mir::options::input_report_opt*;
1979 mir::options::legacy_input_report_opt*;
1980@@ -252,6 +254,7 @@
1981 mir::options::scene_report_opt*;
1982 mir::options::server_socket_opt*;
1983 mir::options::session_mediator_report_opt*;
1984+ mir::options::shared_library_prober_report_opt*;
1985 typeinfo?for?mir::AbnormalExit;
1986 typeinfo?for?mir::EmergencyCleanupRegistry;
1987 typeinfo?for?mir::FatalErrorStrategy;
1988
1989=== modified file 'src/server/CMakeLists.txt'
1990--- src/server/CMakeLists.txt 2014-09-09 14:04:48 +0000
1991+++ src/server/CMakeLists.txt 2014-09-10 08:00:52 +0000
1992@@ -5,6 +5,9 @@
1993 ${PROJECT_SOURCE_DIR}/include.private/server
1994 )
1995
1996+add_definitions(-DMIR_SERVER_PLATFORM_PLUGIN_PATH="${MIR_SERVER_PLATFORM_PLUGIN_PATH}")
1997+add_definitions(-DSERVER_PLATFORM_VERSION="${SERVER_PLATFORM_VERSION}")
1998+
1999 add_subdirectory(compositor/)
2000 add_subdirectory(graphics/)
2001 add_subdirectory(input/)
2002@@ -68,8 +71,9 @@
2003 )
2004
2005 target_link_libraries(mirserver LINK_PUBLIC
2006+
2007+ mirclient
2008 mirplatform
2009- mirclient
2010 mircommon
2011 3rd_party
2012 xcursorloader
2013
2014=== modified file 'src/server/graphics/CMakeLists.txt'
2015--- src/server/graphics/CMakeLists.txt 2014-09-08 04:12:17 +0000
2016+++ src/server/graphics/CMakeLists.txt 2014-09-10 08:00:52 +0000
2017@@ -1,4 +1,4 @@
2018-include_directories(${GLESv2_INCLUDE_DIRS})
2019+include_directories(${GLESv2_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR})
2020
2021 add_library(
2022 mirgraphics OBJECT
2023
2024=== modified file 'src/server/graphics/default_configuration.cpp'
2025--- src/server/graphics/default_configuration.cpp 2014-09-08 04:12:17 +0000
2026+++ src/server/graphics/default_configuration.cpp 2014-09-10 08:00:52 +0000
2027@@ -28,10 +28,11 @@
2028 #include "mir/graphics/buffer_initializer.h"
2029 #include "mir/graphics/gl_config.h"
2030 #include "mir/graphics/cursor.h"
2031+#include "src/platform/graphics/platform_probe.h"
2032 #include "program_factory.h"
2033
2034 #include "mir/shared_library.h"
2035-#include "mir/shared_library_loader.h"
2036+#include "mir/shared_library_prober.h"
2037 #include "mir/abnormal_exit.h"
2038 #include "mir/emergency_cleanup.h"
2039
2040@@ -43,6 +44,12 @@
2041
2042 namespace mg = mir::graphics;
2043
2044+namespace
2045+{
2046+// TODO: Temporary, until we actually manage module lifetimes
2047+static std::shared_ptr<mir::SharedLibrary> platform_library;
2048+}
2049+
2050 std::shared_ptr<mg::BufferInitializer>
2051 mir::DefaultServerConfiguration::the_buffer_initializer()
2052 {
2053@@ -71,14 +78,27 @@
2054 if (!the_options()->is_set(options::host_socket_opt))
2055 {
2056 // fallback to standalone if host socket is unset
2057- auto graphics_lib = mir::load_library(the_options()->get<std::string>(options::platform_graphics_lib));
2058- auto create_platform = graphics_lib->load_function<mg::CreatePlatform>("create_platform");
2059+ if (the_options()->is_set(options::platform_graphics_lib))
2060+ {
2061+ platform_library = std::make_shared<mir::SharedLibrary>(the_options()->get<std::string>(options::platform_graphics_lib));
2062+ }
2063+ else
2064+ {
2065+ auto platforms = mir::libraries_for_path(the_options()->get<std::string>(options::platform_graphics_path), *the_shared_library_prober_report());
2066+ if (platforms.empty())
2067+ {
2068+ throw std::runtime_error("Failed to find any platform plugins in: " MIR_SERVER_PLATFORM_PLUGIN_PATH);
2069+ }
2070+ platform_library = mir::graphics::module_for_device(platforms);
2071+ }
2072+ auto create_platform = platform_library->load_function<mg::CreatePlatform>("create_platform",
2073+ SERVER_PLATFORM_VERSION);
2074 return create_platform(the_options(), the_emergency_cleanup(), the_display_report());
2075 }
2076
2077 return std::make_shared<mir::graphics::nested::NestedPlatform>(
2078 the_host_connection(),
2079- the_input_dispatcher(),
2080+ the_input_dispatcher(),
2081 the_display_report(),
2082 the_graphics_native_platform());
2083 });
2084@@ -89,8 +109,21 @@
2085 return graphics_native_platform(
2086 [this]()
2087 {
2088- auto graphics_lib = mir::load_library(the_options()->get<std::string>(options::platform_graphics_lib));
2089- auto create_native_platform = graphics_lib->load_function<mg::CreateNativePlatform>("create_native_platform");
2090+ if (the_options()->is_set(options::platform_graphics_lib))
2091+ {
2092+ platform_library = std::make_shared<mir::SharedLibrary>(the_options()->get<std::string>(options::platform_graphics_lib));
2093+ }
2094+ else
2095+ {
2096+ auto platforms = mir::libraries_for_path(the_options()->get<std::string>(options::platform_graphics_path), *the_shared_library_prober_report());
2097+ if (platforms.empty())
2098+ {
2099+ throw std::runtime_error("Failed to find any platform plugins in: " MIR_SERVER_PLATFORM_PLUGIN_PATH);
2100+ }
2101+ platform_library = mir::graphics::module_for_device(platforms);
2102+ }
2103+ auto create_native_platform = platform_library->load_function<mg::CreateNativePlatform>("create_native_platform",
2104+ SERVER_PLATFORM_VERSION);
2105
2106 return create_native_platform(the_display_report());
2107 });
2108
2109=== modified file 'src/server/logging/CMakeLists.txt'
2110--- src/server/logging/CMakeLists.txt 2014-09-08 04:12:17 +0000
2111+++ src/server/logging/CMakeLists.txt 2014-09-10 08:00:52 +0000
2112@@ -12,4 +12,3 @@
2113
2114 ${LOGGING_SOURCES}
2115 )
2116-
2117
2118=== modified file 'src/server/report/default_server_configuration.cpp'
2119--- src/server/report/default_server_configuration.cpp 2014-03-06 06:05:17 +0000
2120+++ src/server/report/default_server_configuration.cpp 2014-09-10 08:00:52 +0000
2121@@ -117,3 +117,12 @@
2122 return report_factory(options::scene_report_opt)->create_scene_report();
2123 });
2124 }
2125+
2126+auto mir::DefaultServerConfiguration::the_shared_library_prober_report() -> std::shared_ptr<SharedLibraryProberReport>
2127+{
2128+ return shared_library_prober_report(
2129+ [this]()->std::shared_ptr<SharedLibraryProberReport>
2130+ {
2131+ return report_factory(options::shared_library_prober_report_opt)->create_shared_library_prober_report();
2132+ });
2133+}
2134
2135=== modified file 'src/server/report/logging/CMakeLists.txt'
2136--- src/server/report/logging/CMakeLists.txt 2014-09-08 04:12:17 +0000
2137+++ src/server/report/logging/CMakeLists.txt 2014-09-10 08:00:52 +0000
2138@@ -18,4 +18,3 @@
2139
2140 ${LOGGING_SOURCES}
2141 )
2142-
2143
2144=== modified file 'src/server/report/logging/logging_report_factory.cpp'
2145--- src/server/report/logging/logging_report_factory.cpp 2014-02-11 15:18:07 +0000
2146+++ src/server/report/logging/logging_report_factory.cpp 2014-09-10 08:00:52 +0000
2147@@ -25,6 +25,7 @@
2148 #include "scene_report.h"
2149 #include "session_mediator_report.h"
2150 #include "input_report.h"
2151+#include "mir/logging/shared_library_prober_report.h"
2152
2153 #include "mir/default_server_configuration.h"
2154
2155@@ -72,4 +73,7 @@
2156 return std::make_shared<logging::InputReport>(logger);
2157 }
2158
2159-
2160+std::shared_ptr<mir::SharedLibraryProberReport> mr::LoggingReportFactory::create_shared_library_prober_report()
2161+{
2162+ return std::make_shared<mir::logging::SharedLibraryProberReport>(logger);
2163+}
2164
2165=== modified file 'src/server/report/logging_report_factory.h'
2166--- src/server/report/logging_report_factory.h 2014-02-11 15:18:07 +0000
2167+++ src/server/report/logging_report_factory.h 2014-09-10 08:00:52 +0000
2168@@ -47,6 +47,8 @@
2169 std::shared_ptr<frontend::SessionMediatorReport> create_session_mediator_report() override;
2170 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;
2171 std::shared_ptr<input::InputReport> create_input_report() override;
2172+ std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;
2173+
2174
2175 private:
2176 std::shared_ptr<mir::logging::Logger> const logger;
2177
2178=== modified file 'src/server/report/lttng/CMakeLists.txt'
2179--- src/server/report/lttng/CMakeLists.txt 2014-09-08 04:12:17 +0000
2180+++ src/server/report/lttng/CMakeLists.txt 2014-09-10 08:00:52 +0000
2181@@ -17,6 +17,7 @@
2182 session_mediator_report.cpp
2183 scene_report.cpp
2184 server_tracepoint_provider.cpp
2185+ shared_library_prober_report.cpp
2186 )
2187
2188 add_library(
2189
2190=== modified file 'src/server/report/lttng/lttng_report_factory.cpp'
2191--- src/server/report/lttng/lttng_report_factory.cpp 2014-02-11 15:18:07 +0000
2192+++ src/server/report/lttng/lttng_report_factory.cpp 2014-09-10 08:00:52 +0000
2193@@ -25,6 +25,7 @@
2194 #include "message_processor_report.h"
2195 #include "scene_report.h"
2196 #include "session_mediator_report.h"
2197+#include "shared_library_prober_report.h"
2198
2199 std::shared_ptr<mir::compositor::CompositorReport> mir::report::LttngReportFactory::create_compositor_report()
2200 {
2201@@ -61,4 +62,8 @@
2202 return std::make_shared<lttng::InputReport>();
2203 }
2204
2205+std::shared_ptr<mir::SharedLibraryProberReport> mir::report::LttngReportFactory::create_shared_library_prober_report()
2206+{
2207+ return std::make_shared<lttng::SharedLibraryProberReport>();
2208+}
2209
2210
2211=== added file 'src/server/report/lttng/shared_library_prober_report.cpp'
2212--- src/server/report/lttng/shared_library_prober_report.cpp 1970-01-01 00:00:00 +0000
2213+++ src/server/report/lttng/shared_library_prober_report.cpp 2014-09-10 08:00:52 +0000
2214@@ -0,0 +1,48 @@
2215+/*
2216+ * Copyright © 2014 Canonical Ltd.
2217+ *
2218+ * This program is free software: you can redistribute it and/or modify it
2219+ * under the terms of the GNU General Public License version 3,
2220+ * as published by the Free Software Foundation.
2221+ *
2222+ * This program is distributed in the hope that it will be useful,
2223+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2224+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2225+ * GNU General Public License for more details.
2226+ *
2227+ * You should have received a copy of the GNU General Public License
2228+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2229+ *
2230+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2231+ */
2232+
2233+#include "shared_library_prober_report.h"
2234+#include "mir/report/lttng/mir_tracepoint.h"
2235+
2236+#define TRACEPOINT_DEFINE
2237+#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
2238+#include "shared_library_prober_report_tp.h"
2239+
2240+void mir::report::lttng::SharedLibraryProberReport::probing_path(boost::filesystem::path const& path)
2241+{
2242+ mir_tracepoint(mir_server_shared_library_prober, probing_path,
2243+ path.string().c_str());
2244+}
2245+
2246+void mir::report::lttng::SharedLibraryProberReport::probing_failed(boost::filesystem::path const& path, std::exception const& error)
2247+{
2248+ mir_tracepoint(mir_server_shared_library_prober, probing_failed,
2249+ path.string().c_str(), error.what());
2250+}
2251+
2252+void mir::report::lttng::SharedLibraryProberReport::loading_library(boost::filesystem::path const& filename)
2253+{
2254+ mir_tracepoint(mir_server_shared_library_prober, loading_library,
2255+ filename.string().c_str());
2256+}
2257+
2258+void mir::report::lttng::SharedLibraryProberReport::loading_failed(boost::filesystem::path const& filename, std::exception const& error)
2259+{
2260+ mir_tracepoint(mir_server_shared_library_prober, loading_failed,
2261+ filename.string().c_str(), error.what());
2262+}
2263
2264=== added file 'src/server/report/lttng/shared_library_prober_report.h'
2265--- src/server/report/lttng/shared_library_prober_report.h 1970-01-01 00:00:00 +0000
2266+++ src/server/report/lttng/shared_library_prober_report.h 2014-09-10 08:00:52 +0000
2267@@ -0,0 +1,52 @@
2268+/*
2269+ * Copyright © 2014 Canonical Ltd.
2270+ *
2271+ * This program is free software: you can redistribute it and/or modify it
2272+ * under the terms of the GNU General Public License version 3,
2273+ * as published by the Free Software Foundation.
2274+ *
2275+ * This program is distributed in the hope that it will be useful,
2276+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2277+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2278+ * GNU General Public License for more details.
2279+ *
2280+ * You should have received a copy of the GNU General Public License
2281+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2282+ *
2283+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2284+ */
2285+
2286+#ifndef MIR_REPORT_LTTNG_SHARED_LIBRARY_PROBER_REPORT_H_
2287+#define MIR_REPORT_LTTNG_SHARED_LIBRARY_PROBER_REPORT_H_
2288+
2289+#include "server_tracepoint_provider.h"
2290+
2291+#include "mir/shared_library_prober_report.h"
2292+
2293+#include <stdexcept>
2294+#include <string>
2295+
2296+namespace mir
2297+{
2298+namespace report
2299+{
2300+namespace lttng
2301+{
2302+
2303+class SharedLibraryProberReport : public mir::SharedLibraryProberReport
2304+{
2305+public:
2306+ void probing_path(boost::filesystem::path const& path) override;
2307+ void probing_failed(boost::filesystem::path const& path, std::exception const& error) override;
2308+ void loading_library(boost::filesystem::path const& filename) override;
2309+ void loading_failed(boost::filesystem::path const& filename, std::exception const& error) override;
2310+
2311+private:
2312+ ServerTracepointProvider tp_provider;
2313+};
2314+
2315+}
2316+}
2317+}
2318+
2319+#endif // MIR_REPORT_LTTNG_SHARED_LIBRARY_PROBER_REPORT_H_
2320
2321=== added file 'src/server/report/lttng/shared_library_prober_report_tp.h'
2322--- src/server/report/lttng/shared_library_prober_report_tp.h 1970-01-01 00:00:00 +0000
2323+++ src/server/report/lttng/shared_library_prober_report_tp.h 2014-09-10 08:00:52 +0000
2324@@ -0,0 +1,71 @@
2325+/*
2326+ * Copyright © 2014 Canonical Ltd.
2327+ *
2328+ * This program is free software: you can redistribute it and/or modify it
2329+ * under the terms of the GNU General Public License version 3,
2330+ * as published by the Free Software Foundation.
2331+ *
2332+ * This program is distributed in the hope that it will be useful,
2333+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2334+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2335+ * GNU General Public License for more details.
2336+ *
2337+ * You should have received a copy of the GNU General Public License
2338+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2339+ *
2340+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2341+ */
2342+
2343+#undef TRACEPOINT_PROVIDER
2344+#define TRACEPOINT_PROVIDER mir_server_shared_library_prober
2345+
2346+#undef TRACEPOINT_INCLUDE
2347+#define TRACEPOINT_INCLUDE "./shared_library_prober_report_tp.h"
2348+
2349+#if !defined(MIR_REPORT_LTTNG_SHARED_LIBRARY_PROBER_REPORT_TP_H_) || defined(TRACEPOINT_HEADER_MULTI_READ)
2350+#define MIR_REPORT_LTTNG_SHARED_LIBRARY_PROBER_REPORT_TP_H_
2351+
2352+#include <lttng/tracepoint.h>
2353+#include <stdint.h>
2354+
2355+TRACEPOINT_EVENT(
2356+ mir_server_shared_library_prober,
2357+ probing_path,
2358+ TP_ARGS(const char*, path),
2359+ TP_FIELDS(
2360+ ctf_string(path, path)
2361+ )
2362+)
2363+
2364+TRACEPOINT_EVENT(
2365+ mir_server_shared_library_prober,
2366+ probing_failed,
2367+ TP_ARGS(const char*, path, const char*, message),
2368+ TP_FIELDS(
2369+ ctf_string(path, path)
2370+ ctf_string(message, message)
2371+ )
2372+)
2373+
2374+TRACEPOINT_EVENT(
2375+ mir_server_shared_library_prober,
2376+ loading_library,
2377+ TP_ARGS(const char*, path),
2378+ TP_FIELDS(
2379+ ctf_string(path, path)
2380+ )
2381+)
2382+
2383+TRACEPOINT_EVENT(
2384+ mir_server_shared_library_prober,
2385+ loading_failed,
2386+ TP_ARGS(const char*, path, const char*, message),
2387+ TP_FIELDS(
2388+ ctf_string(path, path)
2389+ ctf_string(message, message)
2390+ )
2391+)
2392+
2393+#endif /* MIR_REPORT_LTTNG_SHARED_LIBRARY_PROBER_REPORT_TP_H_ */
2394+
2395+#include <lttng/tracepoint-event.h>
2396
2397=== modified file 'src/server/report/lttng_report_factory.h'
2398--- src/server/report/lttng_report_factory.h 2014-02-11 15:18:07 +0000
2399+++ src/server/report/lttng_report_factory.h 2014-09-10 08:00:52 +0000
2400@@ -35,6 +35,7 @@
2401 std::shared_ptr<frontend::SessionMediatorReport> create_session_mediator_report() override;
2402 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;
2403 std::shared_ptr<input::InputReport> create_input_report() override;
2404+ std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;
2405 };
2406 }
2407 }
2408
2409=== modified file 'src/server/report/null/CMakeLists.txt'
2410--- src/server/report/null/CMakeLists.txt 2014-09-08 04:12:17 +0000
2411+++ src/server/report/null/CMakeLists.txt 2014-09-10 08:00:52 +0000
2412@@ -9,4 +9,5 @@
2413 null_report_factory.cpp
2414 scene_report.cpp
2415 session_mediator_report.cpp
2416+ shared_library_prober_report.cpp
2417 )
2418
2419=== modified file 'src/server/report/null/null_report_factory.cpp'
2420--- src/server/report/null/null_report_factory.cpp 2014-02-17 22:35:23 +0000
2421+++ src/server/report/null/null_report_factory.cpp 2014-09-10 08:00:52 +0000
2422@@ -25,6 +25,7 @@
2423 #include "display_report.h"
2424 #include "input_report.h"
2425 #include "scene_report.h"
2426+#include "shared_library_prober_report.h"
2427
2428 std::shared_ptr<mir::compositor::CompositorReport> mir::report::NullReportFactory::create_compositor_report()
2429 {
2430@@ -61,6 +62,11 @@
2431 return std::make_shared<null::InputReport>();
2432 }
2433
2434+std::shared_ptr<mir::SharedLibraryProberReport> mir::report::NullReportFactory::create_shared_library_prober_report()
2435+{
2436+ return std::make_shared<null::SharedLibraryProberReport>();
2437+}
2438+
2439 std::shared_ptr<mir::compositor::CompositorReport> mir::report::null_compositor_report()
2440 {
2441 return NullReportFactory{}.create_compositor_report();
2442@@ -90,3 +96,8 @@
2443 {
2444 return NullReportFactory{}.create_input_report();
2445 }
2446+
2447+std::shared_ptr<mir::SharedLibraryProberReport> mir::report::null_shared_library_prober_report()
2448+{
2449+ return NullReportFactory{}.create_shared_library_prober_report();
2450+}
2451
2452=== added file 'src/server/report/null/shared_library_prober_report.cpp'
2453--- src/server/report/null/shared_library_prober_report.cpp 1970-01-01 00:00:00 +0000
2454+++ src/server/report/null/shared_library_prober_report.cpp 2014-09-10 08:00:52 +0000
2455@@ -0,0 +1,35 @@
2456+/*
2457+ * Copyright © 2014 Canonical Ltd.
2458+ *
2459+ * This program is free software: you can redistribute it and/or modify it
2460+ * under the terms of the GNU General Public License version 3,
2461+ * as published by the Free Software Foundation.
2462+ *
2463+ * This program is distributed in the hope that it will be useful,
2464+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2465+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2466+ * GNU General Public License for more details.
2467+ *
2468+ * You should have received a copy of the GNU General Public License
2469+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2470+ *
2471+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2472+ */
2473+
2474+#include "shared_library_prober_report.h"
2475+
2476+void mir::report::null::SharedLibraryProberReport::probing_path(boost::filesystem::path const& /*path*/)
2477+{
2478+}
2479+
2480+void mir::report::null::SharedLibraryProberReport::probing_failed(boost::filesystem::path const& /*path*/, std::exception const& /*error*/)
2481+{
2482+}
2483+
2484+void mir::report::null::SharedLibraryProberReport::loading_library(boost::filesystem::path const& /*filename*/)
2485+{
2486+}
2487+
2488+void mir::report::null::SharedLibraryProberReport::loading_failed(boost::filesystem::path const& /*filename*/, std::exception const& /*error*/)
2489+{
2490+}
2491
2492=== added file 'src/server/report/null/shared_library_prober_report.h'
2493--- src/server/report/null/shared_library_prober_report.h 1970-01-01 00:00:00 +0000
2494+++ src/server/report/null/shared_library_prober_report.h 2014-09-10 08:00:52 +0000
2495@@ -0,0 +1,43 @@
2496+/*
2497+ * Copyright © 2014 Canonical Ltd.
2498+ *
2499+ * This program is free software: you can redistribute it and/or modify it
2500+ * under the terms of the GNU General Public License version 3,
2501+ * as published by the Free Software Foundation.
2502+ *
2503+ * This program is distributed in the hope that it will be useful,
2504+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2505+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2506+ * GNU General Public License for more details.
2507+ *
2508+ * You should have received a copy of the GNU General Public License
2509+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2510+ *
2511+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2512+ */
2513+
2514+#ifndef MIR_REPORT_NULL_SHARED_LIBRARY_PROBER_REPORT_H_
2515+#define MIR_REPORT_NULL_SHARED_LIBRARY_PROBER_REPORT_H_
2516+
2517+#include "mir/shared_library_prober_report.h"
2518+
2519+namespace mir
2520+{
2521+namespace report
2522+{
2523+namespace null
2524+{
2525+class SharedLibraryProberReport : public mir::SharedLibraryProberReport
2526+{
2527+public:
2528+ void probing_path(boost::filesystem::path const& path);
2529+ void probing_failed(boost::filesystem::path const& path, std::exception const& error);
2530+ void loading_library(boost::filesystem::path const& filename);
2531+ void loading_failed(boost::filesystem::path const& filename, std::exception const& error);
2532+};
2533+
2534+}
2535+}
2536+}
2537+
2538+#endif // MIR_REPORT_NULL_SHARED_LIBRARY_PROBER_REPORT_H_
2539
2540=== modified file 'src/server/report/null_report_factory.h'
2541--- src/server/report/null_report_factory.h 2014-02-17 22:35:23 +0000
2542+++ src/server/report/null_report_factory.h 2014-09-10 08:00:52 +0000
2543@@ -35,6 +35,7 @@
2544 std::shared_ptr<frontend::SessionMediatorReport> create_session_mediator_report() override;
2545 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;
2546 std::shared_ptr<input::InputReport> create_input_report() override;
2547+ std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;
2548 };
2549
2550 std::shared_ptr<compositor::CompositorReport> null_compositor_report();
2551@@ -44,7 +45,7 @@
2552 std::shared_ptr<frontend::SessionMediatorReport> null_session_mediator_report();
2553 std::shared_ptr<frontend::MessageProcessorReport> null_message_processor_report();
2554 std::shared_ptr<input::InputReport> null_input_report();
2555-
2556+std::shared_ptr<SharedLibraryProberReport> null_shared_library_prober_report();
2557 }
2558 }
2559
2560
2561=== modified file 'src/server/report/report_factory.h'
2562--- src/server/report/report_factory.h 2014-02-11 15:18:07 +0000
2563+++ src/server/report/report_factory.h 2014-09-10 08:00:52 +0000
2564@@ -23,6 +23,8 @@
2565
2566 namespace mir
2567 {
2568+
2569+class SharedLibraryProberReport;
2570 namespace compositor
2571 {
2572 class CompositorReport;
2573@@ -59,6 +61,7 @@
2574 virtual std::shared_ptr<frontend::SessionMediatorReport> create_session_mediator_report() = 0;
2575 virtual std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() = 0;
2576 virtual std::shared_ptr<input::InputReport> create_input_report() = 0;
2577+ virtual std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() = 0;
2578
2579 protected:
2580 ReportFactory() = default;
2581
2582=== modified file 'src/server/symbols.map'
2583--- src/server/symbols.map 2014-09-09 14:04:48 +0000
2584+++ src/server/symbols.map 2014-09-10 08:00:52 +0000
2585@@ -174,6 +174,7 @@
2586 mir::DefaultServerConfiguration::the_session_event_sink*;
2587 mir::DefaultServerConfiguration::the_session_listener*;
2588 mir::DefaultServerConfiguration::the_session_mediator_report*;
2589+ mir::DefaultServerConfiguration::the_shared_library_prober_report*;
2590 mir::DefaultServerConfiguration::the_shell_display_layout*;
2591 mir::DefaultServerConfiguration::the_shell_focus_setter*;
2592 mir::DefaultServerConfiguration::the_snapshot_strategy*;
2593@@ -754,6 +755,7 @@
2594 non-virtual?thunk?to?mir::DefaultServerConfiguration::the_session_event_sink*;
2595 non-virtual?thunk?to?mir::DefaultServerConfiguration::the_session_listener*;
2596 non-virtual?thunk?to?mir::DefaultServerConfiguration::the_session_mediator_report*;
2597+ non-virtual?thunk?to?mir::DefaultServerConfiguration::the_shared_library_prober_report*;
2598 non-virtual?thunk?to?mir::DefaultServerConfiguration::the_shell_display_layout*;
2599 non-virtual?thunk?to?mir::DefaultServerConfiguration::the_shell_focus_setter*;
2600 non-virtual?thunk?to?mir::DefaultServerConfiguration::the_snapshot_strategy*;
2601
2602=== modified file 'tests/acceptance-tests/CMakeLists.txt'
2603--- tests/acceptance-tests/CMakeLists.txt 2014-09-08 04:12:17 +0000
2604+++ tests/acceptance-tests/CMakeLists.txt 2014-09-10 08:00:52 +0000
2605@@ -93,8 +93,10 @@
2606 "MIR_BUILD_ACCEPTANCE_TESTS"
2607 OFF)
2608
2609+set (MIR_CLIENT_PLATFORM client-platform-dummy.so)
2610+
2611 if (MIR_RUN_ACCEPTANCE_TESTS)
2612- mir_discover_tests(mir_acceptance_tests)
2613+ mir_discover_tests(mir_acceptance_tests MIR_CLIENT_PLATFORM_LIB=${LIBRARY_OUTPUT_PATH}/${MIR_CLIENT_PLATFORM})
2614 endif (MIR_RUN_ACCEPTANCE_TESTS)
2615
2616 install(
2617
2618=== modified file 'tests/acceptance-tests/test_symbols_required_by_mesa.cpp'
2619--- tests/acceptance-tests/test_symbols_required_by_mesa.cpp 2014-07-30 13:19:36 +0000
2620+++ tests/acceptance-tests/test_symbols_required_by_mesa.cpp 2014-09-10 08:00:52 +0000
2621@@ -23,9 +23,9 @@
2622
2623 using namespace testing;
2624
2625-TEST(SymbolsRequiredByMesa, are_exported_by_libmirclientplatform)
2626+TEST(SymbolsRequiredByMesa, are_exported_by_client_platform_mesa)
2627 {
2628- auto const handle = dlopen("libmirclientplatform.so", RTLD_LAZY);
2629+ auto const handle = dlopen("client-platform-mesa.so", RTLD_LAZY);
2630 ASSERT_THAT(handle, NotNull());
2631
2632 auto const sym = dlsym(handle, "mir_client_mesa_egl_native_display_is_valid");
2633@@ -36,7 +36,7 @@
2634
2635 TEST(SymbolsRequiredByMesa, are_exported_by_libmirplatformgraphics)
2636 {
2637- auto const handle = dlopen("libmirplatformgraphics.so", RTLD_LAZY);
2638+ auto const handle = dlopen("platform-graphics-mesa.so", RTLD_LAZY);
2639 ASSERT_THAT(handle, NotNull());
2640
2641 auto const sym = dlsym(handle, "mir_server_mesa_egl_native_display_is_valid");
2642
2643=== modified file 'tests/include/mir_test_doubles/mock_android_alloc_device.h'
2644--- tests/include/mir_test_doubles/mock_android_alloc_device.h 2013-06-18 08:00:49 +0000
2645+++ tests/include/mir_test_doubles/mock_android_alloc_device.h 2014-09-10 08:00:52 +0000
2646@@ -19,7 +19,12 @@
2647 #define MIR_TEST_DOUBLES_MOCK_ANDROID_ALLOC_DEVICE_H_
2648
2649 #include <gmock/gmock.h>
2650+
2651+#pragma GCC diagnostic push
2652+#pragma GCC diagnostic ignored "-Wpedantic"
2653+#pragma GCC diagnostic ignored "-Wunused-parameter"
2654 #include <hardware/gralloc.h>
2655+#pragma GCC diagnostic pop
2656
2657 namespace mir
2658 {
2659
2660=== modified file 'tests/include/mir_test_doubles/mock_android_hw.h'
2661--- tests/include/mir_test_doubles/mock_android_hw.h 2013-05-20 15:55:48 +0000
2662+++ tests/include/mir_test_doubles/mock_android_hw.h 2014-09-10 08:00:52 +0000
2663@@ -21,7 +21,12 @@
2664 #include "mir_test_doubles/mock_android_alloc_device.h"
2665 #include "mir_test_doubles/mock_hwc_composer_device_1.h"
2666
2667+#pragma GCC diagnostic push
2668+#pragma GCC diagnostic ignored "-Wpedantic"
2669+#pragma GCC diagnostic ignored "-Wunused-parameter"
2670 #include <hardware/hardware.h>
2671+#pragma GCC diagnostic pop
2672+
2673 #include <gmock/gmock.h>
2674 #include <memory>
2675
2676
2677=== modified file 'tests/include/mir_test_doubles/mock_hwc_composer_device_1.h'
2678--- tests/include/mir_test_doubles/mock_hwc_composer_device_1.h 2014-03-26 05:48:59 +0000
2679+++ tests/include/mir_test_doubles/mock_hwc_composer_device_1.h 2014-09-10 08:00:52 +0000
2680@@ -19,7 +19,12 @@
2681 #ifndef MIR_TEST_DOUBLES_MOCK_HWC_COMPOSER_DEVICE_1_H_
2682 #define MIR_TEST_DOUBLES_MOCK_HWC_COMPOSER_DEVICE_1_H_
2683
2684+#pragma GCC diagnostic push
2685+#pragma GCC diagnostic ignored "-Wpedantic"
2686+#pragma GCC diagnostic ignored "-Wunused-parameter"
2687 #include <hardware/hwcomposer.h>
2688+#pragma GCC diagnostic pop
2689+
2690 #include <gmock/gmock.h>
2691
2692 namespace mir
2693
2694=== added file 'tests/include/mir_test_framework/client_platform_factory.h'
2695--- tests/include/mir_test_framework/client_platform_factory.h 1970-01-01 00:00:00 +0000
2696+++ tests/include/mir_test_framework/client_platform_factory.h 2014-09-10 08:00:52 +0000
2697@@ -0,0 +1,72 @@
2698+/*
2699+ * Copyright © 2014 Canonical Ltd.
2700+ *
2701+ * This program is free software: you can redistribute it and/or modify
2702+ * it under the terms of the GNU General Public License version 3 as
2703+ * published by the Free Software Foundation.
2704+ *
2705+ * This program is distributed in the hope that it will be useful,
2706+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2707+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2708+ * GNU General Public License for more details.
2709+ *
2710+ * You should have received a copy of the GNU General Public License
2711+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2712+ *
2713+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2714+ */
2715+
2716+#ifndef MIR_TEST_FRAMEWORK_CLIENT_PLATFORM_FACTORY_H_
2717+#define MIR_TEST_FRAMEWORK_CLIENT_PLATFORM_FACTORY_H_
2718+
2719+
2720+#include "mir/shared_library.h"
2721+#include "src/client/client_platform_factory.h"
2722+#include "executable_path.h"
2723+#include "mir_test_doubles/mock_client_context.h"
2724+
2725+namespace mtd = mir::test::doubles;
2726+
2727+namespace mir_test_framework
2728+{
2729+std::shared_ptr<mir::SharedLibrary> platform_library;
2730+
2731+std::shared_ptr<mir::client::ClientPlatform> create_android_client_platform()
2732+{
2733+ using namespace testing;
2734+ mtd::MockClientContext ctx;
2735+ ON_CALL(ctx, populate(_))
2736+ .WillByDefault(Invoke([](MirPlatformPackage& package) { ::memset(&package, 0, sizeof(package)); }));
2737+ platform_library = std::make_shared<mir::SharedLibrary>(library_path() + "/client-platform-android.so");
2738+ auto platform_factory = platform_library->load_function<mir::client::CreateClientPlatform>("create_client_platform");
2739+ return platform_factory(&ctx);
2740+}
2741+
2742+std::shared_ptr<mir::client::ClientPlatform> create_mesa_client_platform()
2743+{
2744+ using namespace testing;
2745+ mtd::MockClientContext ctx;
2746+ ON_CALL(ctx, populate(_))
2747+ .WillByDefault(Invoke([](MirPlatformPackage& package)
2748+ {
2749+ ::memset(&package, 0, sizeof(package));
2750+ package.fd_items = 1;
2751+ }));
2752+ platform_library = std::make_shared<mir::SharedLibrary>(library_path() + "/client-platform-mesa.so");
2753+ auto platform_factory = platform_library->load_function<mir::client::CreateClientPlatform>("create_client_platform");
2754+ return platform_factory(&ctx);
2755+}
2756+
2757+std::shared_ptr<mir::SharedLibrary>
2758+get_platform_library()
2759+{
2760+ if (!platform_library)
2761+ {
2762+ throw std::logic_error{"Must call one of create_*_client_platform() before calling get_platform_library()"};
2763+ }
2764+ return platform_library;
2765+}
2766+
2767+}
2768+
2769+#endif // MIR_TEST_FRAMEWORK_CLIENT_PLATFORM_FACTORY_H_
2770
2771=== modified file 'tests/include/mir_test_framework/executable_path.h'
2772--- tests/include/mir_test_framework/executable_path.h 2014-07-29 12:28:04 +0000
2773+++ tests/include/mir_test_framework/executable_path.h 2014-09-10 08:00:52 +0000
2774@@ -24,5 +24,7 @@
2775 namespace mir_test_framework
2776 {
2777 std::string executable_path();
2778+
2779+std::string library_path();
2780 }
2781 #endif /* MIR_TEST_FRAMEWORK_EXECUTABLE_PATH_H_ */
2782
2783=== added file 'tests/include/mir_test_framework/stub_client_platform_factory.h'
2784--- tests/include/mir_test_framework/stub_client_platform_factory.h 1970-01-01 00:00:00 +0000
2785+++ tests/include/mir_test_framework/stub_client_platform_factory.h 2014-09-10 08:00:52 +0000
2786@@ -0,0 +1,33 @@
2787+/*
2788+ * Copyright © 2014 Canonical Ltd.
2789+ *
2790+ * This program is free software: you can redistribute it and/or modify it
2791+ * under the terms of the GNU General Public License version 3,
2792+ * as published by the Free Software Foundation.
2793+ *
2794+ * This program is distributed in the hope that it will be useful,
2795+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2796+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2797+ * GNU General Public License for more details.
2798+ *
2799+ * You should have received a copy of the GNU General Public License
2800+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2801+ *
2802+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2803+ */
2804+
2805+#ifndef MIR_TEST_FRAMEWORK_STUB_CLIENT_PLATFORM_FACTORY_
2806+#define MIR_TEST_FRAMEWORK_STUB_CLIENT_PLATFORM_FACTORY_
2807+
2808+#include "src/client/client_platform_factory.h"
2809+
2810+namespace mir_test_framework
2811+{
2812+
2813+struct StubClientPlatformFactory : public mir::client::ClientPlatformFactory
2814+{
2815+ std::shared_ptr<mir::client::ClientPlatform> create_client_platform(mir::client::ClientContext* context) override;
2816+};
2817+
2818+}
2819+#endif /* MIR_TEST_FRAMEWORK_STUB_CLIENT_PLATFORM_ */
2820
2821=== modified file 'tests/integration-tests/CMakeLists.txt'
2822--- tests/integration-tests/CMakeLists.txt 2014-09-08 04:12:17 +0000
2823+++ tests/integration-tests/CMakeLists.txt 2014-09-10 08:00:52 +0000
2824@@ -73,6 +73,15 @@
2825 ${GTEST_BOTH_LIBRARIES}
2826 ${GMOCK_LIBRARY}
2827 ${GMOCK_MAIN_LIBRARY}
2828+ # Mesa platform dependencies
2829+ ${DRM_LDFLAGS} ${DRM_LIBRARIES}
2830+ ${GBM_LDFLAGS} ${GBM_LIBRARIES}
2831+ # Android platform dependencies
2832+ ${LIBHARDWARE_LIBRARIES}
2833+ ${ANDROID_PROPERTIES_LIBRARIES}
2834+ # Shared platform dependencies
2835+ ${EGL_LDFLAGS} ${EGL_LIBRARIES}
2836+ ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}
2837 ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
2838 ${DRM_LDFLAGS} ${DRM_LIBRARIES}
2839 ${GBM_LDFLAGS} ${GBM_LIBRARIES}
2840@@ -81,7 +90,7 @@
2841 ${MIR_SERVER_REFERENCES}
2842 )
2843
2844-if (MIR_TEST_PLATFORM STREQUAL "android")
2845+if (MIR_BUILD_PLATFORM_ANDROID)
2846 target_link_libraries(mir_integration_tests
2847 mirsharedandroid
2848 ${ANDROID_PROPERTIES_LDFLAGS}
2849@@ -95,8 +104,18 @@
2850 "MIR_BUILD_INTEGRATION_TESTS"
2851 OFF)
2852
2853+set (MIR_CLIENT_MODULE "client-platform-dummy.so")
2854+
2855+if (MIR_TEST_PLATFORM STREQUAL "android")
2856+ # Android platform integration tests have Android-specific tests
2857+ # requiring a real platform
2858+ set (MIR_CLIENT_MODULE "client-platform-android.so")
2859+endif()
2860+
2861 if (MIR_RUN_INTEGRATION_TESTS)
2862- mir_discover_tests(mir_integration_tests)
2863+ mir_discover_tests(mir_integration_tests
2864+ MIR_CLIENT_PLATFORM_LIB=${LIBRARY_OUTPUT_PATH}/${MIR_CLIENT_MODULE}
2865+ )
2866 endif (MIR_RUN_INTEGRATION_TESTS)
2867
2868 install(
2869
2870=== modified file 'tests/mir_test_doubles/CMakeLists.txt'
2871--- tests/mir_test_doubles/CMakeLists.txt 2014-09-08 04:12:17 +0000
2872+++ tests/mir_test_doubles/CMakeLists.txt 2014-09-10 08:00:52 +0000
2873@@ -23,16 +23,19 @@
2874 ${CMAKE_CURRENT_SOURCE_DIR}/mock_gl.cpp
2875 )
2876
2877-if (MIR_TEST_PLATFORM STREQUAL "mesa")
2878-include_directories(${DRM_INCLUDE_DIRS} ${GBM_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR})
2879-list(APPEND MIR_TEST_DOUBLES_PLATFORM_SRCS
2880- ${CMAKE_CURRENT_SOURCE_DIR}/mock_drm.cpp
2881- ${CMAKE_CURRENT_SOURCE_DIR}/mock_gbm.cpp
2882-)
2883-elseif (MIR_TEST_PLATFORM STREQUAL "android")
2884-list(APPEND MIR_TEST_DOUBLES_PLATFORM_SRCS
2885- ${CMAKE_CURRENT_SOURCE_DIR}/mock_android_hw.cpp
2886-)
2887+if (MIR_BUILD_PLATFORM_MESA)
2888+ include_directories(${DRM_INCLUDE_DIRS} ${GBM_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR})
2889+ list(APPEND MIR_TEST_DOUBLES_PLATFORM_SRCS
2890+ ${CMAKE_CURRENT_SOURCE_DIR}/mock_drm.cpp
2891+ ${CMAKE_CURRENT_SOURCE_DIR}/mock_gbm.cpp
2892+ )
2893+endif()
2894+
2895+if (MIR_BUILD_PLATFORM_ANDROID)
2896+ include_directories(${ANDROID_HEADERS_INCLUDE_DIRS})
2897+ list(APPEND MIR_TEST_DOUBLES_PLATFORM_SRCS
2898+ ${CMAKE_CURRENT_SOURCE_DIR}/mock_android_hw.cpp
2899+ )
2900 endif()
2901
2902 add_library(
2903
2904=== modified file 'tests/mir_test_framework/CMakeLists.txt'
2905--- tests/mir_test_framework/CMakeLists.txt 2014-09-08 04:12:17 +0000
2906+++ tests/mir_test_framework/CMakeLists.txt 2014-09-10 08:00:52 +0000
2907@@ -3,6 +3,7 @@
2908 ${GLESv2_INCLUDE_DIRS}
2909 ${CMAKE_SOURCE_DIR}
2910 ${UMOCKDEV_INCLUDE_DIRS}
2911+ ${ANDROID_HEADERS_INCLUDE_DIRS}
2912 )
2913
2914 set(
2915@@ -20,6 +21,7 @@
2916 display_server_test_fixture.cpp
2917 process.cpp
2918 using_stub_client_platform.cpp
2919+ stub_client_platform_factory.cpp
2920 udev_environment.cpp
2921 declarative_placement_strategy.cpp
2922 fake_event_hub_server_configuration.cpp
2923@@ -55,6 +57,43 @@
2924 ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
2925 )
2926
2927+set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols-client.map)
2928+
2929+add_library(
2930+ mirclientplatformstub MODULE
2931+
2932+ stub_client_platform_module.cpp
2933+)
2934+
2935+target_link_libraries(
2936+ mirclientplatformstub
2937+
2938+ mir-test-framework
2939+ ${UMOCKDEV_LIBRARIES}
2940+)
2941+
2942+set_target_properties(
2943+ mirclientplatformstub PROPERTIES;
2944+ OUTPUT_NAME client-platform-dummy
2945+ PREFIX ""
2946+ LINK_FLAGS "-Wl,--version-script,${symbol_map}"
2947+)
2948+
2949+set(server_symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols-server.map)
2950+add_library(
2951+ mirplatformgraphicsstub MODULE
2952+
2953+ platform_graphics_dummy.cpp
2954+)
2955+
2956+set_target_properties(
2957+ mirplatformgraphicsstub PROPERTIES;
2958+ OUTPUT_NAME platform-graphics-dummy
2959+ PREFIX ""
2960+ LINK_FLAGS "-Wl,--version-script,${server_symbol_map}"
2961+)
2962+
2963+
2964 add_custom_command(TARGET mir-test-framework POST_BUILD
2965 COMMAND ${CMAKE_COMMAND} -E copy_directory
2966 ${CMAKE_CURRENT_SOURCE_DIR}/udev_recordings ${CMAKE_BINARY_DIR}/bin/udev_recordings
2967
2968=== modified file 'tests/mir_test_framework/executable_path.cpp'
2969--- tests/mir_test_framework/executable_path.cpp 2014-07-29 12:28:04 +0000
2970+++ tests/mir_test_framework/executable_path.cpp 2014-09-10 08:00:52 +0000
2971@@ -38,3 +38,8 @@
2972 buf[tmp] = '\0';
2973 return dirname(buf);
2974 }
2975+
2976+std::string mir_test_framework::library_path()
2977+{
2978+ return executable_path() + "/../lib";
2979+}
2980
2981=== added file 'tests/mir_test_framework/platform_graphics_dummy.cpp'
2982--- tests/mir_test_framework/platform_graphics_dummy.cpp 1970-01-01 00:00:00 +0000
2983+++ tests/mir_test_framework/platform_graphics_dummy.cpp 2014-09-10 08:00:52 +0000
2984@@ -0,0 +1,33 @@
2985+/*
2986+ * Copyright © 2014 Canonical Ltd.
2987+ *
2988+ * This program is free software: you can redistribute it and/or modify it
2989+ * under the terms of the GNU General Public License version 3,
2990+ * as published by the Free Software Foundation.
2991+ *
2992+ * This program is distributed in the hope that it will be useful,
2993+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2994+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2995+ * GNU General Public License for more details.
2996+ *
2997+ * You should have received a copy of the GNU General Public License
2998+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2999+ *
3000+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>>
3001+ */
3002+
3003+#include "mir/graphics/platform.h"
3004+
3005+extern "C" mir::graphics::PlatformPriority probe_platform()
3006+{
3007+ return mir::graphics::supported;
3008+}
3009+
3010+mir::graphics::ModuleProperties const description {
3011+ "dummy"
3012+};
3013+
3014+extern "C" mir::graphics::ModuleProperties const* describe_module()
3015+{
3016+ return &description;
3017+}
3018
3019=== added file 'tests/mir_test_framework/stub_client_platform_factory.cpp'
3020--- tests/mir_test_framework/stub_client_platform_factory.cpp 1970-01-01 00:00:00 +0000
3021+++ tests/mir_test_framework/stub_client_platform_factory.cpp 2014-09-10 08:00:52 +0000
3022@@ -0,0 +1,143 @@
3023+/*
3024+ * Copyright © 2014 Canonical Ltd.
3025+ *
3026+ * This program is free software: you can redistribute it and/or modify it
3027+ * under the terms of the GNU General Public License version 3,
3028+ * as published by the Free Software Foundation.
3029+ *
3030+ * This program is distributed in the hope that it will be useful,
3031+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3032+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3033+ * GNU General Public License for more details.
3034+ *
3035+ * You should have received a copy of the GNU General Public License
3036+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3037+ *
3038+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
3039+ */
3040+
3041+#include "mir_test_framework/stub_client_platform_factory.h"
3042+#include "src/client/client_buffer_factory.h"
3043+#include "src/client/client_buffer.h"
3044+#include "src/client/client_platform.h"
3045+
3046+#include <string.h>
3047+
3048+namespace mcl = mir::client;
3049+namespace geom = mir::geometry;
3050+namespace mtf = mir_test_framework;
3051+
3052+namespace
3053+{
3054+class StubClientBuffer : public mcl::ClientBuffer
3055+{
3056+public:
3057+ StubClientBuffer(std::shared_ptr<MirBufferPackage> const& package)
3058+ {
3059+ static_cast<void>(package);
3060+#ifndef ANDROID
3061+ native = package;
3062+#endif
3063+ }
3064+
3065+ std::shared_ptr<mcl::MemoryRegion> secure_for_cpu_write()
3066+ {
3067+ return nullptr;
3068+ }
3069+
3070+ geom::Size size() const
3071+ {
3072+ return geom::Size{};
3073+ }
3074+
3075+ geom::Stride stride() const
3076+ {
3077+ return geom::Stride{};
3078+ }
3079+
3080+ MirPixelFormat pixel_format() const
3081+ {
3082+ return mir_pixel_format_abgr_8888;
3083+ }
3084+
3085+ uint32_t age() const
3086+ {
3087+ return 0;
3088+ }
3089+ void increment_age()
3090+ {
3091+ }
3092+ void mark_as_submitted()
3093+ {
3094+ }
3095+ std::shared_ptr<mir::graphics::NativeBuffer> native_buffer_handle() const
3096+ {
3097+#ifdef ANDROID
3098+ return nullptr;
3099+#else
3100+ return native;
3101+#endif
3102+ }
3103+ void update_from(MirBufferPackage const& package) override
3104+ {
3105+ static_cast<void>(package);
3106+#ifndef ANDROID
3107+ ::memcpy(native.get(), &package, sizeof(package));
3108+#endif
3109+ }
3110+private:
3111+#ifndef ANDROID
3112+ std::shared_ptr<mir::graphics::NativeBuffer> native;
3113+#endif
3114+};
3115+
3116+struct StubClientBufferFactory : public mcl::ClientBufferFactory
3117+{
3118+ std::shared_ptr<mcl::ClientBuffer> create_buffer(std::shared_ptr<MirBufferPackage> const& package,
3119+ geom::Size, MirPixelFormat)
3120+ {
3121+ return std::make_shared<StubClientBuffer>(package);
3122+ }
3123+};
3124+
3125+struct StubClientPlatform : public mcl::ClientPlatform
3126+{
3127+ MirPlatformType platform_type() const
3128+ {
3129+ return mir_platform_type_gbm;
3130+ }
3131+
3132+ std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory()
3133+ {
3134+ return std::make_shared<StubClientBufferFactory>();
3135+ }
3136+
3137+ std::shared_ptr<EGLNativeWindowType> create_egl_native_window(mcl::ClientSurface*)
3138+ {
3139+ auto fake_window = reinterpret_cast<EGLNativeWindowType>(0x12345678lu);
3140+ return std::make_shared<EGLNativeWindowType>(fake_window);
3141+ }
3142+
3143+ std::shared_ptr<EGLNativeDisplayType> create_egl_native_display()
3144+ {
3145+ auto fake_display = reinterpret_cast<EGLNativeDisplayType>(0x12345678lu);
3146+ return std::make_shared<EGLNativeDisplayType>(fake_display);
3147+ }
3148+
3149+ MirNativeBuffer* convert_native_buffer(mir::graphics::NativeBuffer* buf) const
3150+ {
3151+ static_cast<void>(buf);
3152+#ifndef ANDROID
3153+ return buf;
3154+#else
3155+ return nullptr;
3156+#endif
3157+ }
3158+};
3159+}
3160+
3161+std::shared_ptr<mcl::ClientPlatform>
3162+mtf::StubClientPlatformFactory::create_client_platform(mcl::ClientContext*)
3163+{
3164+ return std::make_shared<StubClientPlatform>();
3165+}
3166
3167=== added file 'tests/mir_test_framework/stub_client_platform_module.cpp'
3168--- tests/mir_test_framework/stub_client_platform_module.cpp 1970-01-01 00:00:00 +0000
3169+++ tests/mir_test_framework/stub_client_platform_module.cpp 2014-09-10 08:00:52 +0000
3170@@ -0,0 +1,35 @@
3171+/*
3172+ * Copyright © 2014 Canonical Ltd.
3173+ *
3174+ * This program is free software: you can redistribute it and/or modify it
3175+ * under the terms of the GNU General Public License version 3,
3176+ * as published by the Free Software Foundation.
3177+ *
3178+ * This program is distributed in the hope that it will be useful,
3179+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3180+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3181+ * GNU General Public License for more details.
3182+ *
3183+ * You should have received a copy of the GNU General Public License
3184+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3185+ *
3186+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>>
3187+ */
3188+
3189+#include "src/client/client_platform_factory.h"
3190+
3191+#include "mir_test_framework/stub_client_platform_factory.h"
3192+#include <memory>
3193+
3194+namespace mtf = mir_test_framework;
3195+namespace mcl = mir::client;
3196+
3197+extern "C" std::shared_ptr<mcl::ClientPlatform> create_client_platform(mcl::ClientContext* context)
3198+{
3199+ return mtf::StubClientPlatformFactory{}.create_client_platform(context);
3200+}
3201+
3202+extern "C" bool is_appropriate_module(mcl::ClientContext* /*context*/)
3203+{
3204+ return true;
3205+}
3206
3207=== added file 'tests/mir_test_framework/symbols-client.map'
3208--- tests/mir_test_framework/symbols-client.map 1970-01-01 00:00:00 +0000
3209+++ tests/mir_test_framework/symbols-client.map 2014-09-10 08:00:52 +0000
3210@@ -0,0 +1,7 @@
3211+MIR_CLIENTPLATFORM_1 {
3212+ global:
3213+ create_client_platform;
3214+ is_appropriate_module;
3215+ local:
3216+ *;
3217+};
3218
3219=== added file 'tests/mir_test_framework/symbols-server.map'
3220--- tests/mir_test_framework/symbols-server.map 1970-01-01 00:00:00 +0000
3221+++ tests/mir_test_framework/symbols-server.map 2014-09-10 08:00:52 +0000
3222@@ -0,0 +1,10 @@
3223+MIR_GRAPHICS_PLATFORM_1 {
3224+ global:
3225+ add_platform_options;
3226+ create_platform;
3227+ create_native_platform;
3228+ probe_platform;
3229+ describe_module;
3230+ local:
3231+ *;
3232+};
3233
3234=== modified file 'tests/mir_test_framework/testing_client_options.cpp'
3235--- tests/mir_test_framework/testing_client_options.cpp 2014-09-08 04:12:17 +0000
3236+++ tests/mir_test_framework/testing_client_options.cpp 2014-09-10 08:00:52 +0000
3237@@ -16,112 +16,12 @@
3238 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
3239 */
3240
3241-#include "mir_test_framework/testing_client_configuration.h"
3242 #include "mir_test_framework/stub_client_connection_configuration.h"
3243-#include "mir/options/program_option.h"
3244 #include "src/client/default_connection_configuration.h"
3245-#include "src/client/client_platform_factory.h"
3246-#include "src/client/client_buffer_factory.h"
3247-#include "src/client/client_buffer.h"
3248-#include "src/client/client_platform.h"
3249-#include "src/client/mir_connection.h"
3250+#include "mir_test_framework/stub_client_platform_factory.h"
3251
3252 namespace mcl = mir::client;
3253-namespace mtf=mir_test_framework;
3254-namespace geom = mir::geometry;
3255-
3256-
3257-namespace
3258-{
3259-class StubClientBuffer : public mcl::ClientBuffer
3260-{
3261- std::shared_ptr<mcl::MemoryRegion> secure_for_cpu_write()
3262- {
3263- return nullptr;
3264- }
3265-
3266- geom::Size size() const
3267- {
3268- return geom::Size{};
3269- }
3270-
3271- geom::Stride stride() const
3272- {
3273- return geom::Stride{};
3274- }
3275-
3276- MirPixelFormat pixel_format() const
3277- {
3278- return mir_pixel_format_abgr_8888;
3279- }
3280-
3281- uint32_t age() const
3282- {
3283- return 0;
3284- }
3285- void increment_age()
3286- {
3287- }
3288- void mark_as_submitted()
3289- {
3290- }
3291- std::shared_ptr<mir::graphics::NativeBuffer> native_buffer_handle() const
3292- {
3293- return nullptr;
3294- }
3295- void update_from(MirBufferPackage const&) override
3296- {
3297- }
3298-};
3299-
3300-struct StubClientBufferFactory : public mcl::ClientBufferFactory
3301-{
3302- std::shared_ptr<mcl::ClientBuffer> create_buffer(std::shared_ptr<MirBufferPackage> const&,
3303- geom::Size, MirPixelFormat)
3304- {
3305- return std::make_shared<StubClientBuffer>();
3306- }
3307-};
3308-
3309-struct StubClientPlatform : public mcl::ClientPlatform
3310-{
3311- MirPlatformType platform_type() const
3312- {
3313- return mir_platform_type_gbm;
3314- }
3315-
3316- std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory()
3317- {
3318- return std::make_shared<StubClientBufferFactory>();
3319- }
3320-
3321- std::shared_ptr<EGLNativeWindowType> create_egl_native_window(mcl::ClientSurface*)
3322- {
3323- auto fake_window = reinterpret_cast<EGLNativeWindowType>(0x12345678lu);
3324- return std::make_shared<EGLNativeWindowType>(fake_window);
3325- }
3326-
3327- std::shared_ptr<EGLNativeDisplayType> create_egl_native_display()
3328- {
3329- auto fake_display = reinterpret_cast<EGLNativeDisplayType>(0x12345678lu);
3330- return std::make_shared<EGLNativeDisplayType>(fake_display);
3331- }
3332-
3333- MirNativeBuffer* convert_native_buffer(mir::graphics::NativeBuffer*) const
3334- {
3335- return nullptr;
3336- }
3337-};
3338-
3339-struct StubClientPlatformFactory : public mcl::ClientPlatformFactory
3340-{
3341- std::shared_ptr<mcl::ClientPlatform> create_client_platform(mcl::ClientContext*)
3342- {
3343- return std::make_shared<StubClientPlatform>();
3344- }
3345-};
3346-
3347-}
3348+namespace mtf = mir_test_framework;
3349
3350 mtf::StubConnectionConfiguration::StubConnectionConfiguration(std::string const& socket_file)
3351 : DefaultConnectionConfiguration(socket_file)
3352
3353=== modified file 'tests/unit-tests/CMakeLists.txt'
3354--- tests/unit-tests/CMakeLists.txt 2014-09-09 11:19:01 +0000
3355+++ tests/unit-tests/CMakeLists.txt 2014-09-10 08:00:52 +0000
3356@@ -2,7 +2,23 @@
3357
3358 add_definitions(-DTEST_RECORDINGS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/input_recordings/")
3359
3360-include_directories(${DRM_INCLUDE_DIRS} ${GBM_INCLUDE_DIRS} ${UMOCKDEV_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR})
3361+if (MIR_BUILD_PLATFORM_ANDROID)
3362+ add_definitions(-DMIR_BUILD_PLATFORM_ANDROID)
3363+endif()
3364+
3365+if (MIR_BUILD_PLATFORM_MESA)
3366+ add_definitions(-DMIR_BUILD_PLATFORM_MESA)
3367+endif()
3368+
3369+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
3370+
3371+include_directories(
3372+ ${ANDROID_HEADERS_INCLUDE_DIRS}
3373+ ${DRM_INCLUDE_DIRS}
3374+ ${GBM_INCLUDE_DIRS}
3375+ ${UMOCKDEV_INCLUDE_DIRS}
3376+ ${CMAKE_SOURCE_DIR}
3377+)
3378 # TODO: Aim to remove
3379 include_directories(${MIR_XCURSOR_INCLUDE_DIRECTORIES})
3380
3381@@ -19,6 +35,7 @@
3382 test_thread_name.cpp
3383 test_default_emergency_cleanup.cpp
3384 test_basic_observers.cpp
3385+ test_shared_library_prober.cpp
3386 test_fatal.cpp
3387 test_fd.cpp
3388 test_shared_library_prober.cpp
3389@@ -75,6 +92,15 @@
3390 ${GMOCK_MAIN_LIBRARY}
3391 ${Boost_LIBRARIES}
3392 ${UMOCKDEV_LIBRARIES}
3393+ # Mesa platform dependencies
3394+ ${DRM_LDFLAGS} ${DRM_LIBRARIES}
3395+ ${GBM_LDFLAGS} ${GBM_LIBRARIES}
3396+ # Android platform dependencies
3397+ ${LIBHARDWARE_LIBRARIES}
3398+ ${ANDROID_PROPERTIES_LIBRARIES}
3399+ # Shared platform dependencies
3400+ ${EGL_LDFLAGS} ${EGL_LIBRARIES}
3401+ ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}
3402 ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
3403 ${LIBHARDWARE_LDFLAGS} ${LIBHARDWARE_LIBRARIES}
3404 ${DRM_LDFLAGS} ${DRM_LIBRARIES}
3405@@ -83,7 +109,7 @@
3406 ${MIR_SERVER_REFERENCES}
3407 )
3408
3409-if (MIR_TEST_PLATFORM STREQUAL "android")
3410+if (MIR_BUILD_PLATFORM_ANDROID)
3411 target_link_libraries(mir_unit_tests
3412 mirsharedandroid
3413 ${ANDROID_PROPERTIES_LDFLAGS}
3414@@ -100,8 +126,14 @@
3415 "MIR_BUILD_UNIT_TESTS"
3416 OFF)
3417
3418+set (MIR_CLIENT_PLATFORM client-platform-dummy.so)
3419+
3420 if (MIR_RUN_UNIT_TESTS)
3421- mir_discover_tests(mir_unit_tests LD_PRELOAD=libumockdev-preload.so.0 G_SLICE=always-malloc G_DEBUG=gc-friendly)
3422+ mir_discover_tests(mir_unit_tests
3423+ LD_PRELOAD=libumockdev-preload.so.0
3424+ G_SLICE=always-malloc
3425+ G_DEBUG=gc-friendly
3426+ MIR_CLIENT_PLATFORM_LIB=${LIBRARY_OUTPUT_PATH}/${MIR_CLIENT_PLATFORM})
3427 endif (MIR_RUN_UNIT_TESTS)
3428
3429 install(
3430
3431=== modified file 'tests/unit-tests/client/CMakeLists.txt'
3432--- tests/unit-tests/client/CMakeLists.txt 2014-09-08 04:12:17 +0000
3433+++ tests/unit-tests/client/CMakeLists.txt 2014-09-10 08:00:52 +0000
3434@@ -12,6 +12,7 @@
3435 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_rpc_channel.cpp
3436 ${CMAKE_CURRENT_SOURCE_DIR}/test_mir_prompt_session.cpp
3437 ${CMAKE_CURRENT_SOURCE_DIR}/test_event_distributor.cpp
3438+ ${CMAKE_CURRENT_SOURCE_DIR}/test_probing_client_platform_factory.cpp
3439 )
3440
3441 if(MIR_TEST_PLATFORM STREQUAL "android")
3442
3443=== modified file 'tests/unit-tests/client/android/test_android_client_platform.cpp'
3444--- tests/unit-tests/client/android/test_android_client_platform.cpp 2014-03-06 06:05:17 +0000
3445+++ tests/unit-tests/client/android/test_android_client_platform.cpp 2014-09-10 08:00:52 +0000
3446@@ -17,9 +17,9 @@
3447 */
3448
3449 #include "src/client/client_platform.h"
3450-#include "src/client/android/client_platform_factory.h"
3451 #include "mir_test_doubles/mock_client_context.h"
3452 #include "mir_test_doubles/mock_client_surface.h"
3453+#include "mir_test_framework/client_platform_factory.h"
3454
3455 #include <EGL/egl.h>
3456
3457@@ -28,13 +28,12 @@
3458 namespace mcl = mir::client;
3459 namespace mt = mir::test;
3460 namespace mtd = mt::doubles;
3461+namespace mtf = mir_test_framework;
3462
3463 TEST(AndroidClientPlatformTest, egl_native_display_is_egl_default_display)
3464 {
3465- mtd::MockClientContext context;
3466- mcl::android::ClientPlatformFactory factory;
3467 mtd::MockClientSurface surface;
3468- auto platform = factory.create_client_platform(&context);
3469+ auto platform = mtf::create_android_client_platform();
3470 auto mock_client_surface = std::make_shared<mtd::MockClientSurface>();
3471 auto native_display = platform->create_egl_native_display();
3472 EXPECT_EQ(EGL_DEFAULT_DISPLAY, *native_display);
3473@@ -42,10 +41,8 @@
3474
3475 TEST(AndroidClientPlatformTest, egl_native_window_is_set)
3476 {
3477- mtd::MockClientContext context;
3478- mcl::android::ClientPlatformFactory factory;
3479 mtd::MockClientSurface surface;
3480- auto platform = factory.create_client_platform(&context);
3481+ auto platform = mtf::create_android_client_platform();
3482 auto mock_client_surface = std::make_shared<mtd::MockClientSurface>();
3483 auto egl_native_window = platform->create_egl_native_window(&surface);
3484 EXPECT_NE(nullptr, egl_native_window);
3485
3486=== modified file 'tests/unit-tests/client/mesa/test_client_platform.cpp'
3487--- tests/unit-tests/client/mesa/test_client_platform.cpp 2014-03-06 06:05:17 +0000
3488+++ tests/unit-tests/client/mesa/test_client_platform.cpp 2014-09-10 08:00:52 +0000
3489@@ -17,9 +17,9 @@
3490 */
3491
3492 #include "src/client/client_platform.h"
3493-#include "src/client/mesa/client_platform_factory.h"
3494+#include "mir/shared_library.h"
3495 #include "src/client/mesa/mesa_native_display_container.h"
3496-#include "mir_test_doubles/mock_client_context.h"
3497+#include "mir_test_framework/client_platform_factory.h"
3498 #include "mir_test_doubles/mock_client_surface.h"
3499
3500 #include "mir_toolkit/mesa/native_display.h"
3501@@ -30,19 +30,20 @@
3502 namespace mclm = mir::client::mesa;
3503 namespace mt = mir::test;
3504 namespace mtd = mir::test::doubles;
3505+namespace mtf = mir_test_framework;
3506
3507 TEST(MesaClientPlatformTest, egl_native_display_is_valid_until_released)
3508 {
3509- mtd::MockClientContext context;
3510- mclm::ClientPlatformFactory factory;
3511- auto platform = factory.create_client_platform(&context);
3512+ auto platform = mtf::create_mesa_client_platform();
3513+ auto platform_lib = mtf::get_platform_library();
3514
3515 MirMesaEGLNativeDisplay* nd;
3516 {
3517 std::shared_ptr<EGLNativeDisplayType> native_display = platform->create_egl_native_display();
3518
3519 nd = reinterpret_cast<MirMesaEGLNativeDisplay*>(*native_display);
3520- EXPECT_EQ(MIR_MESA_TRUE, mclm::mir_client_mesa_egl_native_display_is_valid(nd));
3521+ auto validate = platform_lib->load_function<MirBool(*)(MirMesaEGLNativeDisplay*)>("mir_client_mesa_egl_native_display_is_valid");
3522+ EXPECT_EQ(MIR_MESA_TRUE, validate(nd));
3523 }
3524 EXPECT_EQ(MIR_MESA_FALSE, mclm::mir_client_mesa_egl_native_display_is_valid(nd));
3525 }
3526
3527=== modified file 'tests/unit-tests/client/mesa/test_mesa_native_display_container.cpp'
3528--- tests/unit-tests/client/mesa/test_mesa_native_display_container.cpp 2014-03-06 06:05:17 +0000
3529+++ tests/unit-tests/client/mesa/test_mesa_native_display_container.cpp 2014-09-10 08:00:52 +0000
3530@@ -40,7 +40,7 @@
3531 }
3532
3533 std::shared_ptr<mclg::MesaNativeDisplayContainer> const container;
3534- MirConnection* connection;
3535+ mir::client::ClientContext* connection;
3536 };
3537
3538 }
3539
3540=== modified file 'tests/unit-tests/client/test_client_platform.cpp'
3541--- tests/unit-tests/client/test_client_platform.cpp 2014-03-06 06:05:17 +0000
3542+++ tests/unit-tests/client/test_client_platform.cpp 2014-09-10 08:00:52 +0000
3543@@ -20,60 +20,140 @@
3544 #include "src/client/mir_client_surface.h"
3545 #include "mir_test_doubles/mock_client_context.h"
3546 #include "mir_test_doubles/mock_client_surface.h"
3547+#include "mir_test_framework/executable_path.h"
3548
3549-#ifdef ANDROID
3550+#ifdef MIR_BUILD_PLATFORM_ANDROID
3551 #include "mir_test_doubles/mock_android_hw.h"
3552-#include "src/client/android/client_platform_factory.h"
3553-#else
3554-#include "src/client/mesa/client_platform_factory.h"
3555 #endif
3556
3557+#include "src/client/client_platform_factory.h"
3558+
3559+#include "mir/shared_library.h"
3560+
3561 #include <gmock/gmock.h>
3562 #include <gtest/gtest.h>
3563
3564 namespace mcl=mir::client;
3565 namespace mtd = mir::test::doubles;
3566-
3567-struct ClientPlatformTest : public ::testing::Test
3568-{
3569+namespace mtf = mir_test_framework;
3570+
3571+namespace
3572+{
3573+struct ClientPlatformTraits
3574+{
3575+ ClientPlatformTraits(std::string const& library,
3576+ std::function<void(MirPlatformPackage&)> populator,
3577+ MirPlatformType type)
3578+ : platform_library_name{library},
3579+ populate_package_for{populator},
3580+ platform_type{type}
3581+ {
3582+ }
3583+
3584+ std::string const platform_library_name;
3585+ std::function<void(MirPlatformPackage&)> const populate_package_for;
3586+ MirPlatformType const platform_type;
3587+};
3588+
3589+struct ClientPlatformTest : public ::testing::TestWithParam<ClientPlatformTraits const*>
3590+{
3591+ ClientPlatformTest()
3592+ : platform_library{mtf::library_path() + "/" + GetParam()->platform_library_name},
3593+ create_client_platform{platform_library.load_function<mcl::CreateClientPlatform>("create_client_platform")},
3594+ probe{platform_library.load_function<mcl::ClientPlatformProbe>("is_appropriate_module")}
3595+ {
3596+ using namespace testing;
3597+ ON_CALL(context, populate(_))
3598+ .WillByDefault(Invoke(GetParam()->populate_package_for));
3599+ }
3600+
3601 mtd::MockClientContext context;
3602-#ifdef ANDROID
3603+#ifdef MIR_BUILD_PLATFORM_ANDROID
3604 testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock;
3605- mcl::android::ClientPlatformFactory factory;
3606-#else
3607- mcl::mesa::ClientPlatformFactory factory;
3608 #endif
3609+ mir::SharedLibrary platform_library;
3610+ mcl::CreateClientPlatform const create_client_platform;
3611+ mcl::ClientPlatformProbe const probe;
3612 };
3613
3614-TEST_F(ClientPlatformTest, platform_name)
3615-{
3616- auto platform = factory.create_client_platform(&context);
3617-#ifdef ANDROID
3618- auto type = mir_platform_type_android;
3619-#else
3620- auto type = mir_platform_type_gbm;
3621-#endif
3622- EXPECT_EQ(type, platform->platform_type());
3623-}
3624-
3625-TEST_F(ClientPlatformTest, platform_creates)
3626-{
3627- auto platform = factory.create_client_platform(&context);
3628+#ifdef MIR_BUILD_PLATFORM_ANDROID
3629+ClientPlatformTraits const android_platform{"client-platform-android.so",
3630+ [](MirPlatformPackage& pkg)
3631+ {
3632+ ::memset(&pkg, 0, sizeof(pkg));
3633+ },
3634+ mir_platform_type_android
3635+ };
3636+
3637+INSTANTIATE_TEST_CASE_P(Android,
3638+ ClientPlatformTest,
3639+ ::testing::Values(&android_platform));
3640+
3641+#endif
3642+
3643+#ifdef MIR_BUILD_PLATFORM_MESA
3644+ClientPlatformTraits const mesa_platform{"client-platform-mesa.so",
3645+ [](MirPlatformPackage& pkg)
3646+ {
3647+ ::memset(&pkg, 0, sizeof(pkg));
3648+ pkg.fd_items = 1;
3649+ },
3650+ mir_platform_type_gbm
3651+ };
3652+
3653+INSTANTIATE_TEST_CASE_P(Mesa,
3654+ ClientPlatformTest,
3655+ ::testing::Values(&mesa_platform));
3656+
3657+#endif
3658+}
3659+
3660+TEST_P(ClientPlatformTest, platform_name)
3661+{
3662+ auto platform = create_client_platform(&context);
3663+
3664+ EXPECT_EQ(GetParam()->platform_type, platform->platform_type());
3665+}
3666+
3667+TEST_P(ClientPlatformTest, platform_creates)
3668+{
3669+ auto platform = create_client_platform(&context);
3670 auto buffer_factory = platform->create_buffer_factory();
3671 EXPECT_NE(buffer_factory.get(), (mcl::ClientBufferFactory*) NULL);
3672 }
3673
3674-TEST_F(ClientPlatformTest, platform_creates_native_window)
3675+TEST_P(ClientPlatformTest, platform_creates_native_window)
3676 {
3677- auto platform = factory.create_client_platform(&context);
3678+ auto platform = create_client_platform(&context);
3679 auto mock_client_surface = std::make_shared<mtd::MockClientSurface>();
3680 auto native_window = platform->create_egl_native_window(mock_client_surface.get());
3681 EXPECT_NE(*native_window, (EGLNativeWindowType) NULL);
3682 }
3683
3684-TEST_F(ClientPlatformTest, platform_creates_egl_native_display)
3685+TEST_P(ClientPlatformTest, platform_creates_egl_native_display)
3686 {
3687- auto platform = factory.create_client_platform(&context);
3688+ auto platform = create_client_platform(&context);
3689 auto native_display = platform->create_egl_native_display();
3690 EXPECT_NE(nullptr, native_display.get());
3691 }
3692+
3693+TEST_P(ClientPlatformTest, platform_probe_returns_success_when_matching)
3694+{
3695+ EXPECT_TRUE(probe(&context));
3696+}
3697+
3698+TEST_P(ClientPlatformTest, platform_probe_returns_false_when_not_matching)
3699+{
3700+ using namespace testing;
3701+ ON_CALL(context, populate(_))
3702+ .WillByDefault(Invoke([](MirPlatformPackage& pkg)
3703+ {
3704+ //Mock up something that hopefully looks nothing like
3705+ //what the platform is expecting...
3706+ ::memset(&pkg, 0, sizeof(pkg));
3707+ pkg.data_items = 0xdeadbeef;
3708+ pkg.fd_items = -23;
3709+ }));
3710+
3711+ EXPECT_FALSE(probe(&context));
3712+}
3713
3714=== added file 'tests/unit-tests/client/test_probing_client_platform_factory.cpp'
3715--- tests/unit-tests/client/test_probing_client_platform_factory.cpp 1970-01-01 00:00:00 +0000
3716+++ tests/unit-tests/client/test_probing_client_platform_factory.cpp 2014-09-10 08:00:52 +0000
3717@@ -0,0 +1,140 @@
3718+/*
3719+ * Copyright © 2014 Canonical Ltd.
3720+ *
3721+ * This program is free software: you can redistribute it and/or modify
3722+ * it under the terms of the GNU General Public License version 3 as
3723+ * published by the Free Software Foundation.
3724+ *
3725+ * This program is distributed in the hope that it will be useful,
3726+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3727+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3728+ * GNU General Public License for more details.
3729+ *
3730+ * You should have received a copy of the GNU General Public License
3731+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3732+ *
3733+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
3734+ */
3735+
3736+#include "src/client/client_platform.h"
3737+#include "src/client/probing_client_platform_factory.h"
3738+
3739+#include "mir_test_doubles/mock_client_context.h"
3740+#include "mir_test_framework/executable_path.h"
3741+
3742+#include <gmock/gmock.h>
3743+#include <gtest/gtest.h>
3744+
3745+namespace mtf = mir_test_framework;
3746+namespace mtd = mir::test::doubles;
3747+
3748+namespace
3749+{
3750+std::vector<std::shared_ptr<mir::SharedLibrary>>
3751+all_available_modules()
3752+{
3753+ std::vector<std::shared_ptr<mir::SharedLibrary>> modules;
3754+#ifdef MIR_BUILD_PLATFORM_MESA
3755+ modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() + "/client-platform-mesa.so"));
3756+#endif
3757+#ifdef MIR_BUILD_PLATFORM_ANDROID
3758+ modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() + "/client-platform-android.so"));
3759+#endif
3760+ return modules;
3761+}
3762+}
3763+
3764+TEST(ProbingClientPlatformFactory, ThrowsErrorWhenConstructedWithNoPlatforms)
3765+{
3766+ std::vector<std::shared_ptr<mir::SharedLibrary>> empty_modules;
3767+ EXPECT_THROW(mir::client::ProbingClientPlatformFactory{empty_modules},
3768+ std::runtime_error);
3769+}
3770+
3771+TEST(ProbingClientPlatformFactory, ThrowsErrorWhenNoPlatformPluginProbesSuccessfully)
3772+{
3773+ using namespace testing;
3774+
3775+ mir::client::ProbingClientPlatformFactory factory{all_available_modules()};
3776+
3777+ mtd::MockClientContext context;
3778+ ON_CALL(context, populate(_))
3779+ .WillByDefault(Invoke([](MirPlatformPackage& pkg)
3780+ {
3781+ ::memset(&pkg, 0, sizeof(MirPlatformPackage));
3782+ // Mock up a platform package that looks nothing like
3783+ // either an Android or Mesa package
3784+ pkg.fd_items = 0xdeadbeef;
3785+ pkg.data_items = -23;
3786+ }));
3787+
3788+ EXPECT_THROW(factory.create_client_platform(&context),
3789+ std::runtime_error);
3790+}
3791+
3792+#ifdef MIR_BUILD_PLATFORM_MESA
3793+TEST(ProbingClientPlatformFactory, CreatesMesaPlatformWhenAppropriate)
3794+{
3795+ using namespace testing;
3796+
3797+ mir::client::ProbingClientPlatformFactory factory{all_available_modules()};
3798+
3799+ mtd::MockClientContext context;
3800+ ON_CALL(context, populate(_))
3801+ .WillByDefault(Invoke([](MirPlatformPackage& pkg)
3802+ {
3803+ ::memset(&pkg, 0, sizeof(MirPlatformPackage));
3804+ // Mock up something that looks like a GBM platform package,
3805+ // until we send the actual platform type over the wire!
3806+ pkg.fd_items = 1;
3807+ pkg.fd[0] = 23;
3808+ }));
3809+ auto platform = factory.create_client_platform(&context);
3810+ EXPECT_EQ(mir_platform_type_gbm, platform->platform_type());
3811+}
3812+#endif
3813+
3814+#ifdef MIR_BUILD_PLATFORM_ANDROID
3815+TEST(ProbingClientPlatformFactory, CreatesAndroidPlatformWhenAppropriate)
3816+{
3817+ using namespace testing;
3818+
3819+ mir::client::ProbingClientPlatformFactory factory{all_available_modules()};
3820+
3821+ mtd::MockClientContext context;
3822+ ON_CALL(context, populate(_))
3823+ .WillByDefault(Invoke([](MirPlatformPackage& pkg)
3824+ {
3825+ // Mock up something that looks like a Android platform package,
3826+ // until we send the actual platform type over the wire!
3827+ ::memset(&pkg, 0, sizeof(MirPlatformPackage));
3828+ }));
3829+
3830+ auto platform = factory.create_client_platform(&context);
3831+ EXPECT_EQ(mir_platform_type_android, platform->platform_type());
3832+}
3833+#endif
3834+
3835+TEST(ProbingClientPlatformFactory, IgnoresNonClientPlatformModules)
3836+{
3837+ using namespace testing;
3838+
3839+ auto modules = all_available_modules();
3840+ modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() + "/libmirserver.so"));
3841+ modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() + "/client-platform-dummy.so"));
3842+
3843+ mir::client::ProbingClientPlatformFactory factory{modules};
3844+
3845+ mtd::MockClientContext context;
3846+ ON_CALL(context, populate(_))
3847+ .WillByDefault(Invoke([](MirPlatformPackage& pkg)
3848+ {
3849+ // Mock up something that looks like a Dummy platform package,
3850+ // until we send the actual platform type over the wire!
3851+ ::memset(&pkg, 0, sizeof(MirPlatformPackage));
3852+ pkg.data_items = 20;
3853+ strcpy(reinterpret_cast<char*>(pkg.data), "Dummy platform");
3854+ }));
3855+
3856+ auto platform = factory.create_client_platform(&context);
3857+}
3858
3859=== modified file 'tests/unit-tests/graphics/CMakeLists.txt'
3860--- tests/unit-tests/graphics/CMakeLists.txt 2014-09-08 04:12:17 +0000
3861+++ tests/unit-tests/graphics/CMakeLists.txt 2014-09-10 08:00:52 +0000
3862@@ -10,6 +10,7 @@
3863 ${CMAKE_CURRENT_SOURCE_DIR}/test_surfaceless_egl_context.cpp
3864 ${CMAKE_CURRENT_SOURCE_DIR}/test_overlapping_output_grouping.cpp
3865 ${CMAKE_CURRENT_SOURCE_DIR}/test_program_factory.cpp
3866+ ${CMAKE_CURRENT_SOURCE_DIR}/test_platform_prober.cpp
3867 )
3868
3869 add_subdirectory(nested/)
3870
3871=== modified file 'tests/unit-tests/graphics/android/test_android_platform.cpp'
3872--- tests/unit-tests/graphics/android/test_android_platform.cpp 2014-09-08 04:12:17 +0000
3873+++ tests/unit-tests/graphics/android/test_android_platform.cpp 2014-09-10 08:00:52 +0000
3874@@ -29,6 +29,8 @@
3875 #include "mir_test_doubles/fd_matcher.h"
3876 #include "mir_test/fake_shared.h"
3877 #include "mir_test_doubles/mock_android_native_buffer.h"
3878+#include "mir_test_framework/executable_path.h"
3879+#include "mir/shared_library.h"
3880 #include <system/window.h>
3881 #include <gtest/gtest.h>
3882
3883@@ -39,6 +41,7 @@
3884 namespace mr=mir::report;
3885 namespace geom=mir::geometry;
3886 namespace mo=mir::options;
3887+namespace mtf=mir_test_framework;
3888
3889 class PlatformBufferIPCPackaging : public ::testing::Test
3890 {
3891@@ -154,6 +157,27 @@
3892 EXPECT_EQ(EGL_DEFAULT_DISPLAY, platform.egl_native_display());
3893 }
3894
3895+TEST(AndroidGraphicsPlatform, probe_returns_unsupported_when_no_hwaccess)
3896+{
3897+ using namespace testing;
3898+ NiceMock<mtd::HardwareAccessMock> hwaccess;
3899+
3900+ ON_CALL(hwaccess, hw_get_module(_,_)).WillByDefault(Return(-1));
3901+
3902+ mir::SharedLibrary platform_lib{mtf::library_path() + "/platform-graphics-android.so"};
3903+ auto probe = platform_lib.load_function<mg::PlatformProbe>("probe_platform");
3904+ EXPECT_EQ(mg::PlatformPriority::unsupported, probe());
3905+}
3906+
3907+TEST(AndroidGraphicsPlatform, probe_returns_best_when_hwaccess_succeeds)
3908+{
3909+ testing::NiceMock<mtd::HardwareAccessMock> hwaccess;
3910+
3911+ mir::SharedLibrary platform_lib{mtf::library_path() + "/platform-graphics-android.so"};
3912+ auto probe = platform_lib.load_function<mg::PlatformProbe>("probe_platform");
3913+ EXPECT_EQ(mg::PlatformPriority::best, probe());
3914+}
3915+
3916 TEST(NestedPlatformCreation, doesnt_access_display_hardware)
3917 {
3918 using namespace testing;
3919
3920=== modified file 'tests/unit-tests/graphics/android/test_output_builder.cpp'
3921--- tests/unit-tests/graphics/android/test_output_builder.cpp 2014-09-09 12:41:41 +0000
3922+++ tests/unit-tests/graphics/android/test_output_builder.cpp 2014-09-10 08:00:52 +0000
3923@@ -113,6 +113,7 @@
3924 std::shared_ptr<mga::HwcLogger> logger{std::make_shared<mga::NullHwcLogger>()};
3925 };
3926 }
3927+
3928 TEST_F(OutputBuilder, hwc_version_10_success)
3929 {
3930 using namespace testing;
3931
3932=== modified file 'tests/unit-tests/graphics/mesa/test_platform.cpp'
3933--- tests/unit-tests/graphics/mesa/test_platform.cpp 2014-09-08 04:12:17 +0000
3934+++ tests/unit-tests/graphics/mesa/test_platform.cpp 2014-09-10 08:00:52 +0000
3935@@ -23,6 +23,7 @@
3936 #include "src/platform/graphics/mesa/internal_client.h"
3937 #include "src/server/report/null_report_factory.h"
3938 #include "mir/emergency_cleanup_registry.h"
3939+#include "mir/shared_library.h"
3940
3941 #include "mir_test_doubles/mock_buffer.h"
3942 #include "mir_test_doubles/mock_buffer_packer.h"
3943@@ -33,6 +34,7 @@
3944 #include <gtest/gtest.h>
3945
3946 #include "mir_test_framework/udev_environment.h"
3947+#include "mir_test_framework/executable_path.h"
3948 #include "mir_test/pipe.h"
3949
3950 #include "mir_test_doubles/mock_drm.h"
3951@@ -384,3 +386,23 @@
3952
3953 Mock::VerifyAndClearExpectations(&mock_drm);
3954 }
3955+
3956+TEST_F(MesaGraphicsPlatform, probe_returns_unsupported_when_no_drm_udev_devices)
3957+{
3958+ mtf::UdevEnvironment udev_environment;
3959+
3960+ mir::SharedLibrary platform_lib{mtf::library_path() + "/platform-graphics-mesa.so"};
3961+ auto probe = platform_lib.load_function<mg::PlatformProbe>("probe_platform");
3962+ EXPECT_EQ(mg::PlatformPriority::unsupported, probe());
3963+}
3964+
3965+TEST_F(MesaGraphicsPlatform, probe_returns_best_when_drm_devices_exist)
3966+{
3967+ mtf::UdevEnvironment udev_environment;
3968+
3969+ udev_environment.add_standard_device("standard-drm-devices");
3970+
3971+ mir::SharedLibrary platform_lib{mtf::library_path() + "/platform-graphics-mesa.so"};
3972+ auto probe = platform_lib.load_function<mg::PlatformProbe>("probe_platform");
3973+ EXPECT_EQ(mg::PlatformPriority::best, probe());
3974+}
3975
3976=== added file 'tests/unit-tests/graphics/test_platform_prober.cpp'
3977--- tests/unit-tests/graphics/test_platform_prober.cpp 1970-01-01 00:00:00 +0000
3978+++ tests/unit-tests/graphics/test_platform_prober.cpp 2014-09-10 08:00:52 +0000
3979@@ -0,0 +1,212 @@
3980+/*
3981+ * Copyright © 2014 Canonical Ltd.
3982+ *
3983+ * This program is free software: you can redistribute it and/or modify
3984+ * it under the terms of the GNU General Public License version 3 as
3985+ * published by the Free Software Foundation.
3986+ *
3987+ * This program is distributed in the hope that it will be useful,
3988+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3989+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3990+ * GNU General Public License for more details.
3991+ *
3992+ * You should have received a copy of the GNU General Public License
3993+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3994+ *
3995+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
3996+ */
3997+
3998+#include <gtest/gtest.h>
3999+
4000+#include "src/platform/graphics/platform_probe.h"
4001+#include "mir/graphics/platform.h"
4002+
4003+#include "mir/raii.h"
4004+
4005+#ifdef MIR_BUILD_PLATFORM_MESA
4006+#include "mir_test_doubles/mock_drm.h"
4007+#include "mir_test_doubles/mock_gbm.h"
4008+#endif
4009+
4010+#ifdef MIR_BUILD_PLATFORM_ANDROID
4011+#include "mir_test_doubles/mock_android_hw.h"
4012+#endif
4013+
4014+#include "mir_test_framework/udev_environment.h"
4015+#include "mir_test_framework/executable_path.h"
4016+
4017+namespace mtf = mir_test_framework;
4018+namespace mtd = mir::test::doubles;
4019+
4020+namespace
4021+{
4022+std::vector<std::shared_ptr<mir::SharedLibrary>> available_platforms()
4023+{
4024+ std::vector<std::shared_ptr<mir::SharedLibrary>> modules;
4025+
4026+#ifdef MIR_BUILD_PLATFORM_MESA
4027+ modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() + "/platform-graphics-mesa.so"));
4028+#endif
4029+#ifdef MIR_BUILD_PLATFORM_ANDROID
4030+ modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() + "/platform-graphics-android.so"));
4031+#endif
4032+ return modules;
4033+}
4034+
4035+void add_dummy_platform(std::vector<std::shared_ptr<mir::SharedLibrary>>& modules)
4036+{
4037+ modules.insert(modules.begin(), std::make_shared<mir::SharedLibrary>(mtf::library_path() + "/platform-graphics-dummy.so"));
4038+}
4039+
4040+std::shared_ptr<void> ensure_android_probing_fails()
4041+{
4042+#ifdef MIR_BUILD_PLATFORM_ANDROID
4043+ using namespace testing;
4044+ auto mock_android = std::make_shared<NiceMock<mtd::HardwareAccessMock>>();
4045+ ON_CALL(*mock_android, hw_get_module(_, _))
4046+ .WillByDefault(Return(-1));
4047+ return mock_android;
4048+#else
4049+ return std::shared_ptr<void>{};
4050+#endif
4051+}
4052+
4053+std::shared_ptr<void> ensure_mesa_probing_fails()
4054+{
4055+ return std::make_shared<mtf::UdevEnvironment>();
4056+}
4057+
4058+std::shared_ptr<void> ensure_mesa_probing_succeeds()
4059+{
4060+ auto udev = std::make_shared<mtf::UdevEnvironment>();
4061+
4062+ udev->add_standard_device("standard-drm-devices");
4063+
4064+ return udev;
4065+}
4066+
4067+std::shared_ptr<void> ensure_android_probing_succeeds()
4068+{
4069+#ifdef MIR_BUILD_PLATFORM_ANDROID
4070+ using namespace testing;
4071+ auto mock_android = std::make_shared<NiceMock<mtd::HardwareAccessMock>>();
4072+ ON_CALL(*mock_android, hw_get_module(_, _))
4073+ .WillByDefault(Return(0));
4074+ return mock_android;
4075+#else
4076+ return std::shared_ptr<void>{};
4077+#endif
4078+}
4079+}
4080+
4081+TEST(ServerPlatformProbe, ConstructingWithNoModulesIsAnError)
4082+{
4083+ std::vector<std::shared_ptr<mir::SharedLibrary>> empty_modules;
4084+ EXPECT_THROW(mir::graphics::module_for_device(empty_modules),
4085+ std::runtime_error);
4086+}
4087+
4088+#ifdef MIR_BUILD_PLATFORM_MESA
4089+TEST(ServerPlatformProbe, LoadsMesaPlatformWhenDrmDevicePresent)
4090+{
4091+ using namespace testing;
4092+ auto block_android = ensure_android_probing_fails();
4093+ auto fake_mesa = ensure_mesa_probing_succeeds();
4094+
4095+ auto modules = available_platforms();
4096+
4097+ auto module = mir::graphics::module_for_device(modules);
4098+ ASSERT_NE(nullptr, module);
4099+
4100+ auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
4101+ auto description = descriptor();
4102+
4103+ EXPECT_THAT(description->name, HasSubstr("mesa"));
4104+}
4105+#endif
4106+
4107+#ifdef MIR_BUILD_PLATFORM_ANDROID
4108+TEST(ServerPlatformProbe, LoadsAndroidPlatformWhenHwaccessSucceeds)
4109+{
4110+ using namespace testing;
4111+
4112+ auto block_mesa = ensure_mesa_probing_fails();
4113+ auto fake_android = ensure_android_probing_succeeds();
4114+
4115+ auto modules = available_platforms();
4116+
4117+ auto module = mir::graphics::module_for_device(modules);
4118+ ASSERT_NE(nullptr, module);
4119+
4120+ auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
4121+ auto description = descriptor();
4122+
4123+ EXPECT_THAT(description->name, HasSubstr("android"));
4124+}
4125+#endif
4126+
4127+TEST(ServerPlatformProbe, ThrowsExceptionWhenNothingProbesSuccessfully)
4128+{
4129+ using namespace testing;
4130+ auto block_android = ensure_android_probing_fails();
4131+ auto block_mesa = ensure_mesa_probing_fails();
4132+
4133+
4134+ EXPECT_THROW(mir::graphics::module_for_device(available_platforms()),
4135+ std::runtime_error);
4136+}
4137+
4138+TEST(ServerPlatformProbe, LoadsSupportedModuleWhenNoBestModule)
4139+{
4140+ using namespace testing;
4141+ auto block_android = ensure_android_probing_fails();
4142+ auto block_mesa = ensure_mesa_probing_fails();
4143+
4144+ auto modules = available_platforms();
4145+ add_dummy_platform(modules);
4146+
4147+ auto module = mir::graphics::module_for_device(modules);
4148+ ASSERT_NE(nullptr, module);
4149+
4150+ auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
4151+ auto description = descriptor();
4152+
4153+ EXPECT_THAT(description->name, HasSubstr("dummy"));
4154+}
4155+
4156+TEST(ServerPlatformProbe, LoadsMesaOrAndroidInPreferenceToDummy)
4157+{
4158+ using namespace testing;
4159+
4160+ auto ensure_mesa = ensure_mesa_probing_succeeds();
4161+ auto ensure_android = ensure_android_probing_succeeds();
4162+
4163+ auto modules = available_platforms();
4164+ add_dummy_platform(modules);
4165+
4166+ auto module = mir::graphics::module_for_device(modules);
4167+ ASSERT_NE(nullptr, module);
4168+
4169+ auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
4170+ auto description = descriptor();
4171+
4172+ EXPECT_THAT(description->name, Not(HasSubstr("dummy")));
4173+}
4174+
4175+TEST(ServerPlatformProbe, IgnoresNonPlatformModules)
4176+{
4177+ using namespace testing;
4178+
4179+ auto ensure_mesa = ensure_mesa_probing_succeeds();
4180+ auto ensure_android = ensure_android_probing_succeeds();
4181+
4182+ auto modules = available_platforms();
4183+ add_dummy_platform(modules);
4184+
4185+ modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() +
4186+ "/libmirclient.so"));
4187+
4188+
4189+ auto module = mir::graphics::module_for_device(modules);
4190+ EXPECT_NE(nullptr, module);
4191+}
4192
4193=== modified file 'tests/unit-tests/shared_library_test.cpp'
4194--- tests/unit-tests/shared_library_test.cpp 2013-06-21 12:08:34 +0000
4195+++ tests/unit-tests/shared_library_test.cpp 2014-09-10 08:00:52 +0000
4196@@ -21,15 +21,19 @@
4197 #include <gtest/gtest.h>
4198
4199 #include <boost/exception/diagnostic_information.hpp>
4200-
4201 #include <stdexcept>
4202
4203+#include "mir_test_framework/executable_path.h"
4204+
4205+namespace mtf = mir_test_framework;
4206+
4207 namespace
4208 {
4209 class HasSubstring
4210 {
4211 public:
4212 HasSubstring(char const* substring) : substring(substring) {}
4213+ HasSubstring(std::string const& substring) : substring{substring.c_str()} {}
4214
4215 friend::testing::AssertionResult operator,(std::string const& target, HasSubstring const& match)
4216 {
4217@@ -50,18 +54,35 @@
4218
4219 #define EXPECT_THAT(target, condition) EXPECT_TRUE((target, condition))
4220
4221-char const* const nonexistent_library = "nonexistent_library";
4222-char const* const existing_library = "libmirplatformgraphics.so";
4223-char const* const nonexistent_function = "nonexistent_library";
4224-char const* const existing_function = "create_platform";
4225+class SharedLibrary : public testing::Test
4226+{
4227+public:
4228+ SharedLibrary()
4229+ : nonexistent_library{"imma_totally_not_a_library"},
4230+ existing_library{mtf::library_path() + "/client-platform-mesa.so"},
4231+ nonexistent_function{"yo_dawg"},
4232+ existing_function{"create_client_platform"},
4233+ existent_version{"MIR_CLIENTPLATFORM_1"},
4234+ nonexistent_version{"GOATS_ON_THE_GREEN"}
4235+ {
4236+ }
4237+
4238+ std::string const nonexistent_library;
4239+ std::string const existing_library;
4240+ std::string const nonexistent_function;
4241+ std::string const existing_function;
4242+ std::string const existent_version;
4243+ std::string const nonexistent_version;
4244+};
4245+
4246 }
4247
4248-TEST(SharedLibrary, load_nonexistent_library_fails)
4249+TEST_F(SharedLibrary, load_nonexistent_library_fails)
4250 {
4251 EXPECT_THROW({ mir::SharedLibrary nonexistent(nonexistent_library); }, std::runtime_error);
4252 }
4253
4254-TEST(SharedLibrary, load_nonexistent_library_fails_with_useful_info)
4255+TEST_F(SharedLibrary, load_nonexistent_library_fails_with_useful_info)
4256 {
4257 try
4258 {
4259@@ -76,19 +97,19 @@
4260 }
4261 }
4262
4263-TEST(SharedLibrary, load_valid_library_works)
4264+TEST_F(SharedLibrary, load_valid_library_works)
4265 {
4266 mir::SharedLibrary existing(existing_library);
4267 }
4268
4269-TEST(SharedLibrary, load_nonexistent_function_fails)
4270+TEST_F(SharedLibrary, load_nonexistent_function_fails)
4271 {
4272 mir::SharedLibrary existing(existing_library);
4273
4274 EXPECT_THROW({ existing.load_function<void(*)()>(nonexistent_function); }, std::runtime_error);
4275 }
4276
4277-TEST(SharedLibrary, load_nonexistent_function_fails_with_useful_info)
4278+TEST_F(SharedLibrary, load_nonexistent_function_fails_with_useful_info)
4279 {
4280 mir::SharedLibrary existing(existing_library);
4281
4282@@ -106,9 +127,33 @@
4283 }
4284 }
4285
4286-TEST(SharedLibrary, load_valid_function_works)
4287+TEST_F(SharedLibrary, load_valid_function_works)
4288 {
4289 mir::SharedLibrary existing(existing_library);
4290 existing.load_function<void(*)()>(existing_function);
4291 }
4292
4293+TEST_F(SharedLibrary, load_valid_versioned_function_works)
4294+{
4295+ mir::SharedLibrary existing{existing_library};
4296+ existing.load_function<void(*)()>(existing_function, existent_version);
4297+}
4298+
4299+TEST_F(SharedLibrary, load_invalid_versioned_function_fails_with_appropriate_error)
4300+{
4301+ mir::SharedLibrary existing{existing_library};
4302+
4303+ try
4304+ {
4305+ existing.load_function<void(*)()>(existing_function, nonexistent_version);
4306+ }
4307+ catch (std::exception const& error)
4308+ {
4309+ auto info = boost::diagnostic_information(error);
4310+
4311+ EXPECT_THAT(info, HasSubstring("undefined symbol")) << "What went wrong";
4312+ EXPECT_THAT(info, HasSubstring(nonexistent_version)) << "Version info";
4313+ EXPECT_THAT(info, HasSubstring(existing_library)) << "Name of library";
4314+ EXPECT_THAT(info, HasSubstring(existing_function)) << "Name of function";
4315+ }
4316+}
4317
4318=== modified file 'tests/unit-tests/test_shared_library_prober.cpp'
4319--- tests/unit-tests/test_shared_library_prober.cpp 2014-09-08 04:21:49 +0000
4320+++ tests/unit-tests/test_shared_library_prober.cpp 2014-09-10 08:00:52 +0000
4321@@ -26,6 +26,7 @@
4322 #include <cstring>
4323
4324 #include <system_error>
4325+
4326 #include <gtest/gtest.h>
4327 #include <gmock/gmock.h>
4328
4329@@ -33,6 +34,7 @@
4330
4331 namespace
4332 {
4333+
4334 class MockSharedLibraryProberReport : public mir::SharedLibraryProberReport
4335 {
4336 public:
4337
4338=== modified file 'tools/valgrind_suppressions_armhf'
4339--- tools/valgrind_suppressions_armhf 2014-03-26 05:48:59 +0000
4340+++ tools/valgrind_suppressions_armhf 2014-09-10 08:00:52 +0000
4341@@ -119,6 +119,15 @@
4342 # memory errors.
4343
4344 {
4345+ spurious_strlen_addr4
4346+ Memcheck:Addr4
4347+ ...
4348+ fun:dlsym
4349+ ...
4350+ fun:_ZN50SharedLibrary_load_nonexistent_function_fails_Test8TestBodyEv
4351+}
4352+
4353+{
4354 mir_sharedlibrary_cond
4355 Memcheck:Cond
4356 fun:_ZN3mir13SharedLibraryC1EPKc

Subscribers

People subscribed via source and target branches