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
1=== modified file 'include/platform/mir/graphics/display_report.h'
2--- include/platform/mir/graphics/display_report.h 2013-08-28 03:41:48 +0000
3+++ include/platform/mir/graphics/display_report.h 2013-12-19 09:18:52 +0000
4@@ -29,17 +29,10 @@
5 class DisplayReport
6 {
7 public:
8-
9- virtual void report_successful_setup_of_native_resources() = 0;
10- virtual void report_successful_egl_make_current_on_construction() = 0;
11- virtual void report_successful_egl_buffer_swap_on_construction() = 0;
12- virtual void report_successful_display_construction() = 0;
13+ virtual void report_success(bool success, char const* what) = 0;
14 virtual void report_egl_configuration(EGLDisplay disp, EGLConfig cfg) = 0;
15 /* gbm specific */
16- virtual void report_successful_drm_mode_set_crtc_on_construction() = 0;
17 virtual void report_drm_master_failure(int error) = 0;
18- virtual void report_vt_switch_away_failure() = 0;
19- virtual void report_vt_switch_back_failure() = 0;
20 /* android specific */
21 virtual void report_hwc_composition_in_use(int major, int minor) = 0;
22 virtual void report_gpu_composition_in_use() = 0;
23
24=== modified file 'include/platform/mir/graphics/null_display_report.h'
25--- include/platform/mir/graphics/null_display_report.h 2013-08-28 03:41:48 +0000
26+++ include/platform/mir/graphics/null_display_report.h 2013-12-19 09:18:52 +0000
27@@ -31,15 +31,8 @@
28 class NullDisplayReport : public graphics::DisplayReport
29 {
30 public:
31-
32- virtual void report_successful_setup_of_native_resources();
33- virtual void report_successful_egl_make_current_on_construction();
34- virtual void report_successful_egl_buffer_swap_on_construction();
35- virtual void report_successful_drm_mode_set_crtc_on_construction();
36- virtual void report_successful_display_construction();
37+ virtual void report_success(bool success, char const* what);
38 virtual void report_drm_master_failure(int error);
39- virtual void report_vt_switch_away_failure();
40- virtual void report_vt_switch_back_failure();
41 virtual void report_hwc_composition_in_use(int major, int minor);
42 virtual void report_gpu_composition_in_use();
43 virtual void report_egl_configuration(EGLDisplay disp, EGLConfig cfg);
44
45=== modified file 'include/test/mir_test_doubles/mock_display_report.h'
46--- include/test/mir_test_doubles/mock_display_report.h 2013-05-10 18:16:51 +0000
47+++ include/test/mir_test_doubles/mock_display_report.h 2013-12-19 09:18:52 +0000
48@@ -33,14 +33,8 @@
49 class MockDisplayReport : public graphics::DisplayReport
50 {
51 public:
52- MOCK_METHOD0(report_successful_setup_of_native_resources, void());
53- MOCK_METHOD0(report_successful_egl_make_current_on_construction, void());
54- MOCK_METHOD0(report_successful_egl_buffer_swap_on_construction, void());
55- MOCK_METHOD0(report_successful_drm_mode_set_crtc_on_construction, void());
56- MOCK_METHOD0(report_successful_display_construction, void());
57+ MOCK_METHOD2(report_success, void(bool, char const*));
58 MOCK_METHOD1(report_drm_master_failure, void(int));
59- MOCK_METHOD0(report_vt_switch_away_failure, void());
60- MOCK_METHOD0(report_vt_switch_back_failure, void());
61 MOCK_METHOD2(report_hwc_composition_in_use, void(int,int));
62 MOCK_METHOD0(report_gpu_composition_in_use, void());
63 MOCK_METHOD2(report_egl_configuration, void(EGLDisplay,EGLConfig));
64
65=== modified file 'src/platform/graphics/android/android_display.cpp'
66--- src/platform/graphics/android/android_display.cpp 2013-12-17 18:24:51 +0000
67+++ src/platform/graphics/android/android_display.cpp 2013-12-19 09:18:52 +0000
68@@ -39,12 +39,12 @@
69 display_buffer{display_builder->create_display_buffer(display_device, gl_context)},
70 current_configuration{display_buffer->view_area().size}
71 {
72- display_report->report_successful_setup_of_native_resources();
73+ display_report->report_success(true, "setup of native resources");
74
75 gl_context.make_current();
76
77- display_report->report_successful_egl_make_current_on_construction();
78- display_report->report_successful_display_construction();
79+ display_report->report_success(true, "set context current on construction");
80+ display_report->report_success(true, "construction");
81 }
82
83 void mga::AndroidDisplay::for_each_display_buffer(std::function<void(mg::DisplayBuffer&)> const& f)
84
85=== modified file 'src/platform/graphics/mesa/display_buffer.cpp'
86--- src/platform/graphics/mesa/display_buffer.cpp 2013-12-17 18:24:51 +0000
87+++ src/platform/graphics/mesa/display_buffer.cpp 2013-12-19 09:18:52 +0000
88@@ -112,11 +112,11 @@
89 {
90 egl.setup(platform->gbm, surface_gbm.get(), shared_context);
91
92- listener->report_successful_setup_of_native_resources();
93+ listener->report_success(true, "setup of native resources");
94
95 make_current();
96
97- listener->report_successful_egl_make_current_on_construction();
98+ listener->report_success(true, "set context current on construction");
99
100 ensure_egl_image_extensions();
101
102@@ -125,7 +125,7 @@
103 if (!egl.swap_buffers())
104 BOOST_THROW_EXCEPTION(std::runtime_error("Failed to perform initial surface buffer swap"));
105
106- listener->report_successful_egl_buffer_swap_on_construction();
107+ listener->report_success(true, "egl buffer swap on construction");
108
109 last_flipped_bufobj = get_front_buffer_object();
110 if (!last_flipped_bufobj)
111@@ -139,8 +139,8 @@
112
113 egl.release_current();
114
115- listener->report_successful_drm_mode_set_crtc_on_construction();
116- listener->report_successful_display_construction();
117+ listener->report_success(true, "drm mode setup on construction");
118+ listener->report_success(true, "construction");
119 egl.report_egl_configuration(
120 [&listener] (EGLDisplay disp, EGLConfig cfg)
121 {
122
123=== modified file 'src/platform/graphics/mesa/linux_virtual_terminal.cpp'
124--- src/platform/graphics/mesa/linux_virtual_terminal.cpp 2013-12-17 18:24:51 +0000
125+++ src/platform/graphics/mesa/linux_virtual_terminal.cpp 2013-12-19 09:18:52 +0000
126@@ -138,7 +138,7 @@
127 if (!active)
128 {
129 if (!switch_back())
130- report->report_vt_switch_back_failure();
131+ report->report_success(false, "switch back to Mir VT");
132 fops->ioctl(vt_fd.fd(), VT_RELDISP, VT_ACKACQ);
133 active = true;
134 }
135@@ -156,7 +156,7 @@
136 else
137 {
138 action = disallow_switch;
139- report->report_vt_switch_away_failure();
140+ report->report_success(false, "switch away from Mir VT");
141 }
142
143 fops->ioctl(vt_fd.fd(), VT_RELDISP, action);
144
145=== modified file 'src/platform/graphics/null_display_report.cpp'
146--- src/platform/graphics/null_display_report.cpp 2013-08-28 03:41:48 +0000
147+++ src/platform/graphics/null_display_report.cpp 2013-12-19 09:18:52 +0000
148@@ -20,14 +20,8 @@
149
150 namespace mg = mir::graphics;
151
152-void mg::NullDisplayReport::report_successful_setup_of_native_resources() {}
153-void mg::NullDisplayReport::report_successful_egl_make_current_on_construction() {}
154-void mg::NullDisplayReport::report_successful_egl_buffer_swap_on_construction() {}
155-void mg::NullDisplayReport::report_successful_drm_mode_set_crtc_on_construction() {}
156-void mg::NullDisplayReport::report_successful_display_construction() {}
157+void mg::NullDisplayReport::report_success(bool, char const*) {}
158 void mg::NullDisplayReport::report_drm_master_failure(int) {}
159-void mg::NullDisplayReport::report_vt_switch_away_failure() {}
160-void mg::NullDisplayReport::report_vt_switch_back_failure() {}
161 void mg::NullDisplayReport::report_hwc_composition_in_use(int, int) {}
162 void mg::NullDisplayReport::report_gpu_composition_in_use() {}
163 void mg::NullDisplayReport::report_egl_configuration(EGLDisplay, EGLConfig) {}
164
165=== modified file 'src/server/logging/display_report.cpp'
166--- src/server/logging/display_report.cpp 2013-12-17 18:24:51 +0000
167+++ src/server/logging/display_report.cpp 2013-12-19 09:18:52 +0000
168@@ -24,6 +24,11 @@
169
170 namespace ml=mir::logging;
171
172+namespace
173+{
174+ const char * const component = "graphics";
175+}
176+
177 ml::DisplayReport::DisplayReport(const std::shared_ptr<Logger>& logger) : logger(logger)
178 {
179 }
180@@ -32,36 +37,13 @@
181 {
182 }
183
184-const char* ml::DisplayReport::component()
185-{
186- static const char* s = "graphics";
187- return s;
188-}
189-
190-
191-void ml::DisplayReport::report_successful_setup_of_native_resources()
192-{
193- logger->log(Logger::informational, "Successfully setup native resources.", component());
194-}
195-
196-void ml::DisplayReport::report_successful_egl_make_current_on_construction()
197-{
198- logger->log(Logger::informational, "Successfully made egl context current on construction.", component());
199-}
200-
201-void ml::DisplayReport::report_successful_egl_buffer_swap_on_construction()
202-{
203- logger->log(Logger::informational, "Successfully performed egl buffer swap on construction.", component());
204-}
205-
206-void ml::DisplayReport::report_successful_drm_mode_set_crtc_on_construction()
207-{
208- logger->log(Logger::informational, "Successfully performed drm mode setup on construction.", component());
209-}
210-
211-void ml::DisplayReport::report_successful_display_construction()
212-{
213- logger->log(Logger::informational, "Successfully finished construction.", component());
214+void ml::DisplayReport::report_success(bool success, char const* what)
215+{
216+ std::string msg = success ? "Successful " : "Failed ";
217+ msg += what;
218+ Logger::Severity sev = success ? Logger::informational :
219+ Logger::error;
220+ logger->log(sev, msg, component);
221 }
222
223 void ml::DisplayReport::report_drm_master_failure(int error)
224@@ -71,29 +53,19 @@
225 if (error == EPERM || error == EACCES)
226 ss << " Try running Mir with root privileges.";
227
228- logger->log(Logger::warning, ss.str(), component());
229-}
230-
231-void ml::DisplayReport::report_vt_switch_away_failure()
232-{
233- logger->log(Logger::warning, "Failed to switch away from Mir VT.", component());
234-}
235-
236-void ml::DisplayReport::report_vt_switch_back_failure()
237-{
238- logger->log(Logger::warning, "Failed to switch back to Mir VT.", component());
239+ logger->log(Logger::warning, ss.str(), component);
240 }
241
242 void ml::DisplayReport::report_hwc_composition_in_use(int major, int minor)
243 {
244 std::stringstream ss;
245 ss << "HWC version " << major << "." << minor << " in use for display.";
246- logger->log(Logger::informational, ss.str(), component());
247+ logger->log(Logger::informational, ss.str(), component);
248 }
249
250 void ml::DisplayReport::report_gpu_composition_in_use()
251 {
252- logger->log(Logger::informational, "GPU backup in use for display.", component());
253+ logger->log(Logger::informational, "GPU backup in use for display.", component);
254 }
255
256 void ml::DisplayReport::report_egl_configuration(EGLDisplay disp, EGLConfig config)
257@@ -143,12 +115,12 @@
258 };
259 #undef STRMACRO
260
261- logger->log(Logger::informational, "Display EGL Configuration:", component());
262+ logger->log(Logger::informational, "Display EGL Configuration:", component);
263 for( auto &i : egl_string_mapping)
264 {
265 EGLint value;
266 eglGetConfigAttrib(disp, config, i.val, &value);
267 logger->log(Logger::informational,
268- " [" + i.name + "] : " + std::to_string(value), component());
269+ " [" + i.name + "] : " + std::to_string(value), component);
270 }
271 }
272
273=== modified file 'src/server/logging/display_report.h'
274--- src/server/logging/display_report.h 2013-12-17 18:24:51 +0000
275+++ src/server/logging/display_report.h 2013-12-19 09:18:52 +0000
276@@ -33,20 +33,11 @@
277 class DisplayReport : public graphics::DisplayReport
278 {
279 public:
280-
281- static const char* component();
282-
283 DisplayReport(const std::shared_ptr<Logger>& logger);
284 virtual ~DisplayReport();
285
286- virtual void report_successful_setup_of_native_resources();
287- virtual void report_successful_egl_make_current_on_construction();
288- virtual void report_successful_egl_buffer_swap_on_construction();
289- virtual void report_successful_drm_mode_set_crtc_on_construction();
290- virtual void report_successful_display_construction();
291+ virtual void report_success(bool success, char const* what);
292 virtual void report_drm_master_failure(int error);
293- virtual void report_vt_switch_away_failure();
294- virtual void report_vt_switch_back_failure();
295 virtual void report_hwc_composition_in_use(int major, int minor);
296 virtual void report_gpu_composition_in_use();
297 virtual void report_egl_configuration(EGLDisplay disp, EGLConfig cfg);
298
299=== modified file 'tests/unit-tests/graphics/android/test_android_fb.cpp'
300--- tests/unit-tests/graphics/android/test_android_fb.cpp 2013-12-17 18:24:51 +0000
301+++ tests/unit-tests/graphics/android/test_android_fb.cpp 2013-12-19 09:18:52 +0000
302@@ -154,15 +154,19 @@
303 TEST_F(AndroidDisplayTest, display_logging)
304 {
305 using namespace testing;
306- EXPECT_CALL(*mock_display_report, report_successful_setup_of_native_resources())
307+
308+ EXPECT_CALL(*mock_display_report,
309+ report_success(true, StrEq("setup of native resources")))
310 .Times(1);
311 EXPECT_CALL(*mock_display_report, report_egl_configuration(_,_))
312 .Times(1);
313- EXPECT_CALL(*mock_display_report, report_successful_egl_make_current_on_construction())
314- .Times(1);
315- EXPECT_CALL(*mock_display_report, report_successful_display_construction())
316- .Times(1);
317-
318+ EXPECT_CALL(*mock_display_report,
319+ report_success(true, StrEq("set context current on construction")))
320+ .Times(1);
321+ EXPECT_CALL(*mock_display_report,
322+ report_success(true, StrEq("construction")))
323+ .Times(1);
324+
325 mga::AndroidDisplay display(stub_db_factory, mock_display_report);
326 }
327
328@@ -170,14 +174,17 @@
329 {
330 using namespace testing;
331
332- EXPECT_CALL(*mock_display_report, report_successful_setup_of_native_resources())
333+ EXPECT_CALL(*mock_display_report,
334+ report_success(true, StrEq("setup of native resources")))
335 .Times(1);
336 EXPECT_CALL(mock_egl, eglMakeCurrent(dummy_display, _, _, _))
337 .Times(1)
338 .WillOnce(Return(EGL_FALSE));
339- EXPECT_CALL(*mock_display_report, report_successful_egl_make_current_on_construction())
340+ EXPECT_CALL(*mock_display_report,
341+ report_success(_, StrEq("set context current on construction")))
342 .Times(0);
343- EXPECT_CALL(*mock_display_report, report_successful_display_construction())
344+ EXPECT_CALL(*mock_display_report,
345+ report_success(_, StrEq("construction")))
346 .Times(0);
347
348 EXPECT_THROW({
349@@ -189,11 +196,7 @@
350 {
351 using namespace testing;
352
353- EXPECT_CALL(*mock_display_report, report_successful_setup_of_native_resources())
354- .Times(0);
355- EXPECT_CALL(*mock_display_report, report_successful_egl_make_current_on_construction())
356- .Times(0);
357- EXPECT_CALL(*mock_display_report, report_successful_display_construction())
358+ EXPECT_CALL(*mock_display_report, report_success(_,_))
359 .Times(0);
360
361 EXPECT_CALL(mock_egl, eglCreatePbufferSurface(_,_,_))
362
363=== modified file 'tests/unit-tests/graphics/mesa/test_display.cpp'
364--- tests/unit-tests/graphics/mesa/test_display.cpp 2013-12-17 18:24:51 +0000
365+++ tests/unit-tests/graphics/mesa/test_display.cpp 2013-12-19 09:18:52 +0000
366@@ -492,24 +492,27 @@
367 {
368 using namespace ::testing;
369
370- EXPECT_CALL(
371- *mock_report,
372- report_successful_setup_of_native_resources()).Times(Exactly(1));
373- EXPECT_CALL(
374- *mock_report,
375- report_successful_egl_make_current_on_construction()).Times(Exactly(1));
376-
377- EXPECT_CALL(
378- *mock_report,
379- report_successful_egl_buffer_swap_on_construction()).Times(Exactly(1));
380-
381- EXPECT_CALL(
382- *mock_report,
383- report_successful_drm_mode_set_crtc_on_construction()).Times(Exactly(1));
384-
385- EXPECT_CALL(
386- *mock_report,
387- report_successful_display_construction()).Times(Exactly(1));
388+ // Is there really any value in these expectations?...
389+
390+ EXPECT_CALL(*mock_report,
391+ report_success(true, StrEq("setup of native resources")))
392+ .Times(Exactly(1));
393+
394+ EXPECT_CALL(*mock_report,
395+ report_success(true, StrEq("set context current on construction")))
396+ .Times(Exactly(1));
397+
398+ EXPECT_CALL(*mock_report,
399+ report_success(true, StrEq("egl buffer swap on construction")))
400+ .Times(Exactly(1));
401+
402+ EXPECT_CALL(*mock_report,
403+ report_success(true, StrEq("drm mode setup on construction")))
404+ .Times(Exactly(1));
405+
406+ EXPECT_CALL(*mock_report,
407+ report_success(true, StrEq("construction")))
408+ .Times(Exactly(1));
409
410 EXPECT_CALL(
411 *mock_report,
412@@ -521,68 +524,36 @@
413 mock_report);
414 }
415
416-TEST_F(MesaDisplayTest, outputs_correct_string_for_successful_setup_of_native_resources)
417-{
418- using namespace ::testing;
419-
420- auto logger = std::make_shared<MockLogger>();
421- auto reporter = std::make_shared<ml::DisplayReport>(logger);
422-
423- EXPECT_CALL(
424- *logger,
425- log(Eq(ml::Logger::informational),
426- StrEq("Successfully setup native resources."),
427- StrEq("graphics"))).Times(Exactly(1));
428-
429- reporter->report_successful_setup_of_native_resources();
430-}
431-
432-TEST_F(MesaDisplayTest, outputs_correct_string_for_successful_egl_make_current_on_construction)
433-{
434- using namespace ::testing;
435-
436- auto logger = std::make_shared<MockLogger>();
437- auto reporter = std::make_shared<ml::DisplayReport>(logger);
438-
439- EXPECT_CALL(
440- *logger,
441- log(Eq(ml::Logger::informational),
442- StrEq("Successfully made egl context current on construction."),
443- StrEq("graphics"))).Times(Exactly(1));
444-
445- reporter->report_successful_egl_make_current_on_construction();
446-}
447-
448-TEST_F(MesaDisplayTest, outputs_correct_string_for_successful_egl_buffer_swap_on_construction)
449-{
450- using namespace ::testing;
451-
452- auto logger = std::make_shared<MockLogger>();
453- auto reporter = std::make_shared<ml::DisplayReport>(logger);
454-
455- EXPECT_CALL(
456- *logger,
457- log(Eq(ml::Logger::informational),
458- StrEq("Successfully performed egl buffer swap on construction."),
459- StrEq("graphics"))).Times(Exactly(1));
460-
461- reporter->report_successful_egl_buffer_swap_on_construction();
462-}
463-
464-TEST_F(MesaDisplayTest, outputs_correct_string_for_successful_drm_mode_set_crtc_on_construction)
465-{
466- using namespace ::testing;
467-
468- auto logger = std::make_shared<MockLogger>();
469- auto reporter = std::make_shared<ml::DisplayReport>(logger);
470-
471- EXPECT_CALL(
472- *logger,
473- log(Eq(ml::Logger::informational),
474- StrEq("Successfully performed drm mode setup on construction."),
475- StrEq("graphics"))).Times(Exactly(1));
476-
477- reporter->report_successful_drm_mode_set_crtc_on_construction();
478+TEST_F(MesaDisplayTest, outputs_correct_success_string)
479+{
480+ using namespace ::testing;
481+
482+ auto logger = std::make_shared<MockLogger>();
483+ auto reporter = std::make_shared<ml::DisplayReport>(logger);
484+
485+ EXPECT_CALL(
486+ *logger,
487+ log(Eq(ml::Logger::informational),
488+ StrEq("Successful something"),
489+ StrEq("graphics"))).Times(Exactly(1));
490+
491+ reporter->report_success(true, "something");
492+}
493+
494+TEST_F(MesaDisplayTest, outputs_correct_failure_string)
495+{
496+ using namespace ::testing;
497+
498+ auto logger = std::make_shared<MockLogger>();
499+ auto reporter = std::make_shared<ml::DisplayReport>(logger);
500+
501+ EXPECT_CALL(
502+ *logger,
503+ log(Eq(ml::Logger::error),
504+ StrEq("Failed something"),
505+ StrEq("graphics"))).Times(Exactly(1));
506+
507+ reporter->report_success(false, "something");
508 }
509
510 TEST_F(MesaDisplayTest, constructor_throws_if_egl_mesa_drm_image_not_supported)
511
512=== modified file 'tests/unit-tests/graphics/mesa/test_linux_virtual_terminal.cpp'
513--- tests/unit-tests/graphics/mesa/test_linux_virtual_terminal.cpp 2013-12-17 18:24:51 +0000
514+++ tests/unit-tests/graphics/mesa/test_linux_virtual_terminal.cpp 2013-12-19 09:18:52 +0000
515@@ -430,12 +430,14 @@
516 set_up_expectations_for_switch_handler(SIGUSR1);
517
518 /* First switch away attempt */
519- EXPECT_CALL(mock_report, report_vt_switch_away_failure());
520+ EXPECT_CALL(mock_report,
521+ report_success(false, StrEq("switch away from Mir VT")));
522 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP,
523 MatcherCast<int>(disallow_switch)));
524
525 /* Second switch away attempt */
526- EXPECT_CALL(mock_report, report_vt_switch_away_failure());
527+ EXPECT_CALL(mock_report,
528+ report_success(false, StrEq("switch away from Mir VT")));
529 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP,
530 MatcherCast<int>(disallow_switch)));
531
532@@ -472,7 +474,8 @@
533 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP, allow_switch));
534
535 /* Switch back */
536- EXPECT_CALL(mock_report, report_vt_switch_back_failure());
537+ EXPECT_CALL(mock_report,
538+ report_success(false, StrEq("switch back to Mir VT")));
539 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_RELDISP, VT_ACKACQ));
540
541 set_up_expectations_for_vt_teardown();

Subscribers

People subscribed via source and target branches