summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorChristopher Michael <devilhorns@comcast.net>2020-06-10 08:32:40 -0400
committerChristopher Michael <devilhorns@comcast.net>2020-06-10 08:32:40 -0400
commitca1eba10af084bd44d2aa1738b2b55a408ece802 (patch)
treeeae20eaf3639d588c04b3bbd2651eb8150d561f3 /src/tests
parente48ac73bdcd43ffff1177739d2aa2c015da9a3cb (diff)
tests/ecore_wl2: Fix unchecked return value
Coverity reports eglChooseConfig is called without checking return value here. This patch fixes the issue by checking the return value and by also making _init_egl return a bool so that we can fail the test if eglChooseConfig results in failure. Fixes Coverity CID1412365
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_test_window.c5
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h16
2 files changed, 18 insertions, 3 deletions
diff --git a/src/tests/ecore_wl2/ecore_wl2_test_window.c b/src/tests/ecore_wl2/ecore_wl2_test_window.c
index c094515e93..4b9e734d61 100644
--- a/src/tests/ecore_wl2/ecore_wl2_test_window.c
+++ b/src/tests/ecore_wl2/ecore_wl2_test_window.c
@@ -324,6 +324,7 @@ _test_activated_window_activate(void *data EINA_UNUSED, int type EINA_UNUSED, vo
324EFL_START_TEST(wl2_window_activated) 324EFL_START_TEST(wl2_window_activated)
325{ 325{
326 Test_Data *td; 326 Test_Data *td;
327 Eina_Bool ret = EINA_FALSE;
327 328
328 ecore_wl2_init(); 329 ecore_wl2_init();
329 330
@@ -345,7 +346,9 @@ EFL_START_TEST(wl2_window_activated)
345 346
346 ecore_wl2_window_show(td->win); 347 ecore_wl2_window_show(td->win);
347 348
348 _init_egl(td); 349 ret = _init_egl(td);
350 fail_if(ret != EINA_TRUE);
351
349 td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE, 352 td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
350 _test_activated_configure_complete, td); 353 _test_activated_configure_complete, td);
351 ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ACTIVATE, 354 ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ACTIVATE,
diff --git a/src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h b/src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h
index 27fa4a615e..f235a481bb 100644
--- a/src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h
+++ b/src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h
@@ -5,7 +5,7 @@
5#include <EGL/egl.h> 5#include <EGL/egl.h>
6#include <GLES2/gl2.h> 6#include <GLES2/gl2.h>
7 7
8static void 8static Eina_Bool
9_init_egl(Test_Data *td) 9_init_egl(Test_Data *td)
10{ 10{
11 eglBindAPI(EGL_OPENGL_API); 11 eglBindAPI(EGL_OPENGL_API);
@@ -21,18 +21,30 @@ _init_egl(Test_Data *td)
21 21
22 td->egl_display = 22 td->egl_display =
23 eglGetDisplay((EGLNativeDisplayType)ecore_wl2_display_get(td->display)); 23 eglGetDisplay((EGLNativeDisplayType)ecore_wl2_display_get(td->display));
24
24 eglInitialize(td->egl_display, NULL, NULL); 25 eglInitialize(td->egl_display, NULL, NULL);
25 eglChooseConfig(td->egl_display, attributes, &td->egl_conf, 1, &num_config); 26
27 if (!eglChooseConfig(td->egl_display, attributes, &td->egl_conf,
28 1, &num_config))
29 {
30 ERR("Failed to choose egl config");
31 eglTerminate(td->egl_display);
32 return EINA_FALSE;
33 }
34
26 td->egl_context = 35 td->egl_context =
27 eglCreateContext(td->egl_display, td->egl_conf, EGL_NO_CONTEXT, NULL); 36 eglCreateContext(td->egl_display, td->egl_conf, EGL_NO_CONTEXT, NULL);
28 37
29 td->egl_window = wl_egl_window_create(td->surface, td->width, td->height); 38 td->egl_window = wl_egl_window_create(td->surface, td->width, td->height);
39
30 td->egl_surface = 40 td->egl_surface =
31 eglCreateWindowSurface(td->egl_display, 41 eglCreateWindowSurface(td->egl_display,
32 td->egl_conf, td->egl_window, NULL); 42 td->egl_conf, td->egl_window, NULL);
33 43
34 eglMakeCurrent(td->egl_display, td->egl_surface, 44 eglMakeCurrent(td->egl_display, td->egl_surface,
35 td->egl_surface, td->egl_context); 45 td->egl_surface, td->egl_context);
46
47 return EINA_TRUE;
36} 48}
37 49
38static void 50static void