Mir

Merge lp:~vanvugt/mir/simplify-DisplayReport into lp:mir

Proposed by Daniel van Vugt
Status: Rejected
Rejected by: Daniel van Vugt
Proposed branch: lp:~vanvugt/mir/simplify-DisplayReport
Merge into: lp:mir
Diff against target: 541 lines (+106/-192)
12 files modified
include/platform/mir/graphics/display_report.h (+1/-8)
include/platform/mir/graphics/null_display_report.h (+1/-8)
include/test/mir_test_doubles/mock_display_report.h (+1/-7)
src/platform/graphics/android/android_display.cpp (+3/-3)
src/platform/graphics/mesa/display_buffer.cpp (+5/-5)
src/platform/graphics/mesa/linux_virtual_terminal.cpp (+2/-2)
src/platform/graphics/null_display_report.cpp (+1/-7)
src/server/logging/display_report.cpp (+17/-45)
src/server/logging/display_report.h (+1/-10)
tests/unit-tests/graphics/android/test_android_fb.cpp (+17/-14)
tests/unit-tests/graphics/mesa/test_display.cpp (+51/-80)
tests/unit-tests/graphics/mesa/test_linux_virtual_terminal.cpp (+6/-3)
To merge this branch: bzr merge lp:~vanvugt/mir/simplify-DisplayReport
Reviewer Review Type Date Requested Status
Andreas Pokorny (community) Needs Fixing
Robert Carr (community) Needs Fixing
Alan Griffiths Needs Fixing
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+199629@code.launchpad.net

Commit message

Simplify DisplayReport, merging success/failure reports into a single
interface.

Description of the change

This is a marginal improvement to the coupling and scalability of DisplayReport. Some people may disagree with it, which I kind of understand. But if this isn't sufficiently better then I hope it gets you thinking about what else might be. Because pure virtual report classes which you have to implement every function of should not be growing so large or fast (I need to add to it soon).

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I'm not saying that this report couldn't do with improvement but...

