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
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
27 #include "piglit-util-gl.h"
28 #include "piglit-util-waffle.h"
31 wfl_log(const char *tag
, const char *func_name
)
33 const struct waffle_error_info
*info
= waffle_error_get_info();
36 assert(info
->code
!= WAFFLE_NO_ERROR
);
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");
47 wfl_log_debug(const char *func_name
)
49 static int debug
= -1;
52 const char *env
= getenv("PIGLIT_DEBUG");
55 } else if (strcmp(env
, "0") == 0) {
57 } else if (strcmp(env
, "1") == 0) {
60 fprintf(stderr
, "PIGLIT_DEBUG has invalid value:"
67 wfl_log("debug", func_name
);
71 wfl_log_error(const char *func_name
)
73 wfl_log("error", func_name
);
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
);
89 piglit_report_result(PIGLIT_FAIL
);