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
=== added file 'include/platform/mir/graphics/platform_probe_report.h'
--- include/platform/mir/graphics/platform_probe_report.h 1970-01-01 00:00:00 +0000
+++ include/platform/mir/graphics/platform_probe_report.h 2014-09-11 23:16:08 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_GRAPHICS_PLATFORM_PROBE_REPORT_H_
20#define MIR_GRAPHICS_PLATFORM_PROBE_REPORT_H_
21
22#include "mir/graphics/platform.h"
23
24namespace mir
25{
26namespace graphics
27{
28
29class PlatformProbeReport
30{
31public:
32 PlatformProbeReport() = default;
33 virtual ~PlatformProbeReport() = default;
34
35 PlatformProbeReport(PlatformProbeReport const&) = delete;
36 PlatformProbeReport& operator=(PlatformProbeReport const&) = delete;
37
38 virtual void module_probed(ModuleProperties const& module, PlatformPriority probe_value) = 0;
39 virtual void invalid_module_probed(std::exception const& error) = 0;
40 virtual void module_selected(ModuleProperties const& module) = 0;
41};
42}
43}
44
45#endif // MIR_GRAPHICS_PLATFORM_PROBE_REPORT_H_
046
=== modified file 'include/platform/mir/options/configuration.h'
--- include/platform/mir/options/configuration.h 2014-09-11 23:16:06 +0000
+++ include/platform/mir/options/configuration.h 2014-09-11 23:16:08 +0000
@@ -43,6 +43,7 @@
43extern char const* const host_socket_opt;43extern char const* const host_socket_opt;
44extern char const* const frontend_threads_opt;44extern char const* const frontend_threads_opt;
45extern char const* const fatal_abort_opt;45extern char const* const fatal_abort_opt;
46extern char const* const platform_probe_report_opt;
4647
47extern char const* const name_opt;48extern char const* const name_opt;
48extern char const* const offscreen_opt;49extern char const* const offscreen_opt;
4950
=== modified file 'include/server/mir/default_server_configuration.h'
--- include/server/mir/default_server_configuration.h 2014-09-11 23:16:06 +0000
+++ include/server/mir/default_server_configuration.h 2014-09-11 23:16:08 +0000
@@ -110,6 +110,7 @@
110class CursorImage;110class CursorImage;
111class GLConfig;111class GLConfig;
112class GLProgramFactory;112class GLProgramFactory;
113class PlatformProbeReport;
113namespace nested { class HostConnection; }114namespace nested { class HostConnection; }
114}115}
115namespace input116namespace input
@@ -309,6 +310,7 @@
309 virtual std::shared_ptr<time::Clock> the_clock();310 virtual std::shared_ptr<time::Clock> the_clock();
310 virtual std::shared_ptr<ServerActionQueue> the_server_action_queue();311 virtual std::shared_ptr<ServerActionQueue> the_server_action_queue();
311 virtual std::shared_ptr<SharedLibraryProberReport> the_shared_library_prober_report();312 virtual std::shared_ptr<SharedLibraryProberReport> the_shared_library_prober_report();
313 virtual std::shared_ptr<graphics::PlatformProbeReport> the_platform_probe_report();
312314
313protected:315protected:
314 std::shared_ptr<options::Option> the_options() const;316 std::shared_ptr<options::Option> the_options() const;
@@ -410,6 +412,7 @@
410 CachedPtr<EmergencyCleanup> emergency_cleanup;412 CachedPtr<EmergencyCleanup> emergency_cleanup;
411 CachedPtr<shell::HostLifecycleEventListener> host_lifecycle_event_listener;413 CachedPtr<shell::HostLifecycleEventListener> host_lifecycle_event_listener;
412 CachedPtr<SharedLibraryProberReport> shared_library_prober_report;414 CachedPtr<SharedLibraryProberReport> shared_library_prober_report;
415 CachedPtr<graphics::PlatformProbeReport> platform_probe_report;
413416
414private:417private:
415 std::shared_ptr<options::Configuration> const configuration_options;418 std::shared_ptr<options::Configuration> const configuration_options;
416419
=== modified file 'platform-ABI-sha1sums'
--- platform-ABI-sha1sums 2014-09-11 23:16:06 +0000
+++ platform-ABI-sha1sums 2014-09-11 23:16:08 +0000
@@ -25,8 +25,9 @@
25815405c5aee8000bc18c1c9480bac620a451b416 include/platform/mir/graphics/event_handler_register.h25815405c5aee8000bc18c1c9480bac620a451b416 include/platform/mir/graphics/event_handler_register.h
265dc095474ef3e294c0aa4008e9ed997bdb21d34c include/platform/mir/graphics/gl_config.h265dc095474ef3e294c0aa4008e9ed997bdb21d34c include/platform/mir/graphics/gl_config.h
27d0442a5d5d88a4be6e3e1f99e433c1c43a86bfce include/platform/mir/graphics/gl_context.h27d0442a5d5d88a4be6e3e1f99e433c1c43a86bfce include/platform/mir/graphics/gl_context.h
283f38702323495a5f649155a967b7b88c3f5b356a include/platform/mir/graphics/platform_probe_report.h
2815f201741a465de33e55ffc1ea775b507a5be950 include/platform/mir/graphics/renderable.h2915f201741a465de33e55ffc1ea775b507a5be950 include/platform/mir/graphics/renderable.h
29df61c1168b1798c628d087fc17900d58d608a6fa include/platform/mir/options/configuration.h30dfadb98ded10296a5fc900c97c29ba4e07427868 include/platform/mir/options/configuration.h
3047007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h3147007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h
31b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h32b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h
323c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h333c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h
3334
=== modified file 'server-ABI-sha1sums'
--- server-ABI-sha1sums 2014-09-11 23:16:06 +0000
+++ server-ABI-sha1sums 2014-09-11 23:16:08 +0000
@@ -25,13 +25,14 @@
25815405c5aee8000bc18c1c9480bac620a451b416 include/platform/mir/graphics/event_handler_register.h25815405c5aee8000bc18c1c9480bac620a451b416 include/platform/mir/graphics/event_handler_register.h
265dc095474ef3e294c0aa4008e9ed997bdb21d34c include/platform/mir/graphics/gl_config.h265dc095474ef3e294c0aa4008e9ed997bdb21d34c include/platform/mir/graphics/gl_config.h
27d0442a5d5d88a4be6e3e1f99e433c1c43a86bfce include/platform/mir/graphics/gl_context.h27d0442a5d5d88a4be6e3e1f99e433c1c43a86bfce include/platform/mir/graphics/gl_context.h
283f38702323495a5f649155a967b7b88c3f5b356a include/platform/mir/graphics/platform_probe_report.h
2815f201741a465de33e55ffc1ea775b507a5be950 include/platform/mir/graphics/renderable.h2915f201741a465de33e55ffc1ea775b507a5be950 include/platform/mir/graphics/renderable.h
29df61c1168b1798c628d087fc17900d58d608a6fa include/platform/mir/options/configuration.h30dfadb98ded10296a5fc900c97c29ba4e07427868 include/platform/mir/options/configuration.h
3047007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h3147007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h
31b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h32b45f14082c4f8b29efaa1b13de795dcb29deb738 include/platform/mir/options/option.h
323c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h333c37cc31e8b290b89c311d82f02e07d342766451 include/platform/mir/options/program_option.h
33f4030e400baf8baa9c38e7c6ec6b4a5ad7134aeb include/server/mir/compositor/compositor.h34f4030e400baf8baa9c38e7c6ec6b4a5ad7134aeb include/server/mir/compositor/compositor.h
34d69ff1401221ffa9adce7f8d85074a6f8b234baf include/server/mir/default_server_configuration.h357431f70be1309f15ccd14e5f3973bd5ffc5bac5c include/server/mir/default_server_configuration.h
35af1ff0714be973ac76d56006a2e5991f68cd1dec include/server/mir/display_server.h36af1ff0714be973ac76d56006a2e5991f68cd1dec include/server/mir/display_server.h
3665db331f1c0e956eced5c9fc73a2b2122dbc8dc7 include/server/mir/frontend/connection_creator.h3765db331f1c0e956eced5c9fc73a2b2122dbc8dc7 include/server/mir/frontend/connection_creator.h
37e6e92642301fc9bb85e1d38087a5dd84e5d30fd7 include/server/mir/frontend/connections.h38e6e92642301fc9bb85e1d38087a5dd84e5d30fd7 include/server/mir/frontend/connections.h
3839
=== modified file 'src/platform/graphics/platform_probe.cpp'
--- src/platform/graphics/platform_probe.cpp 2014-09-11 23:16:06 +0000
+++ src/platform/graphics/platform_probe.cpp 2014-09-11 23:16:08 +0000
@@ -20,7 +20,8 @@
20#include "platform_probe.h"20#include "platform_probe.h"
2121
22std::shared_ptr<mir::SharedLibrary>22std::shared_ptr<mir::SharedLibrary>
23mir::graphics::module_for_device(std::vector<std::shared_ptr<SharedLibrary>> const& modules)23mir::graphics::module_for_device(std::vector<std::shared_ptr<SharedLibrary>> const& modules,
24 PlatformProbeReport& report)
24{25{
25 mir::graphics::PlatformPriority best_priority_so_far = mir::graphics::unsupported;26 mir::graphics::PlatformPriority best_priority_so_far = mir::graphics::unsupported;
26 std::shared_ptr<mir::SharedLibrary> best_module_so_far;27 std::shared_ptr<mir::SharedLibrary> best_module_so_far;
@@ -31,19 +32,22 @@
31 auto probe = module->load_function<mir::graphics::PlatformProbe>("probe_platform",32 auto probe = module->load_function<mir::graphics::PlatformProbe>("probe_platform",
32 SERVER_PLATFORM_VERSION);33 SERVER_PLATFORM_VERSION);
33 auto module_priority = probe();34 auto module_priority = probe();
35 auto describe = module->load_function<DescribeModule>("describe_module");
36 report.module_probed(*describe(), module_priority);
34 if (module_priority > best_priority_so_far)37 if (module_priority > best_priority_so_far)
35 {38 {
36 best_priority_so_far = module_priority;39 best_priority_so_far = module_priority;
37 best_module_so_far = module;40 best_module_so_far = module;
38 }41 }
39 }42 }
40 catch (std::runtime_error)43 catch (std::runtime_error const& error)
41 {44 {
42 // Tried to probe a SharedLibrary that isn't a platform module?45 report.invalid_module_probed(error);
43 }46 }
44 }47 }
45 if (best_priority_so_far > mir::graphics::unsupported)48 if (best_priority_so_far > mir::graphics::unsupported)
46 {49 {
50 report.module_selected(*best_module_so_far->load_function<DescribeModule>("describe_module")());
47 return best_module_so_far;51 return best_module_so_far;
48 }52 }
49 throw std::runtime_error{"Failed to find platform for current system"};53 throw std::runtime_error{"Failed to find platform for current system"};
5054
=== modified file 'src/platform/graphics/platform_probe.h'
--- src/platform/graphics/platform_probe.h 2014-09-11 23:16:06 +0000
+++ src/platform/graphics/platform_probe.h 2014-09-11 23:16:08 +0000
@@ -22,6 +22,7 @@
22#include <vector>22#include <vector>
23#include <memory>23#include <memory>
24#include "mir/shared_library.h"24#include "mir/shared_library.h"
25#include "mir/graphics/platform_probe_report.h"
2526
26namespace mir27namespace mir
27{28{
@@ -29,7 +30,7 @@
29{30{
30class Platform;31class Platform;
3132
32std::shared_ptr<SharedLibrary> module_for_device(std::vector<std::shared_ptr<SharedLibrary>> const& modules);33std::shared_ptr<SharedLibrary> module_for_device(std::vector<std::shared_ptr<SharedLibrary>> const& modules, PlatformProbeReport& report);
3334
34}35}
35}36}
3637
=== modified file 'src/platform/options/default_configuration.cpp'
--- src/platform/options/default_configuration.cpp 2014-09-11 23:16:06 +0000
+++ src/platform/options/default_configuration.cpp 2014-09-11 23:16:08 +0000
@@ -46,6 +46,7 @@
46char const* const mo::name_opt = "name";46char const* const mo::name_opt = "name";
47char const* const mo::offscreen_opt = "offscreen";47char const* const mo::offscreen_opt = "offscreen";
48char const* const mo::fatal_abort_opt = "on-fatal-error-abort";48char const* const mo::fatal_abort_opt = "on-fatal-error-abort";
49char const* const mo::platform_probe_report_opt = "platform-probe-report";
4950
5051
51char const* const mo::glog = "glog";52char const* const mo::glog = "glog";
@@ -140,6 +141,8 @@
140 "How to handle to Input report. [{log,lttng,off}]")141 "How to handle to Input report. [{log,lttng,off}]")
141 (legacy_input_report_opt, po::value<std::string>()->default_value(off_opt_value),142 (legacy_input_report_opt, po::value<std::string>()->default_value(off_opt_value),
142 "How to handle the Legacy Input report. [{log,off}]")143 "How to handle the Legacy Input report. [{log,off}]")
144 (platform_probe_report_opt, po::value<std::string>()->default_value(log_opt_value),
145 "How to handle the Platform Probe report. [{log,lttng,off}]")
143 (session_mediator_report_opt, po::value<std::string>()->default_value(off_opt_value),146 (session_mediator_report_opt, po::value<std::string>()->default_value(off_opt_value),
144 "How to handle the SessionMediator report. [{log,lttng,off}]")147 "How to handle the SessionMediator report. [{log,lttng,off}]")
145 (msg_processor_report_opt, po::value<std::string>()->default_value(off_opt_value),148 (msg_processor_report_opt, po::value<std::string>()->default_value(off_opt_value),
@@ -193,6 +196,19 @@
193 {196 {
194 }197 }
195};198};
199
200class NullPlatformProbeReport : public mir::graphics::PlatformProbeReport
201{
202 void module_probed(mir::graphics::ModuleProperties const&, mir::graphics::PlatformPriority) override
203 {
204 }
205 void module_selected(mir::graphics::ModuleProperties const&) override
206 {
207 }
208 void invalid_module_probed(std::exception const&) override
209 {
210 }
211};
196}212}
197213
198void mo::DefaultConfiguration::add_platform_options()214void mo::DefaultConfiguration::add_platform_options()
@@ -227,9 +243,10 @@
227 else243 else
228 {244 {
229 auto const plugin_path = env_libpath ? env_libpath : options.get<std::string>(platform_graphics_path);245 auto const plugin_path = env_libpath ? env_libpath : options.get<std::string>(platform_graphics_path);
230 NullSharedLibraryProberReport nuller;246 NullSharedLibraryProberReport null_shared_library_report;
231 auto plugins = mir::libraries_for_path(plugin_path, nuller);247 NullPlatformProbeReport null_platform_probe_report;
232 graphics_lib = mir::graphics::module_for_device(plugins);248 auto plugins = mir::libraries_for_path(plugin_path, null_shared_library_report);
249 graphics_lib = mir::graphics::module_for_device(plugins, null_platform_probe_report);
233 }250 }
234251
235 auto add_platform_options = graphics_lib->load_function<mir::graphics::AddPlatformOptions>(std::string("add_platform_options"));252 auto add_platform_options = graphics_lib->load_function<mir::graphics::AddPlatformOptions>(std::string("add_platform_options"));
236253
=== modified file 'src/platform/symbols.map'
--- src/platform/symbols.map 2014-09-11 23:16:06 +0000
+++ src/platform/symbols.map 2014-09-11 23:16:08 +0000
@@ -242,6 +242,7 @@
242 mir::options::Option::operator*;242 mir::options::Option::operator*;
243 mir::options::Option::?Option*;243 mir::options::Option::?Option*;
244 mir::options::Option::Option*;244 mir::options::Option::Option*;
245 mir::options::platform_probe_report_opt*;
245 mir::options::platform_graphics_lib*;246 mir::options::platform_graphics_lib*;
246 mir::options::ProgramOption::get*;247 mir::options::ProgramOption::get*;
247 mir::options::ProgramOption::is_set*;248 mir::options::ProgramOption::is_set*;
248249
=== modified file 'src/server/graphics/default_configuration.cpp'
--- src/server/graphics/default_configuration.cpp 2014-09-11 23:16:06 +0000
+++ src/server/graphics/default_configuration.cpp 2014-09-11 23:16:08 +0000
@@ -89,7 +89,7 @@
89 {89 {
90 throw std::runtime_error("Failed to find any platform plugins in: " MIR_SERVER_PLATFORM_PLUGIN_PATH);90 throw std::runtime_error("Failed to find any platform plugins in: " MIR_SERVER_PLATFORM_PLUGIN_PATH);
91 }91 }
92 platform_library = mir::graphics::module_for_device(platforms);92 platform_library = mir::graphics::module_for_device(platforms, *the_platform_probe_report());
93 }93 }
94 auto create_platform = platform_library->load_function<mg::CreatePlatform>("create_platform",94 auto create_platform = platform_library->load_function<mg::CreatePlatform>("create_platform",
95 SERVER_PLATFORM_VERSION);95 SERVER_PLATFORM_VERSION);
@@ -104,7 +104,7 @@
104 });104 });
105}105}
106106
107std::shared_ptr<mg::NativePlatform> mir::DefaultServerConfiguration::the_graphics_native_platform()107std::shared_ptr<mg::NativePlatform> mir::DefaultServerConfiguration::the_graphics_native_platform()
108{108{
109 return graphics_native_platform(109 return graphics_native_platform(
110 [this]()110 [this]()
@@ -120,7 +120,7 @@
120 {120 {
121 throw std::runtime_error("Failed to find any platform plugins in: " MIR_SERVER_PLATFORM_PLUGIN_PATH);121 throw std::runtime_error("Failed to find any platform plugins in: " MIR_SERVER_PLATFORM_PLUGIN_PATH);
122 }122 }
123 platform_library = mir::graphics::module_for_device(platforms);123 platform_library = mir::graphics::module_for_device(platforms, *the_platform_probe_report());
124 }124 }
125 auto create_native_platform = platform_library->load_function<mg::CreateNativePlatform>("create_native_platform",125 auto create_native_platform = platform_library->load_function<mg::CreateNativePlatform>("create_native_platform",
126 SERVER_PLATFORM_VERSION);126 SERVER_PLATFORM_VERSION);
127127
=== modified file 'src/server/report/default_server_configuration.cpp'
--- src/server/report/default_server_configuration.cpp 2014-09-11 23:16:06 +0000
+++ src/server/report/default_server_configuration.cpp 2014-09-11 23:16:08 +0000
@@ -126,3 +126,12 @@
126 return report_factory(options::shared_library_prober_report_opt)->create_shared_library_prober_report();126 return report_factory(options::shared_library_prober_report_opt)->create_shared_library_prober_report();
127 });127 });
128}128}
129
130auto mir::DefaultServerConfiguration::the_platform_probe_report() -> std::shared_ptr<mg::PlatformProbeReport>
131{
132 return platform_probe_report(
133 [this]() -> std::shared_ptr<mir::graphics::PlatformProbeReport>
134 {
135 return report_factory(options::platform_probe_report_opt)->create_platform_probe_report();
136 });
137}
129138
=== modified file 'src/server/report/logging/CMakeLists.txt'
--- src/server/report/logging/CMakeLists.txt 2014-09-11 23:16:06 +0000
+++ src/server/report/logging/CMakeLists.txt 2014-09-11 23:16:08 +0000
@@ -11,6 +11,7 @@
11 compositor_report.cpp11 compositor_report.cpp
12 scene_report.cpp12 scene_report.cpp
13 logging_report_factory.cpp13 logging_report_factory.cpp
14 platform_probe_report.cpp
14)15)
1516
16add_library(17add_library(
1718
=== modified file 'src/server/report/logging/logging_report_factory.cpp'
--- src/server/report/logging/logging_report_factory.cpp 2014-09-11 23:16:06 +0000
+++ src/server/report/logging/logging_report_factory.cpp 2014-09-11 23:16:08 +0000
@@ -26,6 +26,7 @@
26#include "session_mediator_report.h"26#include "session_mediator_report.h"
27#include "input_report.h"27#include "input_report.h"
28#include "mir/logging/shared_library_prober_report.h"28#include "mir/logging/shared_library_prober_report.h"
29#include "platform_probe_report.h"
2930
30#include "mir/default_server_configuration.h"31#include "mir/default_server_configuration.h"
3132
@@ -77,3 +78,8 @@
77{78{
78 return std::make_shared<mir::logging::SharedLibraryProberReport>(logger);79 return std::make_shared<mir::logging::SharedLibraryProberReport>(logger);
79}80}
81
82std::shared_ptr<mir::graphics::PlatformProbeReport> mr::LoggingReportFactory::create_platform_probe_report()
83{
84 return std::make_shared<logging::PlatformProbeReport>(logger);
85}
8086
=== added file 'src/server/report/logging/platform_probe_report.cpp'
--- src/server/report/logging/platform_probe_report.cpp 1970-01-01 00:00:00 +0000
+++ src/server/report/logging/platform_probe_report.cpp 2014-09-11 23:16:08 +0000
@@ -0,0 +1,55 @@
1#include "platform_probe_report.h"
2#include "mir/logging/logger.h"
3
4#include <sstream>
5#include <string>
6
7namespace ml = mir::logging;
8namespace mg = mir::graphics;
9
10mir::report::logging::PlatformProbeReport::PlatformProbeReport(std::shared_ptr<ml::Logger> const& logger)
11 : logger{logger}
12{
13}
14
15namespace
16{
17std::string priority_to_string(mg::PlatformPriority priority)
18{
19 switch (priority)
20 {
21 case mg::PlatformPriority::unsupported:
22 return "unsupported";
23 case mg::PlatformPriority::supported:
24 return "supported";
25 case mg::PlatformPriority::best:
26 return "best";
27 default:
28 return std::to_string(static_cast<int>(priority));
29 }
30}
31}
32
33
34void mir::report::logging::PlatformProbeReport::module_probed(mg::ModuleProperties const& module, mg::PlatformPriority probe_value)
35{
36 std::stringstream ss;
37 ss << "Module probed" << std::endl
38 << "\tName: " << module.name << std::endl
39 << "\tPriority: " << priority_to_string(probe_value);
40 logger->log(ml::Logger::informational, ss.str(), "Platform");
41}
42
43void mir::report::logging::PlatformProbeReport::invalid_module_probed(std::exception const& error)
44{
45 std::stringstream ss;
46 ss << "Failed to probe module. Error was: " << error.what();
47 logger->log(ml::Logger::warning, ss.str(), "Platform");
48}
49
50void mir::report::logging::PlatformProbeReport::module_selected(mg::ModuleProperties const& module)
51{
52 std::stringstream ss;
53 ss << "Selected module: " << module.name;
54 logger->log(ml::Logger::informational, ss.str(), "Platform");
55}
056
=== added file 'src/server/report/logging/platform_probe_report.h'
--- src/server/report/logging/platform_probe_report.h 1970-01-01 00:00:00 +0000
+++ src/server/report/logging/platform_probe_report.h 2014-09-11 23:16:08 +0000
@@ -0,0 +1,55 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_REPORT_LOGGING_PLATFORM_PROBE_REPORT_H_
20#define MIR_REPORT_LOGGING_PLATFORM_PROBE_REPORT_H_
21
22#include "mir/graphics/platform_probe_report.h"
23
24#include <memory>
25
26namespace mir
27{
28namespace logging
29{
30class Logger;
31}
32namespace report
33{
34namespace logging
35{
36
37class PlatformProbeReport : public graphics::PlatformProbeReport
38{
39public:
40 PlatformProbeReport(std::shared_ptr<mir::logging::Logger> const& logger);
41
42 void module_probed(const graphics::ModuleProperties &module, graphics::PlatformPriority probe_value);
43 void invalid_module_probed(const std::exception &error);
44 void module_selected(const graphics::ModuleProperties &module);
45
46private:
47 std::shared_ptr<mir::logging::Logger> const logger;
48};
49
50}
51}
52}
53
54
55#endif /* MIR_REPORT_LOGGING_PLATFORM_PROBE_REPORT_H_ */
056
=== modified file 'src/server/report/logging_report_factory.h'
--- src/server/report/logging_report_factory.h 2014-09-11 23:16:06 +0000
+++ src/server/report/logging_report_factory.h 2014-09-11 23:16:08 +0000
@@ -48,6 +48,7 @@
48 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;48 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;
49 std::shared_ptr<input::InputReport> create_input_report() override;49 std::shared_ptr<input::InputReport> create_input_report() override;
50 std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;50 std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;
51 std::shared_ptr<graphics::PlatformProbeReport> create_platform_probe_report() override;
5152
5253
53private:54private:
5455
=== modified file 'src/server/report/lttng/CMakeLists.txt'
--- src/server/report/lttng/CMakeLists.txt 2014-09-11 23:16:06 +0000
+++ src/server/report/lttng/CMakeLists.txt 2014-09-11 23:16:08 +0000
@@ -14,6 +14,7 @@
14 input_report.cpp14 input_report.cpp
15 message_processor_report.cpp15 message_processor_report.cpp
16 lttng_report_factory.cpp16 lttng_report_factory.cpp
17 platform_probe_report.cpp
17 session_mediator_report.cpp18 session_mediator_report.cpp
18 scene_report.cpp19 scene_report.cpp
19 server_tracepoint_provider.cpp20 server_tracepoint_provider.cpp
2021
=== modified file 'src/server/report/lttng/lttng_report_factory.cpp'
--- src/server/report/lttng/lttng_report_factory.cpp 2014-09-11 23:16:06 +0000
+++ src/server/report/lttng/lttng_report_factory.cpp 2014-09-11 23:16:08 +0000
@@ -23,6 +23,7 @@
23#include "display_report.h"23#include "display_report.h"
24#include "input_report.h"24#include "input_report.h"
25#include "message_processor_report.h"25#include "message_processor_report.h"
26#include "platform_probe_report.h"
26#include "scene_report.h"27#include "scene_report.h"
27#include "session_mediator_report.h"28#include "session_mediator_report.h"
28#include "shared_library_prober_report.h"29#include "shared_library_prober_report.h"
@@ -67,3 +68,8 @@
67 return std::make_shared<lttng::SharedLibraryProberReport>();68 return std::make_shared<lttng::SharedLibraryProberReport>();
68}69}
6970
71std::shared_ptr<mir::graphics::PlatformProbeReport> mir::report::LttngReportFactory::create_platform_probe_report()
72{
73 return std::make_shared<lttng::PlatformProbeReport>();
74}
75
7076
=== added file 'src/server/report/lttng/platform_probe_report.cpp'
--- src/server/report/lttng/platform_probe_report.cpp 1970-01-01 00:00:00 +0000
+++ src/server/report/lttng/platform_probe_report.cpp 2014-09-11 23:16:08 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#include "platform_probe_report.h"
20
21#include "mir/report/lttng/mir_tracepoint.h"
22
23#define TRACEPOINT_DEFINE
24#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
25#include "platform_probe_report_tp.h"
26
27
28
29void mir::report::lttng::PlatformProbeReport::module_probed(mir::graphics::ModuleProperties const& module, mir::graphics::PlatformPriority probe_value)
30{
31 mir_tracepoint(mir_server_platform_probe, module_probed, module.name, probe_value);
32}
33
34void mir::report::lttng::PlatformProbeReport::invalid_module_probed(std::exception const& error)
35{
36 mir_tracepoint(mir_server_platform_probe, invalid_module_probed, error.what());
37}
38
39void mir::report::lttng::PlatformProbeReport::module_selected(mir::graphics::ModuleProperties const& module)
40{
41 mir_tracepoint(mir_server_platform_probe, module_selected, module.name);
42}
043
=== added file 'src/server/report/lttng/platform_probe_report.h'
--- src/server/report/lttng/platform_probe_report.h 1970-01-01 00:00:00 +0000
+++ src/server/report/lttng/platform_probe_report.h 2014-09-11 23:16:08 +0000
@@ -0,0 +1,47 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_REPORT_LTTNG_PLATFORM_PROBE_REPORT_H_
20#define MIR_REPORT_LTTNG_PLATFORM_PROBE_REPORT_H_
21
22#include "server_tracepoint_provider.h"
23
24#include "mir/graphics/platform_probe_report.h"
25
26namespace mir
27{
28namespace report
29{
30namespace lttng
31{
32class PlatformProbeReport : public graphics::PlatformProbeReport
33{
34public:
35 void module_probed(graphics::ModuleProperties const& module,
36 graphics::PlatformPriority probe_value) override;
37 void invalid_module_probed(std::exception const& error) override;
38 void module_selected(graphics::ModuleProperties const& module) override;
39
40private:
41 ServerTracepointProvider tp_provider;
42};
43}
44}
45}
46
47#endif /* MIR_REPORT_LTTNG_PLATFORM_PROBE_REPORT_H_ */
048
=== added file 'src/server/report/lttng/platform_probe_report_tp.h'
--- src/server/report/lttng/platform_probe_report_tp.h 1970-01-01 00:00:00 +0000
+++ src/server/report/lttng/platform_probe_report_tp.h 2014-09-11 23:16:08 +0000
@@ -0,0 +1,57 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#undef TRACEPOINT_PROVIDER
20#define TRACEPOINT_PROVIDER mir_server_platform_probe
21
22#undef TRACEPOINT_INCLUDE
23#define TRACEPOINT_INCLUDE "./platform_probe_report_tp.h"
24
25#if !defined(MIR_LTTNG_PLATFORM_PROBE_REPORT_TP_H_) || defined(TRACEPOINT_HEADER_MULTI_READ)
26#define MIR_LTTNG_PLATFORM_PROBE_REPORT_TP_H_
27
28#include "lttng_utils.h"
29
30MIR_LTTNG_VOID_TRACE_CLASS(mir_server_platform_probe)
31
32TRACEPOINT_EVENT(
33 TRACEPOINT_PROVIDER,
34 module_probed,
35 TP_ARGS(char const*, name, int, priority),
36 TP_FIELDS(ctf_string(name, name), ctf_integer(int, priority, priority))
37)
38
39TRACEPOINT_EVENT(
40 TRACEPOINT_PROVIDER,
41 invalid_module_probed,
42 TP_ARGS(char const*, error),
43 TP_FIELDS(ctf_string(name, name))
44)
45
46TRACEPOINT_EVENT(
47 TRACEPOINT_PROVIDER,
48 module_selected,
49 TP_ARGS(char const*, name),
50 TP_FIELDS(ctf_string(name, name))
51)
52
53#include "lttng_utils_pop.h"
54
55#endif /* MIR_LTTNG_COMPOSITOR_REPORT_TP_H_ */
56
57#include <lttng/tracepoint-event.h>
058
=== modified file 'src/server/report/lttng_report_factory.h'
--- src/server/report/lttng_report_factory.h 2014-09-11 23:16:06 +0000
+++ src/server/report/lttng_report_factory.h 2014-09-11 23:16:08 +0000
@@ -36,6 +36,7 @@
36 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;36 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;
37 std::shared_ptr<input::InputReport> create_input_report() override;37 std::shared_ptr<input::InputReport> create_input_report() override;
38 std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;38 std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;
39 std::shared_ptr<graphics::PlatformProbeReport> create_platform_probe_report() override;
39};40};
40}41}
41}42}
4243
=== modified file 'src/server/report/null/CMakeLists.txt'
--- src/server/report/null/CMakeLists.txt 2014-09-11 23:16:06 +0000
+++ src/server/report/null/CMakeLists.txt 2014-09-11 23:16:08 +0000
@@ -7,7 +7,8 @@
7 input_report.cpp7 input_report.cpp
8 message_processor_report.cpp8 message_processor_report.cpp
9 null_report_factory.cpp9 null_report_factory.cpp
10 platform_probe_report.cpp
10 scene_report.cpp11 scene_report.cpp
11 session_mediator_report.cpp12 session_mediator_report.cpp
12 shared_library_prober_report.cpp13 shared_library_prober_report.cpp
13 )14)
1415
=== modified file 'src/server/report/null/null_report_factory.cpp'
--- src/server/report/null/null_report_factory.cpp 2014-09-11 23:16:06 +0000
+++ src/server/report/null/null_report_factory.cpp 2014-09-11 23:16:08 +0000
@@ -24,6 +24,7 @@
24#include "session_mediator_report.h"24#include "session_mediator_report.h"
25#include "display_report.h"25#include "display_report.h"
26#include "input_report.h"26#include "input_report.h"
27#include "platform_probe_report.h"
27#include "scene_report.h"28#include "scene_report.h"
28#include "shared_library_prober_report.h"29#include "shared_library_prober_report.h"
2930
@@ -67,6 +68,11 @@
67 return std::make_shared<null::SharedLibraryProberReport>();68 return std::make_shared<null::SharedLibraryProberReport>();
68}69}
6970
71std::shared_ptr<mir::graphics::PlatformProbeReport> mir::report::NullReportFactory::create_platform_probe_report()
72{
73 return std::make_shared<null::PlatformProbeReport>();
74}
75
70std::shared_ptr<mir::compositor::CompositorReport> mir::report::null_compositor_report()76std::shared_ptr<mir::compositor::CompositorReport> mir::report::null_compositor_report()
71{77{
72 return NullReportFactory{}.create_compositor_report();78 return NullReportFactory{}.create_compositor_report();
@@ -101,3 +107,8 @@
101{107{
102 return NullReportFactory{}.create_shared_library_prober_report();108 return NullReportFactory{}.create_shared_library_prober_report();
103}109}
110
111std::shared_ptr<mir::graphics::PlatformProbeReport> mir::report::null_platform_probe_report()
112{
113 return NullReportFactory{}.create_platform_probe_report();
114}
104115
=== added file 'src/server/report/null/platform_probe_report.cpp'
--- src/server/report/null/platform_probe_report.cpp 1970-01-01 00:00:00 +0000
+++ src/server/report/null/platform_probe_report.cpp 2014-09-11 23:16:08 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#include "platform_probe_report.h"
20
21void mir::report::null::PlatformProbeReport::module_probed(mir::graphics::ModuleProperties const&,
22 mir::graphics::PlatformPriority)
23{
24}
25
26void mir::report::null::PlatformProbeReport::invalid_module_probed(std::exception const&)
27{
28}
29
30void mir::report::null::PlatformProbeReport::module_selected(mir::graphics::ModuleProperties const&)
31{
32}
033
=== added file 'src/server/report/null/platform_probe_report.h'
--- src/server/report/null/platform_probe_report.h 1970-01-01 00:00:00 +0000
+++ src/server/report/null/platform_probe_report.h 2014-09-11 23:16:08 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_REPORT_NULL_PLATFORM_PROBE_REPORT_H_
20#define MIR_REPORT_NULL_PLATFORM_PROBE_REPORT_H_
21
22#include "mir/graphics/platform_probe_report.h"
23
24namespace mir
25{
26namespace report
27{
28namespace null
29{
30class PlatformProbeReport : public graphics::PlatformProbeReport
31{
32public:
33 void module_probed(graphics::ModuleProperties const& module,
34 graphics::PlatformPriority probe_value) override;
35 void invalid_module_probed(std::exception const& error) override;
36 void module_selected(graphics::ModuleProperties const& module) override;
37};
38}
39}
40}
41
42#endif /* MIR_REPORT_NULL_PLATFORM_PROBE_REPORT_H_ */
043
=== modified file 'src/server/report/null_report_factory.h'
--- src/server/report/null_report_factory.h 2014-09-11 23:16:06 +0000
+++ src/server/report/null_report_factory.h 2014-09-11 23:16:08 +0000
@@ -36,6 +36,7 @@
36 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;36 std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() override;
37 std::shared_ptr<input::InputReport> create_input_report() override;37 std::shared_ptr<input::InputReport> create_input_report() override;
38 std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;38 std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() override;
39 std::shared_ptr<graphics::PlatformProbeReport> create_platform_probe_report() override;
39};40};
4041
41std::shared_ptr<compositor::CompositorReport> null_compositor_report();42std::shared_ptr<compositor::CompositorReport> null_compositor_report();
@@ -46,6 +47,7 @@
46std::shared_ptr<frontend::MessageProcessorReport> null_message_processor_report();47std::shared_ptr<frontend::MessageProcessorReport> null_message_processor_report();
47std::shared_ptr<input::InputReport> null_input_report();48std::shared_ptr<input::InputReport> null_input_report();
48std::shared_ptr<SharedLibraryProberReport> null_shared_library_prober_report();49std::shared_ptr<SharedLibraryProberReport> null_shared_library_prober_report();
50std::shared_ptr<graphics::PlatformProbeReport> null_platform_probe_report();
49}51}
50}52}
5153
5254
=== modified file 'src/server/report/report_factory.h'
--- src/server/report/report_factory.h 2014-09-11 23:16:06 +0000
+++ src/server/report/report_factory.h 2014-09-11 23:16:08 +0000
@@ -38,6 +38,7 @@
38namespace graphics38namespace graphics
39{39{
40class DisplayReport;40class DisplayReport;
41class PlatformProbeReport;
41}42}
42namespace input43namespace input
43{44{
@@ -62,6 +63,7 @@
62 virtual std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() = 0;63 virtual std::shared_ptr<frontend::MessageProcessorReport> create_message_processor_report() = 0;
63 virtual std::shared_ptr<input::InputReport> create_input_report() = 0;64 virtual std::shared_ptr<input::InputReport> create_input_report() = 0;
64 virtual std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() = 0;65 virtual std::shared_ptr<SharedLibraryProberReport> create_shared_library_prober_report() = 0;
66 virtual std::shared_ptr<graphics::PlatformProbeReport> create_platform_probe_report() = 0;
6567
66protected:68protected:
67 ReportFactory() = default;69 ReportFactory() = default;
6870
=== modified file 'tests/unit-tests/graphics/test_platform_prober.cpp'
--- tests/unit-tests/graphics/test_platform_prober.cpp 2014-09-11 23:16:06 +0000
+++ tests/unit-tests/graphics/test_platform_prober.cpp 2014-09-11 23:16:08 +0000
@@ -17,9 +17,11 @@
17 */17 */
1818
19#include <gtest/gtest.h>19#include <gtest/gtest.h>
20#include <gmock/gmock.h>
2021
21#include "src/platform/graphics/platform_probe.h"22#include "src/platform/graphics/platform_probe.h"
22#include "mir/graphics/platform.h"23#include "mir/graphics/platform.h"
24#include "mir/graphics/platform_probe_report.h"
2325
24#include "mir/raii.h"26#include "mir/raii.h"
2527
@@ -37,6 +39,7 @@
3739
38namespace mtf = mir_test_framework;40namespace mtf = mir_test_framework;
39namespace mtd = mir::test::doubles;41namespace mtd = mir::test::doubles;
42namespace mg = mir::graphics;
4043
41namespace44namespace
42{45{
@@ -97,17 +100,32 @@
97 return std::shared_ptr<void>{};100 return std::shared_ptr<void>{};
98#endif101#endif
99}102}
103
104class MockPlatformProbeReport : public mir::graphics::PlatformProbeReport
105{
106public:
107 MOCK_METHOD2(module_probed, void(mg::ModuleProperties const&, mg::PlatformPriority));
108 MOCK_METHOD1(module_selected, void(mg::ModuleProperties const&));
109 MOCK_METHOD1(invalid_module_probed, void(std::exception const&));
110};
111using StubPlatformProbeReport = testing::NiceMock<MockPlatformProbeReport>;
112
113class ServerPlatformProbe : public testing::Test
114{
115public:
116 StubPlatformProbeReport stub_probe_report;
117};
100}118}
101119
102TEST(ServerPlatformProbe, ConstructingWithNoModulesIsAnError)120TEST_F(ServerPlatformProbe, ConstructingWithNoModulesIsAnError)
103{121{
104 std::vector<std::shared_ptr<mir::SharedLibrary>> empty_modules;122 std::vector<std::shared_ptr<mir::SharedLibrary>> empty_modules;
105 EXPECT_THROW(mir::graphics::module_for_device(empty_modules),123 EXPECT_THROW(mir::graphics::module_for_device(empty_modules, stub_probe_report),
106 std::runtime_error);124 std::runtime_error);
107}125}
108126
109#ifdef MIR_BUILD_PLATFORM_MESA127#ifdef MIR_BUILD_PLATFORM_MESA
110TEST(ServerPlatformProbe, LoadsMesaPlatformWhenDrmDevicePresent)128TEST_F(ServerPlatformProbe, LoadsMesaPlatformWhenDrmDevicePresent)
111{129{
112 using namespace testing;130 using namespace testing;
113 auto block_android = ensure_android_probing_fails();131 auto block_android = ensure_android_probing_fails();
@@ -115,7 +133,7 @@
115133
116 auto modules = available_platforms();134 auto modules = available_platforms();
117135
118 auto module = mir::graphics::module_for_device(modules);136 auto module = mir::graphics::module_for_device(modules, stub_probe_report);
119 ASSERT_NE(nullptr, module);137 ASSERT_NE(nullptr, module);
120138
121 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");139 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
@@ -126,7 +144,7 @@
126#endif144#endif
127145
128#ifdef MIR_BUILD_PLATFORM_ANDROID146#ifdef MIR_BUILD_PLATFORM_ANDROID
129TEST(ServerPlatformProbe, LoadsAndroidPlatformWhenHwaccessSucceeds)147TEST_F(ServerPlatformProbe, LoadsAndroidPlatformWhenHwaccessSucceeds)
130{148{
131 using namespace testing;149 using namespace testing;
132150
@@ -135,7 +153,7 @@
135153
136 auto modules = available_platforms();154 auto modules = available_platforms();
137155
138 auto module = mir::graphics::module_for_device(modules);156 auto module = mir::graphics::module_for_device(modules, stub_probe_report);
139 ASSERT_NE(nullptr, module);157 ASSERT_NE(nullptr, module);
140158
141 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");159 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
@@ -145,18 +163,18 @@
145}163}
146#endif164#endif
147165
148TEST(ServerPlatformProbe, ThrowsExceptionWhenNothingProbesSuccessfully)166TEST_F(ServerPlatformProbe, ThrowsExceptionWhenNothingProbesSuccessfully)
149{167{
150 using namespace testing;168 using namespace testing;
151 auto block_android = ensure_android_probing_fails();169 auto block_android = ensure_android_probing_fails();
152 auto block_mesa = ensure_mesa_probing_fails();170 auto block_mesa = ensure_mesa_probing_fails();
153171
154172
155 EXPECT_THROW(mir::graphics::module_for_device(available_platforms()),173 EXPECT_THROW(mir::graphics::module_for_device(available_platforms(), stub_probe_report),
156 std::runtime_error);174 std::runtime_error);
157}175}
158176
159TEST(ServerPlatformProbe, LoadsSupportedModuleWhenNoBestModule)177TEST_F(ServerPlatformProbe, LoadsSupportedModuleWhenNoBestModule)
160{178{
161 using namespace testing;179 using namespace testing;
162 auto block_android = ensure_android_probing_fails();180 auto block_android = ensure_android_probing_fails();
@@ -165,7 +183,7 @@
165 auto modules = available_platforms();183 auto modules = available_platforms();
166 add_dummy_platform(modules);184 add_dummy_platform(modules);
167185
168 auto module = mir::graphics::module_for_device(modules);186 auto module = mir::graphics::module_for_device(modules, stub_probe_report);
169 ASSERT_NE(nullptr, module);187 ASSERT_NE(nullptr, module);
170188
171 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");189 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
@@ -174,7 +192,7 @@
174 EXPECT_THAT(description->name, HasSubstr("dummy"));192 EXPECT_THAT(description->name, HasSubstr("dummy"));
175}193}
176194
177TEST(ServerPlatformProbe, LoadsMesaOrAndroidInPreferenceToDummy)195TEST_F(ServerPlatformProbe, LoadsMesaOrAndroidInPreferenceToDummy)
178{196{
179 using namespace testing;197 using namespace testing;
180198
@@ -184,7 +202,7 @@
184 auto modules = available_platforms();202 auto modules = available_platforms();
185 add_dummy_platform(modules);203 add_dummy_platform(modules);
186204
187 auto module = mir::graphics::module_for_device(modules);205 auto module = mir::graphics::module_for_device(modules, stub_probe_report);
188 ASSERT_NE(nullptr, module);206 ASSERT_NE(nullptr, module);
189207
190 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");208 auto descriptor = module->load_function<mir::graphics::DescribeModule>("describe_module");
@@ -193,7 +211,123 @@
193 EXPECT_THAT(description->name, Not(HasSubstr("dummy")));211 EXPECT_THAT(description->name, Not(HasSubstr("dummy")));
194}212}
195213
196TEST(ServerPlatformProbe, IgnoresNonPlatformModules)214TEST_F(ServerPlatformProbe, LogsEachModuleProbed)
215{
216 using namespace testing;
217
218 auto ensure_mesa = ensure_mesa_probing_succeeds();
219 auto ensure_android = ensure_android_probing_succeeds();
220
221 auto modules = available_platforms();
222 add_dummy_platform(modules);
223
224 NiceMock<MockPlatformProbeReport> report;
225 EXPECT_CALL(report, module_probed(_,_)).Times(modules.size());
226
227 auto module = mir::graphics::module_for_device(modules, report);
228}
229
230namespace
231{
232MATCHER_P(ModuleNameMatches, name, "")
233{
234 return strcmp(name, arg.name) == 0;
235}
236}
237
238TEST_F(ServerPlatformProbe, LogsWithCorrectPriorityAllSupported)
239{
240 using namespace testing;
241
242 auto ensure_mesa = ensure_mesa_probing_succeeds();
243 auto ensure_android = ensure_android_probing_succeeds();
244
245 auto modules = available_platforms();
246 add_dummy_platform(modules);
247
248 NiceMock<MockPlatformProbeReport> report;
249 EXPECT_CALL(report,
250 module_probed(ModuleNameMatches("dummy"),mir::graphics::supported));
251 EXPECT_CALL(report,
252 module_probed(ModuleNameMatches("mesa"),mir::graphics::best))
253 .Times(AtMost(1));
254 EXPECT_CALL(report,
255 module_probed(ModuleNameMatches("android"),mir::graphics::best))
256 .Times(AtMost(1));
257
258 auto module = mir::graphics::module_for_device(modules, report);
259}
260
261TEST_F(ServerPlatformProbe, LogsWithCorrectPriorityOnlyAndroidSupported)
262{
263 using namespace testing;
264
265 auto ensure_mesa = ensure_mesa_probing_fails();
266 auto ensure_android = ensure_android_probing_succeeds();
267
268 auto modules = available_platforms();
269 add_dummy_platform(modules);
270
271 NiceMock<MockPlatformProbeReport> report;
272 EXPECT_CALL(report,
273 module_probed(ModuleNameMatches("dummy"),mir::graphics::supported));
274 EXPECT_CALL(report,
275 module_probed(ModuleNameMatches("mesa"),mir::graphics::unsupported))
276 .Times(AtMost(1));
277 EXPECT_CALL(report,
278 module_probed(ModuleNameMatches("android"),mir::graphics::best))
279 .Times(AtMost(1));
280
281 auto module = mir::graphics::module_for_device(modules, report);
282}
283
284TEST_F(ServerPlatformProbe, LogsWithCorrectPriorityOnlyMesaSupported)
285{
286 using namespace testing;
287
288 auto ensure_mesa = ensure_mesa_probing_succeeds();
289 auto ensure_android = ensure_android_probing_fails();
290
291 auto modules = available_platforms();
292 add_dummy_platform(modules);
293
294 NiceMock<MockPlatformProbeReport> report;
295 EXPECT_CALL(report,
296 module_probed(ModuleNameMatches("dummy"),mir::graphics::supported));
297 EXPECT_CALL(report,
298 module_probed(ModuleNameMatches("mesa"),mir::graphics::best))
299 .Times(AtMost(1));
300 EXPECT_CALL(report,
301 module_probed(ModuleNameMatches("android"),mir::graphics::unsupported))
302 .Times(AtMost(1));
303
304 auto module = mir::graphics::module_for_device(modules, report);
305}
306
307TEST_F(ServerPlatformProbe, LogsSelectedPlugin)
308{
309 using namespace testing;
310
311 auto ensure_mesa = ensure_mesa_probing_succeeds();
312 auto ensure_android = ensure_android_probing_succeeds();
313
314 auto modules = available_platforms();
315 add_dummy_platform(modules);
316
317 NiceMock<MockPlatformProbeReport> report;
318 char const* selected_name;
319 EXPECT_CALL(report, module_selected(_))
320 .WillOnce(Invoke([&selected_name](mir::graphics::ModuleProperties const& descriptor)
321 {
322 selected_name = descriptor.name;
323 }));
324
325 auto module = mir::graphics::module_for_device(modules, report);
326 auto describe = module->load_function<mir::graphics::DescribeModule>("describe_module");
327 EXPECT_STREQ(describe()->name, selected_name);
328}
329
330TEST_F(ServerPlatformProbe, IgnoresNonPlatformModules)
197{331{
198 using namespace testing;332 using namespace testing;
199333
@@ -207,6 +341,27 @@
207 "/libmirclient.so"));341 "/libmirclient.so"));
208342
209343
210 auto module = mir::graphics::module_for_device(modules);344 NiceMock<MockPlatformProbeReport> report;
345 auto module = mir::graphics::module_for_device(modules, report);
211 EXPECT_NE(nullptr, module);346 EXPECT_NE(nullptr, module);
212}347}
348
349TEST_F(ServerPlatformProbe, LogsModulesThatFailToLoad)
350{
351 using namespace testing;
352
353 std::vector<std::shared_ptr<mir::SharedLibrary>> modules;
354 modules.push_back(std::make_shared<mir::SharedLibrary>(mtf::library_path() +
355 "/libmirclient.so"));
356 add_dummy_platform(modules);
357
358
359 NiceMock<MockPlatformProbeReport> report;
360 EXPECT_CALL(report, invalid_module_probed(_))
361 .WillOnce(Invoke([](std::exception const& error)
362 {
363 EXPECT_THAT(error.what(), HasSubstr("libmirclient")) << "Name of the failing module";
364 EXPECT_THAT(error.what(), HasSubstr("probe_platform")) << "Name of the expected function";
365 }));
366 auto module = mir::graphics::module_for_device(modules, report);
367}

Subscribers

People subscribed via source and target branches