Merge lp:~afrantzis/mir/report-egl-errors-in-exceptions into lp:mir
- report-egl-errors-in-exceptions
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Alan Griffiths |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2497 |
Proposed branch: | lp:~afrantzis/mir/report-egl-errors-in-exceptions |
Merge into: | lp:mir |
Diff against target: |
625 lines (+267/-32) 15 files modified
src/include/platform/mir/graphics/egl_error.h (+40/-0) src/platform/graphics/CMakeLists.txt (+1/-0) src/platform/graphics/egl_error.cpp (+72/-0) src/platform/graphics/egl_resources.cpp (+3/-2) src/platform/symbols.map (+1/-0) src/platforms/android/server/buffer.cpp (+3/-2) src/platforms/android/server/gl_context.cpp (+6/-10) src/platforms/mesa/server/buffer_allocator.cpp (+2/-1) src/platforms/mesa/server/display_helpers.cpp (+9/-7) src/server/graphics/nested/display.cpp (+6/-5) src/server/graphics/nested/display_buffer.cpp (+2/-1) src/server/graphics/offscreen/display.cpp (+3/-2) src/server/graphics/surfaceless_egl_context.cpp (+3/-2) tests/unit-tests/graphics/CMakeLists.txt (+1/-0) tests/unit-tests/graphics/test_egl_error.cpp (+115/-0) |
To merge this branch: | bzr merge lp:~afrantzis/mir/report-egl-errors-in-exceptions |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Kevin DuBois (community) | Approve | ||
Alan Griffiths | Approve | ||
Robert Carr (community) | Approve | ||
Review via email:
|
Commit message
server,platform: Report the EGL error code when throwing exceptions for EGL errors
Description of the change
server,platform: Report the EGL error code when throwing exceptions for EGL errors
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Carr (robertcarr) wrote : | # |
LGTM! A few preexisting \n in exception strings that I guess shouldn't be there?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Carr (robertcarr) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexandros Frantzis (afrantzis) wrote : | # |
> A few preexisting \n in exception strings that I guess shouldn't be there?
Fixed!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2494
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
38+ egl_error(
39+ : std::system_
40+ {
41+ }
I'm not sure why this code is inline (which requires egl_category() to be published)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kevin DuBois (kdub) wrote : | # |
could the code in src/platforms/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andreas Pokorny (andreas-pokorny) wrote : | # |
I think it would be better to expose egl_error and its typeinfo since it gets thrown around? But I might be wrong, and boost::exception already deals with that.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andreas Pokorny (andreas-pokorny) wrote : | # |
I was thinking about cases in which somebody wants to catch egl_error outside of libmirserver.so
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexandros Frantzis (afrantzis) wrote : | # |
@Kevin
> could the code in src/platforms/
12 +++ src/platforms/
:)
@Andreas
> I think it would be better to expose egl_error and its typeinfo since it gets thrown around?
mg::egl_error is a convenience class. For all intents the purpose, the exception we are throwing is a std::system_error with an egl_category.
@Alan
> I'm not sure why this code is inline (which requires egl_category() to be published)
See above, and also, in some cases this convenience class may not be usable, since it calls eglGetError() itself.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
> mg::egl_error is a convenience class. For all intents the purpose, the
> exception we are throwing is a std::system_error with an egl_category.
a convenience class that could be replaced by a convenience function?
inline auto egl_error(
{
return std::system_
}
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexandros Frantzis (afrantzis) wrote : | # |
> a convenience class that could be replaced by a convenience function?
Better, thanks.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2495
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === added file 'src/include/platform/mir/graphics/egl_error.h' | |||
2 | --- src/include/platform/mir/graphics/egl_error.h 1970-01-01 00:00:00 +0000 | |||
3 | +++ src/include/platform/mir/graphics/egl_error.h 2015-04-17 15:49:38 +0000 | |||
4 | @@ -0,0 +1,40 @@ | |||
5 | 1 | /* | ||
6 | 2 | * Copyright © 2015 Canonical Ltd. | ||
7 | 3 | * | ||
8 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
9 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
10 | 6 | * as published by the Free Software Foundation. | ||
11 | 7 | * | ||
12 | 8 | * This program is distributed in the hope that it will be useful, | ||
13 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | 11 | * GNU Lesser General Public License for more details. | ||
16 | 12 | * | ||
17 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
18 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | 15 | * | ||
20 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
21 | 17 | */ | ||
22 | 18 | |||
23 | 19 | #ifndef MIR_GRAPHICS_EGL_ERROR_H_ | ||
24 | 20 | #define MIR_GRAPHICS_EGL_ERROR_H_ | ||
25 | 21 | |||
26 | 22 | #include <system_error> | ||
27 | 23 | #include <EGL/egl.h> | ||
28 | 24 | |||
29 | 25 | namespace mir | ||
30 | 26 | { | ||
31 | 27 | namespace graphics | ||
32 | 28 | { | ||
33 | 29 | |||
34 | 30 | std::error_category const& egl_category(); | ||
35 | 31 | |||
36 | 32 | inline auto egl_error(std::string const& msg) -> std::system_error | ||
37 | 33 | { | ||
38 | 34 | return std::system_error{eglGetError(), egl_category(), msg}; | ||
39 | 35 | } | ||
40 | 36 | |||
41 | 37 | } | ||
42 | 38 | } | ||
43 | 39 | |||
44 | 40 | #endif | ||
45 | 0 | 41 | ||
46 | === modified file 'src/platform/graphics/CMakeLists.txt' | |||
47 | --- src/platform/graphics/CMakeLists.txt 2015-03-31 02:35:42 +0000 | |||
48 | +++ src/platform/graphics/CMakeLists.txt 2015-04-17 15:49:38 +0000 | |||
49 | @@ -5,6 +5,7 @@ | |||
50 | 5 | 5 | ||
51 | 6 | egl_extensions.cpp | 6 | egl_extensions.cpp |
52 | 7 | egl_resources.cpp | 7 | egl_resources.cpp |
53 | 8 | egl_error.cpp | ||
54 | 8 | display_configuration.cpp | 9 | display_configuration.cpp |
55 | 9 | buffer_basic.cpp | 10 | buffer_basic.cpp |
56 | 10 | pixel_format_utils.cpp | 11 | pixel_format_utils.cpp |
57 | 11 | 12 | ||
58 | === added file 'src/platform/graphics/egl_error.cpp' | |||
59 | --- src/platform/graphics/egl_error.cpp 1970-01-01 00:00:00 +0000 | |||
60 | +++ src/platform/graphics/egl_error.cpp 2015-04-17 15:49:38 +0000 | |||
61 | @@ -0,0 +1,72 @@ | |||
62 | 1 | /* | ||
63 | 2 | * Copyright © 2015 Canonical Ltd. | ||
64 | 3 | * | ||
65 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
66 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
67 | 6 | * as published by the Free Software Foundation. | ||
68 | 7 | * | ||
69 | 8 | * This program is distributed in the hope that it will be useful, | ||
70 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
71 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
72 | 11 | * GNU Lesser General Public License for more details. | ||
73 | 12 | * | ||
74 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
75 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
76 | 15 | * | ||
77 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
78 | 17 | */ | ||
79 | 18 | |||
80 | 19 | #include "mir/graphics/egl_error.h" | ||
81 | 20 | #include <sstream> | ||
82 | 21 | |||
83 | 22 | namespace | ||
84 | 23 | { | ||
85 | 24 | |||
86 | 25 | std::string to_hex_string(int n) | ||
87 | 26 | { | ||
88 | 27 | std::stringstream ss; | ||
89 | 28 | ss << std::showbase << std::hex << n; | ||
90 | 29 | return ss.str(); | ||
91 | 30 | } | ||
92 | 31 | |||
93 | 32 | struct egl_category : std::error_category | ||
94 | 33 | { | ||
95 | 34 | const char* name() const noexcept override { return "egl"; } | ||
96 | 35 | |||
97 | 36 | std::string message(int ev) const override | ||
98 | 37 | { | ||
99 | 38 | #define CASE_FOR_ERROR(error) \ | ||
100 | 39 | case error: return #error " (" + to_hex_string(error) + ")"; | ||
101 | 40 | switch (ev) | ||
102 | 41 | { | ||
103 | 42 | CASE_FOR_ERROR(EGL_SUCCESS) | ||
104 | 43 | CASE_FOR_ERROR(EGL_NOT_INITIALIZED) | ||
105 | 44 | CASE_FOR_ERROR(EGL_BAD_ACCESS) | ||
106 | 45 | CASE_FOR_ERROR(EGL_BAD_ALLOC) | ||
107 | 46 | CASE_FOR_ERROR(EGL_BAD_ATTRIBUTE) | ||
108 | 47 | CASE_FOR_ERROR(EGL_BAD_CONFIG) | ||
109 | 48 | CASE_FOR_ERROR(EGL_BAD_CONTEXT) | ||
110 | 49 | CASE_FOR_ERROR(EGL_BAD_CURRENT_SURFACE) | ||
111 | 50 | CASE_FOR_ERROR(EGL_BAD_DISPLAY) | ||
112 | 51 | CASE_FOR_ERROR(EGL_BAD_MATCH) | ||
113 | 52 | CASE_FOR_ERROR(EGL_BAD_NATIVE_PIXMAP) | ||
114 | 53 | CASE_FOR_ERROR(EGL_BAD_NATIVE_WINDOW) | ||
115 | 54 | CASE_FOR_ERROR(EGL_BAD_PARAMETER) | ||
116 | 55 | CASE_FOR_ERROR(EGL_BAD_SURFACE) | ||
117 | 56 | CASE_FOR_ERROR(EGL_CONTEXT_LOST) | ||
118 | 57 | |||
119 | 58 | default: | ||
120 | 59 | return "Unknown error (" + to_hex_string(ev) + ")"; | ||
121 | 60 | } | ||
122 | 61 | #undef CASE_ERROR | ||
123 | 62 | } | ||
124 | 63 | }; | ||
125 | 64 | |||
126 | 65 | } | ||
127 | 66 | |||
128 | 67 | std::error_category const& mir::graphics::egl_category() | ||
129 | 68 | { | ||
130 | 69 | static class egl_category const egl_category_instance{}; | ||
131 | 70 | |||
132 | 71 | return egl_category_instance; | ||
133 | 72 | } | ||
134 | 0 | 73 | ||
135 | === modified file 'src/platform/graphics/egl_resources.cpp' | |||
136 | --- src/platform/graphics/egl_resources.cpp 2014-03-12 02:46:58 +0000 | |||
137 | +++ src/platform/graphics/egl_resources.cpp 2015-04-17 15:49:38 +0000 | |||
138 | @@ -17,6 +17,7 @@ | |||
139 | 17 | */ | 17 | */ |
140 | 18 | 18 | ||
141 | 19 | #include "mir/graphics/egl_resources.h" | 19 | #include "mir/graphics/egl_resources.h" |
142 | 20 | #include "mir/graphics/egl_error.h" | ||
143 | 20 | 21 | ||
144 | 21 | #include <boost/throw_exception.hpp> | 22 | #include <boost/throw_exception.hpp> |
145 | 22 | #include <stdexcept> | 23 | #include <stdexcept> |
146 | @@ -31,7 +32,7 @@ | |||
147 | 31 | : egl_display_{egl_display}, egl_context_{egl_context} | 32 | : egl_display_{egl_display}, egl_context_{egl_context} |
148 | 32 | { | 33 | { |
149 | 33 | if (egl_context_ == EGL_NO_CONTEXT) | 34 | if (egl_context_ == EGL_NO_CONTEXT) |
151 | 34 | BOOST_THROW_EXCEPTION(std::runtime_error("Could not create egl context\n")); | 35 | BOOST_THROW_EXCEPTION(mg::egl_error("Could not create egl context")); |
152 | 35 | } | 36 | } |
153 | 36 | 37 | ||
154 | 37 | mg::EGLContextStore::~EGLContextStore() noexcept | 38 | mg::EGLContextStore::~EGLContextStore() noexcept |
155 | @@ -62,7 +63,7 @@ | |||
156 | 62 | : egl_display_{egl_display}, egl_surface_{egl_surface} | 63 | : egl_display_{egl_display}, egl_surface_{egl_surface} |
157 | 63 | { | 64 | { |
158 | 64 | if (egl_surface_ == EGL_NO_SURFACE && !allow_no_surface) | 65 | if (egl_surface_ == EGL_NO_SURFACE && !allow_no_surface) |
160 | 65 | BOOST_THROW_EXCEPTION(std::runtime_error("Could not create egl surface\n")); | 66 | BOOST_THROW_EXCEPTION(mg::egl_error("Could not create egl surface")); |
161 | 66 | } | 67 | } |
162 | 67 | 68 | ||
163 | 68 | mg::EGLSurfaceStore::EGLSurfaceStore(EGLDisplay egl_display, EGLSurface egl_surface) | 69 | mg::EGLSurfaceStore::EGLSurfaceStore(EGLDisplay egl_display, EGLSurface egl_surface) |
164 | 69 | 70 | ||
165 | === modified file 'src/platform/symbols.map' | |||
166 | --- src/platform/symbols.map 2015-04-09 06:20:31 +0000 | |||
167 | +++ src/platform/symbols.map 2015-04-17 15:49:38 +0000 | |||
168 | @@ -246,6 +246,7 @@ | |||
169 | 246 | mir::graphics::EGLSurfaceStore::EGLSurfaceStore*; | 246 | mir::graphics::EGLSurfaceStore::EGLSurfaceStore*; |
170 | 247 | mir::graphics::EGLSurfaceStore::EGLSurfaceStore*; | 247 | mir::graphics::EGLSurfaceStore::EGLSurfaceStore*; |
171 | 248 | mir::graphics::EGLSurfaceStore::operator*; | 248 | mir::graphics::EGLSurfaceStore::operator*; |
172 | 249 | mir::graphics::egl_category*; | ||
173 | 249 | mir::graphics::GLTexture::bind*; | 250 | mir::graphics::GLTexture::bind*; |
174 | 250 | mir::graphics::GLTexture::?GLTexture*; | 251 | mir::graphics::GLTexture::?GLTexture*; |
175 | 251 | mir::graphics::GLTexture::GLTexture*; | 252 | mir::graphics::GLTexture::GLTexture*; |
176 | 252 | 253 | ||
177 | === modified file 'src/platforms/android/server/buffer.cpp' | |||
178 | --- src/platforms/android/server/buffer.cpp 2015-04-09 17:37:55 +0000 | |||
179 | +++ src/platforms/android/server/buffer.cpp 2015-04-17 15:49:38 +0000 | |||
180 | @@ -18,6 +18,7 @@ | |||
181 | 18 | */ | 18 | */ |
182 | 19 | 19 | ||
183 | 20 | #include "mir/graphics/egl_extensions.h" | 20 | #include "mir/graphics/egl_extensions.h" |
184 | 21 | #include "mir/graphics/egl_error.h" | ||
185 | 21 | #include "mir/graphics/android/native_buffer.h" | 22 | #include "mir/graphics/android/native_buffer.h" |
186 | 22 | #include "mir/graphics/android/sync_fence.h" | 23 | #include "mir/graphics/android/sync_fence.h" |
187 | 23 | #include "android_format_conversion-inl.h" | 24 | #include "android_format_conversion-inl.h" |
188 | @@ -83,7 +84,7 @@ | |||
189 | 83 | 84 | ||
190 | 84 | if (current.first == EGL_NO_DISPLAY) | 85 | if (current.first == EGL_NO_DISPLAY) |
191 | 85 | { | 86 | { |
193 | 86 | BOOST_THROW_EXCEPTION(std::runtime_error("cannot bind buffer to texture without EGL context\n")); | 87 | BOOST_THROW_EXCEPTION(std::runtime_error("cannot bind buffer to texture without EGL context")); |
194 | 87 | } | 88 | } |
195 | 88 | 89 | ||
196 | 89 | static const EGLint image_attrs[] = | 90 | static const EGLint image_attrs[] = |
197 | @@ -102,7 +103,7 @@ | |||
198 | 102 | 103 | ||
199 | 103 | if (image == EGL_NO_IMAGE_KHR) | 104 | if (image == EGL_NO_IMAGE_KHR) |
200 | 104 | { | 105 | { |
202 | 105 | BOOST_THROW_EXCEPTION(std::runtime_error("error binding buffer to texture\n")); | 106 | BOOST_THROW_EXCEPTION(mg::egl_error("error binding buffer to texture")); |
203 | 106 | } | 107 | } |
204 | 107 | egl_image_map[current] = image; | 108 | egl_image_map[current] = image; |
205 | 108 | } | 109 | } |
206 | 109 | 110 | ||
207 | === modified file 'src/platforms/android/server/gl_context.cpp' | |||
208 | --- src/platforms/android/server/gl_context.cpp 2015-01-22 09:00:14 +0000 | |||
209 | +++ src/platforms/android/server/gl_context.cpp 2015-04-17 15:49:38 +0000 | |||
210 | @@ -21,6 +21,7 @@ | |||
211 | 21 | #include "android_format_conversion-inl.h" | 21 | #include "android_format_conversion-inl.h" |
212 | 22 | #include "mir/graphics/display_report.h" | 22 | #include "mir/graphics/display_report.h" |
213 | 23 | #include "mir/graphics/gl_config.h" | 23 | #include "mir/graphics/gl_config.h" |
214 | 24 | #include "mir/graphics/egl_error.h" | ||
215 | 24 | 25 | ||
216 | 25 | #include <algorithm> | 26 | #include <algorithm> |
217 | 26 | #include <boost/throw_exception.hpp> | 27 | #include <boost/throw_exception.hpp> |
218 | @@ -52,13 +53,13 @@ | |||
219 | 52 | 53 | ||
220 | 53 | auto egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); | 54 | auto egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
221 | 54 | if (egl_display == EGL_NO_DISPLAY) | 55 | if (egl_display == EGL_NO_DISPLAY) |
223 | 55 | BOOST_THROW_EXCEPTION(std::runtime_error("eglGetDisplay failed\n")); | 56 | BOOST_THROW_EXCEPTION(mg::egl_error("eglGetDisplay failed")); |
224 | 56 | 57 | ||
225 | 57 | if (eglInitialize(egl_display, &major, &minor) == EGL_FALSE) | 58 | if (eglInitialize(egl_display, &major, &minor) == EGL_FALSE) |
227 | 58 | BOOST_THROW_EXCEPTION(std::runtime_error("eglInitialize failure\n")); | 59 | BOOST_THROW_EXCEPTION(mg::egl_error("eglInitialize failure")); |
228 | 59 | 60 | ||
229 | 60 | if ((major != 1) || (minor != 4)) | 61 | if ((major != 1) || (minor != 4)) |
231 | 61 | BOOST_THROW_EXCEPTION(std::runtime_error("must have EGL 1.4\n")); | 62 | BOOST_THROW_EXCEPTION(std::runtime_error("must have EGL 1.4")); |
232 | 62 | return egl_display; | 63 | return egl_display; |
233 | 63 | } | 64 | } |
234 | 64 | 65 | ||
235 | @@ -108,7 +109,7 @@ | |||
236 | 108 | if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context) == EGL_FALSE) | 109 | if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context) == EGL_FALSE) |
237 | 109 | { | 110 | { |
238 | 110 | BOOST_THROW_EXCEPTION( | 111 | BOOST_THROW_EXCEPTION( |
240 | 111 | std::runtime_error("could not activate surface with eglMakeCurrent\n")); | 112 | mg::egl_error("could not activate surface with eglMakeCurrent")); |
241 | 112 | } | 113 | } |
242 | 113 | } | 114 | } |
243 | 114 | 115 | ||
244 | @@ -186,13 +187,8 @@ | |||
245 | 186 | 187 | ||
246 | 187 | void mga::FramebufferGLContext::swap_buffers() const | 188 | void mga::FramebufferGLContext::swap_buffers() const |
247 | 188 | { | 189 | { |
248 | 189 | eglGetError(); | ||
249 | 190 | if (eglSwapBuffers(egl_display, egl_surface) == EGL_FALSE) | 190 | if (eglSwapBuffers(egl_display, egl_surface) == EGL_FALSE) |
255 | 191 | { | 191 | BOOST_THROW_EXCEPTION(mg::egl_error("eglSwapBuffers failure")); |
251 | 192 | std::stringstream sstream; | ||
252 | 193 | sstream << "eglSwapBuffers failure: EGL error code " << std::hex << eglGetError(); | ||
253 | 194 | BOOST_THROW_EXCEPTION(std::runtime_error(sstream.str())); | ||
254 | 195 | } | ||
256 | 196 | } | 192 | } |
257 | 197 | 193 | ||
258 | 198 | std::shared_ptr<mg::Buffer> mga::FramebufferGLContext::last_rendered_buffer() const | 194 | std::shared_ptr<mg::Buffer> mga::FramebufferGLContext::last_rendered_buffer() const |
259 | 199 | 195 | ||
260 | === modified file 'src/platforms/mesa/server/buffer_allocator.cpp' | |||
261 | --- src/platforms/mesa/server/buffer_allocator.cpp 2015-04-14 12:22:18 +0000 | |||
262 | +++ src/platforms/mesa/server/buffer_allocator.cpp 2015-04-17 15:49:38 +0000 | |||
263 | @@ -23,6 +23,7 @@ | |||
264 | 23 | #include "anonymous_shm_file.h" | 23 | #include "anonymous_shm_file.h" |
265 | 24 | #include "shm_buffer.h" | 24 | #include "shm_buffer.h" |
266 | 25 | #include "mir/graphics/egl_extensions.h" | 25 | #include "mir/graphics/egl_extensions.h" |
267 | 26 | #include "mir/graphics/egl_error.h" | ||
268 | 26 | #include "mir/graphics/buffer_properties.h" | 27 | #include "mir/graphics/buffer_properties.h" |
269 | 27 | #include <boost/throw_exception.hpp> | 28 | #include <boost/throw_exception.hpp> |
270 | 28 | 29 | ||
271 | @@ -86,7 +87,7 @@ | |||
272 | 86 | reinterpret_cast<void*>(bo_raw), | 87 | reinterpret_cast<void*>(bo_raw), |
273 | 87 | image_attrs); | 88 | image_attrs); |
274 | 88 | if (egl_image == EGL_NO_IMAGE_KHR) | 89 | if (egl_image == EGL_NO_IMAGE_KHR) |
276 | 89 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create EGLImage from GBM bo")); | 90 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGLImage from GBM bo")); |
277 | 90 | } | 91 | } |
278 | 91 | } | 92 | } |
279 | 92 | 93 | ||
280 | 93 | 94 | ||
281 | === modified file 'src/platforms/mesa/server/display_helpers.cpp' | |||
282 | --- src/platforms/mesa/server/display_helpers.cpp 2015-01-22 09:00:14 +0000 | |||
283 | +++ src/platforms/mesa/server/display_helpers.cpp 2015-04-17 15:49:38 +0000 | |||
284 | @@ -20,6 +20,7 @@ | |||
285 | 20 | #include "drm_close_threadsafe.h" | 20 | #include "drm_close_threadsafe.h" |
286 | 21 | 21 | ||
287 | 22 | #include "mir/graphics/gl_config.h" | 22 | #include "mir/graphics/gl_config.h" |
288 | 23 | #include "mir/graphics/egl_error.h" | ||
289 | 23 | #include "mir/udev/wrapper.h" | 24 | #include "mir/udev/wrapper.h" |
290 | 24 | 25 | ||
291 | 25 | #include <boost/exception/errinfo_errno.hpp> | 26 | #include <boost/exception/errinfo_errno.hpp> |
292 | @@ -31,6 +32,7 @@ | |||
293 | 31 | #include <xf86drm.h> | 32 | #include <xf86drm.h> |
294 | 32 | #include <fcntl.h> | 33 | #include <fcntl.h> |
295 | 33 | 34 | ||
296 | 35 | namespace mg = mir::graphics; | ||
297 | 34 | namespace mgm = mir::graphics::mesa; | 36 | namespace mgm = mir::graphics::mesa; |
298 | 35 | namespace mgmh = mir::graphics::mesa::helpers; | 37 | namespace mgmh = mir::graphics::mesa::helpers; |
299 | 36 | 38 | ||
300 | @@ -317,7 +319,7 @@ | |||
301 | 317 | 319 | ||
302 | 318 | egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attr); | 320 | egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attr); |
303 | 319 | if (egl_context == EGL_NO_CONTEXT) | 321 | if (egl_context == EGL_NO_CONTEXT) |
305 | 320 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create EGL context")); | 322 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
306 | 321 | } | 323 | } |
307 | 322 | 324 | ||
308 | 323 | void mgmh::EGLHelper::setup(GBMHelper const& gbm, EGLContext shared_context) | 325 | void mgmh::EGLHelper::setup(GBMHelper const& gbm, EGLContext shared_context) |
309 | @@ -331,7 +333,7 @@ | |||
310 | 331 | 333 | ||
311 | 332 | egl_context = eglCreateContext(egl_display, egl_config, shared_context, context_attr); | 334 | egl_context = eglCreateContext(egl_display, egl_config, shared_context, context_attr); |
312 | 333 | if (egl_context == EGL_NO_CONTEXT) | 335 | if (egl_context == EGL_NO_CONTEXT) |
314 | 334 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create EGL context")); | 336 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
315 | 335 | } | 337 | } |
316 | 336 | 338 | ||
317 | 337 | void mgmh::EGLHelper::setup(GBMHelper const& gbm, gbm_surface* surface_gbm, | 339 | void mgmh::EGLHelper::setup(GBMHelper const& gbm, gbm_surface* surface_gbm, |
318 | @@ -346,11 +348,11 @@ | |||
319 | 346 | 348 | ||
320 | 347 | egl_surface = eglCreateWindowSurface(egl_display, egl_config, surface_gbm, nullptr); | 349 | egl_surface = eglCreateWindowSurface(egl_display, egl_config, surface_gbm, nullptr); |
321 | 348 | if(egl_surface == EGL_NO_SURFACE) | 350 | if(egl_surface == EGL_NO_SURFACE) |
323 | 349 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create EGL window surface")); | 351 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL window surface")); |
324 | 350 | 352 | ||
325 | 351 | egl_context = eglCreateContext(egl_display, egl_config, shared_context, context_attr); | 353 | egl_context = eglCreateContext(egl_display, egl_config, shared_context, context_attr); |
326 | 352 | if (egl_context == EGL_NO_CONTEXT) | 354 | if (egl_context == EGL_NO_CONTEXT) |
328 | 353 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create EGL context")); | 355 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
329 | 354 | } | 356 | } |
330 | 355 | 357 | ||
331 | 356 | mgmh::EGLHelper::~EGLHelper() noexcept | 358 | mgmh::EGLHelper::~EGLHelper() noexcept |
332 | @@ -408,14 +410,14 @@ | |||
333 | 408 | 410 | ||
334 | 409 | egl_display = eglGetDisplay(static_cast<EGLNativeDisplayType>(gbm.device)); | 411 | egl_display = eglGetDisplay(static_cast<EGLNativeDisplayType>(gbm.device)); |
335 | 410 | if (egl_display == EGL_NO_DISPLAY) | 412 | if (egl_display == EGL_NO_DISPLAY) |
337 | 411 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to get EGL display")); | 413 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to get EGL display")); |
338 | 412 | 414 | ||
339 | 413 | if (initialize) | 415 | if (initialize) |
340 | 414 | { | 416 | { |
341 | 415 | EGLint major, minor; | 417 | EGLint major, minor; |
342 | 416 | 418 | ||
343 | 417 | if (eglInitialize(egl_display, &major, &minor) == EGL_FALSE) | 419 | if (eglInitialize(egl_display, &major, &minor) == EGL_FALSE) |
345 | 418 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to initialize EGL display")); | 420 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to initialize EGL display")); |
346 | 419 | 421 | ||
347 | 420 | if ((major != required_egl_version_major) || (minor != required_egl_version_minor)) | 422 | if ((major != required_egl_version_major) || (minor != required_egl_version_minor)) |
348 | 421 | { | 423 | { |
349 | @@ -432,7 +434,7 @@ | |||
350 | 432 | if (eglChooseConfig(egl_display, config_attr, &egl_config, 1, &num_egl_configs) == EGL_FALSE || | 434 | if (eglChooseConfig(egl_display, config_attr, &egl_config, 1, &num_egl_configs) == EGL_FALSE || |
351 | 433 | num_egl_configs != 1) | 435 | num_egl_configs != 1) |
352 | 434 | { | 436 | { |
354 | 435 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to choose ARGB EGL config")); | 437 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to choose ARGB EGL config")); |
355 | 436 | } | 438 | } |
356 | 437 | } | 439 | } |
357 | 438 | 440 | ||
358 | 439 | 441 | ||
359 | === modified file 'src/server/graphics/nested/display.cpp' | |||
360 | --- src/server/graphics/nested/display.cpp 2015-04-08 03:02:37 +0000 | |||
361 | +++ src/server/graphics/nested/display.cpp 2015-04-17 15:49:38 +0000 | |||
362 | @@ -28,6 +28,7 @@ | |||
363 | 28 | #include "mir/graphics/display_configuration_policy.h" | 28 | #include "mir/graphics/display_configuration_policy.h" |
364 | 29 | #include "mir/graphics/overlapping_output_grouping.h" | 29 | #include "mir/graphics/overlapping_output_grouping.h" |
365 | 30 | #include "mir/graphics/gl_config.h" | 30 | #include "mir/graphics/gl_config.h" |
366 | 31 | #include "mir/graphics/egl_error.h" | ||
367 | 31 | 32 | ||
368 | 32 | #include <boost/throw_exception.hpp> | 33 | #include <boost/throw_exception.hpp> |
369 | 33 | #include <stdexcept> | 34 | #include <stdexcept> |
370 | @@ -48,7 +49,7 @@ | |||
371 | 48 | { | 49 | { |
372 | 49 | if (egl_surface == EGL_NO_SURFACE) | 50 | if (egl_surface == EGL_NO_SURFACE) |
373 | 50 | { | 51 | { |
375 | 51 | BOOST_THROW_EXCEPTION(std::runtime_error("Nested Mir Display Error: Failed to create EGL surface.")); | 52 | BOOST_THROW_EXCEPTION(mg::egl_error("Nested Mir Display Error: Failed to create EGL surface.")); |
376 | 52 | } | 53 | } |
377 | 53 | } | 54 | } |
378 | 54 | 55 | ||
379 | @@ -66,7 +67,7 @@ | |||
380 | 66 | { | 67 | { |
381 | 67 | egl_display = eglGetDisplay(native_display); | 68 | egl_display = eglGetDisplay(native_display); |
382 | 68 | if (egl_display == EGL_NO_DISPLAY) | 69 | if (egl_display == EGL_NO_DISPLAY) |
384 | 69 | BOOST_THROW_EXCEPTION(std::runtime_error("Nested Mir Display Error: Failed to fetch EGL display.")); | 70 | BOOST_THROW_EXCEPTION(mg::egl_error("Nested Mir Display Error: Failed to fetch EGL display.")); |
385 | 70 | } | 71 | } |
386 | 71 | 72 | ||
387 | 72 | void mgn::detail::EGLDisplayHandle::initialize(MirPixelFormat format) | 73 | void mgn::detail::EGLDisplayHandle::initialize(MirPixelFormat format) |
388 | @@ -76,13 +77,13 @@ | |||
389 | 76 | 77 | ||
390 | 77 | if (eglInitialize(egl_display, &major, &minor) != EGL_TRUE) | 78 | if (eglInitialize(egl_display, &major, &minor) != EGL_TRUE) |
391 | 78 | { | 79 | { |
393 | 79 | BOOST_THROW_EXCEPTION(std::runtime_error("Nested Mir Display Error: Failed to initialize EGL.")); | 80 | BOOST_THROW_EXCEPTION(mg::egl_error("Nested Mir Display Error: Failed to initialize EGL.")); |
394 | 80 | } | 81 | } |
395 | 81 | 82 | ||
396 | 82 | egl_context_ = eglCreateContext(egl_display, choose_windowed_es_config(format), EGL_NO_CONTEXT, detail::nested_egl_context_attribs); | 83 | egl_context_ = eglCreateContext(egl_display, choose_windowed_es_config(format), EGL_NO_CONTEXT, detail::nested_egl_context_attribs); |
397 | 83 | 84 | ||
398 | 84 | if (egl_context_ == EGL_NO_CONTEXT) | 85 | if (egl_context_ == EGL_NO_CONTEXT) |
400 | 85 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create shared EGL context")); | 86 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create shared EGL context")); |
401 | 86 | } | 87 | } |
402 | 87 | 88 | ||
403 | 88 | EGLConfig mgn::detail::EGLDisplayHandle::choose_windowed_es_config(MirPixelFormat format) const | 89 | EGLConfig mgn::detail::EGLDisplayHandle::choose_windowed_es_config(MirPixelFormat format) const |
404 | @@ -104,7 +105,7 @@ | |||
405 | 104 | 105 | ||
406 | 105 | int res = eglChooseConfig(egl_display, nested_egl_config_attribs, &result, 1, &n); | 106 | int res = eglChooseConfig(egl_display, nested_egl_config_attribs, &result, 1, &n); |
407 | 106 | if ((res != EGL_TRUE) || (n != 1)) | 107 | if ((res != EGL_TRUE) || (n != 1)) |
409 | 107 | BOOST_THROW_EXCEPTION(std::runtime_error("Nested Mir Display Error: Failed to choose EGL configuration.")); | 108 | BOOST_THROW_EXCEPTION(mg::egl_error("Nested Mir Display Error: Failed to choose EGL configuration.")); |
410 | 108 | 109 | ||
411 | 109 | return result; | 110 | return result; |
412 | 110 | } | 111 | } |
413 | 111 | 112 | ||
414 | === modified file 'src/server/graphics/nested/display_buffer.cpp' | |||
415 | --- src/server/graphics/nested/display_buffer.cpp 2015-04-10 01:59:08 +0000 | |||
416 | +++ src/server/graphics/nested/display_buffer.cpp 2015-04-17 15:49:38 +0000 | |||
417 | @@ -21,6 +21,7 @@ | |||
418 | 21 | #include "host_connection.h" | 21 | #include "host_connection.h" |
419 | 22 | #include "mir/input/input_dispatcher.h" | 22 | #include "mir/input/input_dispatcher.h" |
420 | 23 | #include "mir/graphics/pixel_format_utils.h" | 23 | #include "mir/graphics/pixel_format_utils.h" |
421 | 24 | #include "mir/graphics/egl_error.h" | ||
422 | 24 | #include "mir/events/event_private.h" | 25 | #include "mir/events/event_private.h" |
423 | 25 | 26 | ||
424 | 26 | #include <boost/throw_exception.hpp> | 27 | #include <boost/throw_exception.hpp> |
425 | @@ -56,7 +57,7 @@ | |||
426 | 56 | void mgn::detail::DisplayBuffer::make_current() | 57 | void mgn::detail::DisplayBuffer::make_current() |
427 | 57 | { | 58 | { |
428 | 58 | if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context) != EGL_TRUE) | 59 | if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context) != EGL_TRUE) |
430 | 59 | BOOST_THROW_EXCEPTION(std::runtime_error("Nested Mir Display Error: Failed to update EGL surface.\n")); | 60 | BOOST_THROW_EXCEPTION(mg::egl_error("Nested Mir Display Error: Failed to update EGL surface")); |
431 | 60 | } | 61 | } |
432 | 61 | 62 | ||
433 | 62 | void mgn::detail::DisplayBuffer::release_current() | 63 | void mgn::detail::DisplayBuffer::release_current() |
434 | 63 | 64 | ||
435 | === modified file 'src/server/graphics/offscreen/display.cpp' | |||
436 | --- src/server/graphics/offscreen/display.cpp 2015-03-31 02:35:42 +0000 | |||
437 | +++ src/server/graphics/offscreen/display.cpp 2015-04-17 15:49:38 +0000 | |||
438 | @@ -19,6 +19,7 @@ | |||
439 | 19 | #include "display.h" | 19 | #include "display.h" |
440 | 20 | #include "display_buffer.h" | 20 | #include "display_buffer.h" |
441 | 21 | #include "mir/graphics/display_configuration_policy.h" | 21 | #include "mir/graphics/display_configuration_policy.h" |
442 | 22 | #include "mir/graphics/egl_error.h" | ||
443 | 22 | #include "mir/geometry/size.h" | 23 | #include "mir/geometry/size.h" |
444 | 23 | 24 | ||
445 | 24 | #include <boost/throw_exception.hpp> | 25 | #include <boost/throw_exception.hpp> |
446 | @@ -45,7 +46,7 @@ | |||
447 | 45 | : egl_display{eglGetDisplay(native_display)} | 46 | : egl_display{eglGetDisplay(native_display)} |
448 | 46 | { | 47 | { |
449 | 47 | if (egl_display == EGL_NO_DISPLAY) | 48 | if (egl_display == EGL_NO_DISPLAY) |
451 | 48 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to get EGL display")); | 49 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to get EGL display")); |
452 | 49 | } | 50 | } |
453 | 50 | 51 | ||
454 | 51 | mgo::detail::EGLDisplayHandle::EGLDisplayHandle(EGLDisplayHandle&& other) | 52 | mgo::detail::EGLDisplayHandle::EGLDisplayHandle(EGLDisplayHandle&& other) |
455 | @@ -59,7 +60,7 @@ | |||
456 | 59 | int major, minor; | 60 | int major, minor; |
457 | 60 | 61 | ||
458 | 61 | if (eglInitialize(egl_display, &major, &minor) == EGL_FALSE) | 62 | if (eglInitialize(egl_display, &major, &minor) == EGL_FALSE) |
460 | 62 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to initialize EGL")); | 63 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to initialize EGL")); |
461 | 63 | 64 | ||
462 | 64 | if ((major != 1) || (minor != 4)) | 65 | if ((major != 1) || (minor != 4)) |
463 | 65 | BOOST_THROW_EXCEPTION(std::runtime_error("EGL version 1.4 needed")); | 66 | BOOST_THROW_EXCEPTION(std::runtime_error("EGL version 1.4 needed")); |
464 | 66 | 67 | ||
465 | === modified file 'src/server/graphics/surfaceless_egl_context.cpp' | |||
466 | --- src/server/graphics/surfaceless_egl_context.cpp 2015-04-13 14:26:52 +0000 | |||
467 | +++ src/server/graphics/surfaceless_egl_context.cpp 2015-04-17 15:49:38 +0000 | |||
468 | @@ -18,6 +18,7 @@ | |||
469 | 18 | 18 | ||
470 | 19 | #include "mir/graphics/surfaceless_egl_context.h" | 19 | #include "mir/graphics/surfaceless_egl_context.h" |
471 | 20 | #include "mir/graphics/gl_extensions_base.h" | 20 | #include "mir/graphics/gl_extensions_base.h" |
472 | 21 | #include "mir/graphics/egl_error.h" | ||
473 | 21 | 22 | ||
474 | 22 | #include <boost/throw_exception.hpp> | 23 | #include <boost/throw_exception.hpp> |
475 | 23 | #include <stdexcept> | 24 | #include <stdexcept> |
476 | @@ -99,7 +100,7 @@ | |||
477 | 99 | if (eglChooseConfig(egl_display, attribs, &egl_config, 1, &num_egl_configs) == EGL_FALSE || | 100 | if (eglChooseConfig(egl_display, attribs, &egl_config, 1, &num_egl_configs) == EGL_FALSE || |
478 | 100 | num_egl_configs != 1) | 101 | num_egl_configs != 1) |
479 | 101 | { | 102 | { |
481 | 102 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to choose EGL config")); | 103 | BOOST_THROW_EXCEPTION(mg::egl_error("Failed to choose EGL config")); |
482 | 103 | } | 104 | } |
483 | 104 | 105 | ||
484 | 105 | return egl_config; | 106 | return egl_config; |
485 | @@ -186,7 +187,7 @@ | |||
486 | 186 | egl_context) == EGL_FALSE) | 187 | egl_context) == EGL_FALSE) |
487 | 187 | { | 188 | { |
488 | 188 | BOOST_THROW_EXCEPTION( | 189 | BOOST_THROW_EXCEPTION( |
490 | 189 | std::runtime_error("could not make context current\n")); | 190 | mg::egl_error("could not make context current")); |
491 | 190 | } | 191 | } |
492 | 191 | } | 192 | } |
493 | 192 | 193 | ||
494 | 193 | 194 | ||
495 | === modified file 'tests/unit-tests/graphics/CMakeLists.txt' | |||
496 | --- tests/unit-tests/graphics/CMakeLists.txt 2015-04-09 06:20:31 +0000 | |||
497 | +++ tests/unit-tests/graphics/CMakeLists.txt 2015-04-17 15:49:38 +0000 | |||
498 | @@ -2,6 +2,7 @@ | |||
499 | 2 | ${CMAKE_CURRENT_SOURCE_DIR}/test_graphics_platform.cpp | 2 | ${CMAKE_CURRENT_SOURCE_DIR}/test_graphics_platform.cpp |
500 | 3 | ${CMAKE_CURRENT_SOURCE_DIR}/test_display_configuration.cpp | 3 | ${CMAKE_CURRENT_SOURCE_DIR}/test_display_configuration.cpp |
501 | 4 | ${CMAKE_CURRENT_SOURCE_DIR}/test_egl_extensions.cpp | 4 | ${CMAKE_CURRENT_SOURCE_DIR}/test_egl_extensions.cpp |
502 | 5 | ${CMAKE_CURRENT_SOURCE_DIR}/test_egl_error.cpp | ||
503 | 5 | ${CMAKE_CURRENT_SOURCE_DIR}/test_display.cpp | 6 | ${CMAKE_CURRENT_SOURCE_DIR}/test_display.cpp |
504 | 6 | ${CMAKE_CURRENT_SOURCE_DIR}/test_default_display_configuration_policy.cpp | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/test_default_display_configuration_policy.cpp |
505 | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_id.cpp | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_id.cpp |
506 | 8 | 9 | ||
507 | === added file 'tests/unit-tests/graphics/test_egl_error.cpp' | |||
508 | --- tests/unit-tests/graphics/test_egl_error.cpp 1970-01-01 00:00:00 +0000 | |||
509 | +++ tests/unit-tests/graphics/test_egl_error.cpp 2015-04-17 15:49:38 +0000 | |||
510 | @@ -0,0 +1,115 @@ | |||
511 | 1 | /* | ||
512 | 2 | * Copyright © 2015 Canonical Ltd. | ||
513 | 3 | * | ||
514 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
515 | 5 | * under the terms of the GNU General Public License version 3, | ||
516 | 6 | * as published by the Free Software Foundation. | ||
517 | 7 | * | ||
518 | 8 | * This program is distributed in the hope that it will be useful, | ||
519 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
520 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
521 | 11 | * GNU General Public License for more details. | ||
522 | 12 | * | ||
523 | 13 | * You should have received a copy of the GNU General Public License | ||
524 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
525 | 15 | * | ||
526 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
527 | 17 | */ | ||
528 | 18 | |||
529 | 19 | #include "mir/graphics/egl_error.h" | ||
530 | 20 | #include "mir_test_doubles/mock_egl.h" | ||
531 | 21 | |||
532 | 22 | #include <gtest/gtest.h> | ||
533 | 23 | #include <gmock/gmock.h> | ||
534 | 24 | |||
535 | 25 | namespace mg = mir::graphics; | ||
536 | 26 | namespace mtd = mir::test::doubles; | ||
537 | 27 | |||
538 | 28 | namespace | ||
539 | 29 | { | ||
540 | 30 | |||
541 | 31 | std::string to_hex_string(int n) | ||
542 | 32 | { | ||
543 | 33 | std::stringstream ss; | ||
544 | 34 | ss << std::showbase << std::hex << n; | ||
545 | 35 | return ss.str(); | ||
546 | 36 | } | ||
547 | 37 | |||
548 | 38 | struct EGLErrorTest : ::testing::Test | ||
549 | 39 | { | ||
550 | 40 | testing::NiceMock<mtd::MockEGL> mock_egl; | ||
551 | 41 | |||
552 | 42 | std::string const user_message{"Something failed"}; | ||
553 | 43 | std::string const egl_error_code_str{"EGL_BAD_MATCH"}; | ||
554 | 44 | int const egl_error_code{EGL_BAD_MATCH}; | ||
555 | 45 | }; | ||
556 | 46 | |||
557 | 47 | } | ||
558 | 48 | |||
559 | 49 | TEST_F(EGLErrorTest, produces_correct_error_code) | ||
560 | 50 | { | ||
561 | 51 | using namespace testing; | ||
562 | 52 | |||
563 | 53 | EXPECT_CALL(mock_egl, eglGetError()) | ||
564 | 54 | .WillOnce(Return(egl_error_code)); | ||
565 | 55 | |||
566 | 56 | std::error_code ec; | ||
567 | 57 | |||
568 | 58 | try | ||
569 | 59 | { | ||
570 | 60 | throw mg::egl_error(""); | ||
571 | 61 | } | ||
572 | 62 | catch (std::system_error const& error) | ||
573 | 63 | { | ||
574 | 64 | ec = error.code(); | ||
575 | 65 | } | ||
576 | 66 | |||
577 | 67 | EXPECT_THAT(ec.value(), Eq(egl_error_code)); | ||
578 | 68 | } | ||
579 | 69 | |||
580 | 70 | TEST_F(EGLErrorTest, produces_message_with_user_string_and_error_code_for_known_error) | ||
581 | 71 | { | ||
582 | 72 | using namespace testing; | ||
583 | 73 | |||
584 | 74 | EXPECT_CALL(mock_egl, eglGetError()) | ||
585 | 75 | .WillOnce(Return(egl_error_code)); | ||
586 | 76 | |||
587 | 77 | std::string error_message; | ||
588 | 78 | |||
589 | 79 | try | ||
590 | 80 | { | ||
591 | 81 | throw mg::egl_error(user_message); | ||
592 | 82 | } | ||
593 | 83 | catch (std::system_error const& error) | ||
594 | 84 | { | ||
595 | 85 | error_message = error.what(); | ||
596 | 86 | } | ||
597 | 87 | |||
598 | 88 | EXPECT_THAT(error_message, HasSubstr(user_message)); | ||
599 | 89 | EXPECT_THAT(error_message, HasSubstr(egl_error_code_str)); | ||
600 | 90 | EXPECT_THAT(error_message, HasSubstr(to_hex_string(egl_error_code))); | ||
601 | 91 | } | ||
602 | 92 | |||
603 | 93 | TEST_F(EGLErrorTest, produces_message_with_user_string_and_error_code_for_unknown_error) | ||
604 | 94 | { | ||
605 | 95 | using namespace testing; | ||
606 | 96 | |||
607 | 97 | int const unknown_egl_error_code{0x131313}; | ||
608 | 98 | |||
609 | 99 | EXPECT_CALL(mock_egl, eglGetError()) | ||
610 | 100 | .WillOnce(Return(unknown_egl_error_code)); | ||
611 | 101 | |||
612 | 102 | std::string error_message; | ||
613 | 103 | |||
614 | 104 | try | ||
615 | 105 | { | ||
616 | 106 | throw mg::egl_error(user_message); | ||
617 | 107 | } | ||
618 | 108 | catch (std::system_error const& error) | ||
619 | 109 | { | ||
620 | 110 | error_message = error.what(); | ||
621 | 111 | } | ||
622 | 112 | |||
623 | 113 | EXPECT_THAT(error_message, HasSubstr(user_message)); | ||
624 | 114 | EXPECT_THAT(error_message, HasSubstr(to_hex_string(unknown_egl_error_code))); | ||
625 | 115 | } |
FAILED: Continuous integration, rev:2492 jenkins. qa.ubuntu. com/job/ mir-ci/ 3545/ jenkins. qa.ubuntu. com/job/ mir-android- vivid-i386- build/2085 jenkins. qa.ubuntu. com/job/ mir-clang- vivid-amd64- build/2084 jenkins. qa.ubuntu. com/job/ mir-mediumtests -vivid- touch/2035 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 1542/console jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 2035 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 2035/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- mako/4968 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 19717
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/mir- ci/3545/ rebuild
http://