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(FILE *out
, 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
);
40 fprintf(out
, "piglit: %s: %s failed due to %s",
41 tag
, func_name
, waffle_error_to_string(info
->code
));
42 if (info
->message_length
> 0)
43 fprintf(out
, ": %s", info
->message
);
48 wfl_log_debug(const char *func_name
)
50 static int debug
= -1;
53 const char *env
= getenv("PIGLIT_DEBUG");
56 } else if (strcmp(env
, "0") == 0) {
58 } else if (strcmp(env
, "1") == 0) {
61 fprintf(stderr
, "PIGLIT_DEBUG has invalid value:"
68 wfl_log(stderr
, "debug", func_name
);
72 wfl_log_error(const char *func_name
)
74 wfl_log(stderr
, "error", func_name
);
78 wfl_log_error_stdout(const char *func_name
)
80 wfl_log(stdout
, "error", func_name
);
84 wfl_fatal_error(const char *func_name
)
86 const struct waffle_error_info
*info
= waffle_error_get_info();
88 assert(info
->code
!= WAFFLE_NO_ERROR
);
90 wfl_log_error(func_name
);
92 if (info
->code
== WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM
||
93 info
->code
== WAFFLE_ERROR_BUILT_WITHOUT_SUPPORT
)
94 piglit_report_result(PIGLIT_SKIP
);
96 piglit_report_result(PIGLIT_FAIL
);