[Piglit] [PATCH] util: migrate the SUBTEST* macros to piglit-util.sh
Martin Peres
martin.peres at linux.intel.com
Wed Feb 18 06:15:27 PST 2015
Laura requested me to move these macros to piglit-util. However, this is
not the first time such a macro has been written. For example, curro
introduced subtest() in /tests/spec/arb_shader_image_load_store/common.h.
He said he also used another macro for another test.
Not sure if my macros are generic-enough though. They however can make a
good base for implementing most tests. They were definitely sufficient to
implement all my DSA-related tests.
Signed-off-by: Martin Peres <martin.peres at linux.intel.com>
---
tests/spec/arb_direct_state_access/dsa-utils.h | 16 -------------
tests/util/piglit-util.h | 32 ++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/tests/spec/arb_direct_state_access/dsa-utils.h b/tests/spec/arb_direct_state_access/dsa-utils.h
index 25b5524..a2f70b2 100644
--- a/tests/spec/arb_direct_state_access/dsa-utils.h
+++ b/tests/spec/arb_direct_state_access/dsa-utils.h
@@ -39,22 +39,6 @@ extern "C" {
#include "piglit-util-gl.h"
-#define SUBTEST(error, global, format, args...) \
-do { \
- bool local = piglit_check_gl_error((error)); \
- global = global && local; \
- piglit_report_subtest_result(local ? PIGLIT_PASS : PIGLIT_FAIL, \
- (format), ##args); \
-} while (0)
-
-#define SUBTESTCONDITION(condition, global, format, args...) \
-do { \
- bool cond = (condition); \
- global = global && cond; \
- piglit_report_subtest_result(cond ? PIGLIT_PASS : PIGLIT_FAIL, \
- (format), ##args); \
-} while (0)
-
void dsa_init_program(void);
void dsa_texture_with_unit(GLuint);
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 1c522a1..9a53964 100755
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -343,6 +343,38 @@ piglit_parse_subtest_args(int *argc, char *argv[],
uint64_t
piglit_gettid(void);
+/**
+ * \brief Run a subtest checking the error code of OpenGL
+ *
+ * This macro checks if the current gl error is \a error and reports the result
+ * using piglit_report_subtest_result, using the test name \a format. Finally,
+ * it updates the \a global variable that makes sure that the reported state of
+ * the test as a whole is false if any of the subtest failed.
+ */
+#define SUBTEST(error, global, format, args...) \
+do { \
+ bool local = piglit_check_gl_error((error)); \
+ global = global && local; \
+ piglit_report_subtest_result(local ? PIGLIT_PASS : PIGLIT_FAIL, \
+ (format), ##args); \
+} while (0)
+
+/**
+ * \brief Run a subtest checking a condition
+ *
+ * This macro checks if the \a condition is true and reports the result using
+ * piglit_report_subtest_result, using the test name \a format. Finally, it
+ * updates the \a global variable that makes sure that the reported state of
+ * the test as a whole is false if any of the subtest failed.
+ */
+#define SUBTESTCONDITION(condition, global, format, args...) \
+do { \
+ bool cond = (condition); \
+ global = global && cond; \
+ piglit_report_subtest_result(cond ? PIGLIT_PASS : PIGLIT_FAIL, \
+ (format), ##args); \
+} while (0)
+
#ifdef __cplusplus
} /* end extern "C" */
#endif
--
2.3.0
More information about the Piglit
mailing list