Merge lp:~mir-team/mir/probe-client-drivers into lp:mir
- probe-client-drivers
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Alan Griffiths |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2179 |
Proposed branch: | lp:~mir-team/mir/probe-client-drivers |
Merge into: | lp:mir |
Prerequisite: | lp:~raof/mir/fix-all-the-CI |
Diff against target: |
2440 lines (+954/-387) 65 files modified
benchmarks/frame-uniformity/main.cpp (+7/-0) benchmarks/frame-uniformity/touch_measuring_client.cpp (+11/-2) cmake/FindGtest.cmake (+2/-3) cmake/MirCommon.cmake (+23/-0) cmake/src/wrapper.c (+16/-0) debian/control (+5/-5) debian/create_postinst_prerm_scripts.sh (+1/-1) debian/mir-client-platform-android.install (+1/-1) debian/mir-client-platform-mesa.install (+1/-1) debian/mir-test-tools.install (+1/-0) debian/rules (+3/-6) examples/CMakeLists.txt (+19/-48) playground/demo-shell/CMakeLists.txt (+1/-3) src/CMakeLists.txt (+1/-0) src/client/CMakeLists.txt (+17/-16) src/client/android/CMakeLists.txt (+7/-22) src/client/android/android_native_display_container.cpp (+12/-4) src/client/android/android_native_display_container.h (+10/-3) src/client/android/client_platform_factory.cpp (+22/-5) src/client/android/client_platform_factory.h (+0/-41) src/client/android/symbols.map (+5/-4) src/client/client_context.h (+2/-1) src/client/client_platform_factory.h (+5/-2) src/client/connection_configuration.h (+0/-3) src/client/default_connection_configuration.cpp (+22/-18) src/client/default_connection_configuration.h (+0/-4) src/client/egl_native_display_container.h (+3/-1) src/client/mesa/CMakeLists.txt (+6/-22) src/client/mesa/client_platform.cpp (+1/-1) src/client/mesa/client_platform_factory.cpp (+20/-5) src/client/mesa/client_platform_factory.h (+0/-41) 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 (+6/-4) src/client/mir_connection.cpp (+7/-9) src/client/mir_connection.h (+2/-2) src/client/probing_client_platform_factory.cpp (+38/-0) src/client/probing_client_platform_factory.h (+26/-0) src/common/symbols.map (+12/-12) tests/CMakeLists.txt (+9/-1) tests/acceptance-tests/CMakeLists.txt (+2/-8) tests/acceptance-tests/test_client_library.cpp (+4/-4) tests/acceptance-tests/test_client_library_drm.cpp (+9/-4) tests/acceptance-tests/test_symbols_required_by_mesa.cpp (+5/-2) tests/include/mir_test_doubles/mock_client_context.h (+0/-6) tests/include/mir_test_doubles/stub_client_buffer.h (+4/-0) tests/include/mir_test_framework/client_platform_factory.h (+72/-0) tests/include/mir_test_framework/stub_client_platform_factory.h (+33/-0) tests/include/mir_test_framework/stub_platform_helpers.h (+53/-0) tests/integration-tests/CMakeLists.txt (+1/-6) tests/mir_test_doubles/CMakeLists.txt (+3/-2) tests/mir_test_framework/CMakeLists.txt (+30/-4) tests/mir_test_framework/stub_client_platform_factory.cpp (+74/-0) tests/mir_test_framework/stub_client_platform_module.cpp (+41/-0) tests/mir_test_framework/stubbed_graphics_platform.cpp (+5/-1) tests/mir_test_framework/symbols-client.map (+7/-0) tests/unit-tests/CMakeLists.txt (+1/-6) 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 (+122/-29) tests/unit-tests/client/test_probing_client_platform_factory.cpp (+142/-0) tests/unit-tests/shared_library_test.cpp (+3/-3) |
To merge this branch: | bzr merge lp:~mir-team/mir/probe-client-drivers |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Alan Griffiths | Approve | ||
Andreas Pokorny (community) | Approve | ||
Chris Halse Rogers | Approve | ||
Robert Carr (community) | Approve | ||
Daniel van Vugt | Pending | ||
Cemil Azizoglu | Pending | ||
Alexandros Frantzis | Pending | ||
Review via email: mp+244963@code.launchpad.net |
This proposal supersedes a proposal from 2014-12-12.
Commit message
Add probing for client platform modules.
The client library now looks in MIR_CLIENT_
Description of the change
The smallest individually landable piece of proper driver probing; the client library side of it.
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal | # |
(3) We need C calling convention because I'm not going to write load_symbol(
(5) PEBCAK - You're trying to run those uninstalled; the client library is (probably) looking for platform modules in /usr/local/
Set MIR_CLIENT_
I'll fix the rest.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:2119
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal | # |
> Set MIR_CLIENT_
Note that it's not just the examples but also the tests that need this.
This is bad in two ways:
1. It's more complicated to run executables from inside the build dir.
2. Forgetting to set the proper path may lead to platform libraries from the system being used inadvertently, instead of the expected ones from inside the build dir.
Until now, executing anything from inside the build dir was guaranteed to prefer code from that directory (due to cmake setting RPATH). This setup has served us well and I think we should keep it, even if doing so involves some hackery.
One way would be to search for platform libs in all the places the dynamic linker would look for, but unfortunately there doesn't seem to be a way to access the shared library search paths directly.
Another way would be to take advantage of the RPATH setting, for example:
1. Create a mir/libmirtestc
2. Build it in build/lib/, but don't install it.
3. When figuring out where to search for the platform libs ([1]), try to load the mir/libmirtestc
3.1. In case of an executable/library from the build dir, mir/libmirtestc
3.2. In case of an installed executable/library no RPATH is present and mir/libmirtestc
[1] In mcl::DefaultCon
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
> (5) PEBCAK - You're trying to run those uninstalled; the client library is
> (probably) looking for platform modules in /usr/local/
> and not finding them. If our examples actually called
> mir_connection_
>
> Set MIR_CLIENT_
> uninstalled.
That doesn't seem like an adequate answer:
We've always been able to run the built binaries from within the build tree (cmake does rpath magic).
This makes it far too easy to accidentally load the wrong (installed) binaries. Could we e.g. look relative to the current library?
Robert Carr (robertcarr) wrote : Posted in a previous version of this proposal | # |
Seems ok but yeah it would be nice to load from the build dir. One trick ive seen is to use wrapper scripts for the binaries in the build-dir (not installed of course) which exports the appropriate var.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:2120
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
I like the idea of taking advantage of RPATH. One of the best (and worst) things about CMake is its RPATH behaviour. And it's designed that way precisely so you can run things in-situ within the source tree. Haven't assessed alf's plan in detail though.
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
There's a hint in the dlopen docs about how it might be achieved:
dlopen()
...
o (ELF only) If the executable file for the calling program contains
a DT_RPATH tag, and does not contain a DT_RUNPATH tag, then the
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal | # |
Yeah, dlopen(
I'm doing the CMakery required to provide wrapper scripts, though. I
strongly prefer that the release build not contain code required only
to set up the test environment.
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal | # |
> I'm doing the CMakery required to provide wrapper scripts, though
Please make sure that it's still easy to run the examples and tests with gdb/valgrind/other tools.
Cemil Azizoglu (cemil-azizoglu) wrote : Posted in a previous version of this proposal | # |
Needs information:
Has this been tested under chroot/sbuild? (We don't wanna have last minute packaging issues during release.)
Nits/Comments:
719 + // TODO: Actually check what platform we're using, rather than blindly
Perhaps MirPlatformPackage should include a "platform signature". Something like "MESA", "ANDR", "STUB".
-------
android.so, mesa.so, dummy.so are too generic. client-
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:2128
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal | # |
@Cemil - tested, and passed, under sbuild.
I think I'd like to handle platform discovery a slightly different way; at the moment, MirPlatformPackage contains enough data to be a unique signature in itself.
The drivers are android.so, mesa.so, etc because they're in the client-platform/ directory. Their full name looks like client-
I think client-
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:2130
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:2131
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
$MIR_CLIENT_
We could write DefaultConnecti
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal | # |
I'm not entirely sure what you think is fragile about executable_path()? We're already using it elsewhere in the tests.
If you're concerned about the ../lib/ relative path, then; whoops! Now uses mtf::library_
I much prefer the current solution to using dladdr() in the release code. Using dladdr() we make some assumptions about the code that the compiler emits and if those assumptions fail then our release code fails. If the assumptions we set MIR_CLIENT_
Regardless of how we find the platform libraries by default we'll want a MIR_CLIENT_
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal | # |
There already is a stub_client_
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
> I'm not entirely sure what you think is fragile about executable_path()? We're
> already using it elsewhere in the tests.
Having looked again I think I misunderstood how this solution works. It isn't as bad as I thought.
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
183 === added file 'cmake/
184 --- cmake/wrapper-
185 +++ cmake/wrapper-
186 @@ -0,0 +1,5 @@
187 +#!/bin/sh
188 +
189 +export MIR_CLIENT_
190 +
191 +exec @BUILD_
Isn't this obsolete?
Cemil Azizoglu (cemil-azizoglu) wrote : Posted in a previous version of this proposal | # |
> @Cemil - tested, and passed, under sbuild.
Great. How about testing downstreams by installing the generated packages?
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal | # |
@Cemil - downstreams built and happy.
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
62 +#include <error.h>
...
73 + error(1, 0, "Surface creation failed: %s\n", mir_surface_
I think this is our first use of this GNU extension. I'm not opposed, but think it needs discussion before adding this dependency.
~~~~
671 + auto it = valid_displays.
672 + if (it == valid_displays.
673 + return;
674 +
675 + valid_displays.
AFICS this is a verbose and inefficient
valid_
But I wouldn't block on it as it isn't a critical path.
~~~~
741 + throw new std::runtime_
1. Don't throw pointers
2. Use BOOST_THROW_
~~~~
1067 + throw std::runtime_
...
1602 + throw std::logic_
Use BOOST_THROW_
Cemil Azizoglu (cemil-azizoglu) wrote : Posted in a previous version of this proposal | # |
Assuming downstreams not just build, but also run happily, I have no more to add.
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
Diff against target: 2448 lines (+975/-294) 68 files modified (has conflicts)
Text conflict in examples/
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
(2) Unnecessary (and undesirable) formatting changes:
575 -target_
576 +target_
577 + mirclient
578 +
because the first parameter is special and independent of those that follow it.
(4) Minor optimization: You can avoid a template instantiation using std::atomic_bool for
1250 + std::atomic<bool> connect_done;
(8) The library re-ordering appears to be pointless, or is there a reason?...
benchmarks/
Can we revert all changes to that file?
(9) Clients now start, but the wrapper that makes it possible feels inelegant...
$ ls -a bin/
mir_acceptance_
.mir_acceptance
mir_demo_
.mir_demo_
mir_demo_
.mir_demo_
mir_demo_
.mir_demo_
mir_demo_
.mir_demo_
...
I suspect we can do better without needing a wrapper. But if we do use this then please don't hide binaries from developers: ".foo-uninstalled" should be "foo.bin"
(10) wrapper.c compiles to 10KB, but could be replaced with a trivial shell script instead.
(11) This is new on the end. What's it do?
1343 +} MIR_COMMON_3;
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal | # |
On Wed, Dec 10, 2014 at 2:44 PM, Daniel van Vugt
<email address hidden> wrote:
> Review: Needs Fixing
>
> (2) Unnecessary (and undesirable) formatting changes:
> 575 -target_
> 576 +target_
> 577 + mirclient
> 578 +
> because the first parameter is special and independent of those that
> follow it.
>
> (4) Minor optimization: You can avoid a template instantiation using
> std::atomic_bool for
> 1250 + std::atomic<bool> connect_done;
>
> (8) The library re-ordering appears to be pointless, or is there a
> reason?...
> benchmarks/
> Can we revert all changes to that file?
>
> (9) Clients now start, but the wrapper that makes it possible feels
> inelegant...
> $ ls -a bin/
> mir_acceptance_
> .mir_acceptance
> mir_demo_
> .mir_demo_
> mir_demo_
> .mir_demo_
> mir_demo_
> .mir_demo_
> mir_demo_
> .mir_demo_
> ...
> I suspect we can do better without needing a wrapper. But if we do
> use this then please don't hide binaries from developers:
> ".foo-uninstalled" should be "foo.bin"
I think we need one of (a) a wrapper, or (b) code in the libraries we
release solely there to negate the need for a trivial wrapper.
Choosing (b) introduces the possibility of otherwise-
having user-visible bugs, so I chose (a).
I hid the real binaries in the time-honoured tradition of libtool
(which uses wrapper scripts, and hides everything in a .libs/
directory). You've got a choice between developers going “why are
there all these *.bin that don't work when I try to run them lying
around in my build tree” and “why are there all these hidden
binaries lying around in my build tree”.
I think hidden files are less confusing. The (normal) directory listing
lists everything you should be running.
> (10) wrapper.c compiles to 10KB, but could be replaced with a trivial
> shell script instead.
Said shell script makes it more difficult to run gdb which is why I
switched to wrapper.c.
>
> (11) This is new on the end. What's it do?
> 1343 +} MIR_COMMON_3;
“MIR_COMMON_3.1 depends on MIR_COMMON_3”
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal | # |
> (4) Minor optimization: You can avoid a template instantiation using
> std::atomic_bool for
> 1250 + std::atomic<bool> connect_done;
We already use std::atomic<bool> elsewhere, so this saves no template instatiations.
Also, std::atomic_bool is not the same as std::atomic<bool>. It's a vestigial attempt to match possibly C1y threading support.
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal | # |
looks good to me.
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
I'm not keen on the wrapper trick, but won't block when I don't have a better idea.
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
Text conflict in benchmarks/
1 conflicts encountered.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:2141
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
I still believe we could bend rpath* to our will and avoid wrappers. Although it's not impossible to figure that part out later and then drop the wrapper.
As for the minor cleanups, I still recommend resolving them. But I haven't revised this branch in detail. The end goal is rather important even if parts of the solution feel a bit ugly. I don't want to block it either.
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal | # |
I think I *have* resolved all your minor cleanups, with the exception
of replacing std::atomic<bool> with the non-equivalent std::atomic_bool.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:2142
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Alexandros Frantzis (afrantzis) : Posted in a previous version of this proposal | # |
Robert Carr (robertcarr) wrote : Posted in a previous version of this proposal | # |
LGTM. Happy we can still run gdb on the wrappers.
Surprised by the gtest matcher used outside of expectation setting at l1901
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:2143
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal | # |
Still need another merge with lp:mir it seems:
Text conflict in benchmarks/
Text conflict in tests/acceptanc
Andreas Pokorny (andreas-pokorny) wrote : | # |
I merged with the new changes on lp:mir and made tiny tweaks to share the SharedLibraryPr
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2144
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2145
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2146
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Chris Halse Rogers (raof) wrote : | # |
Still looks sensible to me
Daniel van Vugt (vanvugt) wrote : | # |
(2) Spurious whitespace:
511 target_
512 +
(4) Minor optimization: You can avoid a template instantiation using std::atomic_bool for
1176 + std::atomic<bool> connect_done;
(9) I think we can do better than the wrapper approach. And I might do a proof of concept for rpath magic. It would be easier to get it in from the beginning than to have to unwind and remove all the wrapper stuff later.
Andreas Pokorny (andreas-pokorny) wrote : | # |
> (9) I think we can do better than the wrapper approach. And I might do a proof
> of concept for rpath magic. It would be easier to get it in from the beginning
> than to have to unwind and remove all the wrapper stuff later.
I doubt rpath magic can that..
Andreas Pokorny (andreas-pokorny) wrote : | # |
>
> > (9) I think we can do better than the wrapper approach. And I might do a
> proof
> > of concept for rpath magic. It would be easier to get it in from the
> beginning
> > than to have to unwind and remove all the wrapper stuff later.
>
> I doubt rpath magic can that..
I mean the wrapper solves knowing in which directory to search for platform modules to load and probe, while rpath solves finding a library through a (path-free) library file name - by adding more search paths.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2147
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Andreas Pokorny (andreas-pokorny) wrote : | # |
[0;31m[ FAILED ] [m1 test, listed below:
[0;31m[ FAILED ] [mTestClientIn
1 FAILED TEST
[0;33m YOU HAVE 8 DISABLED TESTS
not related to this change.
--
lgtm
Alan Griffiths (alan-griffiths) wrote : | # |
40 +#include <iostream>
41 #include <assert.h>
42
43 namespace mt = mir::test;
44 @@ -45,7 +46,11 @@
45 mir_display_
46
47 auto surface = mir_connection_
48 - assert(
49 + if (!mir_surface_
50 + {
51 + std::cerr << "Surface creation failed: " << mir_surface_
52 + exit(1);
53 + }
54
55 return surface;
56 }
57 @@ -93,7 +98,11 @@
58 void TouchMeasuringC
59 {
60 auto connection = mir_connect_
61 - assert(
62 + if (!mir_connectio
63 + {
64 + std::cerr << "Connection to Mir failed: " << mir_connection_
65 + exit(1);
66 + }
wouldn't "#undef NDEBUG" before including <cassert> be simpler and clearer?
Alan Griffiths (alan-griffiths) wrote : | # |
995 === modified file 'src/client/
This file is /1/ effectively empty and /2/ isn't referenced. It can be removed. (Also the android counterpart)
Chris Halse Rogers (raof) wrote : | # |
On Thu, Dec 18, 2014 at 11:46 PM, Alan Griffiths <email address hidden>
wrote:
> 40 +#include <iostream>
> 41 #include <assert.h>
> 42
> 43 namespace mt = mir::test;
> 44 @@ -45,7 +46,11 @@
> 45 mir_display_
> 46
> 47 auto surface = mir_connection_
> &surface_params);
> 48 - assert(
> 49 + if (!mir_surface_
> 50 + {
> 51 + std::cerr << "Surface creation failed: " <<
> mir_surface_
> 52 + exit(1);
> 53 + }
> 54
> 55 return surface;
> 56 }
> 57 @@ -93,7 +98,11 @@
> 58 void TouchMeasuringC
> 59 {
> 60 auto connection = mir_connect_
> "frame-
> 61 - assert(
> 62 + if (!mir_connectio
> 63 + {
> 64 + std::cerr << "Connection to Mir failed: " <<
> mir_connection_
> 65 + exit(1);
> 66 + }
>
> wouldn't "#undef NDEBUG" before including <cassert> be simpler and
> clearer?
No, because that wouldn't print any diagnostics as to why the
connection/surface was invalid. I added those when debugging why the
frame_uniformity test was assert()ing :)
There might be an argument for having mir_assert_
functions in the client library that do this, now that we've got client
library logging!
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2148
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : | # |
Yes, rpath will have limitations. But there might be other alternatives to wrapping that are possible. Not sure yet, and I'm not blocking on the hypothesis.
Alan Griffiths (alan-griffiths) wrote : | # |
OK. I still have some misgivings, but nothing to block on. And the changes are useful.
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'benchmarks/frame-uniformity/main.cpp' | |||
2 | --- benchmarks/frame-uniformity/main.cpp 2014-10-26 02:13:36 +0000 | |||
3 | +++ benchmarks/frame-uniformity/main.cpp 2014-12-18 22:43:30 +0000 | |||
4 | @@ -17,6 +17,7 @@ | |||
5 | 17 | */ | 17 | */ |
6 | 18 | 18 | ||
7 | 19 | #include "frame_uniformity_test.h" | 19 | #include "frame_uniformity_test.h" |
8 | 20 | #include "mir_test_framework/executable_path.h" | ||
9 | 20 | 21 | ||
10 | 21 | #include <assert.h> | 22 | #include <assert.h> |
11 | 22 | #include <cmath> | 23 | #include <cmath> |
12 | @@ -27,6 +28,7 @@ | |||
13 | 27 | #include <gtest/gtest.h> | 28 | #include <gtest/gtest.h> |
14 | 28 | 29 | ||
15 | 29 | namespace geom = mir::geometry; | 30 | namespace geom = mir::geometry; |
16 | 31 | namespace mtf = mir_test_framework; | ||
17 | 30 | 32 | ||
18 | 31 | namespace | 33 | namespace |
19 | 32 | { | 34 | { |
20 | @@ -116,6 +118,11 @@ | |||
21 | 116 | int const run_count = 1; | 118 | int const run_count = 1; |
22 | 117 | double average_lag = 0, average_uniformity = 0; | 119 | double average_lag = 0, average_uniformity = 0; |
23 | 118 | 120 | ||
24 | 121 | // Ensure we load the correct platform libraries | ||
25 | 122 | setenv("MIR_CLIENT_PLATFORM_PATH", | ||
26 | 123 | (mtf::library_path() + "/client-modules").c_str(), | ||
27 | 124 | true); | ||
28 | 125 | |||
29 | 119 | for (int i = 0; i < run_count; i++) | 126 | for (int i = 0; i < run_count; i++) |
30 | 120 | { | 127 | { |
31 | 121 | FrameUniformityTest t({screen_size, touch_start_point, touch_end_point, touch_duration}); | 128 | FrameUniformityTest t({screen_size, touch_start_point, touch_end_point, touch_duration}); |
32 | 122 | 129 | ||
33 | === modified file 'benchmarks/frame-uniformity/touch_measuring_client.cpp' | |||
34 | --- benchmarks/frame-uniformity/touch_measuring_client.cpp 2014-10-26 02:13:36 +0000 | |||
35 | +++ benchmarks/frame-uniformity/touch_measuring_client.cpp 2014-12-18 22:43:30 +0000 | |||
36 | @@ -26,6 +26,7 @@ | |||
37 | 26 | #include <memory> | 26 | #include <memory> |
38 | 27 | #include <vector> | 27 | #include <vector> |
39 | 28 | 28 | ||
40 | 29 | #include <iostream> | ||
41 | 29 | #include <assert.h> | 30 | #include <assert.h> |
42 | 30 | 31 | ||
43 | 31 | namespace mt = mir::test; | 32 | namespace mt = mir::test; |
44 | @@ -45,7 +46,11 @@ | |||
45 | 45 | mir_display_output_id_invalid}; | 46 | mir_display_output_id_invalid}; |
46 | 46 | 47 | ||
47 | 47 | auto surface = mir_connection_create_surface_sync(connection, &surface_params); | 48 | auto surface = mir_connection_create_surface_sync(connection, &surface_params); |
49 | 48 | assert(mir_surface_is_valid(surface)); | 49 | if (!mir_surface_is_valid(surface)) |
50 | 50 | { | ||
51 | 51 | std::cerr << "Surface creation failed: " << mir_surface_get_error_message(surface) << std::endl; | ||
52 | 52 | exit(1); | ||
53 | 53 | } | ||
54 | 49 | 54 | ||
55 | 50 | return surface; | 55 | return surface; |
56 | 51 | } | 56 | } |
57 | @@ -93,7 +98,11 @@ | |||
58 | 93 | void TouchMeasuringClient::run(std::string const& connect_string) | 98 | void TouchMeasuringClient::run(std::string const& connect_string) |
59 | 94 | { | 99 | { |
60 | 95 | auto connection = mir_connect_sync(connect_string.c_str(), "frame-uniformity-test"); | 100 | auto connection = mir_connect_sync(connect_string.c_str(), "frame-uniformity-test"); |
62 | 96 | assert(mir_connection_is_valid(connection)); | 101 | if (!mir_connection_is_valid(connection)) |
63 | 102 | { | ||
64 | 103 | std::cerr << "Connection to Mir failed: " << mir_connection_get_error_message(connection) << std::endl; | ||
65 | 104 | exit(1); | ||
66 | 105 | } | ||
67 | 97 | 106 | ||
68 | 98 | /* | 107 | /* |
69 | 99 | * Set a null callback to avoid killing the process | 108 | * Set a null callback to avoid killing the process |
70 | 100 | 109 | ||
71 | === modified file 'cmake/FindGtest.cmake' | |||
72 | --- cmake/FindGtest.cmake 2014-11-24 03:09:00 +0000 | |||
73 | +++ cmake/FindGtest.cmake 2014-12-18 22:43:30 +0000 | |||
74 | @@ -20,10 +20,9 @@ | |||
75 | 20 | set(GMOCK_BINARY_DIR ${CMAKE_BINARY_DIR}/${GMOCK_PREFIX}/libs) | 20 | set(GMOCK_BINARY_DIR ${CMAKE_BINARY_DIR}/${GMOCK_PREFIX}/libs) |
76 | 21 | set(GTEST_BINARY_DIR ${GMOCK_BINARY_DIR}/gtest) | 21 | set(GTEST_BINARY_DIR ${GMOCK_BINARY_DIR}/gtest) |
77 | 22 | 22 | ||
79 | 23 | set(GTEST_CMAKE_ARGS "") | 23 | set(GTEST_CMAKE_ARGS "-DCMAKE_CXX_FLAGS=-fPIC") |
80 | 24 | if (${CMAKE_CROSSCOMPILING}) | 24 | if (${CMAKE_CROSSCOMPILING}) |
83 | 25 | set(GTEST_CMAKE_ARGS | 25 | list(APPEND GTEST_CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_MODULE_PATH}/LinuxCrossCompile.cmake) |
82 | 26 | -DCMAKE_TOOLCHAIN_FILE=${CMAKE_MODULE_PATH}/LinuxCrossCompile.cmake) | ||
84 | 27 | endif() | 26 | endif() |
85 | 28 | 27 | ||
86 | 29 | ExternalProject_Add( | 28 | ExternalProject_Add( |
87 | 30 | 29 | ||
88 | === modified file 'cmake/MirCommon.cmake' | |||
89 | --- cmake/MirCommon.cmake 2014-12-08 04:03:47 +0000 | |||
90 | +++ cmake/MirCommon.cmake 2014-12-18 22:43:30 +0000 | |||
91 | @@ -168,3 +168,26 @@ | |||
92 | 168 | add_dependencies(${TARGET} ${TARGET}_pch) | 168 | add_dependencies(${TARGET} ${TARGET}_pch) |
93 | 169 | endif() | 169 | endif() |
94 | 170 | endfunction() | 170 | endfunction() |
95 | 171 | |||
96 | 172 | function (mir_add_wrapped_executable TARGET) | ||
97 | 173 | set(REAL_EXECUTABLE .${TARGET}-uninstalled) | ||
98 | 174 | add_executable(${TARGET} ${ARGN}) | ||
99 | 175 | set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${REAL_EXECUTABLE}) | ||
100 | 176 | |||
101 | 177 | add_executable(${TARGET}-wrapper ${PROJECT_SOURCE_DIR}/cmake/src/wrapper.c) | ||
102 | 178 | set_property(TARGET ${TARGET}-wrapper | ||
103 | 179 | APPEND_STRING PROPERTY COMPILE_FLAGS " -DEXECUTABLE=\\\"${REAL_EXECUTABLE}\\\"") | ||
104 | 180 | set_property(TARGET ${TARGET}-wrapper | ||
105 | 181 | APPEND_STRING PROPERTY COMPILE_FLAGS " -DBUILD_PREFIX=\\\"${CMAKE_BINARY_DIR}\\\"") | ||
106 | 182 | set_property(TARGET ${TARGET}-wrapper | ||
107 | 183 | APPEND_STRING PROPERTY COMPILE_FLAGS " -D_BSD_SOURCE") | ||
108 | 184 | set_property(TARGET ${TARGET}-wrapper | ||
109 | 185 | PROPERTY OUTPUT_NAME ${TARGET}) | ||
110 | 186 | |||
111 | 187 | add_dependencies(${TARGET} ${TARGET}-wrapper) | ||
112 | 188 | |||
113 | 189 | install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/${REAL_EXECUTABLE} | ||
114 | 190 | DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
115 | 191 | RENAME ${TARGET} | ||
116 | 192 | ) | ||
117 | 193 | endfunction() | ||
118 | 171 | 194 | ||
119 | === added file 'cmake/src/wrapper.c' | |||
120 | --- cmake/src/wrapper.c 1970-01-01 00:00:00 +0000 | |||
121 | +++ cmake/src/wrapper.c 2014-12-18 22:43:30 +0000 | |||
122 | @@ -0,0 +1,16 @@ | |||
123 | 1 | #include <stdlib.h> | ||
124 | 2 | #include <stdio.h> | ||
125 | 3 | #include <unistd.h> | ||
126 | 4 | #include <assert.h> | ||
127 | 5 | |||
128 | 6 | int main(int argc, char** argv) | ||
129 | 7 | { | ||
130 | 8 | assert(argc > 0); | ||
131 | 9 | setenv("MIR_CLIENT_PLATFORM_PATH", BUILD_PREFIX "/lib/client-modules/", 1); | ||
132 | 10 | |||
133 | 11 | argv[0] = BUILD_PREFIX "/bin/" EXECUTABLE; | ||
134 | 12 | execv(argv[0], argv); | ||
135 | 13 | |||
136 | 14 | perror("Failed to execute real binary " EXECUTABLE); | ||
137 | 15 | return 1; | ||
138 | 16 | } | ||
139 | 0 | 17 | ||
140 | === modified file 'debian/control' | |||
141 | --- debian/control 2014-12-08 04:03:47 +0000 | |||
142 | +++ debian/control 2014-12-18 22:43:30 +0000 | |||
143 | @@ -143,7 +143,7 @@ | |||
144 | 143 | Pre-Depends: ${misc:Pre-Depends} | 143 | Pre-Depends: ${misc:Pre-Depends} |
145 | 144 | Depends: ${misc:Depends}, | 144 | Depends: ${misc:Depends}, |
146 | 145 | ${shlibs:Depends}, | 145 | ${shlibs:Depends}, |
148 | 146 | libmir${client-driver}-mesa | libmir${client-driver}-android, | 146 | mir-client-platform-mesa | mir-client-platform-android, |
149 | 147 | Description: Display server for Ubuntu - client library | 147 | Description: Display server for Ubuntu - client library |
150 | 148 | Mir is a display server running on linux systems, with a focus on efficiency, | 148 | Mir is a display server running on linux systems, with a focus on efficiency, |
151 | 149 | robust operation and a well-defined driver model. | 149 | robust operation and a well-defined driver model. |
152 | @@ -265,7 +265,7 @@ | |||
153 | 265 | Contains the shared libraries required for the Mir server and client. | 265 | Contains the shared libraries required for the Mir server and client. |
154 | 266 | 266 | ||
155 | 267 | # Longer-term these drivers should move out-of-tree | 267 | # Longer-term these drivers should move out-of-tree |
157 | 268 | Package: libmirclient8driver-mesa | 268 | Package: mir-client-platform-mesa |
158 | 269 | Section: libs | 269 | Section: libs |
159 | 270 | Architecture: i386 amd64 armhf arm64 | 270 | Architecture: i386 amd64 armhf arm64 |
160 | 271 | Multi-Arch: same | 271 | Multi-Arch: same |
161 | @@ -279,7 +279,7 @@ | |||
162 | 279 | Contains the shared libraries required for the Mir clients to interact with | 279 | Contains the shared libraries required for the Mir clients to interact with |
163 | 280 | the underlying hardware platform using the Mesa drivers. | 280 | the underlying hardware platform using the Mesa drivers. |
164 | 281 | 281 | ||
166 | 282 | Package: libmirclient8driver-android | 282 | Package: mir-client-platform-android |
167 | 283 | Section: libs | 283 | Section: libs |
168 | 284 | Architecture: i386 amd64 armhf | 284 | Architecture: i386 amd64 armhf |
169 | 285 | Multi-Arch: same | 285 | Multi-Arch: same |
170 | @@ -328,7 +328,7 @@ | |||
171 | 328 | Pre-Depends: ${misc:Pre-Depends} | 328 | Pre-Depends: ${misc:Pre-Depends} |
172 | 329 | Depends: ${misc:Depends}, | 329 | Depends: ${misc:Depends}, |
173 | 330 | libmir${platform-driver}-mesa, | 330 | libmir${platform-driver}-mesa, |
175 | 331 | libmir${client-driver}-mesa | 331 | mir-client-platform-mesa |
176 | 332 | Description: Display server for Ubuntu - desktop driver metapackage | 332 | Description: Display server for Ubuntu - desktop driver metapackage |
177 | 333 | Mir is a display server running on linux systems, with a focus on efficiency, | 333 | Mir is a display server running on linux systems, with a focus on efficiency, |
178 | 334 | robust operation and a well-defined driver model. | 334 | robust operation and a well-defined driver model. |
179 | @@ -343,7 +343,7 @@ | |||
180 | 343 | Pre-Depends: ${misc:Pre-Depends} | 343 | Pre-Depends: ${misc:Pre-Depends} |
181 | 344 | Depends: ${misc:Depends}, | 344 | Depends: ${misc:Depends}, |
182 | 345 | libmir${platform-driver}-android, | 345 | libmir${platform-driver}-android, |
184 | 346 | libmir${client-driver}-android | 346 | mir-client-platform-android |
185 | 347 | Description: Display server for Ubuntu - android driver metapackage | 347 | Description: Display server for Ubuntu - android driver metapackage |
186 | 348 | Mir is a display server running on linux systems, with a focus on efficiency, | 348 | Mir is a display server running on linux systems, with a focus on efficiency, |
187 | 349 | robust operation and a well-defined driver model. | 349 | robust operation and a well-defined driver model. |
188 | 350 | 350 | ||
189 | === modified file 'debian/create_postinst_prerm_scripts.sh' | |||
190 | --- debian/create_postinst_prerm_scripts.sh 2014-12-08 04:03:47 +0000 | |||
191 | +++ debian/create_postinst_prerm_scripts.sh 2014-12-18 22:43:30 +0000 | |||
192 | @@ -6,7 +6,7 @@ | |||
193 | 6 | deb_host_arch=$1 | 6 | deb_host_arch=$1 |
194 | 7 | deb_host_multiarch=$2 | 7 | deb_host_multiarch=$2 |
195 | 8 | 8 | ||
197 | 9 | mir_platform_types="${PLATFORM_DRIVER} ${CLIENT_DRIVER}" | 9 | mir_platform_types="${PLATFORM_DRIVER}" |
198 | 10 | case $deb_host_arch in | 10 | case $deb_host_arch in |
199 | 11 | arm64) | 11 | arm64) |
200 | 12 | mir_platforms="mesa" | 12 | mir_platforms="mesa" |
201 | 13 | 13 | ||
202 | === renamed file 'debian/libmirclient8driver-android.install' => 'debian/mir-client-platform-android.install' | |||
203 | --- debian/libmirclient8driver-android.install 2014-12-08 04:03:47 +0000 | |||
204 | +++ debian/mir-client-platform-android.install 2014-12-18 22:43:30 +0000 | |||
205 | @@ -1,1 +1,1 @@ | |||
207 | 1 | usr/lib/*/mir/client*driver/android/* | 1 | usr/lib/*/mir/client-platform/android.so |
208 | 2 | 2 | ||
209 | === renamed file 'debian/libmirclient8driver-mesa.install' => 'debian/mir-client-platform-mesa.install' | |||
210 | --- debian/libmirclient8driver-mesa.install 2014-12-08 04:03:47 +0000 | |||
211 | +++ debian/mir-client-platform-mesa.install 2014-12-18 22:43:30 +0000 | |||
212 | @@ -1,1 +1,1 @@ | |||
214 | 1 | usr/lib/*/mir/client*driver/mesa/* | 1 | usr/lib/*/mir/client-platform/mesa.so |
215 | 2 | 2 | ||
216 | === modified file 'debian/mir-test-tools.install' | |||
217 | --- debian/mir-test-tools.install 2014-12-08 04:03:47 +0000 | |||
218 | +++ debian/mir-test-tools.install 2014-12-18 22:43:30 +0000 | |||
219 | @@ -6,3 +6,4 @@ | |||
220 | 6 | usr/lib/*/mir/tools/libmirclientlttng.so | 6 | usr/lib/*/mir/tools/libmirclientlttng.so |
221 | 7 | usr/lib/*/mir/tools/libmirserverlttng.so | 7 | usr/lib/*/mir/tools/libmirserverlttng.so |
222 | 8 | usr/lib/*/libmirplatformstub.so | 8 | usr/lib/*/libmirplatformstub.so |
223 | 9 | usr/lib/*/mir/client-platform/dummy.so | ||
224 | 9 | 10 | ||
225 | === modified file 'debian/rules' | |||
226 | --- debian/rules 2014-12-08 04:03:47 +0000 | |||
227 | +++ debian/rules 2014-12-18 22:43:30 +0000 | |||
228 | @@ -14,7 +14,6 @@ | |||
229 | 14 | export CXX=$(DEB_HOST_GNU_TYPE)-g++-4.9 | 14 | export CXX=$(DEB_HOST_GNU_TYPE)-g++-4.9 |
230 | 15 | 15 | ||
231 | 16 | export PLATFORM_DRIVER = platform5driver | 16 | export PLATFORM_DRIVER = platform5driver |
232 | 17 | export CLIENT_DRIVER = client8driver | ||
233 | 18 | 17 | ||
234 | 19 | %: | 18 | %: |
235 | 20 | dh $@ --parallel --fail-missing | 19 | dh $@ --parallel --fail-missing |
236 | @@ -57,10 +56,9 @@ | |||
237 | 57 | # Nothing outside Mir should link to libmirprotobuf directly. | 56 | # Nothing outside Mir should link to libmirprotobuf directly. |
238 | 58 | # Delete the symlink so that --fail-missing doesn't think we've missed it | 57 | # Delete the symlink so that --fail-missing doesn't think we've missed it |
239 | 59 | # accidentally. | 58 | # accidentally. |
241 | 60 | rm debian/tmp/usr/lib/*/libmirprotobuf.so | 59 | -rm debian/tmp/usr/lib/*/libmirprotobuf.so |
242 | 61 | dh_install --fail-missing \ | 60 | dh_install --fail-missing \ |
245 | 62 | -Xusr/lib/$(DEB_HOST_MULTIARCH)/libmir$(PLATFORM_DRIVER).so \ | 61 | -Xusr/lib/$(DEB_HOST_MULTIARCH)/libmir$(PLATFORM_DRIVER).so |
244 | 63 | -Xusr/lib/$(DEB_HOST_MULTIARCH)/libmir$(CLIENT_DRIVER).so | ||
246 | 64 | sh debian/install_ld_so_conf.sh $(DEB_HOST_ARCH) $(DEB_HOST_MULTIARCH) | 62 | sh debian/install_ld_so_conf.sh $(DEB_HOST_ARCH) $(DEB_HOST_MULTIARCH) |
247 | 65 | 63 | ||
248 | 66 | override_dh_installdeb: | 64 | override_dh_installdeb: |
249 | @@ -70,5 +68,4 @@ | |||
250 | 70 | 68 | ||
251 | 71 | override_dh_gencontrol: | 69 | override_dh_gencontrol: |
252 | 72 | dh_gencontrol -- \ | 70 | dh_gencontrol -- \ |
255 | 73 | -Vplatform-driver=$(PLATFORM_DRIVER) \ | 71 | -Vplatform-driver=$(PLATFORM_DRIVER) |
254 | 74 | -Vclient-driver=$(CLIENT_DRIVER) | ||
256 | 75 | 72 | ||
257 | === modified file 'examples/CMakeLists.txt' | |||
258 | --- examples/CMakeLists.txt 2014-12-17 06:23:34 +0000 | |||
259 | +++ examples/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
260 | @@ -32,38 +32,38 @@ | |||
261 | 32 | ${EGL_LIBRARIES} | 32 | ${EGL_LIBRARIES} |
262 | 33 | ${GLESv2_LIBRARIES} | 33 | ${GLESv2_LIBRARIES} |
263 | 34 | ) | 34 | ) |
265 | 35 | add_executable(mir_demo_client_eglflash | 35 | mir_add_wrapped_executable(mir_demo_client_eglflash |
266 | 36 | eglflash.c | 36 | eglflash.c |
267 | 37 | ) | 37 | ) |
268 | 38 | target_link_libraries(mir_demo_client_eglflash | 38 | target_link_libraries(mir_demo_client_eglflash |
269 | 39 | eglapp | 39 | eglapp |
270 | 40 | ) | 40 | ) |
272 | 41 | add_executable(mir_demo_client_egltriangle | 41 | mir_add_wrapped_executable(mir_demo_client_egltriangle |
273 | 42 | egltriangle.c | 42 | egltriangle.c |
274 | 43 | ) | 43 | ) |
275 | 44 | target_link_libraries(mir_demo_client_egltriangle | 44 | target_link_libraries(mir_demo_client_egltriangle |
276 | 45 | eglapp | 45 | eglapp |
277 | 46 | ) | 46 | ) |
279 | 47 | add_executable(mir_demo_client_eglcounter | 47 | mir_add_wrapped_executable(mir_demo_client_eglcounter |
280 | 48 | eglcounter.cpp | 48 | eglcounter.cpp |
281 | 49 | ) | 49 | ) |
282 | 50 | target_link_libraries(mir_demo_client_eglcounter | 50 | target_link_libraries(mir_demo_client_eglcounter |
283 | 51 | eglapp | 51 | eglapp |
284 | 52 | ) | 52 | ) |
286 | 53 | add_executable(mir_demo_client_eglplasma | 53 | mir_add_wrapped_executable(mir_demo_client_eglplasma |
287 | 54 | eglplasma.c | 54 | eglplasma.c |
288 | 55 | ) | 55 | ) |
289 | 56 | target_link_libraries(mir_demo_client_eglplasma | 56 | target_link_libraries(mir_demo_client_eglplasma |
290 | 57 | eglapp | 57 | eglapp |
291 | 58 | ) | 58 | ) |
293 | 59 | add_executable(mir_demo_client_cursors | 59 | mir_add_wrapped_executable(mir_demo_client_cursors |
294 | 60 | cursors_demo_client.c | 60 | cursors_demo_client.c |
295 | 61 | ) | 61 | ) |
296 | 62 | target_link_libraries(mir_demo_client_cursors | 62 | target_link_libraries(mir_demo_client_cursors |
297 | 63 | eglapp | 63 | eglapp |
298 | 64 | ) | 64 | ) |
299 | 65 | 65 | ||
301 | 66 | add_executable(mir_demo_client_basic | 66 | mir_add_wrapped_executable(mir_demo_client_basic |
302 | 67 | basic.c | 67 | basic.c |
303 | 68 | ) | 68 | ) |
304 | 69 | 69 | ||
305 | @@ -75,22 +75,22 @@ | |||
306 | 75 | ${CMAKE_THREAD_LIBS_INIT} | 75 | ${CMAKE_THREAD_LIBS_INIT} |
307 | 76 | ) | 76 | ) |
308 | 77 | 77 | ||
311 | 78 | add_executable(mir_test_client_release_at_exit release_at_exit.c) | 78 | mir_add_wrapped_executable(mir_demo_client_release_at_exit release_at_exit.c) |
312 | 79 | target_link_libraries(mir_test_client_release_at_exit mirclient) | 79 | target_link_libraries(mir_demo_client_release_at_exit mirclient) |
313 | 80 | 80 | ||
315 | 81 | add_executable(mir_demo_client_multiwin multiwin.c) | 81 | mir_add_wrapped_executable(mir_demo_client_multiwin multiwin.c) |
316 | 82 | target_link_libraries(mir_demo_client_multiwin mirclient) | 82 | target_link_libraries(mir_demo_client_multiwin mirclient) |
317 | 83 | 83 | ||
319 | 84 | add_executable(mir_demo_client_fingerpaint fingerpaint.c) | 84 | mir_add_wrapped_executable(mir_demo_client_fingerpaint fingerpaint.c) |
320 | 85 | target_link_libraries(mir_demo_client_fingerpaint mirclient) | 85 | target_link_libraries(mir_demo_client_fingerpaint mirclient) |
321 | 86 | 86 | ||
323 | 87 | add_executable(mir_demo_client_progressbar progressbar.c) | 87 | mir_add_wrapped_executable(mir_demo_client_progressbar progressbar.c) |
324 | 88 | target_link_libraries(mir_demo_client_progressbar mirclient) | 88 | target_link_libraries(mir_demo_client_progressbar mirclient) |
325 | 89 | 89 | ||
327 | 90 | add_executable(mir_demo_client_display_config demo_client_display_config.c) | 90 | mir_add_wrapped_executable(mir_demo_client_display_config demo_client_display_config.c) |
328 | 91 | target_link_libraries(mir_demo_client_display_config eglapp) | 91 | target_link_libraries(mir_demo_client_display_config eglapp) |
329 | 92 | 92 | ||
331 | 93 | add_executable(mir_demo_client_flicker | 93 | mir_add_wrapped_executable(mir_demo_client_flicker |
332 | 94 | flicker.c | 94 | flicker.c |
333 | 95 | ) | 95 | ) |
334 | 96 | 96 | ||
335 | @@ -102,7 +102,7 @@ | |||
336 | 102 | ${CMAKE_THREAD_LIBS_INIT} | 102 | ${CMAKE_THREAD_LIBS_INIT} |
337 | 103 | ) | 103 | ) |
338 | 104 | 104 | ||
340 | 105 | add_executable(mir_demo_client_scroll | 105 | mir_add_wrapped_executable(mir_demo_client_scroll |
341 | 106 | scroll.cpp | 106 | scroll.cpp |
342 | 107 | ) | 107 | ) |
343 | 108 | 108 | ||
344 | @@ -118,7 +118,7 @@ | |||
345 | 118 | 118 | ||
346 | 119 | ) | 119 | ) |
347 | 120 | 120 | ||
349 | 121 | add_executable(mir_demo_client_prompt_session prompt_session.c) | 121 | mir_add_wrapped_executable(mir_demo_client_prompt_session prompt_session.c) |
350 | 122 | target_link_libraries(mir_demo_client_prompt_session mirclient) | 122 | target_link_libraries(mir_demo_client_prompt_session mirclient) |
351 | 123 | 123 | ||
352 | 124 | add_library(mirdraw STATIC graphics_utils.cpp) | 124 | add_library(mirdraw STATIC graphics_utils.cpp) |
353 | @@ -131,7 +131,7 @@ | |||
354 | 131 | ${GLESv2_INCLUDE_DIRS} | 131 | ${GLESv2_INCLUDE_DIRS} |
355 | 132 | ) | 132 | ) |
356 | 133 | 133 | ||
358 | 134 | add_executable(mir_demo_standalone_render_to_fb | 134 | mir_add_wrapped_executable(mir_demo_standalone_render_to_fb |
359 | 135 | render_to_fb.cpp | 135 | render_to_fb.cpp |
360 | 136 | ) | 136 | ) |
361 | 137 | 137 | ||
362 | @@ -141,25 +141,7 @@ | |||
363 | 141 | ${Boost_LIBRARIES} | 141 | ${Boost_LIBRARIES} |
364 | 142 | ) | 142 | ) |
365 | 143 | 143 | ||
385 | 144 | set (INSTALL_DEMOS | 144 | mir_add_wrapped_executable(mir_demo_server |
367 | 145 | mir_demo_client_basic | ||
368 | 146 | mir_demo_client_flicker | ||
369 | 147 | mir_demo_client_scroll | ||
370 | 148 | mir_demo_client_eglflash | ||
371 | 149 | mir_demo_client_egltriangle | ||
372 | 150 | mir_demo_client_eglplasma | ||
373 | 151 | mir_demo_client_eglcounter | ||
374 | 152 | mir_demo_client_fingerpaint | ||
375 | 153 | mir_demo_client_multiwin | ||
376 | 154 | mir_demo_client_display_config | ||
377 | 155 | mir_demo_client_progressbar | ||
378 | 156 | mir_demo_client_prompt_session | ||
379 | 157 | mir_demo_standalone_render_to_fb | ||
380 | 158 | ) | ||
381 | 159 | |||
382 | 160 | install(TARGETS ${INSTALL_DEMOS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
383 | 161 | |||
384 | 162 | add_executable(mir_demo_server | ||
386 | 163 | server_example.cpp | 145 | server_example.cpp |
387 | 164 | glog_logger.cpp | 146 | glog_logger.cpp |
388 | 165 | ) | 147 | ) |
389 | @@ -172,17 +154,10 @@ | |||
390 | 172 | ${Boost_LIBRARIES} | 154 | ${Boost_LIBRARIES} |
391 | 173 | ) | 155 | ) |
392 | 174 | 156 | ||
398 | 175 | install(TARGETS mir_demo_server | 157 | mir_add_wrapped_executable(mir_demo_server_minimal server_minimal.cpp) |
394 | 176 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
395 | 177 | ) | ||
396 | 178 | |||
397 | 179 | add_executable(mir_demo_server_minimal server_minimal.cpp) | ||
399 | 180 | target_link_libraries(mir_demo_server_minimal mirserver) | 158 | target_link_libraries(mir_demo_server_minimal mirserver) |
400 | 181 | install(TARGETS mir_demo_server_minimal | ||
401 | 182 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
402 | 183 | ) | ||
403 | 184 | 159 | ||
405 | 185 | add_executable(mir_demo_standalone_render_overlays | 160 | mir_add_wrapped_executable(mir_demo_standalone_render_overlays |
406 | 186 | render_overlays.cpp | 161 | render_overlays.cpp |
407 | 187 | ) | 162 | ) |
408 | 188 | 163 | ||
409 | @@ -190,7 +165,3 @@ | |||
410 | 190 | mirserver | 165 | mirserver |
411 | 191 | mircommon | 166 | mircommon |
412 | 192 | ) | 167 | ) |
413 | 193 | |||
414 | 194 | install(TARGETS mir_demo_standalone_render_overlays | ||
415 | 195 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
416 | 196 | ) | ||
417 | 197 | 168 | ||
418 | === modified file 'playground/demo-shell/CMakeLists.txt' | |||
419 | --- playground/demo-shell/CMakeLists.txt 2014-12-17 02:32:08 +0000 | |||
420 | +++ playground/demo-shell/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
421 | @@ -4,7 +4,7 @@ | |||
422 | 4 | window_manager.cpp | 4 | window_manager.cpp |
423 | 5 | ) | 5 | ) |
424 | 6 | 6 | ||
426 | 7 | add_executable(mir_proving_server | 7 | mir_add_wrapped_executable(mir_proving_server |
427 | 8 | demo_shell.cpp | 8 | demo_shell.cpp |
428 | 9 | ) | 9 | ) |
429 | 10 | 10 | ||
430 | @@ -14,5 +14,3 @@ | |||
431 | 14 | playgroundserverconfig | 14 | playgroundserverconfig |
432 | 15 | exampleserverconfig | 15 | exampleserverconfig |
433 | 16 | ) | 16 | ) |
434 | 17 | |||
435 | 18 | install(TARGETS mir_proving_server RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
436 | 19 | 17 | ||
437 | === modified file 'src/CMakeLists.txt' | |||
438 | --- src/CMakeLists.txt 2014-12-17 06:58:58 +0000 | |||
439 | +++ src/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
440 | @@ -34,3 +34,4 @@ | |||
441 | 34 | set(MIR_PLATFORM_REFERENCES ${MIR_PLATFORM_REFERENCES} PARENT_SCOPE) | 34 | set(MIR_PLATFORM_REFERENCES ${MIR_PLATFORM_REFERENCES} PARENT_SCOPE) |
442 | 35 | set(MIR_COMMON_OBJECTS ${MIR_COMMON_OBJECTS} PARENT_SCOPE) | 35 | set(MIR_COMMON_OBJECTS ${MIR_COMMON_OBJECTS} PARENT_SCOPE) |
443 | 36 | set(MIR_COMMON_REFERENCES ${MIR_COMMON_REFERENCES} PARENT_SCOPE) | 36 | set(MIR_COMMON_REFERENCES ${MIR_COMMON_REFERENCES} PARENT_SCOPE) |
444 | 37 | set(MIR_CLIENT_PLATFORM_PATH ${MIR_CLIENT_PLATFORM_PATH} PARENT_SCOPE) | ||
445 | 37 | 38 | ||
446 | === modified file 'src/client/CMakeLists.txt' | |||
447 | --- src/client/CMakeLists.txt 2014-12-15 06:24:03 +0000 | |||
448 | +++ src/client/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
449 | @@ -1,13 +1,3 @@ | |||
450 | 1 | set(MIRCLIENT_ABI 8) | ||
451 | 2 | set(CLIENT_DRIVER client${MIRCLIENT_ABI}driver) | ||
452 | 3 | set(MIR_CLIENT_DRIVER mir${CLIENT_DRIVER}) | ||
453 | 4 | set(MIR_CLIENT_DRIVER_BINARY lib${MIR_CLIENT_DRIVER}.so | ||
454 | 5 | CACHE STRING "File name of Mir client drivers") | ||
455 | 6 | add_definitions( | ||
456 | 7 | -DMIR_CLIENT_DRIVER_BINARY="${MIR_CLIENT_DRIVER_BINARY}" | ||
457 | 8 | -DMIR_LOG_COMPONENT_FALLBACK="mirclient" | ||
458 | 9 | ) | ||
459 | 10 | |||
460 | 11 | set(PREFIX "${CMAKE_INSTALL_PREFIX}") | 1 | set(PREFIX "${CMAKE_INSTALL_PREFIX}") |
461 | 12 | set(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}") | 2 | set(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}") |
462 | 13 | set(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}") | 3 | set(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}") |
463 | @@ -33,6 +23,20 @@ | |||
464 | 33 | ${DRM_INCLUDE_DIRS} | 23 | ${DRM_INCLUDE_DIRS} |
465 | 34 | ) | 24 | ) |
466 | 35 | 25 | ||
467 | 26 | set(MIRCLIENT_ABI 8) | ||
468 | 27 | set(CLIENT_PLATFORM_VERSION "MIR_CLIENT_PLATFORM_2") | ||
469 | 28 | set(symbol_map ${CMAKE_SOURCE_DIR}/src/client/symbols.map) | ||
470 | 29 | |||
471 | 30 | set(MIR_CLIENT_PLATFORM_PATH | ||
472 | 31 | ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/mir/client-platform | ||
473 | 32 | ) | ||
474 | 33 | set(MIR_CLIENT_PLATFORM_PATH ${MIR_CLIENT_PLATFORM_PATH} PARENT_SCOPE) | ||
475 | 34 | |||
476 | 35 | add_definitions(-DMIR_CLIENT_PLATFORM_PATH="${MIR_CLIENT_PLATFORM_PATH}/") | ||
477 | 36 | add_definitions(-DCLIENT_PLATFORM_VERSION="${CLIENT_PLATFORM_VERSION}") | ||
478 | 37 | add_definitions(-DMIR_LOGGING_COMPONENT_FALLBACK="mirclient") | ||
479 | 38 | |||
480 | 39 | |||
481 | 36 | add_subdirectory(rpc/) | 40 | add_subdirectory(rpc/) |
482 | 37 | add_subdirectory(lttng/) | 41 | add_subdirectory(lttng/) |
483 | 38 | 42 | ||
484 | @@ -72,20 +76,17 @@ | |||
485 | 72 | mir_prompt_session.cpp | 76 | mir_prompt_session.cpp |
486 | 73 | mir_prompt_session_api.cpp | 77 | mir_prompt_session_api.cpp |
487 | 74 | mir_event_distributor.cpp | 78 | mir_event_distributor.cpp |
488 | 79 | probing_client_platform_factory.cpp | ||
489 | 75 | periodic_perf_report.cpp | 80 | periodic_perf_report.cpp |
490 | 76 | mir_platform_message_api.cpp | 81 | mir_platform_message_api.cpp |
491 | 77 | ) | 82 | ) |
492 | 78 | 83 | ||
495 | 79 | add_library( | 84 | add_library(mirclient SHARED |
494 | 80 | mirclient SHARED | ||
496 | 81 | 85 | ||
497 | 82 | $<TARGET_OBJECTS:mirclientobjects> | 86 | $<TARGET_OBJECTS:mirclientobjects> |
498 | 83 | ) | 87 | ) |
499 | 84 | 88 | ||
504 | 85 | set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map) | 89 | set_target_properties(mirclient |
501 | 86 | |||
502 | 87 | set_target_properties( | ||
503 | 88 | mirclient | ||
505 | 89 | 90 | ||
506 | 90 | PROPERTIES | 91 | PROPERTIES |
507 | 91 | SOVERSION ${MIRCLIENT_ABI} | 92 | SOVERSION ${MIRCLIENT_ABI} |
508 | 92 | 93 | ||
509 | === modified file 'src/client/android/CMakeLists.txt' | |||
510 | --- src/client/android/CMakeLists.txt 2014-12-08 04:03:47 +0000 | |||
511 | +++ src/client/android/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
512 | @@ -14,17 +14,18 @@ | |||
513 | 14 | ) | 14 | ) |
514 | 15 | 15 | ||
515 | 16 | add_library( | 16 | add_library( |
518 | 17 | mirclientplatformandroid SHARED | 17 | mirclientplatformandroid MODULE |
519 | 18 | 18 | ||
520 | 19 | $<TARGET_OBJECTS:mirclientplatformandroidobjects> | 19 | $<TARGET_OBJECTS:mirclientplatformandroidobjects> |
521 | 20 | $<TARGET_OBJECTS:mirclient_platformimpl> | 20 | $<TARGET_OBJECTS:mirclient_platformimpl> |
522 | 21 | ) | 21 | ) |
523 | 22 | 22 | ||
524 | 23 | set_target_properties( | 23 | set_target_properties( |
525 | 24 | mirclientplatformandroid PROPERTIES | 24 | mirclientplatformandroid PROPERTIES |
529 | 25 | OUTPUT_NAME ${MIR_CLIENT_DRIVER} | 25 | OUTPUT_NAME android |
530 | 26 | LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/android | 26 | LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/client-modules |
531 | 27 | LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}" | 27 | PREFIX "" |
532 | 28 | LINK_FLAGS "-Wl,--version-script,${symbol_map}" | ||
533 | 28 | ) | 29 | ) |
534 | 29 | 30 | ||
535 | 30 | target_link_libraries(mirclientplatformandroid | 31 | target_link_libraries(mirclientplatformandroid |
536 | @@ -33,20 +34,4 @@ | |||
537 | 33 | ${LIBHARDWARE_LIBRARIES} | 34 | ${LIBHARDWARE_LIBRARIES} |
538 | 34 | ) | 35 | ) |
539 | 35 | 36 | ||
557 | 36 | install(TARGETS mirclientplatformandroid LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/${CLIENT_DRIVER}/android) | 37 | install(TARGETS mirclientplatformandroid LIBRARY DESTINATION ${MIR_CLIENT_PLATFORM_PATH}) |
541 | 37 | |||
542 | 38 | if (MIR_TEST_PLATFORM STREQUAL "android") | ||
543 | 39 | add_custom_command(TARGET mirclientplatformandroid | ||
544 | 40 | POST_BUILD | ||
545 | 41 | COMMAND ${CMAKE_COMMAND} -E remove ${MIR_CLIENT_DRIVER_BINARY} | ||
546 | 42 | COMMAND ${CMAKE_COMMAND} -E create_symlink android/$<TARGET_FILE_NAME:mirclientplatformandroid> ${MIR_CLIENT_DRIVER_BINARY} | ||
547 | 43 | WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} | ||
548 | 44 | ) | ||
549 | 45 | |||
550 | 46 | install(CODE | ||
551 | 47 | "execute_process( | ||
552 | 48 | COMMAND ln -sf mir/${CLIENT_DRIVER}/android/${MIR_CLIENT_DRIVER_BINARY} | ||
553 | 49 | WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} | ||
554 | 50 | )" | ||
555 | 51 | ) | ||
556 | 52 | endif() | ||
558 | 53 | 38 | ||
559 | === modified file 'src/client/android/android_native_display_container.cpp' | |||
560 | --- src/client/android/android_native_display_container.cpp 2014-12-08 04:03:47 +0000 | |||
561 | +++ src/client/android/android_native_display_container.cpp 2014-12-18 22:43:30 +0000 | |||
562 | @@ -62,16 +62,24 @@ | |||
563 | 62 | bool | 62 | bool |
564 | 63 | mcla::AndroidNativeDisplayContainer::validate(MirEGLNativeDisplayType display) const | 63 | mcla::AndroidNativeDisplayContainer::validate(MirEGLNativeDisplayType display) const |
565 | 64 | { | 64 | { |
567 | 65 | return mir_connection_is_valid(static_cast<MirConnection*>(display)); | 65 | std::lock_guard<std::mutex> lg(guard); |
568 | 66 | return (valid_displays.find(display) != valid_displays.end()); | ||
569 | 66 | } | 67 | } |
570 | 67 | 68 | ||
571 | 68 | MirEGLNativeDisplayType | 69 | MirEGLNativeDisplayType |
573 | 69 | mcla::AndroidNativeDisplayContainer::create(MirConnection* connection) | 70 | mcla::AndroidNativeDisplayContainer::create(ClientContext* context) |
574 | 70 | { | 71 | { |
576 | 71 | return static_cast<MirEGLNativeDisplayType>(connection); | 72 | std::lock_guard<std::mutex> lg(guard); |
577 | 73 | auto egl_display = static_cast<MirEGLNativeDisplayType>(context); | ||
578 | 74 | valid_displays.insert(egl_display); | ||
579 | 75 | |||
580 | 76 | return egl_display; | ||
581 | 72 | } | 77 | } |
582 | 73 | 78 | ||
583 | 74 | void | 79 | void |
585 | 75 | mcla::AndroidNativeDisplayContainer::release(MirEGLNativeDisplayType /* display */) | 80 | mcla::AndroidNativeDisplayContainer::release(MirEGLNativeDisplayType display) |
586 | 76 | { | 81 | { |
587 | 82 | std::lock_guard<std::mutex> lg(guard); | ||
588 | 83 | |||
589 | 84 | valid_displays.erase(display); | ||
590 | 77 | } | 85 | } |
591 | 78 | 86 | ||
592 | === modified file 'src/client/android/android_native_display_container.h' | |||
593 | --- src/client/android/android_native_display_container.h 2013-05-02 00:11:18 +0000 | |||
594 | +++ src/client/android/android_native_display_container.h 2014-12-18 22:43:30 +0000 | |||
595 | @@ -23,6 +23,9 @@ | |||
596 | 23 | 23 | ||
597 | 24 | #include "mir_toolkit/client_types.h" | 24 | #include "mir_toolkit/client_types.h" |
598 | 25 | 25 | ||
599 | 26 | #include <unordered_set> | ||
600 | 27 | #include <mutex> | ||
601 | 28 | |||
602 | 26 | namespace mir | 29 | namespace mir |
603 | 27 | { | 30 | { |
604 | 28 | namespace client | 31 | namespace client |
605 | @@ -36,14 +39,18 @@ | |||
606 | 36 | AndroidNativeDisplayContainer(); | 39 | AndroidNativeDisplayContainer(); |
607 | 37 | virtual ~AndroidNativeDisplayContainer(); | 40 | virtual ~AndroidNativeDisplayContainer(); |
608 | 38 | 41 | ||
611 | 39 | MirEGLNativeDisplayType create(MirConnection* connection); | 42 | MirEGLNativeDisplayType create(ClientContext* context) override; |
612 | 40 | void release(MirEGLNativeDisplayType display); | 43 | void release(MirEGLNativeDisplayType display) override; |
613 | 41 | 44 | ||
615 | 42 | bool validate(MirEGLNativeDisplayType display) const; | 45 | bool validate(MirEGLNativeDisplayType display) const override; |
616 | 43 | 46 | ||
617 | 44 | protected: | 47 | protected: |
618 | 45 | AndroidNativeDisplayContainer(AndroidNativeDisplayContainer const&) = delete; | 48 | AndroidNativeDisplayContainer(AndroidNativeDisplayContainer const&) = delete; |
619 | 46 | AndroidNativeDisplayContainer& operator=(AndroidNativeDisplayContainer const&) = delete; | 49 | AndroidNativeDisplayContainer& operator=(AndroidNativeDisplayContainer const&) = delete; |
620 | 50 | |||
621 | 51 | private: | ||
622 | 52 | std::mutex mutable guard; | ||
623 | 53 | std::unordered_set<MirEGLNativeDisplayType> valid_displays; | ||
624 | 47 | }; | 54 | }; |
625 | 48 | 55 | ||
626 | 49 | } | 56 | } |
627 | 50 | 57 | ||
628 | === modified file 'src/client/android/client_platform_factory.cpp' | |||
629 | --- src/client/android/client_platform_factory.cpp 2014-02-07 15:43:41 +0000 | |||
630 | +++ src/client/android/client_platform_factory.cpp 2014-12-18 22:43:30 +0000 | |||
631 | @@ -16,19 +16,36 @@ | |||
632 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
633 | 17 | */ | 17 | */ |
634 | 18 | 18 | ||
636 | 19 | #include "client_platform_factory.h" | 19 | #include "../client_platform_factory.h" |
637 | 20 | #include "mir_toolkit/client_types.h" | ||
638 | 21 | #include "../client_context.h" | ||
639 | 20 | #include "android_client_platform.h" | 22 | #include "android_client_platform.h" |
640 | 21 | 23 | ||
641 | 24 | #include <boost/throw_exception.hpp> | ||
642 | 25 | #include <stdexcept> | ||
643 | 26 | |||
644 | 22 | namespace mcl = mir::client; | 27 | namespace mcl = mir::client; |
645 | 23 | namespace mcla = mcl::android; | 28 | namespace mcla = mcl::android; |
646 | 24 | 29 | ||
649 | 25 | std::shared_ptr<mcl::ClientPlatform> | 30 | extern "C" std::shared_ptr<mcl::ClientPlatform> |
650 | 26 | mcla::ClientPlatformFactory::create_client_platform(mcl::ClientContext* /*context*/) | 31 | mcl::create_client_platform(mcl::ClientContext* context) |
651 | 27 | { | 32 | { |
652 | 33 | MirPlatformPackage platform; | ||
653 | 34 | context->populate(platform); | ||
654 | 35 | if (platform.data_items != 0 || platform.fd_items != 0) | ||
655 | 36 | { | ||
656 | 37 | BOOST_THROW_EXCEPTION((std::runtime_error{"Attempted to create Android client platform on non-Android server"})); | ||
657 | 38 | } | ||
658 | 28 | return std::make_shared<mcla::AndroidClientPlatform>(); | 39 | return std::make_shared<mcla::AndroidClientPlatform>(); |
659 | 29 | } | 40 | } |
660 | 30 | 41 | ||
662 | 31 | extern "C" std::shared_ptr<mcl::ClientPlatformFactory> mcl::create_client_platform_factory() | 42 | extern "C" bool |
663 | 43 | mcl::is_appropriate_module(mcl::ClientContext* context) | ||
664 | 32 | { | 44 | { |
666 | 33 | return std::make_shared<mcla::ClientPlatformFactory>(); | 45 | MirPlatformPackage platform; |
667 | 46 | context->populate(platform); | ||
668 | 47 | // TODO: Actually check what platform we're using, rather than blindly | ||
669 | 48 | // hope we can distinguish them from the stuff they've put in the | ||
670 | 49 | // PlatformPackage. | ||
671 | 50 | return platform.data_items == 0 && platform.fd_items == 0; | ||
672 | 34 | } | 51 | } |
673 | 35 | 52 | ||
674 | === removed file 'src/client/android/client_platform_factory.h' | |||
675 | --- src/client/android/client_platform_factory.h 2014-02-07 15:43:41 +0000 | |||
676 | +++ src/client/android/client_platform_factory.h 1970-01-01 00:00:00 +0000 | |||
677 | @@ -1,41 +0,0 @@ | |||
678 | 1 | /* | ||
679 | 2 | * Copyright © 2014 Canonical Ltd. | ||
680 | 3 | * | ||
681 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
682 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
683 | 6 | * as published by the Free Software Foundation. | ||
684 | 7 | * | ||
685 | 8 | * This program is distributed in the hope that it will be useful, | ||
686 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
687 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
688 | 11 | * GNU Lesser General Public License for more details. | ||
689 | 12 | * | ||
690 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
691 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
692 | 15 | * | ||
693 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
694 | 17 | */ | ||
695 | 18 | |||
696 | 19 | #ifndef MIR_CLIENT_ANDROID_CLIENT_PLATFORM_FACTORY_H_ | ||
697 | 20 | #define MIR_CLIENT_ANDROID_CLIENT_PLATFORM_FACTORY_H_ | ||
698 | 21 | |||
699 | 22 | #include "../client_platform_factory.h" | ||
700 | 23 | |||
701 | 24 | namespace mir | ||
702 | 25 | { | ||
703 | 26 | namespace client | ||
704 | 27 | { | ||
705 | 28 | namespace android | ||
706 | 29 | { | ||
707 | 30 | |||
708 | 31 | class ClientPlatformFactory : public client::ClientPlatformFactory | ||
709 | 32 | { | ||
710 | 33 | public: | ||
711 | 34 | std::shared_ptr<ClientPlatform> create_client_platform(ClientContext* context) override; | ||
712 | 35 | }; | ||
713 | 36 | |||
714 | 37 | } | ||
715 | 38 | } | ||
716 | 39 | } | ||
717 | 40 | |||
718 | 41 | #endif /* MIR_CLIENT_ANDROID_CLIENT_PLATFORM_FACTORY_H_ */ | ||
719 | 42 | 0 | ||
720 | === modified file 'src/client/android/symbols.map' | |||
721 | --- src/client/android/symbols.map 2014-12-08 04:03:47 +0000 | |||
722 | +++ src/client/android/symbols.map 2014-12-18 22:43:30 +0000 | |||
723 | @@ -1,5 +1,6 @@ | |||
727 | 1 | MIR_CLIENTPLATFORM_1 { | 1 | MIR_CLIENT_PLATFORM_2 { |
728 | 2 | global: | 2 | global: |
729 | 3 | create_client_platform_factory; | 3 | create_client_platform; |
730 | 4 | is_appropriate_module; | ||
731 | 4 | local: *; | 5 | local: *; |
732 | 5 | }; | ||
733 | 6 | \ No newline at end of file | 6 | \ No newline at end of file |
734 | 7 | }; | ||
735 | 7 | 8 | ||
736 | === modified file 'src/client/client_context.h' | |||
737 | --- src/client/client_context.h 2013-08-28 03:41:48 +0000 | |||
738 | +++ src/client/client_context.h 2014-12-18 22:43:30 +0000 | |||
739 | @@ -19,6 +19,8 @@ | |||
740 | 19 | #ifndef MIR_CLIENT_CLIENT_CONTEXT_H_ | 19 | #ifndef MIR_CLIENT_CLIENT_CONTEXT_H_ |
741 | 20 | #define MIR_CLIENT_CLIENT_CONTEXT_H_ | 20 | #define MIR_CLIENT_CLIENT_CONTEXT_H_ |
742 | 21 | 21 | ||
743 | 22 | #include "mir_toolkit/client_types.h" | ||
744 | 23 | |||
745 | 22 | namespace mir | 24 | namespace mir |
746 | 23 | { | 25 | { |
747 | 24 | namespace client | 26 | namespace client |
748 | @@ -29,7 +31,6 @@ | |||
749 | 29 | public: | 31 | public: |
750 | 30 | virtual ~ClientContext() {} | 32 | virtual ~ClientContext() {} |
751 | 31 | 33 | ||
752 | 32 | virtual MirConnection* mir_connection() = 0; | ||
753 | 33 | virtual void populate(MirPlatformPackage& platform_package) = 0; | 34 | virtual void populate(MirPlatformPackage& platform_package) = 0; |
754 | 34 | 35 | ||
755 | 35 | protected: | 36 | protected: |
756 | 36 | 37 | ||
757 | === modified file 'src/client/client_platform_factory.h' | |||
758 | --- src/client/client_platform_factory.h 2014-03-06 06:05:17 +0000 | |||
759 | +++ src/client/client_platform_factory.h 2014-12-18 22:43:30 +0000 | |||
760 | @@ -41,8 +41,11 @@ | |||
761 | 41 | ClientPlatformFactory& operator=(ClientPlatformFactory const& p) = delete; | 41 | ClientPlatformFactory& operator=(ClientPlatformFactory const& p) = delete; |
762 | 42 | }; | 42 | }; |
763 | 43 | 43 | ||
766 | 44 | extern "C" typedef std::shared_ptr<ClientPlatformFactory>(*CreateClientPlatformFactory)(); | 44 | extern "C" typedef std::shared_ptr<ClientPlatform>(*CreateClientPlatform)(ClientContext* context); |
767 | 45 | extern "C" std::shared_ptr<ClientPlatformFactory> create_client_platform_factory(); | 45 | extern "C" std::shared_ptr<ClientPlatform> create_client_platform(ClientContext* context); |
768 | 46 | |||
769 | 47 | extern "C" typedef bool (*ClientPlatformProbe)(ClientContext* context); | ||
770 | 48 | extern "C" bool is_appropriate_module(ClientContext* context); | ||
771 | 46 | 49 | ||
772 | 47 | } | 50 | } |
773 | 48 | } | 51 | } |
774 | 49 | 52 | ||
775 | === modified file 'src/client/connection_configuration.h' | |||
776 | --- src/client/connection_configuration.h 2014-12-08 04:03:47 +0000 | |||
777 | +++ src/client/connection_configuration.h 2014-12-18 22:43:30 +0000 | |||
778 | @@ -39,8 +39,6 @@ | |||
779 | 39 | class Logger; | 39 | class Logger; |
780 | 40 | } | 40 | } |
781 | 41 | 41 | ||
782 | 42 | class SharedLibrary; | ||
783 | 43 | |||
784 | 44 | namespace client | 42 | namespace client |
785 | 45 | { | 43 | { |
786 | 46 | class ConnectionSurfaceMap; | 44 | class ConnectionSurfaceMap; |
787 | @@ -65,7 +63,6 @@ | |||
788 | 65 | virtual std::shared_ptr<LifecycleControl> the_lifecycle_control() = 0; | 63 | virtual std::shared_ptr<LifecycleControl> the_lifecycle_control() = 0; |
789 | 66 | virtual std::shared_ptr<EventSink> the_event_sink() = 0; | 64 | virtual std::shared_ptr<EventSink> the_event_sink() = 0; |
790 | 67 | virtual std::shared_ptr<EventHandlerRegister> the_event_handler_register() = 0; | 65 | virtual std::shared_ptr<EventHandlerRegister> the_event_handler_register() = 0; |
791 | 68 | virtual std::shared_ptr<SharedLibrary> the_platform_library() = 0; | ||
792 | 69 | 66 | ||
793 | 70 | protected: | 67 | protected: |
794 | 71 | ConnectionConfiguration() = default; | 68 | ConnectionConfiguration() = default; |
795 | 72 | 69 | ||
796 | === modified file 'src/client/default_connection_configuration.cpp' | |||
797 | --- src/client/default_connection_configuration.cpp 2014-12-08 04:03:47 +0000 | |||
798 | +++ src/client/default_connection_configuration.cpp 2014-12-18 22:43:30 +0000 | |||
799 | @@ -35,6 +35,7 @@ | |||
800 | 35 | #include "lifecycle_control.h" | 35 | #include "lifecycle_control.h" |
801 | 36 | #include "mir/shared_library.h" | 36 | #include "mir/shared_library.h" |
802 | 37 | #include "client_platform_factory.h" | 37 | #include "client_platform_factory.h" |
803 | 38 | #include "probing_client_platform_factory.h" | ||
804 | 38 | #include "mir_event_distributor.h" | 39 | #include "mir_event_distributor.h" |
805 | 39 | #include "mir/shared_library_prober.h" | 40 | #include "mir/shared_library_prober.h" |
806 | 40 | 41 | ||
807 | @@ -47,7 +48,10 @@ | |||
808 | 47 | std::string const off_opt_val{"off"}; | 48 | std::string const off_opt_val{"off"}; |
809 | 48 | std::string const log_opt_val{"log"}; | 49 | std::string const log_opt_val{"log"}; |
810 | 49 | std::string const lttng_opt_val{"lttng"}; | 50 | std::string const lttng_opt_val{"lttng"}; |
812 | 50 | std::string const default_platform_lib{MIR_CLIENT_DRIVER_BINARY}; | 51 | |
813 | 52 | // Shove this here until we properly manage the lifetime of our | ||
814 | 53 | // loadable modules | ||
815 | 54 | std::shared_ptr<mcl::ProbingClientPlatformFactory> the_platform_prober; | ||
816 | 51 | 55 | ||
817 | 52 | // Hack around the way Qt loads mir: | 56 | // Hack around the way Qt loads mir: |
818 | 53 | // qtmir and therefore Mir are loaded via dlopen(..., RTLD_LOCAL). | 57 | // qtmir and therefore Mir are loaded via dlopen(..., RTLD_LOCAL). |
819 | @@ -108,11 +112,23 @@ | |||
820 | 108 | return client_platform_factory( | 112 | return client_platform_factory( |
821 | 109 | [this] | 113 | [this] |
822 | 110 | { | 114 | { |
828 | 111 | auto const create_client_platform_factory = | 115 | ensure_loaded_with_rtld_global(); |
829 | 112 | the_platform_library()->load_function<mcl::CreateClientPlatformFactory>( | 116 | auto const platform_override = getenv("MIR_CLIENT_PLATFORM_LIB"); |
830 | 113 | "create_client_platform_factory"); | 117 | std::vector<std::shared_ptr<mir::SharedLibrary>> platform_plugins; |
831 | 114 | 118 | if (platform_override) | |
832 | 115 | return create_client_platform_factory(); | 119 | { |
833 | 120 | platform_plugins.push_back(std::make_shared<mir::SharedLibrary>(platform_override)); | ||
834 | 121 | } | ||
835 | 122 | else | ||
836 | 123 | { | ||
837 | 124 | auto const platform_path_override = getenv("MIR_CLIENT_PLATFORM_PATH"); | ||
838 | 125 | auto const platform_path = platform_path_override ? platform_path_override : MIR_CLIENT_PLATFORM_PATH; | ||
839 | 126 | platform_plugins = mir::libraries_for_path(platform_path, *the_shared_library_prober_report()); | ||
840 | 127 | } | ||
841 | 128 | |||
842 | 129 | the_platform_prober = std::make_shared<mcl::ProbingClientPlatformFactory>(platform_plugins); | ||
843 | 130 | |||
844 | 131 | return the_platform_prober; | ||
845 | 116 | }); | 132 | }); |
846 | 117 | } | 133 | } |
847 | 118 | 134 | ||
848 | @@ -219,15 +235,3 @@ | |||
849 | 219 | return std::make_shared<mir::logging::NullSharedLibraryProberReport>(); | 235 | return std::make_shared<mir::logging::NullSharedLibraryProberReport>(); |
850 | 220 | }); | 236 | }); |
851 | 221 | } | 237 | } |
852 | 222 | |||
853 | 223 | std::shared_ptr<mir::SharedLibrary> mcl::DefaultConnectionConfiguration::the_platform_library() | ||
854 | 224 | { | ||
855 | 225 | if (!platform_library) | ||
856 | 226 | { | ||
857 | 227 | ensure_loaded_with_rtld_global(); | ||
858 | 228 | auto const val_raw = getenv("MIR_CLIENT_PLATFORM_LIB"); | ||
859 | 229 | std::string const libname{val_raw ? val_raw : default_platform_lib}; | ||
860 | 230 | platform_library = std::make_shared<mir::SharedLibrary>(libname); | ||
861 | 231 | } | ||
862 | 232 | return platform_library; | ||
863 | 233 | } | ||
864 | 234 | 238 | ||
865 | === modified file 'src/client/default_connection_configuration.h' | |||
866 | --- src/client/default_connection_configuration.h 2014-12-08 04:03:47 +0000 | |||
867 | +++ src/client/default_connection_configuration.h 2014-12-18 22:43:30 +0000 | |||
868 | @@ -60,16 +60,12 @@ | |||
869 | 60 | std::shared_ptr<EventSink> the_event_sink() override; | 60 | std::shared_ptr<EventSink> the_event_sink() override; |
870 | 61 | std::shared_ptr<EventHandlerRegister> the_event_handler_register() override; | 61 | std::shared_ptr<EventHandlerRegister> the_event_handler_register() override; |
871 | 62 | std::shared_ptr<mir::SharedLibraryProberReport> the_shared_library_prober_report(); | 62 | std::shared_ptr<mir::SharedLibraryProberReport> the_shared_library_prober_report(); |
872 | 63 | std::shared_ptr<SharedLibrary> the_platform_library() override; | ||
873 | 64 | 63 | ||
874 | 65 | virtual std::string the_socket_file(); | 64 | virtual std::string the_socket_file(); |
875 | 66 | virtual std::shared_ptr<rpc::RpcReport> the_rpc_report(); | 65 | virtual std::shared_ptr<rpc::RpcReport> the_rpc_report(); |
876 | 67 | virtual std::shared_ptr<input::receiver::InputReceiverReport> the_input_receiver_report(); | 66 | virtual std::shared_ptr<input::receiver::InputReceiverReport> the_input_receiver_report(); |
877 | 68 | 67 | ||
878 | 69 | protected: | 68 | protected: |
879 | 70 | // MUST be first data member so it is destroyed last. | ||
880 | 71 | std::shared_ptr<mir::SharedLibrary> platform_library; | ||
881 | 72 | |||
882 | 73 | CachedPtr<google::protobuf::RpcChannel> rpc_channel; | 69 | CachedPtr<google::protobuf::RpcChannel> rpc_channel; |
883 | 74 | CachedPtr<mir::logging::Logger> logger; | 70 | CachedPtr<mir::logging::Logger> logger; |
884 | 75 | CachedPtr<ClientPlatformFactory> client_platform_factory; | 71 | CachedPtr<ClientPlatformFactory> client_platform_factory; |
885 | 76 | 72 | ||
886 | === modified file 'src/client/egl_native_display_container.h' | |||
887 | --- src/client/egl_native_display_container.h 2014-03-06 06:05:17 +0000 | |||
888 | +++ src/client/egl_native_display_container.h 2014-12-18 22:43:30 +0000 | |||
889 | @@ -26,12 +26,14 @@ | |||
890 | 26 | namespace client | 26 | namespace client |
891 | 27 | { | 27 | { |
892 | 28 | 28 | ||
893 | 29 | class ClientContext; | ||
894 | 30 | |||
895 | 29 | class EGLNativeDisplayContainer | 31 | class EGLNativeDisplayContainer |
896 | 30 | { | 32 | { |
897 | 31 | public: | 33 | public: |
898 | 32 | virtual ~EGLNativeDisplayContainer() {} | 34 | virtual ~EGLNativeDisplayContainer() {} |
899 | 33 | 35 | ||
901 | 34 | virtual MirEGLNativeDisplayType create(MirConnection* connection) = 0; | 36 | virtual MirEGLNativeDisplayType create(ClientContext* context) = 0; |
902 | 35 | virtual void release(MirEGLNativeDisplayType display) = 0; | 37 | virtual void release(MirEGLNativeDisplayType display) = 0; |
903 | 36 | 38 | ||
904 | 37 | virtual bool validate(MirEGLNativeDisplayType display) const = 0; | 39 | virtual bool validate(MirEGLNativeDisplayType display) const = 0; |
905 | 38 | 40 | ||
906 | === modified file 'src/client/mesa/CMakeLists.txt' | |||
907 | --- src/client/mesa/CMakeLists.txt 2014-12-08 04:03:47 +0000 | |||
908 | +++ src/client/mesa/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
909 | @@ -15,7 +15,7 @@ | |||
910 | 15 | ) | 15 | ) |
911 | 16 | 16 | ||
912 | 17 | add_library( | 17 | add_library( |
914 | 18 | mirclientplatformmesa SHARED | 18 | mirclientplatformmesa MODULE |
915 | 19 | 19 | ||
916 | 20 | $<TARGET_OBJECTS:mirclientplatformmesaobjects> | 20 | $<TARGET_OBJECTS:mirclientplatformmesaobjects> |
917 | 21 | $<TARGET_OBJECTS:mirclient_platformimpl> | 21 | $<TARGET_OBJECTS:mirclient_platformimpl> |
918 | @@ -23,9 +23,10 @@ | |||
919 | 23 | 23 | ||
920 | 24 | set_target_properties( | 24 | set_target_properties( |
921 | 25 | mirclientplatformmesa PROPERTIES | 25 | mirclientplatformmesa PROPERTIES |
925 | 26 | OUTPUT_NAME ${MIR_CLIENT_DRIVER} | 26 | OUTPUT_NAME mesa |
926 | 27 | LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/mesa | 27 | LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/client-modules |
927 | 28 | LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}" | 28 | PREFIX "" |
928 | 29 | LINK_FLAGS "-Wl,--version-script,${symbol_map}" | ||
929 | 29 | ) | 30 | ) |
930 | 30 | 31 | ||
931 | 31 | target_link_libraries(mirclientplatformmesa | 32 | target_link_libraries(mirclientplatformmesa |
932 | @@ -33,21 +34,4 @@ | |||
933 | 33 | ${DRM_LDFLAGS} ${DRM_LIBRARIES} | 34 | ${DRM_LDFLAGS} ${DRM_LIBRARIES} |
934 | 34 | ) | 35 | ) |
935 | 35 | 36 | ||
954 | 36 | install(TARGETS mirclientplatformmesa LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/${CLIENT_DRIVER}/mesa) | 37 | install(TARGETS mirclientplatformmesa LIBRARY DESTINATION ${MIR_CLIENT_PLATFORM_PATH}) |
937 | 37 | |||
938 | 38 | if (MIR_TEST_PLATFORM STREQUAL "mesa") | ||
939 | 39 | add_custom_command(TARGET mirclientplatformmesa | ||
940 | 40 | POST_BUILD | ||
941 | 41 | COMMAND ${CMAKE_COMMAND} -E remove ${MIR_CLIENT_DRIVER_BINARY} | ||
942 | 42 | COMMAND ${CMAKE_COMMAND} -E create_symlink mesa/$<TARGET_FILE_NAME:mirclientplatformmesa> ${MIR_CLIENT_DRIVER_BINARY} | ||
943 | 43 | WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} | ||
944 | 44 | ) | ||
945 | 45 | |||
946 | 46 | install(CODE | ||
947 | 47 | "execute_process( | ||
948 | 48 | COMMAND ln -sf mir/${CLIENT_DRIVER}/mesa/${MIR_CLIENT_DRIVER_BINARY} | ||
949 | 49 | WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} | ||
950 | 50 | )" | ||
951 | 51 | ) | ||
952 | 52 | endif() | ||
953 | 53 | |||
955 | 54 | 38 | ||
956 | === modified file 'src/client/mesa/client_platform.cpp' | |||
957 | --- src/client/mesa/client_platform.cpp 2014-03-06 06:05:17 +0000 | |||
958 | +++ src/client/mesa/client_platform.cpp 2014-12-18 22:43:30 +0000 | |||
959 | @@ -95,7 +95,7 @@ | |||
960 | 95 | std::shared_ptr<EGLNativeDisplayType> mclm::ClientPlatform::create_egl_native_display() | 95 | std::shared_ptr<EGLNativeDisplayType> mclm::ClientPlatform::create_egl_native_display() |
961 | 96 | { | 96 | { |
962 | 97 | MirEGLNativeDisplayType *mir_native_display = new MirEGLNativeDisplayType; | 97 | MirEGLNativeDisplayType *mir_native_display = new MirEGLNativeDisplayType; |
964 | 98 | *mir_native_display = display_container.create(context->mir_connection()); | 98 | *mir_native_display = display_container.create(context); |
965 | 99 | auto egl_native_display = reinterpret_cast<EGLNativeDisplayType*>(mir_native_display); | 99 | auto egl_native_display = reinterpret_cast<EGLNativeDisplayType*>(mir_native_display); |
966 | 100 | 100 | ||
967 | 101 | return std::shared_ptr<EGLNativeDisplayType>(egl_native_display, NativeDisplayDeleter(display_container)); | 101 | return std::shared_ptr<EGLNativeDisplayType>(egl_native_display, NativeDisplayDeleter(display_container)); |
968 | 102 | 102 | ||
969 | === modified file 'src/client/mesa/client_platform_factory.cpp' | |||
970 | --- src/client/mesa/client_platform_factory.cpp 2014-02-07 15:43:41 +0000 | |||
971 | +++ src/client/mesa/client_platform_factory.cpp 2014-12-18 22:43:30 +0000 | |||
972 | @@ -16,13 +16,17 @@ | |||
973 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
974 | 17 | */ | 17 | */ |
975 | 18 | 18 | ||
977 | 19 | #include "client_platform_factory.h" | 19 | #include "../client_platform_factory.h" |
978 | 20 | #include "client_platform.h" | 20 | #include "client_platform.h" |
979 | 21 | #include "mir_toolkit/client_types.h" | ||
980 | 22 | #include "../client_context.h" | ||
981 | 21 | #include "buffer_file_ops.h" | 23 | #include "buffer_file_ops.h" |
982 | 22 | #include "../egl_native_display_container.h" | 24 | #include "../egl_native_display_container.h" |
983 | 23 | 25 | ||
984 | 24 | #include <sys/mman.h> | 26 | #include <sys/mman.h> |
985 | 25 | #include <unistd.h> | 27 | #include <unistd.h> |
986 | 28 | #include <stdexcept> | ||
987 | 29 | #include <boost/throw_exception.hpp> | ||
988 | 26 | 30 | ||
989 | 27 | namespace mcl = mir::client; | 31 | namespace mcl = mir::client; |
990 | 28 | namespace mclm = mcl::mesa; | 32 | namespace mclm = mcl::mesa; |
991 | @@ -57,15 +61,26 @@ | |||
992 | 57 | 61 | ||
993 | 58 | } | 62 | } |
994 | 59 | 63 | ||
997 | 60 | std::shared_ptr<mcl::ClientPlatform> | 64 | extern "C" std::shared_ptr<mcl::ClientPlatform> mcl::create_client_platform(mcl::ClientContext* context) |
996 | 61 | mclm::ClientPlatformFactory::create_client_platform(mcl::ClientContext* context) | ||
998 | 62 | { | 65 | { |
999 | 66 | MirPlatformPackage package; | ||
1000 | 67 | context->populate(package); | ||
1001 | 68 | if (package.data_items != 0 || package.fd_items != 1) | ||
1002 | 69 | { | ||
1003 | 70 | BOOST_THROW_EXCEPTION((std::runtime_error{"Attempted to create Mesa client platform on non-Mesa server"})); | ||
1004 | 71 | } | ||
1005 | 63 | auto buffer_file_ops = std::make_shared<RealBufferFileOps>(); | 72 | auto buffer_file_ops = std::make_shared<RealBufferFileOps>(); |
1006 | 64 | return std::make_shared<mclm::ClientPlatform>( | 73 | return std::make_shared<mclm::ClientPlatform>( |
1007 | 65 | context, buffer_file_ops, mcl::EGLNativeDisplayContainer::instance()); | 74 | context, buffer_file_ops, mcl::EGLNativeDisplayContainer::instance()); |
1008 | 66 | } | 75 | } |
1009 | 67 | 76 | ||
1011 | 68 | extern "C" std::shared_ptr<mcl::ClientPlatformFactory> mcl::create_client_platform_factory() | 77 | extern "C" bool |
1012 | 78 | mcl::is_appropriate_module(mcl::ClientContext* context) | ||
1013 | 69 | { | 79 | { |
1015 | 70 | return std::make_shared<mclm::ClientPlatformFactory>(); | 80 | MirPlatformPackage platform; |
1016 | 81 | context->populate(platform); | ||
1017 | 82 | // TODO: Actually check what platform we're using, rather than blindly | ||
1018 | 83 | // hope we can distinguish them from the stuff they've put in the | ||
1019 | 84 | // PlatformPackage. | ||
1020 | 85 | return platform.data_items == 0 && platform.fd_items == 1; | ||
1021 | 71 | } | 86 | } |
1022 | 72 | 87 | ||
1023 | === removed file 'src/client/mesa/client_platform_factory.h' | |||
1024 | --- src/client/mesa/client_platform_factory.h 2014-02-07 15:43:41 +0000 | |||
1025 | +++ src/client/mesa/client_platform_factory.h 1970-01-01 00:00:00 +0000 | |||
1026 | @@ -1,41 +0,0 @@ | |||
1027 | 1 | /* | ||
1028 | 2 | * Copyright © 2014 Canonical Ltd. | ||
1029 | 3 | * | ||
1030 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1031 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
1032 | 6 | * as published by the Free Software Foundation. | ||
1033 | 7 | * | ||
1034 | 8 | * This program is distributed in the hope that it will be useful, | ||
1035 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1036 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1037 | 11 | * GNU Lesser General Public License for more details. | ||
1038 | 12 | * | ||
1039 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1040 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1041 | 15 | * | ||
1042 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
1043 | 17 | */ | ||
1044 | 18 | |||
1045 | 19 | #ifndef MIR_CLIENT_MESA_CLIENT_PLATFORM_FACTORY_H_ | ||
1046 | 20 | #define MIR_CLIENT_MESA_CLIENT_PLATFORM_FACTORY_H_ | ||
1047 | 21 | |||
1048 | 22 | #include "../client_platform_factory.h" | ||
1049 | 23 | |||
1050 | 24 | namespace mir | ||
1051 | 25 | { | ||
1052 | 26 | namespace client | ||
1053 | 27 | { | ||
1054 | 28 | namespace mesa | ||
1055 | 29 | { | ||
1056 | 30 | |||
1057 | 31 | class ClientPlatformFactory : public client::ClientPlatformFactory | ||
1058 | 32 | { | ||
1059 | 33 | public: | ||
1060 | 34 | std::shared_ptr<ClientPlatform> create_client_platform(ClientContext* context) override; | ||
1061 | 35 | }; | ||
1062 | 36 | |||
1063 | 37 | } | ||
1064 | 38 | } | ||
1065 | 39 | } | ||
1066 | 40 | |||
1067 | 41 | #endif /* MIR_CLIENT_MESA_CLIENT_PLATFORM_FACTORY_H_ */ | ||
1068 | 42 | 0 | ||
1069 | === modified file 'src/client/mesa/mesa_native_display_container.cpp' | |||
1070 | --- src/client/mesa/mesa_native_display_container.cpp 2014-12-08 04:03:47 +0000 | |||
1071 | +++ src/client/mesa/mesa_native_display_container.cpp 2014-12-18 22:43:30 +0000 | |||
1072 | @@ -18,7 +18,7 @@ | |||
1073 | 18 | 18 | ||
1074 | 19 | #include "mesa_native_display_container.h" | 19 | #include "mesa_native_display_container.h" |
1075 | 20 | 20 | ||
1077 | 21 | #include "mir_toolkit/mir_client_library.h" | 21 | #include "../client_context.h" |
1078 | 22 | 22 | ||
1079 | 23 | #include <cstring> | 23 | #include <cstring> |
1080 | 24 | #include <unordered_set> | 24 | #include <unordered_set> |
1081 | @@ -35,8 +35,8 @@ | |||
1082 | 35 | static int egl_display_get_platform(MirMesaEGLNativeDisplay* display, | 35 | static int egl_display_get_platform(MirMesaEGLNativeDisplay* display, |
1083 | 36 | MirPlatformPackage* package) | 36 | MirPlatformPackage* package) |
1084 | 37 | { | 37 | { |
1087 | 38 | auto connection = static_cast<MirConnection*>(display->context); | 38 | auto context = static_cast<mcl::ClientContext*>(display->context); |
1088 | 39 | mir_connection_get_platform(connection, package); | 39 | context->populate(*package); |
1089 | 40 | return MIR_MESA_TRUE; | 40 | return MIR_MESA_TRUE; |
1090 | 41 | } | 41 | } |
1091 | 42 | 42 | ||
1092 | @@ -93,11 +93,11 @@ | |||
1093 | 93 | } | 93 | } |
1094 | 94 | 94 | ||
1095 | 95 | MirEGLNativeDisplayType | 95 | MirEGLNativeDisplayType |
1097 | 96 | mclm::MesaNativeDisplayContainer::create(MirConnection* connection) | 96 | mclm::MesaNativeDisplayContainer::create(ClientContext* context) |
1098 | 97 | { | 97 | { |
1099 | 98 | MirMesaEGLNativeDisplay* display = new MirMesaEGLNativeDisplay(); | 98 | MirMesaEGLNativeDisplay* display = new MirMesaEGLNativeDisplay(); |
1100 | 99 | display->display_get_platform = egl_display_get_platform; | 99 | display->display_get_platform = egl_display_get_platform; |
1102 | 100 | display->context = connection; | 100 | display->context = context; |
1103 | 101 | 101 | ||
1104 | 102 | std::lock_guard<std::mutex> lg(guard); | 102 | std::lock_guard<std::mutex> lg(guard); |
1105 | 103 | auto egl_display = static_cast<MirEGLNativeDisplayType>(display); | 103 | auto egl_display = static_cast<MirEGLNativeDisplayType>(display); |
1106 | 104 | 104 | ||
1107 | === modified file 'src/client/mesa/mesa_native_display_container.h' | |||
1108 | --- src/client/mesa/mesa_native_display_container.h 2014-03-06 06:05:17 +0000 | |||
1109 | +++ src/client/mesa/mesa_native_display_container.h 2014-12-18 22:43:30 +0000 | |||
1110 | @@ -40,7 +40,7 @@ | |||
1111 | 40 | MesaNativeDisplayContainer(); | 40 | MesaNativeDisplayContainer(); |
1112 | 41 | virtual ~MesaNativeDisplayContainer(); | 41 | virtual ~MesaNativeDisplayContainer(); |
1113 | 42 | 42 | ||
1115 | 43 | MirEGLNativeDisplayType create(MirConnection* connection); | 43 | MirEGLNativeDisplayType create(ClientContext* context); |
1116 | 44 | void release(MirEGLNativeDisplayType display); | 44 | void release(MirEGLNativeDisplayType display); |
1117 | 45 | 45 | ||
1118 | 46 | bool validate(MirEGLNativeDisplayType display) const; | 46 | bool validate(MirEGLNativeDisplayType display) const; |
1119 | 47 | 47 | ||
1120 | === modified file 'src/client/mesa/native_surface.cpp' | |||
1121 | --- src/client/mesa/native_surface.cpp 2014-12-08 04:03:47 +0000 | |||
1122 | +++ src/client/mesa/native_surface.cpp 2014-12-18 22:43:30 +0000 | |||
1123 | @@ -20,7 +20,6 @@ | |||
1124 | 20 | #include "../client_buffer.h" | 20 | #include "../client_buffer.h" |
1125 | 21 | #include "native_surface.h" | 21 | #include "native_surface.h" |
1126 | 22 | 22 | ||
1127 | 23 | #include <iostream> | ||
1128 | 24 | #include <boost/exception/diagnostic_information.hpp> | 23 | #include <boost/exception/diagnostic_information.hpp> |
1129 | 25 | 24 | ||
1130 | 26 | namespace mclm=mir::client::mesa; | 25 | namespace mclm=mir::client::mesa; |
1131 | 27 | 26 | ||
1132 | === modified file 'src/client/mesa/symbols.map' | |||
1133 | --- src/client/mesa/symbols.map 2014-12-08 04:03:47 +0000 | |||
1134 | +++ src/client/mesa/symbols.map 2014-12-18 22:43:30 +0000 | |||
1135 | @@ -1,7 +1,9 @@ | |||
1139 | 1 | MIR_CLIENTPLATFORM_1 { | 1 | MIR_CLIENT_PLATFORM_2 { |
1140 | 2 | global: | 2 | global: |
1141 | 3 | create_client_platform_factory; | 3 | create_client_platform; |
1142 | 4 | is_appropriate_module; | ||
1143 | 4 | # Needed by our Mesa EGL platform | 5 | # Needed by our Mesa EGL platform |
1144 | 5 | mir_client_mesa_egl_native_display_is_valid; | 6 | mir_client_mesa_egl_native_display_is_valid; |
1146 | 6 | local: *; | 7 | local: |
1147 | 8 | *; | ||
1148 | 7 | }; | 9 | }; |
1149 | 8 | 10 | ||
1150 | === modified file 'src/client/mir_connection.cpp' | |||
1151 | --- src/client/mir_connection.cpp 2014-12-15 06:24:03 +0000 | |||
1152 | +++ src/client/mir_connection.cpp 2014-12-18 22:43:30 +0000 | |||
1153 | @@ -96,11 +96,11 @@ | |||
1154 | 96 | MirConnection::MirConnection( | 96 | MirConnection::MirConnection( |
1155 | 97 | mir::client::ConnectionConfiguration& conf) : | 97 | mir::client::ConnectionConfiguration& conf) : |
1156 | 98 | deregisterer{this}, | 98 | deregisterer{this}, |
1157 | 99 | platform_library{conf.the_platform_library()}, | ||
1158 | 100 | channel(conf.the_rpc_channel()), | 99 | channel(conf.the_rpc_channel()), |
1159 | 101 | server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL), | 100 | server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL), |
1160 | 102 | debug(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL), | 101 | debug(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL), |
1161 | 103 | logger(conf.the_logger()), | 102 | logger(conf.the_logger()), |
1162 | 103 | connect_done{false}, | ||
1163 | 104 | client_platform_factory(conf.the_client_platform_factory()), | 104 | client_platform_factory(conf.the_client_platform_factory()), |
1164 | 105 | input_platform(conf.the_input_platform()), | 105 | input_platform(conf.the_input_platform()), |
1165 | 106 | display_configuration(conf.the_display_configuration()), | 106 | display_configuration(conf.the_display_configuration()), |
1166 | @@ -236,6 +236,9 @@ | |||
1167 | 236 | set_error_message("Connect failed"); | 236 | set_error_message("Connect failed"); |
1168 | 237 | } | 237 | } |
1169 | 238 | } | 238 | } |
1170 | 239 | |||
1171 | 240 | connect_done = true; | ||
1172 | 241 | |||
1173 | 239 | /* | 242 | /* |
1174 | 240 | * We need to create the client platform after the connection has been | 243 | * We need to create the client platform after the connection has been |
1175 | 241 | * established, to ensure that the client platform has access to all | 244 | * established, to ensure that the client platform has access to all |
1176 | @@ -420,9 +423,9 @@ | |||
1177 | 420 | 423 | ||
1178 | 421 | void MirConnection::populate(MirPlatformPackage& platform_package) | 424 | void MirConnection::populate(MirPlatformPackage& platform_package) |
1179 | 422 | { | 425 | { |
1183 | 423 | std::lock_guard<decltype(mutex)> lock(mutex); | 426 | // connect_result is write-once: once it's valid, we don't need to lock |
1184 | 424 | 427 | // to use it. | |
1185 | 425 | if (!connect_result.has_error() && connect_result.has_platform()) | 428 | if (connect_done && !connect_result.has_error() && connect_result.has_platform()) |
1186 | 426 | { | 429 | { |
1187 | 427 | auto const& platform = connect_result.platform(); | 430 | auto const& platform = connect_result.platform(); |
1188 | 428 | 431 | ||
1189 | @@ -478,11 +481,6 @@ | |||
1190 | 478 | return platform; | 481 | return platform; |
1191 | 479 | } | 482 | } |
1192 | 480 | 483 | ||
1193 | 481 | MirConnection* MirConnection::mir_connection() | ||
1194 | 482 | { | ||
1195 | 483 | return this; | ||
1196 | 484 | } | ||
1197 | 485 | |||
1198 | 486 | EGLNativeDisplayType MirConnection::egl_native_display() | 484 | EGLNativeDisplayType MirConnection::egl_native_display() |
1199 | 487 | { | 485 | { |
1200 | 488 | std::lock_guard<decltype(mutex)> lock(mutex); | 486 | std::lock_guard<decltype(mutex)> lock(mutex); |
1201 | 489 | 487 | ||
1202 | === modified file 'src/client/mir_connection.h' | |||
1203 | --- src/client/mir_connection.h 2014-12-15 06:24:03 +0000 | |||
1204 | +++ src/client/mir_connection.h 2014-12-18 22:43:30 +0000 | |||
1205 | @@ -22,6 +22,7 @@ | |||
1206 | 22 | #include <memory> | 22 | #include <memory> |
1207 | 23 | #include <unordered_set> | 23 | #include <unordered_set> |
1208 | 24 | #include <unordered_map> | 24 | #include <unordered_map> |
1209 | 25 | #include <atomic> | ||
1210 | 25 | 26 | ||
1211 | 26 | #include <mutex> | 27 | #include <mutex> |
1212 | 27 | 28 | ||
1213 | @@ -122,8 +123,6 @@ | |||
1214 | 122 | 123 | ||
1215 | 123 | static bool is_valid(MirConnection *connection); | 124 | static bool is_valid(MirConnection *connection); |
1216 | 124 | 125 | ||
1217 | 125 | MirConnection* mir_connection(); | ||
1218 | 126 | |||
1219 | 127 | EGLNativeDisplayType egl_native_display(); | 126 | EGLNativeDisplayType egl_native_display(); |
1220 | 128 | 127 | ||
1221 | 129 | void on_surface_created(int id, MirSurface* surface); | 128 | void on_surface_created(int id, MirSurface* surface); |
1222 | @@ -158,6 +157,7 @@ | |||
1223 | 158 | std::shared_ptr<mir::logging::Logger> const logger; | 157 | std::shared_ptr<mir::logging::Logger> const logger; |
1224 | 159 | mir::protobuf::Void void_response; | 158 | mir::protobuf::Void void_response; |
1225 | 160 | mir::protobuf::Connection connect_result; | 159 | mir::protobuf::Connection connect_result; |
1226 | 160 | std::atomic<bool> connect_done; | ||
1227 | 161 | mir::protobuf::Void ignored; | 161 | mir::protobuf::Void ignored; |
1228 | 162 | mir::protobuf::ConnectParameters connect_parameters; | 162 | mir::protobuf::ConnectParameters connect_parameters; |
1229 | 163 | mir::protobuf::DRMAuthMagicStatus drm_auth_magic_status; | 163 | mir::protobuf::DRMAuthMagicStatus drm_auth_magic_status; |
1230 | 164 | 164 | ||
1231 | === added file 'src/client/probing_client_platform_factory.cpp' | |||
1232 | --- src/client/probing_client_platform_factory.cpp 1970-01-01 00:00:00 +0000 | |||
1233 | +++ src/client/probing_client_platform_factory.cpp 2014-12-18 22:43:30 +0000 | |||
1234 | @@ -0,0 +1,38 @@ | |||
1235 | 1 | #include "probing_client_platform_factory.h" | ||
1236 | 2 | |||
1237 | 3 | #include <boost/exception/all.hpp> | ||
1238 | 4 | #include <stdexcept> | ||
1239 | 5 | |||
1240 | 6 | namespace mcl = mir::client; | ||
1241 | 7 | |||
1242 | 8 | mcl::ProbingClientPlatformFactory::ProbingClientPlatformFactory(std::vector<std::shared_ptr<mir::SharedLibrary>> const& modules) | ||
1243 | 9 | : platform_modules{modules} | ||
1244 | 10 | { | ||
1245 | 11 | if (modules.empty()) | ||
1246 | 12 | { | ||
1247 | 13 | BOOST_THROW_EXCEPTION( | ||
1248 | 14 | std::runtime_error{"Attempted to create a ClientPlatformFactory with no platform modules"}); | ||
1249 | 15 | } | ||
1250 | 16 | } | ||
1251 | 17 | |||
1252 | 18 | std::shared_ptr<mcl::ClientPlatform> | ||
1253 | 19 | mcl::ProbingClientPlatformFactory::create_client_platform(mcl::ClientContext* context) | ||
1254 | 20 | { | ||
1255 | 21 | for (auto& module : platform_modules) | ||
1256 | 22 | { | ||
1257 | 23 | try | ||
1258 | 24 | { | ||
1259 | 25 | auto probe = module->load_function<mir::client::ClientPlatformProbe>("is_appropriate_module", CLIENT_PLATFORM_VERSION); | ||
1260 | 26 | if (probe(context)) | ||
1261 | 27 | { | ||
1262 | 28 | auto factory = module->load_function<mir::client::CreateClientPlatform>("create_client_platform", CLIENT_PLATFORM_VERSION); | ||
1263 | 29 | return factory(context); | ||
1264 | 30 | } | ||
1265 | 31 | } | ||
1266 | 32 | catch(std::runtime_error) | ||
1267 | 33 | { | ||
1268 | 34 | // We were handled a SharedLibrary that's not a client platform module? | ||
1269 | 35 | } | ||
1270 | 36 | } | ||
1271 | 37 | BOOST_THROW_EXCEPTION(std::runtime_error{"No appropriate client platform module found"}); | ||
1272 | 38 | } | ||
1273 | 0 | 39 | ||
1274 | === added file 'src/client/probing_client_platform_factory.h' | |||
1275 | --- src/client/probing_client_platform_factory.h 1970-01-01 00:00:00 +0000 | |||
1276 | +++ src/client/probing_client_platform_factory.h 2014-12-18 22:43:30 +0000 | |||
1277 | @@ -0,0 +1,26 @@ | |||
1278 | 1 | #ifndef MIR_CLIENT_PROBING_CLIENT_PLATFORM_FACTORY_H_ | ||
1279 | 2 | #define MIR_CLIENT_PROBING_CLIENT_PLATFORM_FACTORY_H_ | ||
1280 | 3 | |||
1281 | 4 | #include <vector> | ||
1282 | 5 | |||
1283 | 6 | #include "client_platform_factory.h" | ||
1284 | 7 | #include "mir/shared_library.h" | ||
1285 | 8 | |||
1286 | 9 | namespace mir | ||
1287 | 10 | { | ||
1288 | 11 | namespace client | ||
1289 | 12 | { | ||
1290 | 13 | class ProbingClientPlatformFactory : public ClientPlatformFactory | ||
1291 | 14 | { | ||
1292 | 15 | public: | ||
1293 | 16 | ProbingClientPlatformFactory(std::vector<std::shared_ptr<SharedLibrary>> const& modules); | ||
1294 | 17 | |||
1295 | 18 | std::shared_ptr<ClientPlatform> create_client_platform(ClientContext *context) override; | ||
1296 | 19 | private: | ||
1297 | 20 | std::vector<std::shared_ptr<SharedLibrary>> platform_modules; | ||
1298 | 21 | }; | ||
1299 | 22 | |||
1300 | 23 | } | ||
1301 | 24 | } | ||
1302 | 25 | |||
1303 | 26 | #endif // MIR_CLIENT_PROBING_CLIENT_PLATFORM_FACTORY_H_ | ||
1304 | 0 | 27 | ||
1305 | === modified file 'src/common/symbols.map' | |||
1306 | --- src/common/symbols.map 2014-12-17 02:32:08 +0000 | |||
1307 | +++ src/common/symbols.map 2014-12-18 22:43:30 +0000 | |||
1308 | @@ -203,15 +203,15 @@ | |||
1309 | 203 | }; | 203 | }; |
1310 | 204 | 204 | ||
1311 | 205 | MIR_COMMON_3.1 { | 205 | MIR_COMMON_3.1 { |
1324 | 206 | global: | 206 | global: |
1325 | 207 | extern "C++" { | 207 | extern "C++" { |
1326 | 208 | mir_event_get*; | 208 | mir_event_get*; |
1327 | 209 | mir_event_get*; | 209 | mir_event_get*; |
1328 | 210 | mir_input_event_get*; | 210 | mir_input_event_get*; |
1329 | 211 | mir_key_input_event_get*; | 211 | mir_key_input_event_get*; |
1330 | 212 | mir::log*char*; | 212 | mir_touch_input_event_get*; |
1331 | 213 | mir::logv*; | 213 | mir::log*char*; |
1332 | 214 | mir_touch_input_event_get*; | 214 | mir::logv*; |
1333 | 215 | }; | 215 | mir::libraries_for_path*; |
1334 | 216 | }; | 216 | }; |
1335 | 217 | 217 | } MIR_COMMON_3; | |
1336 | 218 | 218 | ||
1337 | === modified file 'tests/CMakeLists.txt' | |||
1338 | --- tests/CMakeLists.txt 2014-12-08 04:03:47 +0000 | |||
1339 | +++ tests/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
1340 | @@ -26,9 +26,17 @@ | |||
1341 | 26 | endif() | 26 | endif() |
1342 | 27 | 27 | ||
1343 | 28 | if (MIR_TEST_PLATFORM STREQUAL "android") | 28 | if (MIR_TEST_PLATFORM STREQUAL "android") |
1344 | 29 | add_definitions(-DANDROID) | ||
1345 | 30 | endif() | ||
1346 | 31 | |||
1347 | 32 | if (MIR_BUILD_PLATFORM_ANDROID) | ||
1348 | 29 | #avoid complaints about poor quality android headers | 33 | #avoid complaints about poor quality android headers |
1349 | 30 | include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS}) | 34 | include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS}) |
1351 | 31 | add_definitions(-DANDROID) | 35 | add_definitions(-DMIR_BUILD_PLATFORM_ANDROID) |
1352 | 36 | endif() | ||
1353 | 37 | |||
1354 | 38 | if (MIR_BUILD_PLATFORM_MESA) | ||
1355 | 39 | add_definitions(-DMIR_BUILD_PLATFORM_MESA) | ||
1356 | 32 | endif() | 40 | endif() |
1357 | 33 | 41 | ||
1358 | 34 | include_directories( | 42 | include_directories( |
1359 | 35 | 43 | ||
1360 | === modified file 'tests/acceptance-tests/CMakeLists.txt' | |||
1361 | --- tests/acceptance-tests/CMakeLists.txt 2014-12-15 06:24:03 +0000 | |||
1362 | +++ tests/acceptance-tests/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
1363 | @@ -6,7 +6,6 @@ | |||
1364 | 6 | 6 | ||
1365 | 7 | add_definitions( | 7 | add_definitions( |
1366 | 8 | -DMIR_PLATFORM_DRIVER_BINARY="${MIR_PLATFORM_DRIVER_BINARY}" | 8 | -DMIR_PLATFORM_DRIVER_BINARY="${MIR_PLATFORM_DRIVER_BINARY}" |
1367 | 9 | -DMIR_CLIENT_DRIVER_BINARY="${MIR_CLIENT_DRIVER_BINARY}" | ||
1368 | 10 | ) | 9 | ) |
1369 | 11 | 10 | ||
1370 | 12 | set( | 11 | set( |
1371 | @@ -48,7 +47,7 @@ | |||
1372 | 48 | 47 | ||
1373 | 49 | add_subdirectory(throwback) | 48 | add_subdirectory(throwback) |
1374 | 50 | 49 | ||
1376 | 51 | add_executable( | 50 | mir_add_wrapped_executable( |
1377 | 52 | mir_acceptance_tests | 51 | mir_acceptance_tests |
1378 | 53 | 52 | ||
1379 | 54 | ${SOURCES} | 53 | ${SOURCES} |
1380 | @@ -68,9 +67,9 @@ | |||
1381 | 68 | mirplatform | 67 | mirplatform |
1382 | 69 | 68 | ||
1383 | 70 | mir-test | 69 | mir-test |
1384 | 71 | mir-test-framework | ||
1385 | 72 | mir-test-doubles | 70 | mir-test-doubles |
1386 | 73 | mir-test-doubles-platform | 71 | mir-test-doubles-platform |
1387 | 72 | mir-test-framework | ||
1388 | 74 | 3rd_party | 73 | 3rd_party |
1389 | 75 | 74 | ||
1390 | 76 | ${PROTOBUF_LIBRARIES} | 75 | ${PROTOBUF_LIBRARIES} |
1391 | @@ -91,8 +90,3 @@ | |||
1392 | 91 | if (MIR_RUN_ACCEPTANCE_TESTS) | 90 | if (MIR_RUN_ACCEPTANCE_TESTS) |
1393 | 92 | mir_discover_tests(mir_acceptance_tests) | 91 | mir_discover_tests(mir_acceptance_tests) |
1394 | 93 | endif (MIR_RUN_ACCEPTANCE_TESTS) | 92 | endif (MIR_RUN_ACCEPTANCE_TESTS) |
1395 | 94 | |||
1396 | 95 | install( | ||
1397 | 96 | TARGETS mir_acceptance_tests | ||
1398 | 97 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
1399 | 98 | ) | ||
1400 | 99 | 93 | ||
1401 | === modified file 'tests/acceptance-tests/test_client_library.cpp' | |||
1402 | --- tests/acceptance-tests/test_client_library.cpp 2014-12-12 01:03:15 +0000 | |||
1403 | +++ tests/acceptance-tests/test_client_library.cpp 2014-12-18 22:43:30 +0000 | |||
1404 | @@ -20,6 +20,7 @@ | |||
1405 | 20 | 20 | ||
1406 | 21 | #include "mir_test_framework/headless_in_process_server.h" | 21 | #include "mir_test_framework/headless_in_process_server.h" |
1407 | 22 | #include "mir_test_framework/using_stub_client_platform.h" | 22 | #include "mir_test_framework/using_stub_client_platform.h" |
1408 | 23 | #include "mir_test_framework/stub_platform_helpers.h" | ||
1409 | 23 | #include "mir_test/validity_matchers.h" | 24 | #include "mir_test/validity_matchers.h" |
1410 | 24 | 25 | ||
1411 | 25 | #include "src/client/client_buffer.h" | 26 | #include "src/client/client_buffer.h" |
1412 | @@ -546,15 +547,14 @@ | |||
1413 | 546 | 547 | ||
1414 | 547 | TEST_F(ClientLibrary, accesses_platform_package) | 548 | TEST_F(ClientLibrary, accesses_platform_package) |
1415 | 548 | { | 549 | { |
1416 | 550 | using namespace testing; | ||
1417 | 549 | mir_wait_for(mir_connect(new_connection().c_str(), __PRETTY_FUNCTION__, connection_callback, this)); | 551 | mir_wait_for(mir_connect(new_connection().c_str(), __PRETTY_FUNCTION__, connection_callback, this)); |
1418 | 550 | 552 | ||
1419 | 551 | MirPlatformPackage platform_package; | 553 | MirPlatformPackage platform_package; |
1422 | 552 | platform_package.data_items = -1; | 554 | ::memset(&platform_package, -1, sizeof(platform_package)); |
1421 | 553 | platform_package.fd_items = -1; | ||
1423 | 554 | 555 | ||
1424 | 555 | mir_connection_get_platform(connection, &platform_package); | 556 | mir_connection_get_platform(connection, &platform_package); |
1427 | 556 | EXPECT_GE(0, platform_package.data_items); | 557 | EXPECT_THAT(platform_package, mtf::IsStubPlatformPackage()); |
1426 | 557 | EXPECT_GE(0, platform_package.fd_items); | ||
1428 | 558 | 558 | ||
1429 | 559 | mir_connection_release(connection); | 559 | mir_connection_release(connection); |
1430 | 560 | } | 560 | } |
1431 | 561 | 561 | ||
1432 | === modified file 'tests/acceptance-tests/test_client_library_drm.cpp' | |||
1433 | --- tests/acceptance-tests/test_client_library_drm.cpp 2014-12-08 04:03:47 +0000 | |||
1434 | +++ tests/acceptance-tests/test_client_library_drm.cpp 2014-12-18 22:43:30 +0000 | |||
1435 | @@ -32,10 +32,15 @@ | |||
1436 | 32 | { | 32 | { |
1437 | 33 | struct gbm_device* dev = reinterpret_cast<struct gbm_device*>(connection); | 33 | struct gbm_device* dev = reinterpret_cast<struct gbm_device*>(connection); |
1438 | 34 | 34 | ||
1439 | 35 | MirPlatformPackage pkg; | ||
1440 | 36 | |||
1441 | 37 | mir_connection_get_platform(connection, &pkg); | ||
1442 | 38 | int const previous_data_count{pkg.data_items}; | ||
1443 | 39 | |||
1444 | 35 | mir_connection_drm_set_gbm_device(connection, dev); | 40 | mir_connection_drm_set_gbm_device(connection, dev); |
1445 | 41 | mir_connection_get_platform(connection, &pkg); | ||
1446 | 36 | 42 | ||
1451 | 37 | MirPlatformPackage pkg; | 43 | EXPECT_THAT(pkg.data_items, Eq(previous_data_count + (sizeof(dev) / sizeof(int)))); |
1452 | 38 | mir_connection_get_platform(connection, &pkg); | 44 | EXPECT_THAT(reinterpret_cast<struct gbm_device*>(pkg.data[previous_data_count]), |
1453 | 39 | EXPECT_THAT(pkg.data_items, Eq(sizeof(dev) / sizeof(int))); | 45 | Eq(dev)); |
1450 | 40 | EXPECT_THAT(*reinterpret_cast<struct gbm_device**>(&pkg.data[0]), Eq(dev)); | ||
1454 | 41 | } | 46 | } |
1455 | 42 | 47 | ||
1456 | === modified file 'tests/acceptance-tests/test_symbols_required_by_mesa.cpp' | |||
1457 | --- tests/acceptance-tests/test_symbols_required_by_mesa.cpp 2014-12-08 04:03:47 +0000 | |||
1458 | +++ tests/acceptance-tests/test_symbols_required_by_mesa.cpp 2014-12-18 22:43:30 +0000 | |||
1459 | @@ -21,11 +21,14 @@ | |||
1460 | 21 | 21 | ||
1461 | 22 | #include <dlfcn.h> | 22 | #include <dlfcn.h> |
1462 | 23 | 23 | ||
1463 | 24 | #include "mir_test_framework/executable_path.h" | ||
1464 | 25 | |||
1465 | 24 | using namespace testing; | 26 | using namespace testing; |
1466 | 27 | namespace mtf = mir_test_framework; | ||
1467 | 25 | 28 | ||
1469 | 26 | TEST(SymbolsRequiredByMesa, are_exported_by_libmirclientplatform) | 29 | TEST(SymbolsRequiredByMesa, are_exported_by_client_platform_mesa) |
1470 | 27 | { | 30 | { |
1472 | 28 | auto const handle = dlopen(MIR_CLIENT_DRIVER_BINARY, RTLD_LAZY); | 31 | auto const handle = dlopen((mtf::library_path() + "/client-modules/mesa.so").c_str(), RTLD_LAZY); |
1473 | 29 | ASSERT_THAT(handle, NotNull()); | 32 | ASSERT_THAT(handle, NotNull()); |
1474 | 30 | 33 | ||
1475 | 31 | auto const sym = dlsym(handle, "mir_client_mesa_egl_native_display_is_valid"); | 34 | auto const sym = dlsym(handle, "mir_client_mesa_egl_native_display_is_valid"); |
1476 | 32 | 35 | ||
1477 | === modified file 'tests/include/mir_test_doubles/mock_client_context.h' | |||
1478 | --- tests/include/mir_test_doubles/mock_client_context.h 2013-04-24 05:22:20 +0000 | |||
1479 | +++ tests/include/mir_test_doubles/mock_client_context.h 2014-12-18 22:43:30 +0000 | |||
1480 | @@ -33,18 +33,12 @@ | |||
1481 | 33 | struct MockClientContext : public client::ClientContext | 33 | struct MockClientContext : public client::ClientContext |
1482 | 34 | { | 34 | { |
1483 | 35 | MockClientContext() | 35 | MockClientContext() |
1484 | 36 | : connection{reinterpret_cast<MirConnection*>(0xabcdef)} | ||
1485 | 37 | { | 36 | { |
1486 | 38 | using namespace testing; | 37 | using namespace testing; |
1487 | 39 | 38 | ||
1488 | 40 | ON_CALL(*this, mir_connection()).WillByDefault(Return(connection)); | ||
1489 | 41 | EXPECT_CALL(*this, mir_connection()).Times(AtLeast(0)); | ||
1490 | 42 | EXPECT_CALL(*this, populate(_)).Times(AtLeast(0)); | 39 | EXPECT_CALL(*this, populate(_)).Times(AtLeast(0)); |
1491 | 43 | } | 40 | } |
1492 | 44 | 41 | ||
1493 | 45 | MirConnection* connection; | ||
1494 | 46 | |||
1495 | 47 | MOCK_METHOD0(mir_connection, MirConnection*()); | ||
1496 | 48 | MOCK_METHOD1(populate, void(MirPlatformPackage&)); | 42 | MOCK_METHOD1(populate, void(MirPlatformPackage&)); |
1497 | 49 | }; | 43 | }; |
1498 | 50 | 44 | ||
1499 | 51 | 45 | ||
1500 | === modified file 'tests/include/mir_test_doubles/stub_client_buffer.h' | |||
1501 | --- tests/include/mir_test_doubles/stub_client_buffer.h 2014-11-24 16:04:38 +0000 | |||
1502 | +++ tests/include/mir_test_doubles/stub_client_buffer.h 2014-12-18 22:43:30 +0000 | |||
1503 | @@ -65,7 +65,11 @@ | |||
1504 | 65 | 65 | ||
1505 | 66 | std::shared_ptr<graphics::NativeBuffer> native_buffer_handle() const override | 66 | std::shared_ptr<graphics::NativeBuffer> native_buffer_handle() const override |
1506 | 67 | { | 67 | { |
1507 | 68 | #ifndef ANDROID | ||
1508 | 69 | return package; | ||
1509 | 70 | #else | ||
1510 | 68 | return std::shared_ptr<graphics::NativeBuffer>(); | 71 | return std::shared_ptr<graphics::NativeBuffer>(); |
1511 | 72 | #endif | ||
1512 | 69 | } | 73 | } |
1513 | 70 | void update_from(MirBufferPackage const&) override {} | 74 | void update_from(MirBufferPackage const&) override {} |
1514 | 71 | void fill_update_msg(MirBufferPackage&) override{} | 75 | void fill_update_msg(MirBufferPackage&) override{} |
1515 | 72 | 76 | ||
1516 | === added file 'tests/include/mir_test_framework/client_platform_factory.h' | |||
1517 | --- tests/include/mir_test_framework/client_platform_factory.h 1970-01-01 00:00:00 +0000 | |||
1518 | +++ tests/include/mir_test_framework/client_platform_factory.h 2014-12-18 22:43:30 +0000 | |||
1519 | @@ -0,0 +1,72 @@ | |||
1520 | 1 | /* | ||
1521 | 2 | * Copyright © 2014 Canonical Ltd. | ||
1522 | 3 | * | ||
1523 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1524 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1525 | 6 | * published by the Free Software Foundation. | ||
1526 | 7 | * | ||
1527 | 8 | * This program is distributed in the hope that it will be useful, | ||
1528 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1529 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1530 | 11 | * GNU General Public License for more details. | ||
1531 | 12 | * | ||
1532 | 13 | * You should have received a copy of the GNU General Public License | ||
1533 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1534 | 15 | * | ||
1535 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
1536 | 17 | */ | ||
1537 | 18 | |||
1538 | 19 | #ifndef MIR_TEST_FRAMEWORK_CLIENT_PLATFORM_FACTORY_H_ | ||
1539 | 20 | #define MIR_TEST_FRAMEWORK_CLIENT_PLATFORM_FACTORY_H_ | ||
1540 | 21 | |||
1541 | 22 | |||
1542 | 23 | #include "mir/shared_library.h" | ||
1543 | 24 | #include "src/client/client_platform_factory.h" | ||
1544 | 25 | #include "executable_path.h" | ||
1545 | 26 | #include "mir_test_doubles/mock_client_context.h" | ||
1546 | 27 | |||
1547 | 28 | namespace mtd = mir::test::doubles; | ||
1548 | 29 | |||
1549 | 30 | namespace mir_test_framework | ||
1550 | 31 | { | ||
1551 | 32 | std::shared_ptr<mir::SharedLibrary> platform_library; | ||
1552 | 33 | |||
1553 | 34 | std::shared_ptr<mir::client::ClientPlatform> create_android_client_platform() | ||
1554 | 35 | { | ||
1555 | 36 | using namespace testing; | ||
1556 | 37 | mtd::MockClientContext ctx; | ||
1557 | 38 | ON_CALL(ctx, populate(_)) | ||
1558 | 39 | .WillByDefault(Invoke([](MirPlatformPackage& package) { ::memset(&package, 0, sizeof(package)); })); | ||
1559 | 40 | platform_library = std::make_shared<mir::SharedLibrary>(library_path() + "/client-modules/android.so"); | ||
1560 | 41 | auto platform_factory = platform_library->load_function<mir::client::CreateClientPlatform>("create_client_platform"); | ||
1561 | 42 | return platform_factory(&ctx); | ||
1562 | 43 | } | ||
1563 | 44 | |||
1564 | 45 | std::shared_ptr<mir::client::ClientPlatform> create_mesa_client_platform() | ||
1565 | 46 | { | ||
1566 | 47 | using namespace testing; | ||
1567 | 48 | mtd::MockClientContext ctx; | ||
1568 | 49 | ON_CALL(ctx, populate(_)) | ||
1569 | 50 | .WillByDefault(Invoke([](MirPlatformPackage& package) | ||
1570 | 51 | { | ||
1571 | 52 | ::memset(&package, 0, sizeof(package)); | ||
1572 | 53 | package.fd_items = 1; | ||
1573 | 54 | })); | ||
1574 | 55 | platform_library = std::make_shared<mir::SharedLibrary>(library_path() + "/client-modules/mesa.so"); | ||
1575 | 56 | auto platform_factory = platform_library->load_function<mir::client::CreateClientPlatform>("create_client_platform"); | ||
1576 | 57 | return platform_factory(&ctx); | ||
1577 | 58 | } | ||
1578 | 59 | |||
1579 | 60 | std::shared_ptr<mir::SharedLibrary> | ||
1580 | 61 | get_platform_library() | ||
1581 | 62 | { | ||
1582 | 63 | if (!platform_library) | ||
1583 | 64 | { | ||
1584 | 65 | throw std::logic_error{"Must call one of create_*_client_platform() before calling get_platform_library()"}; | ||
1585 | 66 | } | ||
1586 | 67 | return platform_library; | ||
1587 | 68 | } | ||
1588 | 69 | |||
1589 | 70 | } | ||
1590 | 71 | |||
1591 | 72 | #endif // MIR_TEST_FRAMEWORK_CLIENT_PLATFORM_FACTORY_H_ | ||
1592 | 0 | 73 | ||
1593 | === added file 'tests/include/mir_test_framework/stub_client_platform_factory.h' | |||
1594 | --- tests/include/mir_test_framework/stub_client_platform_factory.h 1970-01-01 00:00:00 +0000 | |||
1595 | +++ tests/include/mir_test_framework/stub_client_platform_factory.h 2014-12-18 22:43:30 +0000 | |||
1596 | @@ -0,0 +1,33 @@ | |||
1597 | 1 | /* | ||
1598 | 2 | * Copyright © 2014 Canonical Ltd. | ||
1599 | 3 | * | ||
1600 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1601 | 5 | * under the terms of the GNU General Public License version 3, | ||
1602 | 6 | * as published by the Free Software Foundation. | ||
1603 | 7 | * | ||
1604 | 8 | * This program is distributed in the hope that it will be useful, | ||
1605 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1606 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1607 | 11 | * GNU General Public License for more details. | ||
1608 | 12 | * | ||
1609 | 13 | * You should have received a copy of the GNU General Public License | ||
1610 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1611 | 15 | * | ||
1612 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
1613 | 17 | */ | ||
1614 | 18 | |||
1615 | 19 | #ifndef MIR_TEST_FRAMEWORK_STUB_CLIENT_PLATFORM_FACTORY_ | ||
1616 | 20 | #define MIR_TEST_FRAMEWORK_STUB_CLIENT_PLATFORM_FACTORY_ | ||
1617 | 21 | |||
1618 | 22 | #include "src/client/client_platform_factory.h" | ||
1619 | 23 | |||
1620 | 24 | namespace mir_test_framework | ||
1621 | 25 | { | ||
1622 | 26 | |||
1623 | 27 | struct StubClientPlatformFactory : public mir::client::ClientPlatformFactory | ||
1624 | 28 | { | ||
1625 | 29 | std::shared_ptr<mir::client::ClientPlatform> create_client_platform(mir::client::ClientContext* context) override; | ||
1626 | 30 | }; | ||
1627 | 31 | |||
1628 | 32 | } | ||
1629 | 33 | #endif /* MIR_TEST_FRAMEWORK_STUB_CLIENT_PLATFORM_ */ | ||
1630 | 0 | 34 | ||
1631 | === added file 'tests/include/mir_test_framework/stub_platform_helpers.h' | |||
1632 | --- tests/include/mir_test_framework/stub_platform_helpers.h 1970-01-01 00:00:00 +0000 | |||
1633 | +++ tests/include/mir_test_framework/stub_platform_helpers.h 2014-12-18 22:43:30 +0000 | |||
1634 | @@ -0,0 +1,53 @@ | |||
1635 | 1 | /* | ||
1636 | 2 | * Copyright © 2014 Canonical Ltd. | ||
1637 | 3 | * | ||
1638 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1639 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1640 | 6 | * published by the Free Software Foundation. | ||
1641 | 7 | * | ||
1642 | 8 | * This program is distributed in the hope that it will be useful, | ||
1643 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1644 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1645 | 11 | * GNU General Public License for more details. | ||
1646 | 12 | * | ||
1647 | 13 | * You should have received a copy of the GNU General Public License | ||
1648 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1649 | 15 | * | ||
1650 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
1651 | 17 | */ | ||
1652 | 18 | |||
1653 | 19 | #ifndef MIR_TEST_FRAMEWORK_STUB_PLATFORM_HELPERS_H_ | ||
1654 | 20 | #define MIR_TEST_FRAMEWORK_STUB_PLATFORM_HELPERS_H_ | ||
1655 | 21 | |||
1656 | 22 | #include "mir/graphics/platform_ipc_package.h" | ||
1657 | 23 | #include "mir_toolkit/client_types.h" | ||
1658 | 24 | |||
1659 | 25 | #include <gmock/gmock.h> | ||
1660 | 26 | |||
1661 | 27 | namespace mir_test_framework | ||
1662 | 28 | { | ||
1663 | 29 | constexpr int stub_data_size{21}; | ||
1664 | 30 | constexpr int stub_data_guard{0x0eadbeef}; | ||
1665 | 31 | |||
1666 | 32 | static inline void pack_stub_ipc_package(mir::graphics::PlatformIPCPackage& package) | ||
1667 | 33 | { | ||
1668 | 34 | package.ipc_data = std::vector<int32_t>(stub_data_size, -1); | ||
1669 | 35 | package.ipc_data[0] = stub_data_guard; | ||
1670 | 36 | } | ||
1671 | 37 | |||
1672 | 38 | static inline void create_stub_platform_package(MirPlatformPackage& package) | ||
1673 | 39 | { | ||
1674 | 40 | ::memset(&package, 0, sizeof(package)); | ||
1675 | 41 | package.data_items = stub_data_size; | ||
1676 | 42 | package.data[0] = stub_data_guard; | ||
1677 | 43 | } | ||
1678 | 44 | |||
1679 | 45 | MATCHER(IsStubPlatformPackage, "") | ||
1680 | 46 | { | ||
1681 | 47 | return (arg.data_items == stub_data_size) && | ||
1682 | 48 | (arg.data[0] == stub_data_guard) && | ||
1683 | 49 | (arg.fd_items == 0); | ||
1684 | 50 | } | ||
1685 | 51 | } | ||
1686 | 52 | |||
1687 | 53 | #endif // MIR_TEST_FRAMEWORK_STUB_PLATFORM_HELPERS_H_ | ||
1688 | 0 | 54 | ||
1689 | === modified file 'tests/integration-tests/CMakeLists.txt' | |||
1690 | --- tests/integration-tests/CMakeLists.txt 2014-12-08 04:03:47 +0000 | |||
1691 | +++ tests/integration-tests/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
1692 | @@ -66,7 +66,7 @@ | |||
1693 | 66 | endif() | 66 | endif() |
1694 | 67 | 67 | ||
1695 | 68 | link_directories(${LIBRARY_OUTPUT_PATH}) | 68 | link_directories(${LIBRARY_OUTPUT_PATH}) |
1697 | 69 | add_executable( | 69 | mir_add_wrapped_executable( |
1698 | 70 | mir_integration_tests | 70 | mir_integration_tests |
1699 | 71 | ${INTEGRATION_TESTS_SRCS} | 71 | ${INTEGRATION_TESTS_SRCS} |
1700 | 72 | ${MIR_SERVER_OBJECTS} | 72 | ${MIR_SERVER_OBJECTS} |
1701 | @@ -126,8 +126,3 @@ | |||
1702 | 126 | if (MIR_RUN_INTEGRATION_TESTS) | 126 | if (MIR_RUN_INTEGRATION_TESTS) |
1703 | 127 | mir_discover_tests(mir_integration_tests) | 127 | mir_discover_tests(mir_integration_tests) |
1704 | 128 | endif (MIR_RUN_INTEGRATION_TESTS) | 128 | endif (MIR_RUN_INTEGRATION_TESTS) |
1705 | 129 | |||
1706 | 130 | install( | ||
1707 | 131 | TARGETS mir_integration_tests | ||
1708 | 132 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
1709 | 133 | ) | ||
1710 | 134 | 129 | ||
1711 | === modified file 'tests/mir_test_doubles/CMakeLists.txt' | |||
1712 | --- tests/mir_test_doubles/CMakeLists.txt 2014-12-08 04:03:47 +0000 | |||
1713 | +++ tests/mir_test_doubles/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
1714 | @@ -30,13 +30,14 @@ | |||
1715 | 30 | ${CMAKE_CURRENT_SOURCE_DIR}/mock_gl.cpp | 30 | ${CMAKE_CURRENT_SOURCE_DIR}/mock_gl.cpp |
1716 | 31 | ) | 31 | ) |
1717 | 32 | 32 | ||
1719 | 33 | if (MIR_TEST_PLATFORM STREQUAL "mesa") | 33 | if (MIR_BUILD_PLATFORM_MESA) |
1720 | 34 | include_directories(${DRM_INCLUDE_DIRS} ${GBM_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}) | 34 | include_directories(${DRM_INCLUDE_DIRS} ${GBM_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}) |
1721 | 35 | list(APPEND MIR_TEST_DOUBLES_PLATFORM_SRCS | 35 | list(APPEND MIR_TEST_DOUBLES_PLATFORM_SRCS |
1722 | 36 | ${CMAKE_CURRENT_SOURCE_DIR}/mock_drm.cpp | 36 | ${CMAKE_CURRENT_SOURCE_DIR}/mock_drm.cpp |
1723 | 37 | ${CMAKE_CURRENT_SOURCE_DIR}/mock_gbm.cpp | 37 | ${CMAKE_CURRENT_SOURCE_DIR}/mock_gbm.cpp |
1724 | 38 | ) | 38 | ) |
1726 | 39 | elseif (MIR_TEST_PLATFORM STREQUAL "android") | 39 | endif() |
1727 | 40 | if (MIR_BUILD_PLATFORM_ANDROID) | ||
1728 | 40 | list(APPEND MIR_TEST_DOUBLES_PLATFORM_SRCS | 41 | list(APPEND MIR_TEST_DOUBLES_PLATFORM_SRCS |
1729 | 41 | ${CMAKE_CURRENT_SOURCE_DIR}/mock_android_hw.cpp | 42 | ${CMAKE_CURRENT_SOURCE_DIR}/mock_android_hw.cpp |
1730 | 42 | ) | 43 | ) |
1731 | 43 | 44 | ||
1732 | === modified file 'tests/mir_test_framework/CMakeLists.txt' | |||
1733 | --- tests/mir_test_framework/CMakeLists.txt 2014-12-18 07:07:22 +0000 | |||
1734 | +++ tests/mir_test_framework/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
1735 | @@ -4,10 +4,11 @@ | |||
1736 | 4 | ${PROJECT_SOURCE_DIR}/src/include/common | 4 | ${PROJECT_SOURCE_DIR}/src/include/common |
1737 | 5 | ${PROJECT_SOURCE_DIR}/src/include/server | 5 | ${PROJECT_SOURCE_DIR}/src/include/server |
1738 | 6 | ${PROJECT_SOURCE_DIR}/src/include/client | 6 | ${PROJECT_SOURCE_DIR}/src/include/client |
1743 | 7 | ${Boost_INCLUDE_DIRS} | 7 | ${Boost_INCLUDE_DIRS} |
1744 | 8 | ${GLESv2_INCLUDE_DIRS} | 8 | ${GLESv2_INCLUDE_DIRS} |
1745 | 9 | ${CMAKE_SOURCE_DIR} | 9 | ${CMAKE_SOURCE_DIR} |
1746 | 10 | ${UMOCKDEV_INCLUDE_DIRS} | 10 | ${UMOCKDEV_INCLUDE_DIRS} |
1747 | 11 | ${ANDROID_HEADERS_INCLUDE_DIRS} | ||
1748 | 11 | ) | 12 | ) |
1749 | 12 | 13 | ||
1750 | 13 | set( | 14 | set( |
1751 | @@ -32,6 +33,7 @@ | |||
1752 | 32 | display_server_test_fixture.cpp | 33 | display_server_test_fixture.cpp |
1753 | 33 | process.cpp | 34 | process.cpp |
1754 | 34 | using_stub_client_platform.cpp | 35 | using_stub_client_platform.cpp |
1755 | 36 | stub_client_platform_factory.cpp | ||
1756 | 35 | udev_environment.cpp | 37 | udev_environment.cpp |
1757 | 36 | declarative_placement_strategy.cpp | 38 | declarative_placement_strategy.cpp |
1758 | 37 | fake_event_hub_server_configuration.cpp | 39 | fake_event_hub_server_configuration.cpp |
1759 | @@ -69,6 +71,29 @@ | |||
1760 | 69 | ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. | 71 | ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. |
1761 | 70 | ) | 72 | ) |
1762 | 71 | 73 | ||
1763 | 74 | set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols-client.map) | ||
1764 | 75 | |||
1765 | 76 | add_library( | ||
1766 | 77 | mirclientplatformstub MODULE | ||
1767 | 78 | |||
1768 | 79 | stub_client_platform_module.cpp | ||
1769 | 80 | ) | ||
1770 | 81 | |||
1771 | 82 | target_link_libraries( | ||
1772 | 83 | mirclientplatformstub | ||
1773 | 84 | |||
1774 | 85 | mir-test-framework | ||
1775 | 86 | ${UMOCKDEV_LDFLAGS} ${UMOCKDEV_LIBRARIES} | ||
1776 | 87 | ) | ||
1777 | 88 | |||
1778 | 89 | set_target_properties( | ||
1779 | 90 | mirclientplatformstub PROPERTIES; | ||
1780 | 91 | LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/client-modules | ||
1781 | 92 | OUTPUT_NAME dummy | ||
1782 | 93 | PREFIX "" | ||
1783 | 94 | LINK_FLAGS "-Wl,--version-script,${symbol_map}" | ||
1784 | 95 | ) | ||
1785 | 96 | |||
1786 | 72 | add_custom_command(TARGET mir-test-framework POST_BUILD | 97 | add_custom_command(TARGET mir-test-framework POST_BUILD |
1787 | 73 | COMMAND ${CMAKE_COMMAND} -E copy_directory | 98 | COMMAND ${CMAKE_COMMAND} -E copy_directory |
1788 | 74 | ${CMAKE_CURRENT_SOURCE_DIR}/udev_recordings ${CMAKE_BINARY_DIR}/bin/udev_recordings | 99 | ${CMAKE_CURRENT_SOURCE_DIR}/udev_recordings ${CMAKE_BINARY_DIR}/bin/udev_recordings |
1789 | @@ -97,3 +122,4 @@ | |||
1790 | 97 | ) | 122 | ) |
1791 | 98 | 123 | ||
1792 | 99 | install(TARGETS mirplatformstub LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) | 124 | install(TARGETS mirplatformstub LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
1793 | 125 | install(TARGETS mirclientplatformstub LIBRARY DESTINATION ${MIR_CLIENT_PLATFORM_PATH}) | ||
1794 | 100 | 126 | ||
1795 | === added file 'tests/mir_test_framework/stub_client_platform_factory.cpp' | |||
1796 | --- tests/mir_test_framework/stub_client_platform_factory.cpp 1970-01-01 00:00:00 +0000 | |||
1797 | +++ tests/mir_test_framework/stub_client_platform_factory.cpp 2014-12-18 22:43:30 +0000 | |||
1798 | @@ -0,0 +1,74 @@ | |||
1799 | 1 | /* | ||
1800 | 2 | * Copyright © 2014 Canonical Ltd. | ||
1801 | 3 | * | ||
1802 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1803 | 5 | * under the terms of the GNU General Public License version 3, | ||
1804 | 6 | * as published by the Free Software Foundation. | ||
1805 | 7 | * | ||
1806 | 8 | * This program is distributed in the hope that it will be useful, | ||
1807 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1808 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1809 | 11 | * GNU General Public License for more details. | ||
1810 | 12 | * | ||
1811 | 13 | * You should have received a copy of the GNU General Public License | ||
1812 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1813 | 15 | * | ||
1814 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
1815 | 17 | */ | ||
1816 | 18 | |||
1817 | 19 | #include "mir_test_framework/stub_client_platform_factory.h" | ||
1818 | 20 | #include "mir_test_doubles/stub_client_buffer_factory.h" | ||
1819 | 21 | #include "src/client/client_buffer_factory.h" | ||
1820 | 22 | #include "src/client/client_buffer.h" | ||
1821 | 23 | #include "src/client/client_platform.h" | ||
1822 | 24 | |||
1823 | 25 | #include <string.h> | ||
1824 | 26 | |||
1825 | 27 | namespace mcl = mir::client; | ||
1826 | 28 | namespace geom = mir::geometry; | ||
1827 | 29 | namespace mtf = mir_test_framework; | ||
1828 | 30 | namespace mtd = mir::test::doubles; | ||
1829 | 31 | |||
1830 | 32 | namespace | ||
1831 | 33 | { | ||
1832 | 34 | struct StubClientPlatform : public mcl::ClientPlatform | ||
1833 | 35 | { | ||
1834 | 36 | MirPlatformType platform_type() const | ||
1835 | 37 | { | ||
1836 | 38 | return mir_platform_type_gbm; | ||
1837 | 39 | } | ||
1838 | 40 | |||
1839 | 41 | std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory() | ||
1840 | 42 | { | ||
1841 | 43 | return std::make_shared<mtd::StubClientBufferFactory>(); | ||
1842 | 44 | } | ||
1843 | 45 | |||
1844 | 46 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(mcl::ClientSurface*) | ||
1845 | 47 | { | ||
1846 | 48 | auto fake_window = reinterpret_cast<EGLNativeWindowType>(0x12345678lu); | ||
1847 | 49 | return std::make_shared<EGLNativeWindowType>(fake_window); | ||
1848 | 50 | } | ||
1849 | 51 | |||
1850 | 52 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() | ||
1851 | 53 | { | ||
1852 | 54 | auto fake_display = reinterpret_cast<EGLNativeDisplayType>(0x12345678lu); | ||
1853 | 55 | return std::make_shared<EGLNativeDisplayType>(fake_display); | ||
1854 | 56 | } | ||
1855 | 57 | |||
1856 | 58 | MirNativeBuffer* convert_native_buffer(mir::graphics::NativeBuffer* buf) const | ||
1857 | 59 | { | ||
1858 | 60 | static_cast<void>(buf); | ||
1859 | 61 | #ifndef ANDROID | ||
1860 | 62 | return buf; | ||
1861 | 63 | #else | ||
1862 | 64 | return nullptr; | ||
1863 | 65 | #endif | ||
1864 | 66 | } | ||
1865 | 67 | }; | ||
1866 | 68 | } | ||
1867 | 69 | |||
1868 | 70 | std::shared_ptr<mcl::ClientPlatform> | ||
1869 | 71 | mtf::StubClientPlatformFactory::create_client_platform(mcl::ClientContext*) | ||
1870 | 72 | { | ||
1871 | 73 | return std::make_shared<StubClientPlatform>(); | ||
1872 | 74 | } | ||
1873 | 0 | 75 | ||
1874 | === added file 'tests/mir_test_framework/stub_client_platform_module.cpp' | |||
1875 | --- tests/mir_test_framework/stub_client_platform_module.cpp 1970-01-01 00:00:00 +0000 | |||
1876 | +++ tests/mir_test_framework/stub_client_platform_module.cpp 2014-12-18 22:43:30 +0000 | |||
1877 | @@ -0,0 +1,41 @@ | |||
1878 | 1 | /* | ||
1879 | 2 | * Copyright © 2014 Canonical Ltd. | ||
1880 | 3 | * | ||
1881 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1882 | 5 | * under the terms of the GNU General Public License version 3, | ||
1883 | 6 | * as published by the Free Software Foundation. | ||
1884 | 7 | * | ||
1885 | 8 | * This program is distributed in the hope that it will be useful, | ||
1886 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1887 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1888 | 11 | * GNU General Public License for more details. | ||
1889 | 12 | * | ||
1890 | 13 | * You should have received a copy of the GNU General Public License | ||
1891 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1892 | 15 | * | ||
1893 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>> | ||
1894 | 17 | */ | ||
1895 | 18 | |||
1896 | 19 | #include "src/client/client_platform_factory.h" | ||
1897 | 20 | #include "src/client/client_context.h" | ||
1898 | 21 | |||
1899 | 22 | #include "mir_test_framework/stub_client_platform_factory.h" | ||
1900 | 23 | #include "mir_test_framework/stub_platform_helpers.h" | ||
1901 | 24 | #include <memory> | ||
1902 | 25 | #include <gmock/gmock.h> | ||
1903 | 26 | |||
1904 | 27 | namespace mtf = mir_test_framework; | ||
1905 | 28 | namespace mcl = mir::client; | ||
1906 | 29 | |||
1907 | 30 | extern "C" std::shared_ptr<mcl::ClientPlatform> create_client_platform(mcl::ClientContext* context) | ||
1908 | 31 | { | ||
1909 | 32 | return mtf::StubClientPlatformFactory{}.create_client_platform(context); | ||
1910 | 33 | } | ||
1911 | 34 | |||
1912 | 35 | extern "C" bool is_appropriate_module(mcl::ClientContext* context) | ||
1913 | 36 | { | ||
1914 | 37 | using namespace testing; | ||
1915 | 38 | MirPlatformPackage package; | ||
1916 | 39 | context->populate(package); | ||
1917 | 40 | return Matches(mtf::IsStubPlatformPackage())(package); | ||
1918 | 41 | } | ||
1919 | 0 | 42 | ||
1920 | === modified file 'tests/mir_test_framework/stubbed_graphics_platform.cpp' | |||
1921 | --- tests/mir_test_framework/stubbed_graphics_platform.cpp 2014-12-15 06:24:03 +0000 | |||
1922 | +++ tests/mir_test_framework/stubbed_graphics_platform.cpp 2014-12-18 22:43:30 +0000 | |||
1923 | @@ -22,6 +22,8 @@ | |||
1924 | 22 | #include "mir/graphics/buffer_ipc_message.h" | 22 | #include "mir/graphics/buffer_ipc_message.h" |
1925 | 23 | #include "mir/graphics/buffer_writer.h" | 23 | #include "mir/graphics/buffer_writer.h" |
1926 | 24 | 24 | ||
1927 | 25 | #include "mir_test_framework/stub_platform_helpers.h" | ||
1928 | 26 | |||
1929 | 25 | #include "mir_test_doubles/stub_buffer_allocator.h" | 27 | #include "mir_test_doubles/stub_buffer_allocator.h" |
1930 | 26 | #include "mir_test_doubles/stub_display.h" | 28 | #include "mir_test_doubles/stub_display.h" |
1931 | 27 | #include "mir/fd.h" | 29 | #include "mir/fd.h" |
1932 | @@ -149,7 +151,9 @@ | |||
1933 | 149 | 151 | ||
1934 | 150 | std::shared_ptr<mg::PlatformIPCPackage> connection_ipc_package() override | 152 | std::shared_ptr<mg::PlatformIPCPackage> connection_ipc_package() override |
1935 | 151 | { | 153 | { |
1937 | 152 | return std::make_shared<mg::PlatformIPCPackage>(); | 154 | auto package = std::make_shared<mg::PlatformIPCPackage>(); |
1938 | 155 | mtf::pack_stub_ipc_package(*package); | ||
1939 | 156 | return package; | ||
1940 | 153 | } | 157 | } |
1941 | 154 | 158 | ||
1942 | 155 | mg::PlatformOperationMessage platform_operation( | 159 | mg::PlatformOperationMessage platform_operation( |
1943 | 156 | 160 | ||
1944 | === added file 'tests/mir_test_framework/symbols-client.map' | |||
1945 | --- tests/mir_test_framework/symbols-client.map 1970-01-01 00:00:00 +0000 | |||
1946 | +++ tests/mir_test_framework/symbols-client.map 2014-12-18 22:43:30 +0000 | |||
1947 | @@ -0,0 +1,7 @@ | |||
1948 | 1 | MIR_CLIENT_PLATFORM_2 { | ||
1949 | 2 | global: | ||
1950 | 3 | create_client_platform; | ||
1951 | 4 | is_appropriate_module; | ||
1952 | 5 | local: | ||
1953 | 6 | *; | ||
1954 | 7 | }; | ||
1955 | 0 | 8 | ||
1956 | === modified file 'tests/unit-tests/CMakeLists.txt' | |||
1957 | --- tests/unit-tests/CMakeLists.txt 2014-12-08 04:03:47 +0000 | |||
1958 | +++ tests/unit-tests/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
1959 | @@ -56,7 +56,7 @@ | |||
1960 | 56 | 56 | ||
1961 | 57 | link_directories(${LIBRARY_OUTPUT_PATH}) | 57 | link_directories(${LIBRARY_OUTPUT_PATH}) |
1962 | 58 | 58 | ||
1964 | 59 | add_executable(mir_unit_tests | 59 | mir_add_wrapped_executable(mir_unit_tests |
1965 | 60 | ${UNIT_TEST_SOURCES} | 60 | ${UNIT_TEST_SOURCES} |
1966 | 61 | ${MIR_SERVER_OBJECTS} | 61 | ${MIR_SERVER_OBJECTS} |
1967 | 62 | $<TARGET_OBJECTS:mirclientobjects> | 62 | $<TARGET_OBJECTS:mirclientobjects> |
1968 | @@ -117,11 +117,6 @@ | |||
1969 | 117 | mir_discover_tests(mir_unit_tests LD_PRELOAD=libumockdev-preload.so.0 G_SLICE=always-malloc G_DEBUG=gc-friendly) | 117 | mir_discover_tests(mir_unit_tests LD_PRELOAD=libumockdev-preload.so.0 G_SLICE=always-malloc G_DEBUG=gc-friendly) |
1970 | 118 | endif (MIR_RUN_UNIT_TESTS) | 118 | endif (MIR_RUN_UNIT_TESTS) |
1971 | 119 | 119 | ||
1972 | 120 | install( | ||
1973 | 121 | TARGETS mir_unit_tests | ||
1974 | 122 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
1975 | 123 | ) | ||
1976 | 124 | |||
1977 | 125 | add_custom_command(TARGET mir_unit_tests POST_BUILD | 120 | add_custom_command(TARGET mir_unit_tests POST_BUILD |
1978 | 126 | COMMAND ${CMAKE_COMMAND} -E copy_directory | 121 | COMMAND ${CMAKE_COMMAND} -E copy_directory |
1979 | 127 | ${CMAKE_CURRENT_SOURCE_DIR}/test_data ${CMAKE_BINARY_DIR}/bin/test_data | 122 | ${CMAKE_CURRENT_SOURCE_DIR}/test_data ${CMAKE_BINARY_DIR}/bin/test_data |
1980 | 128 | 123 | ||
1981 | === modified file 'tests/unit-tests/client/CMakeLists.txt' | |||
1982 | --- tests/unit-tests/client/CMakeLists.txt 2014-12-08 04:03:47 +0000 | |||
1983 | +++ tests/unit-tests/client/CMakeLists.txt 2014-12-18 22:43:30 +0000 | |||
1984 | @@ -10,6 +10,7 @@ | |||
1985 | 10 | ${CMAKE_CURRENT_SOURCE_DIR}/test_client_display_conf.cpp | 10 | ${CMAKE_CURRENT_SOURCE_DIR}/test_client_display_conf.cpp |
1986 | 11 | ${CMAKE_CURRENT_SOURCE_DIR}/test_mir_screencast.cpp | 11 | ${CMAKE_CURRENT_SOURCE_DIR}/test_mir_screencast.cpp |
1987 | 12 | ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_rpc_channel.cpp | 12 | ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_rpc_channel.cpp |
1988 | 13 | ${CMAKE_CURRENT_SOURCE_DIR}/test_probing_client_platform_factory.cpp | ||
1989 | 13 | ${CMAKE_CURRENT_SOURCE_DIR}/test_mir_prompt_session.cpp | 14 | ${CMAKE_CURRENT_SOURCE_DIR}/test_mir_prompt_session.cpp |
1990 | 14 | ${CMAKE_CURRENT_SOURCE_DIR}/test_event_distributor.cpp | 15 | ${CMAKE_CURRENT_SOURCE_DIR}/test_event_distributor.cpp |
1991 | 15 | ${CMAKE_CURRENT_SOURCE_DIR}/test_periodic_perf_report.cpp | 16 | ${CMAKE_CURRENT_SOURCE_DIR}/test_periodic_perf_report.cpp |
1992 | 16 | 17 | ||
1993 | === modified file 'tests/unit-tests/client/android/test_android_client_platform.cpp' | |||
1994 | --- tests/unit-tests/client/android/test_android_client_platform.cpp 2014-03-06 06:05:17 +0000 | |||
1995 | +++ tests/unit-tests/client/android/test_android_client_platform.cpp 2014-12-18 22:43:30 +0000 | |||
1996 | @@ -17,9 +17,9 @@ | |||
1997 | 17 | */ | 17 | */ |
1998 | 18 | 18 | ||
1999 | 19 | #include "src/client/client_platform.h" | 19 | #include "src/client/client_platform.h" |
2000 | 20 | #include "src/client/android/client_platform_factory.h" | ||
2001 | 21 | #include "mir_test_doubles/mock_client_context.h" | 20 | #include "mir_test_doubles/mock_client_context.h" |
2002 | 22 | #include "mir_test_doubles/mock_client_surface.h" | 21 | #include "mir_test_doubles/mock_client_surface.h" |
2003 | 22 | #include "mir_test_framework/client_platform_factory.h" | ||
2004 | 23 | 23 | ||
2005 | 24 | #include <EGL/egl.h> | 24 | #include <EGL/egl.h> |
2006 | 25 | 25 | ||
2007 | @@ -28,13 +28,12 @@ | |||
2008 | 28 | namespace mcl = mir::client; | 28 | namespace mcl = mir::client; |
2009 | 29 | namespace mt = mir::test; | 29 | namespace mt = mir::test; |
2010 | 30 | namespace mtd = mt::doubles; | 30 | namespace mtd = mt::doubles; |
2011 | 31 | namespace mtf = mir_test_framework; | ||
2012 | 31 | 32 | ||
2013 | 32 | TEST(AndroidClientPlatformTest, egl_native_display_is_egl_default_display) | 33 | TEST(AndroidClientPlatformTest, egl_native_display_is_egl_default_display) |
2014 | 33 | { | 34 | { |
2015 | 34 | mtd::MockClientContext context; | ||
2016 | 35 | mcl::android::ClientPlatformFactory factory; | ||
2017 | 36 | mtd::MockClientSurface surface; | 35 | mtd::MockClientSurface surface; |
2019 | 37 | auto platform = factory.create_client_platform(&context); | 36 | auto platform = mtf::create_android_client_platform(); |
2020 | 38 | auto mock_client_surface = std::make_shared<mtd::MockClientSurface>(); | 37 | auto mock_client_surface = std::make_shared<mtd::MockClientSurface>(); |
2021 | 39 | auto native_display = platform->create_egl_native_display(); | 38 | auto native_display = platform->create_egl_native_display(); |
2022 | 40 | EXPECT_EQ(EGL_DEFAULT_DISPLAY, *native_display); | 39 | EXPECT_EQ(EGL_DEFAULT_DISPLAY, *native_display); |
2023 | @@ -42,10 +41,8 @@ | |||
2024 | 42 | 41 | ||
2025 | 43 | TEST(AndroidClientPlatformTest, egl_native_window_is_set) | 42 | TEST(AndroidClientPlatformTest, egl_native_window_is_set) |
2026 | 44 | { | 43 | { |
2027 | 45 | mtd::MockClientContext context; | ||
2028 | 46 | mcl::android::ClientPlatformFactory factory; | ||
2029 | 47 | mtd::MockClientSurface surface; | 44 | mtd::MockClientSurface surface; |
2031 | 48 | auto platform = factory.create_client_platform(&context); | 45 | auto platform = mtf::create_android_client_platform(); |
2032 | 49 | auto mock_client_surface = std::make_shared<mtd::MockClientSurface>(); | 46 | auto mock_client_surface = std::make_shared<mtd::MockClientSurface>(); |
2033 | 50 | auto egl_native_window = platform->create_egl_native_window(&surface); | 47 | auto egl_native_window = platform->create_egl_native_window(&surface); |
2034 | 51 | EXPECT_NE(nullptr, egl_native_window); | 48 | EXPECT_NE(nullptr, egl_native_window); |
2035 | 52 | 49 | ||
2036 | === modified file 'tests/unit-tests/client/mesa/test_client_platform.cpp' | |||
2037 | --- tests/unit-tests/client/mesa/test_client_platform.cpp 2014-03-06 06:05:17 +0000 | |||
2038 | +++ tests/unit-tests/client/mesa/test_client_platform.cpp 2014-12-18 22:43:30 +0000 | |||
2039 | @@ -17,9 +17,9 @@ | |||
2040 | 17 | */ | 17 | */ |
2041 | 18 | 18 | ||
2042 | 19 | #include "src/client/client_platform.h" | 19 | #include "src/client/client_platform.h" |
2044 | 20 | #include "src/client/mesa/client_platform_factory.h" | 20 | #include "mir/shared_library.h" |
2045 | 21 | #include "src/client/mesa/mesa_native_display_container.h" | 21 | #include "src/client/mesa/mesa_native_display_container.h" |
2047 | 22 | #include "mir_test_doubles/mock_client_context.h" | 22 | #include "mir_test_framework/client_platform_factory.h" |
2048 | 23 | #include "mir_test_doubles/mock_client_surface.h" | 23 | #include "mir_test_doubles/mock_client_surface.h" |
2049 | 24 | 24 | ||
2050 | 25 | #include "mir_toolkit/mesa/native_display.h" | 25 | #include "mir_toolkit/mesa/native_display.h" |
2051 | @@ -30,19 +30,20 @@ | |||
2052 | 30 | namespace mclm = mir::client::mesa; | 30 | namespace mclm = mir::client::mesa; |
2053 | 31 | namespace mt = mir::test; | 31 | namespace mt = mir::test; |
2054 | 32 | namespace mtd = mir::test::doubles; | 32 | namespace mtd = mir::test::doubles; |
2055 | 33 | namespace mtf = mir_test_framework; | ||
2056 | 33 | 34 | ||
2057 | 34 | TEST(MesaClientPlatformTest, egl_native_display_is_valid_until_released) | 35 | TEST(MesaClientPlatformTest, egl_native_display_is_valid_until_released) |
2058 | 35 | { | 36 | { |
2062 | 36 | mtd::MockClientContext context; | 37 | auto platform = mtf::create_mesa_client_platform(); |
2063 | 37 | mclm::ClientPlatformFactory factory; | 38 | auto platform_lib = mtf::get_platform_library(); |
2061 | 38 | auto platform = factory.create_client_platform(&context); | ||
2064 | 39 | 39 | ||
2065 | 40 | MirMesaEGLNativeDisplay* nd; | 40 | MirMesaEGLNativeDisplay* nd; |
2066 | 41 | { | 41 | { |
2067 | 42 | std::shared_ptr<EGLNativeDisplayType> native_display = platform->create_egl_native_display(); | 42 | std::shared_ptr<EGLNativeDisplayType> native_display = platform->create_egl_native_display(); |
2068 | 43 | 43 | ||
2069 | 44 | nd = reinterpret_cast<MirMesaEGLNativeDisplay*>(*native_display); | 44 | nd = reinterpret_cast<MirMesaEGLNativeDisplay*>(*native_display); |
2071 | 45 | EXPECT_EQ(MIR_MESA_TRUE, mclm::mir_client_mesa_egl_native_display_is_valid(nd)); | 45 | auto validate = platform_lib->load_function<MirBool(*)(MirMesaEGLNativeDisplay*)>("mir_client_mesa_egl_native_display_is_valid"); |
2072 | 46 | EXPECT_EQ(MIR_MESA_TRUE, validate(nd)); | ||
2073 | 46 | } | 47 | } |
2074 | 47 | EXPECT_EQ(MIR_MESA_FALSE, mclm::mir_client_mesa_egl_native_display_is_valid(nd)); | 48 | EXPECT_EQ(MIR_MESA_FALSE, mclm::mir_client_mesa_egl_native_display_is_valid(nd)); |
2075 | 48 | } | 49 | } |
2076 | 49 | 50 | ||
2077 | === modified file 'tests/unit-tests/client/mesa/test_mesa_native_display_container.cpp' | |||
2078 | --- tests/unit-tests/client/mesa/test_mesa_native_display_container.cpp 2014-03-06 06:05:17 +0000 | |||
2079 | +++ tests/unit-tests/client/mesa/test_mesa_native_display_container.cpp 2014-12-18 22:43:30 +0000 | |||
2080 | @@ -40,7 +40,7 @@ | |||
2081 | 40 | } | 40 | } |
2082 | 41 | 41 | ||
2083 | 42 | std::shared_ptr<mclg::MesaNativeDisplayContainer> const container; | 42 | std::shared_ptr<mclg::MesaNativeDisplayContainer> const container; |
2085 | 43 | MirConnection* connection; | 43 | mir::client::ClientContext* connection; |
2086 | 44 | }; | 44 | }; |
2087 | 45 | 45 | ||
2088 | 46 | } | 46 | } |
2089 | 47 | 47 | ||
2090 | === modified file 'tests/unit-tests/client/test_client_platform.cpp' | |||
2091 | --- tests/unit-tests/client/test_client_platform.cpp 2014-03-06 06:05:17 +0000 | |||
2092 | +++ tests/unit-tests/client/test_client_platform.cpp 2014-12-18 22:43:30 +0000 | |||
2093 | @@ -20,60 +20,153 @@ | |||
2094 | 20 | #include "src/client/mir_client_surface.h" | 20 | #include "src/client/mir_client_surface.h" |
2095 | 21 | #include "mir_test_doubles/mock_client_context.h" | 21 | #include "mir_test_doubles/mock_client_context.h" |
2096 | 22 | #include "mir_test_doubles/mock_client_surface.h" | 22 | #include "mir_test_doubles/mock_client_surface.h" |
2097 | 23 | #include "mir_test_framework/executable_path.h" | ||
2098 | 24 | #include "mir_test_framework/stub_platform_helpers.h" | ||
2099 | 23 | 25 | ||
2101 | 24 | #ifdef ANDROID | 26 | #ifdef MIR_BUILD_PLATFORM_ANDROID |
2102 | 25 | #include "mir_test_doubles/mock_android_hw.h" | 27 | #include "mir_test_doubles/mock_android_hw.h" |
2103 | 26 | #include "src/client/android/client_platform_factory.h" | ||
2104 | 27 | #else | ||
2105 | 28 | #include "src/client/mesa/client_platform_factory.h" | ||
2106 | 29 | #endif | 28 | #endif |
2107 | 30 | 29 | ||
2108 | 30 | #include "src/client/client_platform_factory.h" | ||
2109 | 31 | |||
2110 | 32 | #include "mir/shared_library.h" | ||
2111 | 33 | |||
2112 | 31 | #include <gmock/gmock.h> | 34 | #include <gmock/gmock.h> |
2113 | 32 | #include <gtest/gtest.h> | 35 | #include <gtest/gtest.h> |
2114 | 33 | 36 | ||
2115 | 34 | namespace mcl=mir::client; | 37 | namespace mcl=mir::client; |
2116 | 35 | namespace mtd = mir::test::doubles; | 38 | namespace mtd = mir::test::doubles; |
2120 | 36 | 39 | namespace mtf = mir_test_framework; | |
2121 | 37 | struct ClientPlatformTest : public ::testing::Test | 40 | |
2122 | 38 | { | 41 | namespace |
2123 | 42 | { | ||
2124 | 43 | struct ClientPlatformTraits | ||
2125 | 44 | { | ||
2126 | 45 | ClientPlatformTraits(std::string const& library, | ||
2127 | 46 | std::function<void(MirPlatformPackage&)> populator, | ||
2128 | 47 | MirPlatformType type) | ||
2129 | 48 | : platform_library_name{library}, | ||
2130 | 49 | populate_package_for{populator}, | ||
2131 | 50 | platform_type{type} | ||
2132 | 51 | { | ||
2133 | 52 | } | ||
2134 | 53 | |||
2135 | 54 | std::string const platform_library_name; | ||
2136 | 55 | std::function<void(MirPlatformPackage&)> const populate_package_for; | ||
2137 | 56 | MirPlatformType const platform_type; | ||
2138 | 57 | }; | ||
2139 | 58 | |||
2140 | 59 | struct ClientPlatformTest : public ::testing::TestWithParam<ClientPlatformTraits const*> | ||
2141 | 60 | { | ||
2142 | 61 | ClientPlatformTest() | ||
2143 | 62 | : platform_library{mtf::library_path() + "/" + GetParam()->platform_library_name}, | ||
2144 | 63 | create_client_platform{platform_library.load_function<mcl::CreateClientPlatform>("create_client_platform")}, | ||
2145 | 64 | probe{platform_library.load_function<mcl::ClientPlatformProbe>("is_appropriate_module")} | ||
2146 | 65 | { | ||
2147 | 66 | using namespace testing; | ||
2148 | 67 | ON_CALL(context, populate(_)) | ||
2149 | 68 | .WillByDefault(Invoke(GetParam()->populate_package_for)); | ||
2150 | 69 | } | ||
2151 | 70 | |||
2152 | 39 | mtd::MockClientContext context; | 71 | mtd::MockClientContext context; |
2154 | 40 | #ifdef ANDROID | 72 | #ifdef MIR_BUILD_PLATFORM_ANDROID |
2155 | 41 | testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock; | 73 | testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock; |
2156 | 42 | mcl::android::ClientPlatformFactory factory; | ||
2157 | 43 | #else | ||
2158 | 44 | mcl::mesa::ClientPlatformFactory factory; | ||
2159 | 45 | #endif | 74 | #endif |
2160 | 75 | mir::SharedLibrary platform_library; | ||
2161 | 76 | mcl::CreateClientPlatform const create_client_platform; | ||
2162 | 77 | mcl::ClientPlatformProbe const probe; | ||
2163 | 46 | }; | 78 | }; |
2164 | 47 | 79 | ||
2179 | 48 | TEST_F(ClientPlatformTest, platform_name) | 80 | #ifdef MIR_BUILD_PLATFORM_ANDROID |
2180 | 49 | { | 81 | ClientPlatformTraits const android_platform{"/client-modules/android.so", |
2181 | 50 | auto platform = factory.create_client_platform(&context); | 82 | [](MirPlatformPackage& pkg) |
2182 | 51 | #ifdef ANDROID | 83 | { |
2183 | 52 | auto type = mir_platform_type_android; | 84 | ::memset(&pkg, 0, sizeof(pkg)); |
2184 | 53 | #else | 85 | }, |
2185 | 54 | auto type = mir_platform_type_gbm; | 86 | mir_platform_type_android |
2186 | 55 | #endif | 87 | }; |
2187 | 56 | EXPECT_EQ(type, platform->platform_type()); | 88 | |
2188 | 57 | } | 89 | INSTANTIATE_TEST_CASE_P(Android, |
2189 | 58 | 90 | ClientPlatformTest, | |
2190 | 59 | TEST_F(ClientPlatformTest, platform_creates) | 91 | ::testing::Values(&android_platform)); |
2191 | 60 | { | 92 | |
2192 | 61 | auto platform = factory.create_client_platform(&context); | 93 | #endif |
2193 | 94 | |||
2194 | 95 | #ifdef MIR_BUILD_PLATFORM_MESA | ||
2195 | 96 | ClientPlatformTraits const mesa_platform{"/client-modules/mesa.so", | ||
2196 | 97 | [](MirPlatformPackage& pkg) | ||
2197 | 98 | { | ||
2198 | 99 | ::memset(&pkg, 0, sizeof(pkg)); | ||
2199 | 100 | pkg.fd_items = 1; | ||
2200 | 101 | }, | ||
2201 | 102 | mir_platform_type_gbm | ||
2202 | 103 | }; | ||
2203 | 104 | |||
2204 | 105 | INSTANTIATE_TEST_CASE_P(Mesa, | ||
2205 | 106 | ClientPlatformTest, | ||
2206 | 107 | ::testing::Values(&mesa_platform)); | ||
2207 | 108 | |||
2208 | 109 | #endif | ||
2209 | 110 | |||
2210 | 111 | ClientPlatformTraits const dummy_platform{"/client-modules/dummy.so", | ||
2211 | 112 | [](MirPlatformPackage& pkg) | ||
2212 | 113 | { | ||
2213 | 114 | mtf::create_stub_platform_package(pkg); | ||
2214 | 115 | }, | ||
2215 | 116 | mir_platform_type_gbm | ||
2216 | 117 | }; | ||
2217 | 118 | |||
2218 | 119 | INSTANTIATE_TEST_CASE_P(Dummy, | ||
2219 | 120 | ClientPlatformTest, | ||
2220 | 121 | ::testing::Values(&dummy_platform)); | ||
2221 | 122 | } | ||
2222 | 123 | |||
2223 | 124 | TEST_P(ClientPlatformTest, platform_name) | ||
2224 | 125 | { | ||
2225 | 126 | auto platform = create_client_platform(&context); | ||
2226 | 127 | |||
2227 | 128 | EXPECT_EQ(GetParam()->platform_type, platform->platform_type()); | ||
2228 | 129 | } | ||
2229 | 130 | |||
2230 | 131 | TEST_P(ClientPlatformTest, platform_creates) | ||
2231 | 132 | { | ||
2232 | 133 | auto platform = create_client_platform(&context); | ||
2233 | 62 | auto buffer_factory = platform->create_buffer_factory(); | 134 | auto buffer_factory = platform->create_buffer_factory(); |
2234 | 63 | EXPECT_NE(buffer_factory.get(), (mcl::ClientBufferFactory*) NULL); | 135 | EXPECT_NE(buffer_factory.get(), (mcl::ClientBufferFactory*) NULL); |
2235 | 64 | } | 136 | } |
2236 | 65 | 137 | ||
2238 | 66 | TEST_F(ClientPlatformTest, platform_creates_native_window) | 138 | TEST_P(ClientPlatformTest, platform_creates_native_window) |
2239 | 67 | { | 139 | { |
2241 | 68 | auto platform = factory.create_client_platform(&context); | 140 | auto platform = create_client_platform(&context); |
2242 | 69 | auto mock_client_surface = std::make_shared<mtd::MockClientSurface>(); | 141 | auto mock_client_surface = std::make_shared<mtd::MockClientSurface>(); |
2243 | 70 | auto native_window = platform->create_egl_native_window(mock_client_surface.get()); | 142 | auto native_window = platform->create_egl_native_window(mock_client_surface.get()); |
2244 | 71 | EXPECT_NE(*native_window, (EGLNativeWindowType) NULL); | 143 | EXPECT_NE(*native_window, (EGLNativeWindowType) NULL); |
2245 | 72 | } | 144 | } |
2246 | 73 | 145 | ||
2248 | 74 | TEST_F(ClientPlatformTest, platform_creates_egl_native_display) | 146 | TEST_P(ClientPlatformTest, platform_creates_egl_native_display) |
2249 | 75 | { | 147 | { |
2251 | 76 | auto platform = factory.create_client_platform(&context); | 148 | auto platform = create_client_platform(&context); |
2252 | 77 | auto native_display = platform->create_egl_native_display(); | 149 | auto native_display = platform->create_egl_native_display(); |
2253 | 78 | EXPECT_NE(nullptr, native_display.get()); | 150 | EXPECT_NE(nullptr, native_display.get()); |
2254 | 79 | } | 151 | } |
2255 | 152 | |||
2256 | 153 | TEST_P(ClientPlatformTest, platform_probe_returns_success_when_matching) | ||
2257 | 154 | { | ||
2258 | 155 | EXPECT_TRUE(probe(&context)); | ||
2259 | 156 | } | ||
2260 | 157 | |||
2261 | 158 | TEST_P(ClientPlatformTest, platform_probe_returns_false_when_not_matching) | ||
2262 | 159 | { | ||
2263 | 160 | using namespace testing; | ||
2264 | 161 | ON_CALL(context, populate(_)) | ||
2265 | 162 | .WillByDefault(Invoke([](MirPlatformPackage& pkg) | ||
2266 | 163 | { | ||
2267 | 164 | //Mock up something that hopefully looks nothing like | ||
2268 | 165 | //what the platform is expecting... | ||
2269 | 166 | ::memset(&pkg, 0, sizeof(pkg)); | ||
2270 | 167 | pkg.data_items = mir_platform_package_max + 1; | ||
2271 | 168 | pkg.fd_items = -23; | ||
2272 | 169 | })); | ||
2273 | 170 | |||
2274 | 171 | EXPECT_FALSE(probe(&context)); | ||
2275 | 172 | } | ||
2276 | 80 | 173 | ||
2277 | === added file 'tests/unit-tests/client/test_probing_client_platform_factory.cpp' | |||
2278 | --- tests/unit-tests/client/test_probing_client_platform_factory.cpp 1970-01-01 00:00:00 +0000 | |||
2279 | +++ tests/unit-tests/client/test_probing_client_platform_factory.cpp 2014-12-18 22:43:30 +0000 | |||
2280 | @@ -0,0 +1,142 @@ | |||
2281 | 1 | /* | ||
2282 | 2 | * Copyright © 2014 Canonical Ltd. | ||
2283 | 3 | * | ||
2284 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2285 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
2286 | 6 | * published by the Free Software Foundation. | ||
2287 | 7 | * | ||
2288 | 8 | * This program is distributed in the hope that it will be useful, | ||
2289 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2290 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2291 | 11 | * GNU General Public License for more details. | ||
2292 | 12 | * | ||
2293 | 13 | * You should have received a copy of the GNU General Public License | ||
2294 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2295 | 15 | * | ||
2296 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
2297 | 17 | */ | ||
2298 | 18 | |||
2299 | 19 | #include "src/client/client_platform.h" | ||
2300 | 20 | #include "src/client/probing_client_platform_factory.h" | ||
2301 | 21 | |||
2302 | 22 | #include "mir_test_doubles/mock_client_context.h" | ||
2303 | 23 | #include "mir_test_framework/executable_path.h" | ||
2304 | 24 | #include "mir_test_framework/stub_platform_helpers.h" | ||
2305 | 25 | |||
2306 | 26 | #include <gmock/gmock.h> | ||
2307 | 27 | #include <gtest/gtest.h> | ||
2308 | 28 | |||
2309 | 29 | namespace mtf = mir_test_framework; | ||
2310 | 30 | namespace mtd = mir::test::doubles; | ||
2311 | 31 | |||
2312 | 32 | namespace | ||
2313 | 33 | { | ||
2314 | 34 | std::vector<std::shared_ptr<mir::SharedLibrary>> | ||
2315 | 35 | all_available_modules() | ||
2316 | 36 | { | ||
2317 | 37 | std::vector<std::shared_ptr<mir::SharedLibrary>> modules; | ||
2318 | 38 | #ifdef MIR_BUILD_PLATFORM_MESA | ||
2319 | 39 | modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() + "/client-modules/mesa.so")); | ||
2320 | 40 | #endif | ||
2321 | 41 | #ifdef MIR_BUILD_PLATFORM_ANDROID | ||
2322 | 42 | modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() + "/client-modules/android.so")); | ||
2323 | 43 | #endif | ||
2324 | 44 | return modules; | ||
2325 | 45 | } | ||
2326 | 46 | } | ||
2327 | 47 | |||
2328 | 48 | TEST(ProbingClientPlatformFactory, ThrowsErrorWhenConstructedWithNoPlatforms) | ||
2329 | 49 | { | ||
2330 | 50 | std::vector<std::shared_ptr<mir::SharedLibrary>> empty_modules; | ||
2331 | 51 | EXPECT_THROW(mir::client::ProbingClientPlatformFactory{empty_modules}, | ||
2332 | 52 | std::runtime_error); | ||
2333 | 53 | } | ||
2334 | 54 | |||
2335 | 55 | TEST(ProbingClientPlatformFactory, ThrowsErrorWhenNoPlatformPluginProbesSuccessfully) | ||
2336 | 56 | { | ||
2337 | 57 | using namespace testing; | ||
2338 | 58 | |||
2339 | 59 | mir::client::ProbingClientPlatformFactory factory{all_available_modules()}; | ||
2340 | 60 | |||
2341 | 61 | mtd::MockClientContext context; | ||
2342 | 62 | ON_CALL(context, populate(_)) | ||
2343 | 63 | .WillByDefault(Invoke([](MirPlatformPackage& pkg) | ||
2344 | 64 | { | ||
2345 | 65 | ::memset(&pkg, 0, sizeof(MirPlatformPackage)); | ||
2346 | 66 | // Mock up a platform package that looks nothing like | ||
2347 | 67 | // either an Android or Mesa package | ||
2348 | 68 | pkg.fd_items = 0xdeadbeef; | ||
2349 | 69 | pkg.data_items = -23; | ||
2350 | 70 | })); | ||
2351 | 71 | |||
2352 | 72 | EXPECT_THROW(factory.create_client_platform(&context), | ||
2353 | 73 | std::runtime_error); | ||
2354 | 74 | } | ||
2355 | 75 | |||
2356 | 76 | #ifdef MIR_BUILD_PLATFORM_MESA | ||
2357 | 77 | TEST(ProbingClientPlatformFactory, CreatesMesaPlatformWhenAppropriate) | ||
2358 | 78 | #else | ||
2359 | 79 | TEST(ProbingClientPlatformFactory, DISABLED_CreatesMesaPlatformWhenAppropriate) | ||
2360 | 80 | #endif | ||
2361 | 81 | { | ||
2362 | 82 | using namespace testing; | ||
2363 | 83 | |||
2364 | 84 | mir::client::ProbingClientPlatformFactory factory{all_available_modules()}; | ||
2365 | 85 | |||
2366 | 86 | mtd::MockClientContext context; | ||
2367 | 87 | ON_CALL(context, populate(_)) | ||
2368 | 88 | .WillByDefault(Invoke([](MirPlatformPackage& pkg) | ||
2369 | 89 | { | ||
2370 | 90 | ::memset(&pkg, 0, sizeof(MirPlatformPackage)); | ||
2371 | 91 | // Mock up something that looks like a GBM platform package, | ||
2372 | 92 | // until we send the actual platform type over the wire! | ||
2373 | 93 | pkg.fd_items = 1; | ||
2374 | 94 | pkg.fd[0] = 23; | ||
2375 | 95 | })); | ||
2376 | 96 | auto platform = factory.create_client_platform(&context); | ||
2377 | 97 | EXPECT_EQ(mir_platform_type_gbm, platform->platform_type()); | ||
2378 | 98 | } | ||
2379 | 99 | |||
2380 | 100 | #ifdef MIR_BUILD_PLATFORM_ANDROID | ||
2381 | 101 | TEST(ProbingClientPlatformFactory, CreatesAndroidPlatformWhenAppropriate) | ||
2382 | 102 | #else | ||
2383 | 103 | TEST(ProbingClientPlatformFactory, DISABLED_CreatesAndroidPlatformWhenAppropriate) | ||
2384 | 104 | #endif | ||
2385 | 105 | { | ||
2386 | 106 | using namespace testing; | ||
2387 | 107 | |||
2388 | 108 | mir::client::ProbingClientPlatformFactory factory{all_available_modules()}; | ||
2389 | 109 | |||
2390 | 110 | mtd::MockClientContext context; | ||
2391 | 111 | ON_CALL(context, populate(_)) | ||
2392 | 112 | .WillByDefault(Invoke([](MirPlatformPackage& pkg) | ||
2393 | 113 | { | ||
2394 | 114 | // Mock up something that looks like a Android platform package, | ||
2395 | 115 | // until we send the actual platform type over the wire! | ||
2396 | 116 | ::memset(&pkg, 0, sizeof(MirPlatformPackage)); | ||
2397 | 117 | })); | ||
2398 | 118 | |||
2399 | 119 | auto platform = factory.create_client_platform(&context); | ||
2400 | 120 | EXPECT_EQ(mir_platform_type_android, platform->platform_type()); | ||
2401 | 121 | } | ||
2402 | 122 | |||
2403 | 123 | TEST(ProbingClientPlatformFactory, IgnoresNonClientPlatformModules) | ||
2404 | 124 | { | ||
2405 | 125 | using namespace testing; | ||
2406 | 126 | |||
2407 | 127 | auto modules = all_available_modules(); | ||
2408 | 128 | // NOTE: For minimum fuss, load something that has minimal side-effects... | ||
2409 | 129 | modules.push_back(std::make_shared<mir::SharedLibrary>("libc.so.6")); | ||
2410 | 130 | modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() + "/client-modules/dummy.so")); | ||
2411 | 131 | |||
2412 | 132 | mir::client::ProbingClientPlatformFactory factory{modules}; | ||
2413 | 133 | |||
2414 | 134 | mtd::MockClientContext context; | ||
2415 | 135 | ON_CALL(context, populate(_)) | ||
2416 | 136 | .WillByDefault(Invoke([](MirPlatformPackage& pkg) | ||
2417 | 137 | { | ||
2418 | 138 | mtf::create_stub_platform_package(pkg); | ||
2419 | 139 | })); | ||
2420 | 140 | |||
2421 | 141 | auto platform = factory.create_client_platform(&context); | ||
2422 | 142 | } | ||
2423 | 0 | 143 | ||
2424 | === modified file 'tests/unit-tests/shared_library_test.cpp' | |||
2425 | --- tests/unit-tests/shared_library_test.cpp 2014-12-08 04:03:47 +0000 | |||
2426 | +++ tests/unit-tests/shared_library_test.cpp 2014-12-18 22:43:30 +0000 | |||
2427 | @@ -59,10 +59,10 @@ | |||
2428 | 59 | public: | 59 | public: |
2429 | 60 | SharedLibrary() | 60 | SharedLibrary() |
2430 | 61 | : nonexistent_library{"imma_totally_not_a_library"}, | 61 | : nonexistent_library{"imma_totally_not_a_library"}, |
2432 | 62 | existing_library{mtf::library_path() + "/" MIR_CLIENT_DRIVER_BINARY}, | 62 | existing_library{mtf::library_path() + "/client-modules/mesa.so"}, |
2433 | 63 | nonexistent_function{"yo_dawg"}, | 63 | nonexistent_function{"yo_dawg"}, |
2436 | 64 | existing_function{"create_client_platform_factory"}, | 64 | existing_function{"create_client_platform"}, |
2437 | 65 | existent_version{"MIR_CLIENTPLATFORM_1"}, | 65 | existent_version{"MIR_CLIENT_PLATFORM_2"}, |
2438 | 66 | nonexistent_version{"GOATS_ON_THE_GREEN"} | 66 | nonexistent_version{"GOATS_ON_THE_GREEN"} |
2439 | 67 | { | 67 | { |
2440 | 68 | } | 68 | } |
(1) Orphaned comment now needs removing: e-tests/
16 # Why does this have to come after mir-test-framework here but not in tests/acceptanc
17 # /CMakeLists.txt? ~racarr
18 - mirplatform
(2) Unnecessary (and undesirable) formatting changes: link_libraries( mirclient link_libraries(
221 -target_
222 +target_
223 + mirclient
224 +
because the first parameter is special and independent of those that follow it.
(3) Remind me why we wanted a C calling convention for C++ code? ptr<mcl: :ClientPlatform >
372 +extern "C" std::shared_
(4) Minor optimization: You can avoid a template instantiation using std::atomic_bool for
898 + std::atomic<bool> connect_done;
(5) Fatal: Clients don't start any more: demo_client_ egltriangle demo_client_ flicker client_ flicker: /home/dan/ bzr/mir/ tmp.pcd/ examples/ flicker. c:134: main: Assertion `mir_connection _is_valid( connection) ' failed.
$ bin/mir_
Can't get connection
$ bin/mir_
Starting
mir_demo_
(6) ProbingClientPl atformFactory sounds a bit awkward. Although I haven't stopped to understand the code enough to suggest anything better yet.
(7) New (old) function exposed without a new stanza. Should be MIR_COMMON_3.1 (?) symbols. map 2014-11-28 05:44:33 +0000 server_ socket; :android: :Lexicon: :translate* ; for_path* ;
980 +++ src/common/
981 @@ -150,6 +150,7 @@
982 # but they are used by libmirplatform, libmirclient or libmirserver
983 mir::default_
984 mir::input:
985 + mir::libraries_