The reason for the "report" interfaces is that we can do more than simply logging events (although that is want we've done mostly - but IMO that is due to the early state of the code).

What I'd like to be able to provide is reporting code that can respond to a "ping" with a summary of current system activity - the state of outputs, connections, surfaces etc. I think this is something that we will need within half year.

The "report" interfaces should provide support for this tracking of the state of the system programmatically - which is far easier if the events that need identifying are distinct calls and not different text strings.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> I'm not saying that this report couldn't do with improvement but...
>
> The reason for the "report" interfaces is that we can do more than simply
> logging events (although that is want we've done mostly - but IMO that is due
> to the early state of the code).
>
> What I'd like to be able to provide is reporting code that can respond to a
> "ping" with a summary of current system activity - the state of outputs,
> connections, surfaces etc. I think this is something that we will need within
> half year.
>
> The "report" interfaces should provide support for this tracking of the state
> of the system programmatically - which is far easier if the events that need
> identifying are distinct calls and not different text strings.

Having looked closer I think the existing interface is too fined grained but that the MP swings too far in the opposite direction.

For example: There are a series of successful setup/construction calls that are really only useful for recording process via logging. But the fact of successful construction is probably worth distinguishing by a separate event.

Similarly, VT switch events are likely significant beyond providing a log of events.

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

Alan,
I understand and agree with your concerns. Although I'm not sure implementing N report functions M times is better than implementing just one report function M times with conditional logic.

The key requirement to improving things, I feel, is to arrive at a design where the report definition doesn't have to change for every new instrumentation point. Something less than O(N*M).

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

I think at the point where you have report->report_success(bool, char const* what), it might as well be
logger->log(is_error, message).

The current interface isn't great. I don't want to move in this direction though.

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

I think I get the intent with the report pattern. And I suspect it works best for arbitrary report types when the input (interface) is minimal and simple.

Although I also think any report implementation class should be able to distinguish different events by string (or some other unique value).

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

> I think I get the intent with the report pattern. And I suspect it works best
> for arbitrary report types when the input (interface) is minimal and simple.
>
> Although I also think any report implementation class should be able to
> distinguish different events by string (or some other unique value).

I think any report implementation should implement handlers for each of the different events being reported on. There's a mechanism (pure virtual functions) in the language that enforces this at compile time. I prefer that to detecting a failure to match strings correctly in a test harness.

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

I am used to systems that have some form of log macro that can be enabled/disabled and runtime and compile time. To say the least it is simple to add further log messages. The solution in mir is quite different. I am curious what led to that solution?

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

Andreas,
Me too. And I was arguing for that kind of simple logging before we had "reports". It has many benefits that you touched on. However if you design a "report" interface carefully then it's potentially very useful in instrumenting to data sinks that aren't necessarily logging (LTTng et al). Still, I feel the right answer is to have both. Because "reports" as they are today in Mir are too brittle (their design is uncomfortably coupled to the logic of another module) and slow to evolve (multiple classes plus tests) compared to adding new log messages.

Back on the subject of this proposal, I'm happy to reject it if we get a third disapproving review :)

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

Yes I see the advantages of the report interfaces too, and in that MP you would kind of limit those. The other question would be - are those methods in the report interface useful for understanding whats happening then they should definitely stay in that way. If not then there is a need for a separate logging facility.

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

> Andreas,
> Me too. And I was arguing for that kind of simple logging before we had
> "reports". It has many benefits that you touched on. However if you design a
> "report" interface carefully then it's potentially very useful in
> instrumenting to data sinks that aren't necessarily logging (LTTng et al).
> Still, I feel the right answer is to have both.

I've no issue with "having both" - indeed that's what I understood to be the intent when we discussed it at the sprint two years ago. For example, report->informational_log("...") or report->debug_log("...").

It is possible to debate where we draw the line between the events that should be reported and information that should be logged, but this report currently has too much of the former and this MP has too much of the latter.

Unmerged revisions

1295. By Daniel van Vugt

Port Android DisplayReports

1294. By Daniel van Vugt

Merge latest development-branch.

1293. By Daniel van Vugt

Initial attempt at simplifying DisplayReport

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/platform/mir/graphics/display_report.h'
--- include/platform/mir/graphics/display_report.h 2013-08-28 03:41:48 +0000
+++ include/platform/mir/graphics/display_report.h 2013-12-19 09:18:52 +0000
@@ -29,17 +29,10 @@
29class DisplayReport29class DisplayReport
30{30{
31public:31public:
3232 virtual void report_success(bool success, char const* what) = 0;
33 virtual void report_successful_setup_of_native_resources() = 0;
34 virtual void report_successful_egl_make_current_on_construction() = 0;
35 virtual void report_successful_egl_buffer_swap_on_construction() = 0;
36 virtual void report_successful_display_construction() = 0;
37 virtual void report_egl_configuration(EGLDisplay disp, EGLConfig cfg) = 0;33 virtual void report_egl_configuration(EGLDisplay disp, EGLConfig cfg) = 0;
38 /* gbm specific */34 /* gbm specific */
39 virtual void report_successful_drm_mode_set_crtc_on_construction() = 0;
40 virtual void report_drm_master_failure(int error) = 0;35 virtual void report_drm_master_failure(int error) = 0;
41 virtual void report_vt_switch_away_failure() = 0;
42 virtual void report_vt_switch_back_failure() = 0;
43 /* android specific */36 /* android specific */
44 virtual void report_hwc_composition_in_use(int major, int minor) = 0;37 virtual void report_hwc_composition_in_use(int major, int minor) = 0;
45 virtual void report_gpu_composition_in_use() = 0;38 virtual void report_gpu_composition_in_use() = 0;
4639
=== modified file 'include/platform/mir/graphics/null_display_report.h'
--- include/platform/mir/graphics/null_display_report.h 2013-08-28 03:41:48 +0000
+++ include/platform/mir/graphics/null_display_report.h 2013-12-19 09:18:52 +0000
@@ -31,15 +31,8 @@
31class NullDisplayReport : public graphics::DisplayReport31class NullDisplayReport : public graphics::DisplayReport
32{32{
33 public:33 public:
3434 virtual void report_success(bool success, char const* what);
35 virtual void report_successful_setup_of_native_resources();
36 virtual void report_successful_egl_make_current_on_construction();
37 virtual void report_successful_egl_buffer_swap_on_construction();
38 virtual void report_successful_drm_mode_set_crtc_on_construction();
39 virtual void report_successful_display_construction();
40 virtual void report_drm_master_failure(int error);35 virtual void report_drm_master_failure(int error);
41 virtual void report_vt_switch_away_failure();
42 virtual void report_vt_switch_back_failure();
43 virtual void report_hwc_composition_in_use(int major, int minor);36 virtual void report_hwc_composition_in_use(int major, int minor);
44 virtual void report_gpu_composition_in_use();37 virtual void report_gpu_composition_in_use();
45 virtual void report_egl_configuration(EGLDisplay disp, EGLConfig cfg);38 virtual void report_egl_configuration(EGLDisplay disp, EGLConfig cfg);
4639
=== modified file 'include/test/mir_test_doubles/mock_display_report.h'
--- include/test/mir_test_doubles/mock_display_report.h 2013-05-10 18:16:51 +0000
+++ include/test/mir_test_doubles/mock_display_report.h 2013-12-19 09:18:52 +0000
@@ -33,14 +33,8 @@
33class MockDisplayReport : public graphics::DisplayReport33class MockDisplayReport : public graphics::DisplayReport
34{34{
35public:35public:
36 MOCK_METHOD0(report_successful_setup_of_native_resources, void());36 MOCK_METHOD2(report_success, void(bool, char const*));
37 MOCK_METHOD0(report_successful_egl_make_current_on_construction, void());
38 MOCK_METHOD0(report_successful_egl_buffer_swap_on_construction, void());
39 MOCK_METHOD0(report_successful_drm_mode_set_crtc_on_construction, void());
40 MOCK_METHOD0(report_successful_display_construction, void());
41 MOCK_METHOD1(report_drm_master_failure, void(int));37 MOCK_METHOD1(report_drm_master_failure, void(int));
42 MOCK_METHOD0(report_vt_switch_away_failure, void());
43 MOCK_METHOD0(report_vt_switch_back_failure, void());
44 MOCK_METHOD2(report_hwc_composition_in_use, void(int,int));38 MOCK_METHOD2(report_hwc_composition_in_use, void(int,int));
45 MOCK_METHOD0(report_gpu_composition_in_use, void());39 MOCK_METHOD0(report_gpu_composition_in_use, void());
46 MOCK_METHOD2(report_egl_configuration, void(EGLDisplay,EGLConfig));40 MOCK_METHOD2(report_egl_configuration, void(EGLDisplay,EGLConfig));
4741
=== modified file 'src/platform/graphics/android/android_display.cpp'
--- src/platform/graphics/android/android_display.cpp 2013-12-17 18:24:51 +0000
+++ src/platform/graphics/android/android_display.cpp 2013-12-19 09:18:52 +0000
@@ -39,12 +39,12 @@
39 display_buffer{display_builder->create_display_buffer(display_device, gl_context)},39 display_buffer{display_builder->create_display_buffer(display_device, gl_context)},
40 current_configuration{display_buffer->view_area().size}40 current_configuration{display_buffer->view_area().size}
41{41{
42 display_report->report_successful_setup_of_native_resources();42 display_report->report_success(true, "setup of native resources");
4343
44 gl_context.make_current();44 gl_context.make_current();
4545
46 display_report->report_successful_egl_make_current_on_construction();46 display_report->report_success(true, "set context current on construction");
47 display_report->report_successful_display_construction();47 display_report->report_success(true, "construction");
48}48}
4949
50void mga::AndroidDisplay::for_each_display_buffer(std::function<void(mg::DisplayBuffer&)> const& f)50void mga::AndroidDisplay::for_each_display_buffer(std::function<void(mg::DisplayBuffer&)> const& f)
5151
=== modified file 'src/platform/graphics/mesa/display_buffer.cpp'
--- src/platform/graphics/mesa/display_buffer.cpp 2013-12-17 18:24:51 +0000
+++ src/platform/graphics/mesa/display_buffer.cpp 2013-12-19 09:18:52 +0000
@@ -112,11 +112,11 @@
112{112{
113 egl.setup(platform->gbm, surface_gbm.get(), shared_context);113 egl.setup(platform->gbm, surface_gbm.get(), shared_context);
114114
115 listener->report_successful_setup_of_native_resources();115 listener->report_success(true, "setup of native resources");
116116
117 make_current();117 make_current();
118118
119 listener->report_successful_egl_make_current_on_construction();119 listener->report_success(true, "set context current on construction");
120120
121 ensure_egl_image_extensions();121 ensure_egl_image_extensions();
122122
@@ -125,7 +125,7 @@
125 if (!egl.swap_buffers())125 if (!egl.swap_buffers())
126 BOOST_THROW_EXCEPTION(std::runtime_error("Failed to perform initial surface buffer swap"));126 BOOST_THROW_EXCEPTION(std::runtime_error("Failed to perform initial surface buffer swap"));
127127
128 listener->report_successful_egl_buffer_swap_on_construction();128 listener->report_success(true, "egl buffer swap on construction");
129129
130 last_flipped_bufobj = get_front_buffer_object();130 last_flipped_bufobj = get_front_buffer_object();
131 if (!last_flipped_bufobj)131 if (!last_flipped_bufobj)
@@ -139,8 +139,8 @@
139139
140 egl.release_current();140 egl.release_current();
141141
142 listener->report_successful_drm_mode_set_crtc_on_construction();142 listener->report_success(true, "drm mode setup on construction");
143 listener->report_successful_display_construction();143 listener->report_success(true, "construction");
144 egl.report_egl_configuration(144 egl.report_egl_configuration(
145 [&listener] (EGLDisplay disp, EGLConfig cfg)145 [&listener] (EGLDisplay disp, EGLConfig cfg)
146 {146 {
147147
=== modified file 'src/platform/graphics/mesa/linux_virtual_terminal.cpp'
--- src/platform/graphics/mesa/linux_virtual_terminal.cpp 2013-12-17 18:24:51 +0000
+++ src/platform/graphics/mesa/linux_virtual_terminal.cpp 2013-12-19 09:18:52 +0000
@@ -138,7 +138,7 @@
138 if (!active)138 if (!active)
139 {139 {
140 if (!switch_back())140 if (!switch_back())
141 report->report_vt_switch_back_failure();141 report->report_success(false, "switch back to Mir VT");
142 fops->ioctl(vt_fd.fd(), VT_RELDISP, VT_ACKACQ);142 fops->ioctl(vt_fd.fd(), VT_RELDISP, VT_ACKACQ);
143 active = true;143 active = true;
144 }144 }
@@ -156,7 +156,7 @@
156 else156 else
157 {157 {
158 action = disallow_switch;158 action = disallow_switch;
159 report->report_vt_switch_away_failure();159 report->report_success(false, "switch away from Mir VT");
160 }160 }
161161
162 fops->ioctl(vt_fd.fd(), VT_RELDISP, action);162 fops->ioctl(vt_fd.fd(), VT_RELDISP, action);
163163
=== modified file 'src/platform/graphics/null_display_report.cpp'
--- src/platform/graphics/null_display_report.cpp 2013-08-28 03:41:48 +0000
+++ src/platform/graphics/null_display_report.cpp 2013-12-19 09:18:52 +0000
@@ -20,14 +20,8 @@
2020
21namespace mg = mir::graphics;21namespace mg = mir::graphics;
2222
23void mg::NullDisplayReport::report_successful_setup_of_native_resources() {}23void mg::NullDisplayReport::report_success(bool, char const*) {}
24void mg::NullDisplayReport::report_successful_egl_make_current_on_construction() {}
25void mg::NullDisplayReport::report_successful_egl_buffer_swap_on_construction() {}
26void mg::NullDisplayReport::report_successful_drm_mode_set_crtc_on_construction() {}
27void mg::NullDisplayReport::report_successful_display_construction() {}
28void mg::NullDisplayReport::report_drm_master_failure(int) {}24void mg::NullDisplayReport::report_drm_master_failure(int) {}
29void mg::NullDisplayReport::report_vt_switch_away_failure() {}
30void mg::NullDisplayReport::report_vt_switch_back_failure() {}
31void mg::NullDisplayReport::report_hwc_composition_in_use(int, int) {}25void mg::NullDisplayReport::report_hwc_composition_in_use(int, int) {}
32void mg::NullDisplayReport::report_gpu_composition_in_use() {}26void mg::NullDisplayReport::report_gpu_composition_in_use() {}
33void mg::NullDisplayReport::report_egl_configuration(EGLDisplay, EGLConfig) {}27void mg::NullDisplayReport::report_egl_configuration(EGLDisplay, EGLConfig) {}
3428
=== modified file 'src/server/logging/display_report.cpp'
--- src/server/logging/display_report.cpp 2013-12-17 18:24:51 +0000
+++ src/server/logging/display_report.cpp 2013-12-19 09:18:52 +0000
@@ -24,6 +24,11 @@
2424
25namespace ml=mir::logging;25namespace ml=mir::logging;
2626
27namespace
28{
29 const char * const component = "graphics";
30}
31
27ml::DisplayReport::DisplayReport(const std::shared_ptr<Logger>& logger) : logger(logger)32ml::DisplayReport::DisplayReport(const std::shared_ptr<Logger>& logger) : logger(logger)
28{33{
29}34}
@@ -32,36 +37,13 @@
32{37{
33}38}
3439
35const char* ml::DisplayReport::component()40void ml::DisplayReport::report_success(bool success, char const* what)
36{41{
37 static const char* s = "graphics";42 std::string msg = success ? "Successful " : "Failed ";
38 return s;43 msg += what;
39}44 Logger::Severity sev = success ? Logger::informational :
4045 Logger::error;
4146 logger->log(sev, msg, component);
42void ml::DisplayReport::report_successful_setup_of_native_resources()
43{
44 logger->log(Logger::informational, "Successfully setup native resources.", component());
45}
46
47void ml::DisplayReport::report_successful_egl_make_current_on_construction()
48{
49 logger->log(Logger::informational, "Successfully made egl context current on construction.", component());
50}
51
52void ml::DisplayReport::report_successful_egl_buffer_swap_on_construction()
53{
54 logger->log(Logger::informational, "Successfully performed egl buffer swap on construction.", component());
55}
56
57void ml::DisplayReport::report_successful_drm_mode_set_crtc_on_construction()
58{
59 logger->log(Logger::informational, "Successfully performed drm mode setup on construction.", component());
60}
61
62void ml::DisplayReport::report_successful_display_construction()
63{
64 logger->log(Logger::informational, "Successfully finished construction.", component());
65}47}
6648
67void ml::DisplayReport::report_drm_master_failure(int error)49void ml::DisplayReport::report_drm_master_failure(int error)
@@ -71,29 +53,19 @@
71 if (error == EPERM || error == EACCES)53 if (error == EPERM || error == EACCES)
72 ss << " Try running Mir with root privileges.";54 ss << " Try running Mir with root privileges.";
7355
74 logger->log(Logger::warning, ss.str(), component());56 logger->log(Logger::warning, ss.str(), component);
75}
76
77void ml::DisplayReport::report_vt_switch_away_failure()
78{
79 logger->log(Logger::warning, "Failed to switch away from Mir VT.", component());
80}
81
82void ml::DisplayReport::report_vt_switch_back_failure()
83{
84 logger->log(Logger::warning, "Failed to switch back to Mir VT.", component());
85}57}
8658
87void ml::DisplayReport::report_hwc_composition_in_use(int major, int minor)59void ml::DisplayReport::report_hwc_composition_in_use(int major, int minor)
88{60{
89 std::stringstream ss;61 std::stringstream ss;
90 ss << "HWC version " << major << "." << minor << " in use for display.";62 ss << "HWC version " << major << "." << minor << " in use for display.";
91 logger->log(Logger::informational, ss.str(), component());63 logger->log(Logger::informational, ss.str(), component);
92}64}
9365
94void ml::DisplayReport::report_gpu_composition_in_use()66void ml::DisplayReport::report_gpu_composition_in_use()
95{67{
96 logger->log(Logger::informational, "GPU backup in use for display.", component());68 logger->log(Logger::informational, "GPU backup in use for display.", component);
97}69}
9870
99void ml::DisplayReport::report_egl_configuration(EGLDisplay disp, EGLConfig config)71void ml::DisplayReport::report_egl_configuration(EGLDisplay disp, EGLConfig config)
@@ -143,12 +115,12 @@
143 };115 };
144 #undef STRMACRO116 #undef STRMACRO
145117
146 logger->log(Logger::informational, "Display EGL Configuration:", component());118 logger->log(Logger::informational, "Display EGL Configuration:", component);
147 for( auto &i : egl_string_mapping)119 for( auto &i : egl_string_mapping)
148 {120 {
149 EGLint value;121 EGLint value;
150 eglGetConfigAttrib(disp, config, i.val, &value);122 eglGetConfigAttrib(disp, config, i.val, &value);
151 logger->log(Logger::informational, 123 logger->log(Logger::informational,
152 " [" + i.name + "] : " + std::to_string(value), component());124 " [" + i.name + "] : " + std::to_string(value), component);
153 }125 }
154}126}
155127
=== modified file 'src/server/logging/display_report.h'
--- src/server/logging/display_report.h 2013-12-17 18:24:51 +0000
+++ src/server/logging/display_report.h 2013-12-19 09:18:52 +0000
@@ -33,20 +33,11 @@
33class DisplayReport : public graphics::DisplayReport33class DisplayReport : public graphics::DisplayReport
34{34{
35 public:35 public:
36
37 static const char* component();
38
39 DisplayReport(const std::shared_ptr<Logger>& logger);36 DisplayReport(const std::shared_ptr<Logger>& logger);
40 virtual ~DisplayReport();37 virtual ~DisplayReport();
4138
42 virtual void report_successful_setup_of_native_resources();39 virtual void report_success(bool success, char const* what);
43 virtual void report_successful_egl_make_current_on_construction();
44 virtual void report_successful_egl_buffer_swap_on_construction();
45 virtual void report_successful_drm_mode_set_crtc_on_construction();
46 virtual void report_successful_display_construction();
47 virtual void report_drm_master_failure(int error);40 virtual void report_drm_master_failure(int error);
48 virtual void report_vt_switch_away_failure();
49 virtual void report_vt_switch_back_failure();
50 virtual void report_hwc_composition_in_use(int major, int minor);41 virtual void report_hwc_composition_in_use(int major, int minor);
51 virtual void report_gpu_composition_in_use();42 virtual void report_gpu_composition_in_use();
52 virtual void report_egl_configuration(EGLDisplay disp, EGLConfig cfg);43 virtual void report_egl_configuration(EGLDisplay disp, EGLConfig cfg);
5344
=== modified file 'tests/unit-tests/graphics/android/test_android_fb.cpp'
--- tests/unit-tests/graphics/android/test_android_fb.cpp 2013-12-17 18:24:51 +0000
+++ tests/unit-tests/graphics/android/test_android_fb.cpp 2013-12-19 09:18:52 +0000
@@ -154,15 +154,19 @@
154TEST_F(AndroidDisplayTest, display_logging)154TEST_F(AndroidDisplayTest, display_logging)
155{155{
156 using namespace testing;156 using namespace testing;
157 EXPECT_CALL(*mock_display_report, report_successful_setup_of_native_resources())157
158 EXPECT_CALL(*mock_display_report,
159 report_success(true, StrEq("setup of native resources")))
158 .Times(1);160 .Times(1);
159 EXPECT_CALL(*mock_display_report, report_egl_configuration(_,_))161 EXPECT_CALL(*mock_display_report, report_egl_configuration(_,_))
160 .Times(1);162 .Times(1);
161 EXPECT_CALL(*mock_display_report, report_successful_egl_make_current_on_construction())163 EXPECT_CALL(*mock_display_report,
162 .Times(1);164 report_success(true, StrEq("set context current on construction")))
163 EXPECT_CALL(*mock_display_report, report_successful_display_construction())165 .Times(1);
164 .Times(1);166 EXPECT_CALL(*mock_display_report,
165167 report_success(true, StrEq("construction")))
168 .Times(1);
169
166 mga::AndroidDisplay display(stub_db_factory, mock_display_report);170 mga::AndroidDisplay display(stub_db_factory, mock_display_report);
167}171}
168172
@@ -170,14 +174,17 @@
170{174{
171 using namespace testing;175 using namespace testing;
172176
173 EXPECT_CALL(*mock_display_report, report_successful_setup_of_native_resources())177 EXPECT_CALL(*mock_display_report,
178 report_success(true, StrEq("setup of native resources")))
174 .Times(1);179 .Times(1);
175 EXPECT_CALL(mock_egl, eglMakeCurrent(dummy_display, _, _, _))180 EXPECT_CALL(mock_egl, eglMakeCurrent(dummy_display, _, _, _))
176 .Times(1)181 .Times(1)
177 .WillOnce(Return(EGL_FALSE));182 .WillOnce(Return(EGL_FALSE));
178 EXPECT_CALL(*mock_display_report, report_successful_egl_make_current_on_construction())183 EXPECT_CALL(*mock_display_report,
184 report_success(_, StrEq("set context current on construction")))
179 .Times(0);185 .Times(0);
180 EXPECT_CALL(*mock_display_report, report_successful_display_construction())186 EXPECT_CALL(*mock_display_report,
187 report_success(_, StrEq("construction")))
181 .Times(0);188 .Times(0);
182189
183 EXPECT_THROW({190 EXPECT_THROW({
@@ -189,11 +196,7 @@
189{196{
190 using namespace testing;197 using namespace testing;
191198
192 EXPECT_CALL(*mock_display_report, report_successful_setup_of_native_resources())199 EXPECT_CALL(*mock_display_report, report_success(_,_))
193 .Times(0);
194 EXPECT_CALL(*mock_display_report, report_successful_egl_make_current_on_construction())
195 .Times(0);
196 EXPECT_CALL(*mock_display_report, report_successful_display_construction())
197 .Times(0);200 .Times(0);
198201
199 EXPECT_CALL(mock_egl, eglCreatePbufferSurface(_,_,_))202 EXPECT_CALL(mock_egl, eglCreatePbufferSurface(_,_,_))
200203
=== modified file 'tests/unit-tests/graphics/mesa/test_display.cpp'
--- tests/unit-tests/graphics/mesa/test_display.cpp 2013-12-17 18:24:51 +0000
+++ tests/unit-tests/graphics/mesa/test_display.cpp 2013-12-19 09:18:52 +0000
@@ -492,24 +492,27 @@
492{492{
493 using namespace ::testing;493 using namespace ::testing;
494494
495 EXPECT_CALL(495 // Is there really any value in these expectations?...
496 *mock_report,496
497 report_successful_setup_of_native_resources()).Times(Exactly(1));497 EXPECT_CALL(*mock_report,
498 EXPECT_CALL(498 report_success(true, StrEq("setup of native resources")))
499 *mock_report,499 .Times(Exactly(1));
500 report_successful_egl_make_current_on_construction()).Times(Exactly(1));500
501501 EXPECT_CALL(*mock_report,
502 EXPECT_CALL(502 report_success(true, StrEq("set context current on construction")))
503 *mock_report,503 .Times(Exactly(1));
504 report_successful_egl_buffer_swap_on_construction()).Times(Exactly(1));504
505505 EXPECT_CALL(*mock_report,
506 EXPECT_CALL(506 report_success(true, StrEq("egl buffer swap on construction")))
507 *mock_report,507 .Times(Exactly(1));
508 report_successful_drm_mode_set_crtc_on_construction()).Times(Exactly(1));508
509509 EXPECT_CALL(*mock_report,
510 EXPECT_CALL(510 report_success(true, StrEq("drm mode setup on construction")))
511 *mock_report,511 .Times(Exactly(1));
512 report_successful_display_construction()).Times(Exactly(1));512
513 EXPECT_CALL(*mock_report,
514 report_success(true, StrEq("construction")))
515 .Times(Exactly(1));
513516
514 EXPECT_CALL(517 EXPECT_CALL(
515 *mock_report,518 *mock_report,
@@ -521,68 +524,36 @@
521 mock_report);524 mock_report);
522}525}
523526
524TEST_F(MesaDisplayTest, outputs_correct_string_for_successful_setup_of_native_resources)527TEST_F(MesaDisplayTest, outputs_correct_success_string)
525{528{
526 using namespace ::testing;529 using namespace ::testing;
527530
528 auto logger = std::make_shared<MockLogger>();531 auto logger = std::make_shared<MockLogger>();
529 auto reporter = std::make_shared<ml::DisplayReport>(logger);532 auto reporter = std::make_shared<ml::DisplayReport>(logger);
530533
531 EXPECT_CALL(534 EXPECT_CALL(
532 *logger,535 *logger,
533 log(Eq(ml::Logger::informational),536 log(Eq(ml::Logger::informational),
534 StrEq("Successfully setup native resources."),537 StrEq("Successful something"),
535 StrEq("graphics"))).Times(Exactly(1));538 StrEq("graphics"))).Times(Exactly(1));
536539
537 reporter->report_successful_setup_of_native_resources();540 reporter->report_success(true, "something");
538}541}
539542
540TEST_F(MesaDisplayTest, outputs_correct_string_for_successful_egl_make_current_on_construction)543TEST_F(MesaDisplayTest, outputs_correct_failure_string)
541{544{
542 using namespace ::testing;545 using namespace ::testing;
543546
544 auto logger = std::make_shared<MockLogger>();547 auto logger = std::make_shared<MockLogger>();
545 auto reporter = std::make_shared<ml::DisplayReport>(logger);548 auto reporter = std::make_shared<ml::DisplayReport>(logger);
546549
547 EXPECT_CALL(550 EXPECT_CALL(
548 *logger,551 *logger,
549 log(Eq(ml::Logger::informational),552 log(Eq(ml::Logger::error),
550 StrEq("Successfully made egl context current on construction."),553 StrEq("Failed something"),
551 StrEq("graphics"))).Times(Exactly(1));554 StrEq("graphics"))).Times(Exactly(1));
552555
553 reporter->report_successful_egl_make_current_on_construction();556 reporter->report_success(false, "something");
554}
555
556TEST_F(MesaDisplayTest, outputs_correct_string_for_successful_egl_buffer_swap_on_construction)
557{
558 using namespace ::testing;
559
560 auto logger = std::make_shared<MockLogger>();
561 auto reporter = std::make_shared<ml::DisplayReport>(logger);
562
563 EXPECT_CALL(
564 *logger,
565 log(Eq(ml::Logger::informational),
566 StrEq("Successfully performed egl buffer swap on construction."),
567 StrEq("graphics"))).Times(Exactly(1));
568
569 reporter->report_successful_egl_buffer_swap_on_construction();
570}
571
572TEST_F(MesaDisplayTest, outputs_correct_string_for_successful_drm_mode_set_crtc_on_construction)
573{
574 using namespace ::testing;
575
576 auto logger = std::make_shared<MockLogger>();
577 auto reporter = std::make_shared<ml::DisplayReport>(logger);
578
579 EXPECT_CALL(
580 *logger,
581 log(Eq(ml::Logger::informational),
582 StrEq("Successfully performed drm mode setup on construction."),
583 StrEq("graphics"))).Times(Exactly(1));
584
585 reporter->report_successful_drm_mode_set_crtc_on_construction();
586}557}
587558
588TEST_F(MesaDisplayTest, constructor_throws_if_egl_mesa_drm_image_not_supported)559TEST_F(MesaDisplayTest, constructor_throws_if_egl_mesa_drm_image_not_supported)
589560
=== modified file 'tests/unit-tests/graphics/mesa/test_linux_virtual_terminal.cpp'
--- tests/unit-tests/graphics/mesa/test_linux_virtual_terminal.cpp 2013-12-17 18:24:51 +0000
+++ tests/unit-tests/graphics/mesa/test_linux_virtual_terminal.cpp 2013-12-19 09:18:52 +0000
@@ -430,12 +430,14 @@
430 set_up_expectations_for_switch_handler(SIGUSR1);430 set_up_expectations_for_switch_handler(SIGUSR1);
431431
432 /* First switch away attempt */432 /* First switch away attempt */
433 EXPECT_CALL(mock_report, report_vt_switch_away_failure());433 EXPECT_CALL(mock_report,
434 report_success(false, StrEq("switch away from Mir VT")));
434 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP,435 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP,
435 MatcherCast<int>(disallow_switch)));436 MatcherCast<int>(disallow_switch)));
436437
437 /* Second switch away attempt */438 /* Second switch away attempt */
438 EXPECT_CALL(mock_report, report_vt_switch_away_failure());439 EXPECT_CALL(mock_report,
440 report_success(false, StrEq("switch away from Mir VT")));
439 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP,441 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP,
440 MatcherCast<int>(disallow_switch)));442 MatcherCast<int>(disallow_switch)));
441443
@@ -472,7 +474,8 @@
472 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP, allow_switch));474 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP, allow_switch));
473475
474 /* Switch back */476 /* Switch back */
475 EXPECT_CALL(mock_report, report_vt_switch_back_failure());477 EXPECT_CALL(mock_report,
478 report_success(false, StrEq("switch back to Mir VT")));
476 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP, VT_ACKACQ));479 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP, VT_ACKACQ));
477480
478 set_up_expectations_for_vt_teardown();481 set_up_expectations_for_vt_teardown();

Subscribers

People subscribed via source and target branches