From 28d633ee9e980b6e3537a38eb9a8d5cbf8b294e2 Mon Sep 17 00:00:00 2001 From: Jeremy Whiting <jeremy.whiting@collabora.com> Date: Wed, 4 Mar 2020 11:53:57 -0700 Subject: [PATCH] Add mock-mixed-check-gl with error output depending on LIBGL_DEBUG. Also add message test to test_mixed_vulkan. --- tests/graphics.c | 8 +++++++ tests/meson.build | 2 +- tests/mock-mixed-check-gl.c | 45 +++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/mock-mixed-check-gl.c diff --git a/tests/graphics.c b/tests/graphics.c index f7d2f7aee..4155cc338 100644 --- a/tests/graphics.c +++ b/tests/graphics.c @@ -775,6 +775,9 @@ test_mixed_vulkan (Fixture *f, "exit-status", &exit_status, "terminating-signal", &terminating_signal, NULL); + g_assert_cmpstr (srt_graphics_get_messages (graphics), ==, + "failed to create window surface!\n"); + g_assert_cmpint (issues, ==, SRT_GRAPHICS_ISSUES_CANNOT_DRAW); g_assert_cmpstr (tuple, ==, "mock-mixed"); g_assert_cmpstr (renderer, ==, SRT_TEST_GOOD_GRAPHICS_RENDERER); @@ -826,6 +829,11 @@ test_mixed_gl (Fixture *f, g_assert_cmpstr (tuple, ==, "mock-mixed"); g_assert_cmpstr (renderer, ==, SRT_TEST_GOOD_GRAPHICS_RENDERER); g_assert_cmpstr (version, ==, SRT_TEST_GOOD_GRAPHICS_VERSION); + g_assert_cmpstr (srt_graphics_get_messages (graphics), ==, + "warning: this warning should always be logged\n" + "Waffle error: 0x2 WAFFLE_ERROR_UNKNOWN: XOpenDisplay failed\n" + "info: you used LIBGL_DEBUG=verbose\n"); + g_free (tuple); g_free (renderer); g_free (version); diff --git a/tests/meson.build b/tests/meson.build index 56bf78007..b774e5b74 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -209,7 +209,6 @@ executable( foreach helper : [ 'mock-bad-check-gl', 'mock-mixed-check-vulkan', - 'mock-mixed-check-gl', ] executable( helper, @@ -230,6 +229,7 @@ foreach helper : [ 'mock-fedora-64-bit-inspect-library', 'mock-fedora-32-bit-inspect-library', 'mock-good-wflinfo', + 'mock-mixed-check-gl', 'mock-software-wflinfo', ] executable( diff --git a/tests/mock-mixed-check-gl.c b/tests/mock-mixed-check-gl.c new file mode 100644 index 000000000..c7caa5e6e --- /dev/null +++ b/tests/mock-mixed-check-gl.c @@ -0,0 +1,45 @@ +/* + * Copyright © 2019 Collabora Ltd. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include <glib.h> +#include <stdio.h> + +int +main (int argc, + char **argv) +{ + // Give bad output + fprintf (stderr, "warning: this warning should always be logged\n"); + + fprintf (stderr, "Waffle error: 0x2 WAFFLE_ERROR_UNKNOWN: XOpenDisplay failed\n"); + + if (g_strcmp0 (g_getenv ("LIBGL_DEBUG"), "verbose") == 0) + { + fprintf (stderr, "info: you used LIBGL_DEBUG=verbose\n"); + } + + return 1; +} + -- GitLab