Mir

Merge lp:~raof/mir/platform-probe-logging into lp:mir

Proposed by Chris Halse Rogers
Status: Work in progress
Proposed branch: lp:~raof/mir/platform-probe-logging
Merge into: lp:mir
Prerequisite: lp:~raof/mir/privatise-all-the-things
Diff against target: 1132 lines (+628/-28)
29 files modified
include/platform/mir/graphics/platform_probe_report.h (+45/-0)
include/platform/mir/options/configuration.h (+1/-0)
include/server/mir/default_server_configuration.h (+3/-0)
platform-ABI-sha1sums (+2/-1)
server-ABI-sha1sums (+3/-2)
src/platform/graphics/platform_probe.cpp (+7/-3)
src/platform/graphics/platform_probe.h (+2/-1)
src/platform/options/default_configuration.cpp (+20/-3)
src/platform/symbols.map (+1/-0)
src/server/graphics/default_configuration.cpp (+3/-3)
src/server/report/default_server_configuration.cpp (+9/-0)
src/server/report/logging/CMakeLists.txt (+1/-0)
src/server/report/logging/logging_report_factory.cpp (+6/-0)
src/server/report/logging/platform_probe_report.cpp (+55/-0)
src/server/report/logging/platform_probe_report.h (+55/-0)
src/server/report/logging_report_factory.h (+1/-0)
src/server/report/lttng/CMakeLists.txt (+1/-0)
src/server/report/lttng/lttng_report_factory.cpp (+6/-0)
src/server/report/lttng/platform_probe_report.cpp (+42/-0)
src/server/report/lttng/platform_probe_report.h (+47/-0)
src/server/report/lttng/platform_probe_report_tp.h (+57/-0)
src/server/report/lttng_report_factory.h (+1/-0)
src/server/report/null/CMakeLists.txt (+2/-1)
src/server/report/null/null_report_factory.cpp (+11/-0)
src/server/report/null/platform_probe_report.cpp (+32/-0)
src/server/report/null/platform_probe_report.h (+42/-0)
src/server/report/null_report_factory.h (+2/-0)
src/server/report/report_factory.h (+2/-0)
tests/unit-tests/graphics/test_platform_prober.cpp (+169/-14)
To merge this branch: bzr merge lp:~raof/mir/platform-probe-logging
Reviewer Review Type Date Requested Status
Alan Griffiths Needs Fixing
Daniel van Vugt Abstain
Kevin DuBois (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Alexandros Frantzis (community) Approve
Review via email: mp+234064@code.launchpad.net

Commit message

Add reporting for the graphics platform probe

Description of the change

Report (not log! ☺) the platform probing process

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

Nits:

35 +public:
36 + PlatformProbeReport() = default;
37 + virtual ~PlatformProbeReport() = default;
38 +
39 + PlatformProbeReport(PlatformProbeReport const&) = delete;
40 + PlatformProbeReport& operator=(PlatformProbeReport const&) = delete;

For abstract base classes, we usually make the constructor and and deleted CopyAssign ops protected (not that it matters functionally).

371 +
452 +
530 +
531 +

Unnecessary blank lines.

review: Approve
lp:~raof/mir/platform-probe-logging updated
1848. By Chris Halse Rogers

Merged private-library-loading into server-probe-logging.

1849. By Chris Halse Rogers

Merged private-library-loading into server-probe-logging.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

looks okay to me. (Although I'm not sure what to do about the ABI numbers. Seems we are changing the binary compatibility of the server library by changing DefaultServerConfiguration though)

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

I think reporting and logging both have their place. Although I would have said this is a job for logging instead. But my opinion aside...

(1) The server ABI has been broken and needs bumping, due to: include/server/mir/default_server_configuration.h
Although you will likely run into the roadblock of bug 1293944 then. So we need at least one fix for bug 1293944 to land first.

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

I've now proposed the ABI bump as a separate branch, since this time round it's particularly troublesome.

review: Abstain
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

24 conflicts encountered.

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote :

I am inclined to agree with Daniel that this is really a case for logging. These aren't really interesting as instrumentation points and only as a historical record.

Unmerged revisions

1849. By Chris Halse Rogers

Merged private-library-loading into server-probe-logging.

1848. By Chris Halse Rogers

Merged private-library-loading into server-probe-logging.

1847. By Chris Halse Rogers

Remerge prereq

1846. By Chris Halse Rogers

Merged private-library-loading into server-probe-logging.

1845. By Chris Halse Rogers

Ooops. Actually implement the PlatformProbeReport

1844. By Chris Halse Rogers

Log when server platforms fail to probe

1843. By Chris Halse Rogers

Merge prereq

1842. By Chris Halse Rogers

Merged private-library-loading into server-probe-logging.

1841. By Chris Halse Rogers

Trivial style cleanup

1840. By Chris Halse Rogers

Update platform and server SHA1sums

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'include/platform/mir/graphics/platform_probe_report.h'
2--- include/platform/mir/graphics/platform_probe_report.h 1970-01-01 00:00:00 +0000
3+++ include/platform/mir/graphics/platform_probe_report.h 2014-09-11 23:16:08 +0000
4@@ -0,0 +1,45 @@
5+/*
6+ * Copyright © 2014 Canonical Ltd.
7+ *
8+ * This program is free software: you can redistribute it and/or modify it
9+ * under the terms of the GNU Lesser General Public License version 3,
10+ * as published by the Free Software Foundation.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ *
20+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
21+ */
22+
23+#ifndef MIR_GRAPHICS_PLATFORM_PROBE_REPORT_H_
24+#define MIR_GRAPHICS_PLATFORM_PROBE_REPORT_H_
25+
26+#include "mir/graphics/platform.h"
27+
28+namespace mir
29+{
30+namespace graphics
31+{
32+
33+class PlatformProbeReport
34+{
35+public:
36+ PlatformProbeReport() = default;
37+ virtual ~PlatformProbeReport() = default;
38+
39+ PlatformProbeReport(PlatformProbeReport const&) = delete;
40+ PlatformProbeReport& operator=(PlatformProbeReport const&) = delete;
41+
42+ virtual void module_probed(ModuleProperties const& module, PlatformPriority probe_value) = 0;
43+ virtual void invalid_module_probed(std::exception const& error) = 0;
44+ virtual void module_selected(ModuleProperties const& module) = 0;
45+};
46+}
47+}
48+
49+#endif // MIR_GRAPHICS_PLATFORM_PROBE_REPORT_H_
50
51=== modified file 'include/platform/mir/options/configuration.h'
52--- include/platform/mir/options/configuration.h 2014-09-11 23:16:06 +0000
53+++ include/platform/mir/options/configuration.h 2014-09-11 23:16:08 +0000
54@@ -43,6 +43,7 @@
55 extern char const* const host_socket_opt;
56 extern char const* const frontend_threads_opt;
57 extern char const* const fatal_abort_opt;
58+extern char const* const platform_probe_report_opt;
59
60 extern char const* const name_opt;
61 extern char const* const offscreen_opt;
62
63=== modified file 'include/server/mir/default_server_configuration.h'
64--- include/server/mir/default_server_configuration.h 2014-09-11 23:16:06 +0000
65+++ include/server/mir/default_server_configuration.h 2014-09-11 23:16:08 +0000
66@@ -110,6 +110,7 @@
67 class CursorImage;
68 class GLConfig;
69 class GLProgramFactory;
70+class PlatformProbeReport;
71 namespace nested { class HostConnection; }
72 }
73 namespace input
74@@ -309,6 +310,7 @@
75 virtual std::shared_ptr<time::Clock> the_clock();
76 virtual std::shared_ptr<ServerActionQueue> the_server_action_queue();
77 virtual std::shared_ptr<SharedLibraryProberReport> the_shared_library_prober_report();
78+ virtual std::shared_ptr<graphics::PlatformProbeReport> the_platform_probe_report();
79
80 protected:
81 std::shared_ptr<options::Option> the_options() const;
82@@ -410,6 +412,7 @@
83 CachedPtr<EmergencyCleanup> emergency_cleanup;
84 CachedPtr<shell::HostLifecycleEventListener> host_lifecycle_event_listener;
85 CachedPtr<SharedLibraryProberReport> shared_library_prober_report;
86+ CachedPtr<graphics::PlatformProbeReport> platform_probe_report;
87
88 private:
89 std::shared_ptr<options::Configuration> const configuration_options;
90
91=== modified file 'platform-ABI-sha1sums'
92--- platform-ABI-sha1sums 2014-09-11 23:16:06 +0000
93+++ platform-ABI-sha1sums 2014-09-11 23:16:08 +0000
94@@ -25,8 +25,9 @@
95 815405c5aee8000bc18c1c9480bac620a451b416 include/platform/mir/graphics/event_handler_register.h
96 5dc095474ef3e294c0aa4008e9ed997bdb21d34c include/platform/mir/graphics/gl_config.h
97 d0442a5d5d88a4be6e3e1f99e433c1c43a86bfce include/platform/mir/graphics/gl_context.h
98+3f38702323495a5f649155a967b7b88c3f5b356a include/platform/mir/graphics/platform_probe_report.h
99 15f201741a465de33e55ffc1ea775b507a5be950 include/platform/mir/graphics/renderable.h
100-df61c1168b1798c628d087fc17900d58d608a6fa include/platform/mir/options/configuration.h
101+dfadb98ded10296a5fc900c97c29ba4e07427868 include/platform/mir/options/configuration.h
102 47007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h
103 b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h
104 3c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h
105
106=== modified file 'server-ABI-sha1sums'
107--- server-ABI-sha1sums 2014-09-11 23:16:06 +0000
108+++ server-ABI-sha1sums 2014-09-11 23:16:08 +0000
109@@ -25,13 +25,14 @@
110 815405c5aee8000bc18c1c9480bac620a451b416 include/platform/mir/graphics/event_handler_register.h
111 5dc095474ef3e294c0aa4008e9ed997bdb21d34c include/platform/mir/graphics/gl_config.h
112 d0442a5d5d88a4be6e3e1f99e433c1c43a86bfce include/platform/mir/graphics/gl_context.h
113+3f38702323495a5f649155a967b7b88c3f5b356a include/platform/mir/graphics/platform_probe_report.h
114 15f201741a465de33e55ffc1ea775b507a5be950 include/platform/mir/graphics/renderable.h
115-df61c1168b1798c628d087fc17900d58d608a6fa include/platform/mir/options/configuration.h
116+dfadb98ded10296a5fc900c97c29ba4e07427868 include/platform/mir/options/configuration.h
117 47007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h
118 b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h
119 3c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h
120 f4030e400baf8baa9c38e7c6ec6b4a5ad7134aeb include/server/mir/compositor/compositor.h
121-d69ff1401221ffa9adce7f8d85074a6f8b234baf include/server/mir/default_server_configuration.h
122+7431f70be1309f15ccd14e5f3973bd5ffc5bac5c include/server/mir/default_server_configuration.h
123 af1ff0714be973ac76d56006a2e5991f68cd1dec include/server/mir/display_server.h
124 65db331f1c0e956eced5c9fc73a2b2122dbc8dc7 include/server/mir/frontend/connection_creator.h
125 e6e92642301fc9bb85e1d38087a5dd84e5d30fd7 include/server/mir/frontend/connections.h
126
127=== modified file 'src/platform/graphics/platform_probe.cpp'
128--- src/platform/graphics/platform_probe.cpp 2014-09-11 23:16:06 +0000
129+++ src/platform/graphics/platform_probe.cpp 2014-09-11 23:16:08 +0000
130@@ -20,7 +20,8 @@
131 #include "platform_probe.h"
132
133 std::shared_ptr<mir::SharedLibrary>
134-mir::graphics::module_for_device(std::vector<std::shared_ptr<SharedLibrary>> const& modules)
135+mir::graphics::module_for_device(std::vector<std::shared_ptr<SharedLibrary>> const& modules,
136+ PlatformProbeReport& report)
137 {
138 mir::graphics::PlatformPriority best_priority_so_far = mir::graphics::unsupported;
139 std::shared_ptr<mir::SharedLibrary> best_module_so_far;
140@@ -31,19 +32,22 @@
141 auto probe = module->load_function<mir::graphics::PlatformProbe>("probe_platform",
142 SERVER_PLATFORM_VERSION);
143 auto module_priority = probe();
144+ auto describe = module->load_function<DescribeModule>("describe_module");
145+ report.module_probed(*describe(), module_priority);
146 if (module_priority > best_priority_so_far)
147 {
148 best_priority_so_far = module_priority;
149 best_module_so_far = module;
150 }
151 }
152- catch (std::runtime_error)
153+ catch (std::runtime_error const& error)
154 {
155- // Tried to probe a SharedLibrary that isn't a platform module?
156+ report.invalid_module_probed(error);
157 }
158 }
159 if (best_priority_so_far > mir::graphics::unsupported)
160 {
161+ report.module_selected(*best_module_so_far->load_function<DescribeModule>("describe_module")());
162 return best_module_so_far;
163 }
164 throw std::runtime_error{"Failed to find platform for current system"};
165
166=== modified file 'src/platform/graphics/platform_probe.h'
167--- src/platform/graphics/platform_probe.h 2014-09-11 23:16:06 +0000
168+++ src/platform/graphics/platform_probe.h 2014-09-11 23:16:08 +0000
169@@ -22,6 +22,7 @@
170 #include <vector>
171 #include <memory>
172 #include "mir/shared_library.h"
173+#include "mir/graphics/platform_probe_report.h"
174
175 namespace mir
176 {
177@@ -29,7 +30,7 @@
178 {
179 class Platform;
180
181-std::shared_ptr<SharedLibrary> module_for_device(std::vector<std::shared_ptr<SharedLibrary>> const& modules);
182+std::shared_ptr<SharedLibrary> module_for_device(std::vector<std::shared_ptr<SharedLibrary>> const& modules, PlatformProbeReport& report);
183
184 }
185 }
186
187=== modified file 'src/platform/options/default_configuration.cpp'
188--- src/platform/options/default_configuration.cpp 2014-09-11 23:16:06 +0000
189+++ src/platform/options/default_configuration.cpp 2014-09-11 23:16:08 +0000
190@@ -46,6 +46,7 @@
191 char const* const mo::name_opt = "name";
192 char const* const mo::offscreen_opt = "offscreen";
193 char const* const mo::fatal_abort_opt = "on-fatal-error-abort";
194+char const* const mo::platform_probe_report_opt = "platform-probe-report";
195
196
197 char const* const mo::glog = "glog";
198@@ -140,6 +141,8 @@
199 "How to handle to Input report. [{log,lttng,off}]")
200 (legacy_input_report_opt, po::value<std::string>()->default_value(off_opt_value),
201 "How to handle the Legacy Input report. [{log,off}]")
202+ (platform_probe_report_opt, po::value<std::string>()->default_value(log_opt_value),
203+ "How to handle the Platform Probe report. [{log,lttng,off}]")
204 (session_mediator_report_opt, po::value<std::string>()->default_value(off_opt_value),
205 "How to handle the SessionMediator report. [{log,lttng,off}]")
206 (msg_processor_report_opt, po::value<std::string>()->default_value(off_opt_value),
207@@ -193,6 +196,19 @@
208 {
209 }
210 };
211+
212+class NullPlatformProbeReport : public mir::graphics::PlatformProbeReport
213+{
214+ void module_probed(mir::graphics::ModuleProperties const&, mir::graphics::PlatformPriority) override
215+ {
216+ }
217+ void module_selected(mir::graphics::ModuleProperties const&) override
218+ {
219+ }
220+ void invalid_module_probed(std::exception const&) override
221+ {
222+ }
223+};
224 }
225
226 void mo::DefaultConfiguration::add_platform_options()
227@@ -227,9 +243,10 @@
228 else
229 {
230 auto const plugin_path = env_libpath ? env_libpath : options.get<std::string>(platform_graphics_path);
231- NullSharedLibraryProberReport nuller;
232- auto plugins = mir::libraries_for_path(plugin_path, nuller);
233- graphics_lib = mir::graphics::module_for_device(plugins);
234+ NullSharedLibraryProberReport null_shared_library_report;
235+ NullPlatformProbeReport null_platform_probe_report;
236+ auto plugins = mir::libraries_for_path(plugin_path, null_shared_library_report);
237+ graphics_lib = mir::graphics::module_for_device(plugins, null_platform_probe_report);
238 }
239
240 auto add_platform_options = graphics_lib->load_function<mir::graphics::AddPlatformOptions>(std::string("add_platform_options"));
241
242=== modified file 'src/platform/symbols.map'
243--- src/platform/symbols.map 2014-09-11 23:16:06 +0000
244+++ src/platform/symbols.map 2014-09-11 23:16:08 +0000
245@@ -242,6 +242,7 @@
246 mir::options::Option::operator*;
247 mir::options::Option::?Option*;
248 mir::options::Option::Option*;
249+ mir::options::platform_probe_report_opt*;
250 mir::options::platform_graphics_lib*;
251 mir::options::ProgramOption::get*;
252 mir::options::ProgramOption::is_set*;
253
254=== modified file 'src/server/graphics/default_configuration.cpp'
255--- src/server/graphics/default_configuration.cpp 2014-09-11 23:16:06 +0000
256+++ src/server/graphics/default_configuration.cpp 2014-09-11 23:16:08 +0000
257@@ -89,7 +89,7 @@
258 {
259 throw std::runtime_error("Failed to find any platform plugins in: " MIR_SERVER_PLATFORM_PLUGIN_PATH);
260 }
261- platform_library = mir::graphics::module_for_device(platforms);
262+ platform_library = mir::graphics::module_for_device(platforms, *the_platform_probe_report());
263 }
264 auto create_platform = platform_library->load_function<mg::CreatePlatform>("create_platform",
265 SERVER_PLATFORM_VERSION);
266@@ -104,7 +104,7 @@
267 });
268 }
269
270-std::shared_ptr<mg::NativePlatform> mir::DefaultServerConfiguration::the_graphics_native_platform()
271+std::shared_ptr<mg::NativePlatform> mir::DefaultServerConfiguration::the_graphics_native_platform()
272 {
273 return graphics_native_platform(
274 [this]()
275@@ -120,7 +120,7 @@
276 {
277 throw std::runtime_error("Failed to find any platform plugins in: " MIR_SERVER_PLATFORM_PLUGIN_PATH);
278 }
279- platform_library = mir::graphics::module_for_device(platforms);
280+ platform_library = mir::graphics::module_for_device(platforms, *the_platform_probe_report());
281 }
282 auto create_native_platform = platform_library->load_function<mg::CreateNativePlatform>("create_native_platform",
283 SERVER_PLATFORM_VERSION);
284
285=== modified file 'src/server/report/default_server_configuration.cpp'
286--- src/server/report/default_server_configuration.cpp 2014-09-11 23:16:06 +0000
287+++ src/server/report/default_server_configuration.cpp 2014-09-11 23:16:08 +0000
288@@ -126,3 +126,12 @@
289 return report_factory(options::shared_library_prober_report_opt)->create_shared_library_prober_report();
290 });
291 }
292+
293+auto mir::DefaultServerConfiguration::the_platform_probe_report() -> std::shared_ptr<mg::PlatformProbeReport>
294+{
295+ return platform_probe_report(
296+ [this]() -> std::shared_ptr<mir::graphics::PlatformProbeReport>
297+ {
298+ return report_factory(options::platform_probe_report_opt)->create_platform_probe_report();
299+ });
300+}
301
302=== modified file 'src/server/report/logging/CMakeLists.txt'
303--- src/server/report/logging/CMakeLists.txt 2014-09-11 23:16:06 +0000
304+++ src/server/report/logging/CMakeLists.txt 2014-09-11 23:16:08 +0000
305@@ -11,6 +11,7 @@
306 compositor_report.cpp
307 scene_report.cpp
308 logging_report_factory.cpp
309+ platform_probe_report.cpp
310 )
311
312 add_library(
313
314=== modified file 'src/server/report/logging/logging_report_factory.cpp'
315--- src/server/report/logging/logging_report_factory.cpp 2014-09-11 23:16:06 +0000
316+++ src/server/report/logging/logging_report_factory.cpp 2014-09-11 23:16:08 +0000
317@@ -26,6 +26,7 @@
318 #include "session_mediator_report.h"
319 #include "input_report.h"
320 #include "mir/logging/shared_library_prober_report.h"
321+#include "platform_probe_report.h"
322
323 #include "mir/default_server_configuration.h"
324
325@@ -77,3 +78,8 @@
326 {
327 return std::make_shared<mir::logging::SharedLibraryProberReport>(logger);
328 }
329+
330+std::shared_ptr<mir::graphics::PlatformProbeReport> mr::LoggingReportFactory::create_platform_probe_report()
331+{
332+ return std::make_shared<logging::PlatformProbeReport>(logger);
333+}
334
335=== added file 'src/server/report/logging/platform_probe_report.cpp'
336--- src/server/report/logging/platform_probe_report.cpp 1970-01-01 00:00:00 +0000
337+++ src/server/report/logging/platform_probe_report.cpp 2014-09-11 23:16:08 +0000
338@@ -0,0 +1,55 @@
339+#include "platform_probe_report.h"
340+#include "mir/logging/logger.h"
341+
342+#include <sstream>
343+#include <string>
344+
345+namespace ml = mir::logging;
346+namespace mg = mir::graphics;
347+
348+mir::report::logging::PlatformProbeReport::PlatformProbeReport(std::shared_ptr<ml::Logger> const& logger)
349+ : logger{logger}
350+{
351+}
352+
353+namespace
354+{
355+std::string priority_to_string(mg::PlatformPriority priority)
356+{
357+ switch (priority)
358+ {
359+ case mg::PlatformPriority::unsupported:
360+ return "unsupported";
361+ case mg::PlatformPriority::supported:
362+ return "supported";
363+ case mg::PlatformPriority::best:
364+ return "best";
365+ default:
366+ return std::to_string(static_cast<int>(priority));
367+ }
368+}
369+}
370+
371+
372+void mir::report::logging::PlatformProbeReport::module_probed(mg::ModuleProperties const& module, mg::PlatformPriority probe_value)
373+{
374+ std::stringstream ss;
375+ ss << "Module probed" << std::endl
376+ << "\tName: " << module.name << std::endl
377+ << "\tPriority: " << priority_to_string(probe_value);
378+ logger->log(ml::Logger::informational, ss.str(), "Platform");
379+}
380+
381+void mir::report::logging::PlatformProbeReport::invalid_module_probed(std::exception const& error)
382+{
383+ std::stringstream ss;
384+ ss << "Failed to probe module. Error was: " << error.what();
385+ logger->log(ml::Logger::warning, ss.str(), "Platform");
386+}
387+
388+void mir::report::logging::PlatformProbeReport::module_selected(mg::ModuleProperties const& module)
389+{
390+ std::stringstream ss;
391+ ss << "Selected module: " << module.name;
392+ logger->log(ml::Logger::informational, ss.str(), "Platform");
393+}
394
395=== added file 'src/server/report/logging/platform_probe_report.h'
396--- src/server/report/logging/platform_probe_report.h 1970-01-01 00:00:00 +0000
397+++ src/server/report/logging/platform_probe_report.h 2014-09-11 23:16:08 +0000
398@@ -0,0 +1,55 @@
399+/*
400+ * Copyright © 2014 Canonical Ltd.
401+ *
402+ * This program is free software: you can redistribute it and/or modify it
403+ * under the terms of the GNU General Public License version 3,
404+ * as published by the Free Software Foundation.
405+ *
406+ * This program is distributed in the hope that it will be useful,
407+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
408+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
409+ * GNU General Public License for more details.
410+ *
411+ * You should have received a copy of the GNU General Public License
412+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
413+ *
414+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
415+ */
416+
417+#ifndef MIR_REPORT_LOGGING_PLATFORM_PROBE_REPORT_H_
418+#define MIR_REPORT_LOGGING_PLATFORM_PROBE_REPORT_H_
419+
420+#include "mir/graphics/platform_probe_report.h"
421+
422+#include <memory>
423+
424+namespace mir
425+{
426+namespace logging
427+{
428+class Logger;
429+}
430+namespace report
431+{
432+namespace logging
433+{
434+
435+class PlatformProbeReport : public graphics::PlatformProbeReport
436+{
437+public:
438+ PlatformProbeReport(std::shared_ptr<mir::logging::Logger> const& logger);
439+
440+ void module_probed(const graphics::ModuleProperties &module, graphics::PlatformPriority probe_value);
441+ void invalid_module_probed(const std::exception &error);
442+ void module_selected(const graphics::ModuleProperties &module);
443+
444+private:
445+ std::shared_ptr<mir::logging::Logger> const logger;
446+};
447+
448+}
449+}
450+}
451+
452+
453+#endif /* MIR_REPORT_LOGGING_PLATFORM_PROBE_REPORT_H_ */
454
455=== modified file 'src/server/report/logging_report_factory.h'
456--- src/server/report/logging_report_factory.h 2014-09-11 23:16:06 +0000
457+++ src/server/report/logging_report_factory.h 2014-09-11 23:16:08 +0000
458@@ -48,6 +48,7 @@
459 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;
460 std::shared_ptr<input::InputReport> create_input_report() override;
461 std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;
462+ std::shared_ptr<graphics::PlatformProbeReport> create_platform_probe_report() override;
463
464
465 private:
466
467=== modified file 'src/server/report/lttng/CMakeLists.txt'
468--- src/server/report/lttng/CMakeLists.txt 2014-09-11 23:16:06 +0000
469+++ src/server/report/lttng/CMakeLists.txt 2014-09-11 23:16:08 +0000
470@@ -14,6 +14,7 @@
471 input_report.cpp
472 message_processor_report.cpp
473 lttng_report_factory.cpp
474+ platform_probe_report.cpp
475 session_mediator_report.cpp
476 scene_report.cpp
477 server_tracepoint_provider.cpp
478
479=== modified file 'src/server/report/lttng/lttng_report_factory.cpp'
480--- src/server/report/lttng/lttng_report_factory.cpp 2014-09-11 23:16:06 +0000
481+++ src/server/report/lttng/lttng_report_factory.cpp 2014-09-11 23:16:08 +0000
482@@ -23,6 +23,7 @@
483 #include "display_report.h"
484 #include "input_report.h"
485 #include "message_processor_report.h"
486+#include "platform_probe_report.h"
487 #include "scene_report.h"
488 #include "session_mediator_report.h"
489 #include "shared_library_prober_report.h"
490@@ -67,3 +68,8 @@
491 return std::make_shared<lttng::SharedLibraryProberReport>();
492 }
493
494+std::shared_ptr<mir::graphics::PlatformProbeReport> mir::report::LttngReportFactory::create_platform_probe_report()
495+{
496+ return std::make_shared<lttng::PlatformProbeReport>();
497+}
498+
499
500=== added file 'src/server/report/lttng/platform_probe_report.cpp'
501--- src/server/report/lttng/platform_probe_report.cpp 1970-01-01 00:00:00 +0000
502+++ src/server/report/lttng/platform_probe_report.cpp 2014-09-11 23:16:08 +0000
503@@ -0,0 +1,42 @@
504+/*
505+ * Copyright © 2014 Canonical Ltd.
506+ *
507+ * This program is free software: you can redistribute it and/or modify it
508+ * under the terms of the GNU General Public License version 3,
509+ * as published by the Free Software Foundation.
510+ *
511+ * This program is distributed in the hope that it will be useful,
512+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
513+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
514+ * GNU General Public License for more details.
515+ *
516+ * You should have received a copy of the GNU General Public License
517+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
518+ *
519+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
520+ */
521+
522+#include "platform_probe_report.h"
523+
524+#include "mir/report/lttng/mir_tracepoint.h"
525+
526+#define TRACEPOINT_DEFINE
527+#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
528+#include "platform_probe_report_tp.h"
529+
530+
531+
532+void mir::report::lttng::PlatformProbeReport::module_probed(mir::graphics::ModuleProperties const& module, mir::graphics::PlatformPriority probe_value)
533+{
534+ mir_tracepoint(mir_server_platform_probe, module_probed, module.name, probe_value);
535+}
536+
537+void mir::report::lttng::PlatformProbeReport::invalid_module_probed(std::exception const& error)
538+{
539+ mir_tracepoint(mir_server_platform_probe, invalid_module_probed, error.what());
540+}
541+
542+void mir::report::lttng::PlatformProbeReport::module_selected(mir::graphics::ModuleProperties const& module)
543+{
544+ mir_tracepoint(mir_server_platform_probe, module_selected, module.name);
545+}
546
547=== added file 'src/server/report/lttng/platform_probe_report.h'
548--- src/server/report/lttng/platform_probe_report.h 1970-01-01 00:00:00 +0000
549+++ src/server/report/lttng/platform_probe_report.h 2014-09-11 23:16:08 +0000
550@@ -0,0 +1,47 @@
551+/*
552+ * Copyright © 2014 Canonical Ltd.
553+ *
554+ * This program is free software: you can redistribute it and/or modify it
555+ * under the terms of the GNU General Public License version 3,
556+ * as published by the Free Software Foundation.
557+ *
558+ * This program is distributed in the hope that it will be useful,
559+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
560+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
561+ * GNU General Public License for more details.
562+ *
563+ * You should have received a copy of the GNU General Public License
564+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
565+ *
566+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
567+ */
568+
569+#ifndef MIR_REPORT_LTTNG_PLATFORM_PROBE_REPORT_H_
570+#define MIR_REPORT_LTTNG_PLATFORM_PROBE_REPORT_H_
571+
572+#include "server_tracepoint_provider.h"
573+
574+#include "mir/graphics/platform_probe_report.h"
575+
576+namespace mir
577+{
578+namespace report
579+{
580+namespace lttng
581+{
582+class PlatformProbeReport : public graphics::PlatformProbeReport
583+{
584+public:
585+ void module_probed(graphics::ModuleProperties const& module,
586+ graphics::PlatformPriority probe_value) override;
587+ void invalid_module_probed(std::exception const& error) override;
588+ void module_selected(graphics::ModuleProperties const& module) override;
589+
590+private:
591+ ServerTracepointProvider tp_provider;
592+};
593+}
594+}
595+}
596+
597+#endif /* MIR_REPORT_LTTNG_PLATFORM_PROBE_REPORT_H_ */
598
599=== added file 'src/server/report/lttng/platform_probe_report_tp.h'
600--- src/server/report/lttng/platform_probe_report_tp.h 1970-01-01 00:00:00 +0000
601+++ src/server/report/lttng/platform_probe_report_tp.h 2014-09-11 23:16:08 +0000
602@@ -0,0 +1,57 @@
603+/*
604+ * Copyright © 2014 Canonical Ltd.
605+ *
606+ * This program is free software: you can redistribute it and/or modify it
607+ * under the terms of the GNU General Public License version 3,
608+ * as published by the Free Software Foundation.
609+ *
610+ * This program is distributed in the hope that it will be useful,
611+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
612+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
613+ * GNU General Public License for more details.
614+ *
615+ * You should have received a copy of the GNU General Public License
616+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
617+ *
618+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
619+ */
620+
621+#undef TRACEPOINT_PROVIDER
622+#define TRACEPOINT_PROVIDER mir_server_platform_probe
623+
624+#undef TRACEPOINT_INCLUDE
625+#define TRACEPOINT_INCLUDE "./platform_probe_report_tp.h"
626+
627+#if !defined(MIR_LTTNG_PLATFORM_PROBE_REPORT_TP_H_) || defined(TRACEPOINT_HEADER_MULTI_READ)
628+#define MIR_LTTNG_PLATFORM_PROBE_REPORT_TP_H_
629+
630+#include "lttng_utils.h"
631+
632+MIR_LTTNG_VOID_TRACE_CLASS(mir_server_platform_probe)
633+
634+TRACEPOINT_EVENT(
635+ TRACEPOINT_PROVIDER,
636+ module_probed,
637+ TP_ARGS(char const*, name, int, priority),
638+ TP_FIELDS(ctf_string(name, name), ctf_integer(int, priority, priority))
639+)
640+
641+TRACEPOINT_EVENT(
642+ TRACEPOINT_PROVIDER,
643+ invalid_module_probed,
644+ TP_ARGS(char const*, error),
645+ TP_FIELDS(ctf_string(name, name))
646+)
647+
648+TRACEPOINT_EVENT(
649+ TRACEPOINT_PROVIDER,
650+ module_selected,
651+ TP_ARGS(char const*, name),
652+ TP_FIELDS(ctf_string(name, name))
653+)
654+
655+#include "lttng_utils_pop.h"
656+
657+#endif /* MIR_LTTNG_COMPOSITOR_REPORT_TP_H_ */
658+
659+#include <lttng/tracepoint-event.h>
660
661=== modified file 'src/server/report/lttng_report_factory.h'
662--- src/server/report/lttng_report_factory.h 2014-09-11 23:16:06 +0000
663+++ src/server/report/lttng_report_factory.h 2014-09-11 23:16:08 +0000
664@@ -36,6 +36,7 @@
665 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;
666 std::shared_ptr<input::InputReport> create_input_report() override;
667 std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;
668+ std::shared_ptr<graphics::PlatformProbeReport> create_platform_probe_report() override;
669 };
670 }
671 }
672
673=== modified file 'src/server/report/null/CMakeLists.txt'
674--- src/server/report/null/CMakeLists.txt 2014-09-11 23:16:06 +0000
675+++ src/server/report/null/CMakeLists.txt 2014-09-11 23:16:08 +0000
676@@ -7,7 +7,8 @@
677 input_report.cpp
678 message_processor_report.cpp
679 null_report_factory.cpp
680+ platform_probe_report.cpp
681 scene_report.cpp
682 session_mediator_report.cpp
683 shared_library_prober_report.cpp
684- )
685+)
686
687=== modified file 'src/server/report/null/null_report_factory.cpp'
688--- src/server/report/null/null_report_factory.cpp 2014-09-11 23:16:06 +0000
689+++ src/server/report/null/null_report_factory.cpp 2014-09-11 23:16:08 +0000
690@@ -24,6 +24,7 @@
691 #include "session_mediator_report.h"
692 #include "display_report.h"
693 #include "input_report.h"
694+#include "platform_probe_report.h"
695 #include "scene_report.h"
696 #include "shared_library_prober_report.h"
697
698@@ -67,6 +68,11 @@
699 return std::make_shared<null::SharedLibraryProberReport>();
700 }
701
702+std::shared_ptr<mir::graphics::PlatformProbeReport> mir::report::NullReportFactory::create_platform_probe_report()
703+{
704+ return std::make_shared<null::PlatformProbeReport>();
705+}
706+
707 std::shared_ptr<mir::compositor::CompositorReport> mir::report::null_compositor_report()
708 {
709 return NullReportFactory{}.create_compositor_report();
710@@ -101,3 +107,8 @@
711 {
712 return NullReportFactory{}.create_shared_library_prober_report();
713 }
714+
715+std::shared_ptr<mir::graphics::PlatformProbeReport> mir::report::null_platform_probe_report()
716+{
717+ return NullReportFactory{}.create_platform_probe_report();
718+}
719
720=== added file 'src/server/report/null/platform_probe_report.cpp'
721--- src/server/report/null/platform_probe_report.cpp 1970-01-01 00:00:00 +0000
722+++ src/server/report/null/platform_probe_report.cpp 2014-09-11 23:16:08 +0000
723@@ -0,0 +1,32 @@
724+/*
725+ * Copyright © 2014 Canonical Ltd.
726+ *
727+ * This program is free software: you can redistribute it and/or modify it
728+ * under the terms of the GNU General Public License version 3,
729+ * as published by the Free Software Foundation.
730+ *
731+ * This program is distributed in the hope that it will be useful,
732+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
733+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
734+ * GNU General Public License for more details.
735+ *
736+ * You should have received a copy of the GNU General Public License
737+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
738+ *
739+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
740+ */
741+
742+#include "platform_probe_report.h"
743+
744+void mir::report::null::PlatformProbeReport::module_probed(mir::graphics::ModuleProperties const&,
745+ mir::graphics::PlatformPriority)
746+{
747+}
748+
749+void mir::report::null::PlatformProbeReport::invalid_module_probed(std::exception const&)
750+{
751+}
752+
753+void mir::report::null::PlatformProbeReport::module_selected(mir::graphics::ModuleProperties const&)
754+{
755+}
756
757=== added file 'src/server/report/null/platform_probe_report.h'
758--- src/server/report/null/platform_probe_report.h 1970-01-01 00:00:00 +0000
759+++ src/server/report/null/platform_probe_report.h 2014-09-11 23:16:08 +0000
760@@ -0,0 +1,42 @@
761+/*
762+ * Copyright © 2014 Canonical Ltd.
763+ *
764+ * This program is free software: you can redistribute it and/or modify it
765+ * under the terms of the GNU General Public License version 3,
766+ * as published by the Free Software Foundation.
767+ *
768+ * This program is distributed in the hope that it will be useful,
769+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
770+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
771+ * GNU General Public License for more details.
772+ *
773+ * You should have received a copy of the GNU General Public License
774+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
775+ *
776+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
777+ */
778+
779+#ifndef MIR_REPORT_NULL_PLATFORM_PROBE_REPORT_H_
780+#define MIR_REPORT_NULL_PLATFORM_PROBE_REPORT_H_
781+
782+#include "mir/graphics/platform_probe_report.h"
783+
784+namespace mir
785+{
786+namespace report
787+{
788+namespace null
789+{
790+class PlatformProbeReport : public graphics::PlatformProbeReport
791+{
792+public:
793+ void module_probed(graphics::ModuleProperties const& module,
794+ graphics::PlatformPriority probe_value) override;
795+ void invalid_module_probed(std::exception const& error) override;
796+ void module_selected(graphics::ModuleProperties const& module) override;
797+};
798+}
799+}
800+}
801+
802+#endif /* MIR_REPORT_NULL_PLATFORM_PROBE_REPORT_H_ */
803
804=== modified file 'src/server/report/null_report_factory.h'
805--- src/server/report/null_report_factory.h 2014-09-11 23:16:06 +0000
806+++ src/server/report/null_report_factory.h 2014-09-11 23:16:08 +0000
807@@ -36,6 +36,7 @@
808 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;
809 std::shared_ptr<input::InputReport> create_input_report() override;
810 std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;
811+ std::shared_ptr<graphics::PlatformProbeReport> create_platform_probe_report() override;
812 };
813
814 std::shared_ptr<compositor::CompositorReport> null_compositor_report();
815@@ -46,6 +47,7 @@
816 std::shared_ptr<frontend::MessageProcessorReport> null_message_processor_report();
817 std::shared_ptr<input::InputReport> null_input_report();
818 std::shared_ptr<SharedLibraryProberReport> null_shared_library_prober_report();
819+std::shared_ptr<graphics::PlatformProbeReport> null_platform_probe_report();
820 }
821 }
822
823
824=== modified file 'src/server/report/report_factory.h'
825--- src/server/report/report_factory.h 2014-09-11 23:16:06 +0000
826+++ src/server/report/report_factory.h 2014-09-11 23:16:08 +0000
827@@ -38,6 +38,7 @@
828 namespace graphics
829 {
830 class DisplayReport;
831+class PlatformProbeReport;
832 }
833 namespace input
834 {
835@@ -62,6 +63,7 @@
836 virtual std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() = 0;
837 virtual std::shared_ptr<input::InputReport> create_input_report() = 0;
838 virtual std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() = 0;
839+ virtual std::shared_ptr<graphics::PlatformProbeReport> create_platform_probe_report() = 0;
840
841 protected:
842 ReportFactory() = default;
843
844=== modified file 'tests/unit-tests/graphics/test_platform_prober.cpp'
845--- tests/unit-tests/graphics/test_platform_prober.cpp 2014-09-11 23:16:06 +0000
846+++ tests/unit-tests/graphics/test_platform_prober.cpp 2014-09-11 23:16:08 +0000
847@@ -17,9 +17,11 @@
848 */
849
850 #include <gtest/gtest.h>
851+#include <gmock/gmock.h>
852
853 #include "src/platform/graphics/platform_probe.h"
854 #include "mir/graphics/platform.h"
855+#include "mir/graphics/platform_probe_report.h"
856
857 #include "mir/raii.h"
858
859@@ -37,6 +39,7 @@
860
861 namespace mtf = mir_test_framework;
862 namespace mtd = mir::test::doubles;
863+namespace mg = mir::graphics;
864
865 namespace
866 {
867@@ -97,17 +100,32 @@
868 return std::shared_ptr<void>{};
869 #endif
870 }
871+
872+class MockPlatformProbeReport : public mir::graphics::PlatformProbeReport
873+{
874+public:
875+ MOCK_METHOD2(module_probed, void(mg::ModuleProperties const&, mg::PlatformPriority));
876+ MOCK_METHOD1(module_selected, void(mg::ModuleProperties const&));
877+ MOCK_METHOD1(invalid_module_probed, void(std::exception const&));
878+};
879+using StubPlatformProbeReport = testing::NiceMock<MockPlatformProbeReport>;
880+
881+class ServerPlatformProbe : public testing::Test
882+{
883+public:
884+ StubPlatformProbeReport stub_probe_report;
885+};
886 }
887
888-TEST(ServerPlatformProbe, ConstructingWithNoModulesIsAnError)
889+TEST_F(ServerPlatformProbe, ConstructingWithNoModulesIsAnError)
890 {
891 std::vector<std::shared_ptr<mir::SharedLibrary>> empty_modules;
892- EXPECT_THROW(mir::graphics::module_for_device(empty_modules),
893+ EXPECT_THROW(mir::graphics::module_for_device(empty_modules, stub_probe_report),
894 std::runtime_error);
895 }
896
897 #ifdef MIR_BUILD_PLATFORM_MESA
898-TEST(ServerPlatformProbe, LoadsMesaPlatformWhenDrmDevicePresent)
899+TEST_F(ServerPlatformProbe, LoadsMesaPlatformWhenDrmDevicePresent)
900 {
901 using namespace testing;
902 auto block_android = ensure_android_probing_fails();
903@@ -115,7 +133,7 @@
904
905 auto modules = available_platforms();
906
907- auto module = mir::graphics::module_for_device(modules);
908+ auto module = mir::graphics::module_for_device(modules, stub_probe_report);
909 ASSERT_NE(nullptr, module);
910
911 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
912@@ -126,7 +144,7 @@
913 #endif
914
915 #ifdef MIR_BUILD_PLATFORM_ANDROID
916-TEST(ServerPlatformProbe, LoadsAndroidPlatformWhenHwaccessSucceeds)
917+TEST_F(ServerPlatformProbe, LoadsAndroidPlatformWhenHwaccessSucceeds)
918 {
919 using namespace testing;
920
921@@ -135,7 +153,7 @@
922
923 auto modules = available_platforms();
924
925- auto module = mir::graphics::module_for_device(modules);
926+ auto module = mir::graphics::module_for_device(modules, stub_probe_report);
927 ASSERT_NE(nullptr, module);
928
929 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
930@@ -145,18 +163,18 @@
931 }
932 #endif
933
934-TEST(ServerPlatformProbe, ThrowsExceptionWhenNothingProbesSuccessfully)
935+TEST_F(ServerPlatformProbe, ThrowsExceptionWhenNothingProbesSuccessfully)
936 {
937 using namespace testing;
938 auto block_android = ensure_android_probing_fails();
939 auto block_mesa = ensure_mesa_probing_fails();
940
941
942- EXPECT_THROW(mir::graphics::module_for_device(available_platforms()),
943+ EXPECT_THROW(mir::graphics::module_for_device(available_platforms(), stub_probe_report),
944 std::runtime_error);
945 }
946
947-TEST(ServerPlatformProbe, LoadsSupportedModuleWhenNoBestModule)
948+TEST_F(ServerPlatformProbe, LoadsSupportedModuleWhenNoBestModule)
949 {
950 using namespace testing;
951 auto block_android = ensure_android_probing_fails();
952@@ -165,7 +183,7 @@
953 auto modules = available_platforms();
954 add_dummy_platform(modules);
955
956- auto module = mir::graphics::module_for_device(modules);
957+ auto module = mir::graphics::module_for_device(modules, stub_probe_report);
958 ASSERT_NE(nullptr, module);
959
960 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
961@@ -174,7 +192,7 @@
962 EXPECT_THAT(description->name, HasSubstr("dummy"));
963 }
964
965-TEST(ServerPlatformProbe, LoadsMesaOrAndroidInPreferenceToDummy)
966+TEST_F(ServerPlatformProbe, LoadsMesaOrAndroidInPreferenceToDummy)
967 {
968 using namespace testing;
969
970@@ -184,7 +202,7 @@
971 auto modules = available_platforms();
972 add_dummy_platform(modules);
973
974- auto module = mir::graphics::module_for_device(modules);
975+ auto module = mir::graphics::module_for_device(modules, stub_probe_report);
976 ASSERT_NE(nullptr, module);
977
978 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
979@@ -193,7 +211,123 @@
980 EXPECT_THAT(description->name, Not(HasSubstr("dummy")));
981 }
982
983-TEST(ServerPlatformProbe, IgnoresNonPlatformModules)
984+TEST_F(ServerPlatformProbe, LogsEachModuleProbed)
985+{
986+ using namespace testing;
987+
988+ auto ensure_mesa = ensure_mesa_probing_succeeds();
989+ auto ensure_android = ensure_android_probing_succeeds();
990+
991+ auto modules = available_platforms();
992+ add_dummy_platform(modules);
993+
994+ NiceMock<MockPlatformProbeReport> report;
995+ EXPECT_CALL(report, module_probed(_,_)).Times(modules.size());
996+
997+ auto module = mir::graphics::module_for_device(modules, report);
998+}
999+
1000+namespace
1001+{
1002+MATCHER_P(ModuleNameMatches, name, "")
1003+{
1004+ return strcmp(name, arg.name) == 0;
1005+}
1006+}
1007+
1008+TEST_F(ServerPlatformProbe, LogsWithCorrectPriorityAllSupported)
1009+{
1010+ using namespace testing;
1011+
1012+ auto ensure_mesa = ensure_mesa_probing_succeeds();
1013+ auto ensure_android = ensure_android_probing_succeeds();
1014+
1015+ auto modules = available_platforms();
1016+ add_dummy_platform(modules);
1017+
1018+ NiceMock<MockPlatformProbeReport> report;
1019+ EXPECT_CALL(report,
1020+ module_probed(ModuleNameMatches("dummy"),mir::graphics::supported));
1021+ EXPECT_CALL(report,
1022+ module_probed(ModuleNameMatches("mesa"),mir::graphics::best))
1023+ .Times(AtMost(1));
1024+ EXPECT_CALL(report,
1025+ module_probed(ModuleNameMatches("android"),mir::graphics::best))
1026+ .Times(AtMost(1));
1027+
1028+ auto module = mir::graphics::module_for_device(modules, report);
1029+}
1030+
1031+TEST_F(ServerPlatformProbe, LogsWithCorrectPriorityOnlyAndroidSupported)
1032+{
1033+ using namespace testing;
1034+
1035+ auto ensure_mesa = ensure_mesa_probing_fails();
1036+ auto ensure_android = ensure_android_probing_succeeds();
1037+
1038+ auto modules = available_platforms();
1039+ add_dummy_platform(modules);
1040+
1041+ NiceMock<MockPlatformProbeReport> report;
1042+ EXPECT_CALL(report,
1043+ module_probed(ModuleNameMatches("dummy"),mir::graphics::supported));
1044+ EXPECT_CALL(report,
1045+ module_probed(ModuleNameMatches("mesa"),mir::graphics::unsupported))
1046+ .Times(AtMost(1));
1047+ EXPECT_CALL(report,
1048+ module_probed(ModuleNameMatches("android"),mir::graphics::best))
1049+ .Times(AtMost(1));
1050+
1051+ auto module = mir::graphics::module_for_device(modules, report);
1052+}
1053+
1054+TEST_F(ServerPlatformProbe, LogsWithCorrectPriorityOnlyMesaSupported)
1055+{
1056+ using namespace testing;
1057+
1058+ auto ensure_mesa = ensure_mesa_probing_succeeds();
1059+ auto ensure_android = ensure_android_probing_fails();
1060+
1061+ auto modules = available_platforms();
1062+ add_dummy_platform(modules);
1063+
1064+ NiceMock<MockPlatformProbeReport> report;
1065+ EXPECT_CALL(report,
1066+ module_probed(ModuleNameMatches("dummy"),mir::graphics::supported));
1067+ EXPECT_CALL(report,
1068+ module_probed(ModuleNameMatches("mesa"),mir::graphics::best))
1069+ .Times(AtMost(1));
1070+ EXPECT_CALL(report,
1071+ module_probed(ModuleNameMatches("android"),mir::graphics::unsupported))
1072+ .Times(AtMost(1));
1073+
1074+ auto module = mir::graphics::module_for_device(modules, report);
1075+}
1076+
1077+TEST_F(ServerPlatformProbe, LogsSelectedPlugin)
1078+{
1079+ using namespace testing;
1080+
1081+ auto ensure_mesa = ensure_mesa_probing_succeeds();
1082+ auto ensure_android = ensure_android_probing_succeeds();
1083+
1084+ auto modules = available_platforms();
1085+ add_dummy_platform(modules);
1086+
1087+ NiceMock<MockPlatformProbeReport> report;
1088+ char const* selected_name;
1089+ EXPECT_CALL(report, module_selected(_))
1090+ .WillOnce(Invoke([&selected_name](mir::graphics::ModuleProperties const& descriptor)
1091+ {
1092+ selected_name = descriptor.name;
1093+ }));
1094+
1095+ auto module = mir::graphics::module_for_device(modules, report);
1096+ auto describe = module->load_function<mir::graphics::DescribeModule>("describe_module");
1097+ EXPECT_STREQ(describe()->name, selected_name);
1098+}
1099+
1100+TEST_F(ServerPlatformProbe, IgnoresNonPlatformModules)
1101 {
1102 using namespace testing;
1103
1104@@ -207,6 +341,27 @@
1105 "/libmirclient.so"));
1106
1107
1108- auto module = mir::graphics::module_for_device(modules);
1109+ NiceMock<MockPlatformProbeReport> report;
1110+ auto module = mir::graphics::module_for_device(modules, report);
1111 EXPECT_NE(nullptr, module);
1112 }
1113+
1114+TEST_F(ServerPlatformProbe, LogsModulesThatFailToLoad)
1115+{
1116+ using namespace testing;
1117+
1118+ std::vector<std::shared_ptr<mir::SharedLibrary>> modules;
1119+ modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() +
1120+ "/libmirclient.so"));
1121+ add_dummy_platform(modules);
1122+
1123+
1124+ NiceMock<MockPlatformProbeReport> report;
1125+ EXPECT_CALL(report, invalid_module_probed(_))
1126+ .WillOnce(Invoke([](std::exception const& error)
1127+ {
1128+ EXPECT_THAT(error.what(), HasSubstr("libmirclient")) << "Name of the failing module";
1129+ EXPECT_THAT(error.what(), HasSubstr("probe_platform")) << "Name of the expected function";
1130+ }));
1131+ auto module = mir::graphics::module_for_device(modules, report);
1132+}

Subscribers

People subscribed via source and target branches