glx-multithread-texture: Avoid front-buffer rendering.
[piglit.git] / tests / util / piglit-util-waffle.c
blob29b4cb2818883eae6a6c53ce592d9aeed3d030b0
1 /*
2 * Copyright © 2012 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
24 #include <assert.h>
25 #include <stdio.h>
27 #include "piglit-util-gl.h"
28 #include "piglit-util-waffle.h"
30 static void
31 wfl_log(const char *tag, const char *func_name)
33 const struct waffle_error_info *info = waffle_error_get_info();
35 assert(tag != NULL);
36 assert(info->code != WAFFLE_NO_ERROR);
38 fflush(stdout);
39 fprintf(stderr, "piglit: %s: %s failed due to %s",
40 tag, func_name, waffle_error_to_string(info->code));
41 if (info->message_length > 0)
42 fprintf(stderr, ": %s", info->message);
43 fprintf(stderr, "\n");
46 void
47 wfl_log_debug(const char *func_name)
49 static int debug = -1;
51 if (debug == -1) {
52 const char *env = getenv("PIGLIT_DEBUG");
53 if (env == NULL) {
54 debug = 0;
55 } else if (strcmp(env, "0") == 0) {
56 debug = 0;
57 } else if (strcmp(env, "1") == 0) {
58 debug = 1;
59 } else {
60 fprintf(stderr, "PIGLIT_DEBUG has invalid value:"
61 " %s\n", env);
62 abort();
66 if (debug == 1)
67 wfl_log("debug", func_name);
70 void
71 wfl_log_error(const char *func_name)
73 wfl_log("error", func_name);
76 void
77 wfl_fatal_error(const char *func_name)
79 const struct waffle_error_info *info = waffle_error_get_info();
81 assert(info->code != WAFFLE_NO_ERROR);
83 wfl_log_error(func_name);
85 if (info->code == WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM ||
86 info->code == WAFFLE_ERROR_BUILT_WITHOUT_SUPPORT)
87 piglit_report_result(PIGLIT_SKIP);
88 else
89 piglit_report_result(PIGLIT_FAIL);