summaryrefslogtreecommitdiff
path: root/lib/drmtest.h
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-02-12 15:19:15 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-02-13 14:41:40 +0100
commiteebdf7f9204686f5d937d6a3084056fb86c6e7de (patch)
tree6ef9dd8a801aa80a666bb5859a9596d4c1aaa283 /lib/drmtest.h
parent60a24a22ba4c7df46ebae0e99f0aa09604a6fb25 (diff)
lib: (somewhat) structured logging support
Apparently there's a bit a need for more verbose output in testcases, mostly for debugging purposes. At least gem_reset_stats and pm_rps have a verbose mode. On top of that we're currently not taking advantage of piglit's "warn" state all that much. But I think it might be useful for testcases which are notorious for some kinds of spurious failures, like e.g. the really nasty timing checks in kms_flip. If we demote some of them to just warnings we could run the overall tests more often. Hence this patchs adds a new igt_log function with the three levels DEBUG, INFO and WARN. Plus a bunch of convenience helpers to keep the test code tidy. The level can be set through an enviroment vairable IGT_LOG_LEVEL with info being the default. Also tests can look at the selected log level in case they want to run costly debug functions only when needed. Comments highly welcome, I plan to roll this out over tests which can use it (not all, imo that's too much churn) once we've settled on the interfaces/semantics. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib/drmtest.h')
-rw-r--r--lib/drmtest.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/drmtest.h b/lib/drmtest.h
index c0398329..b64529b6 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -294,6 +294,33 @@ void igt_wait_helper(struct igt_helper_process *proc);
#define igt_fork_helper(proc) \
for (; __igt_fork_helper(proc); exit(0))
+/* logging support */
+enum igt_log_level {
+ IGT_LOG_DEBUG,
+ IGT_LOG_INFO,
+ IGT_LOG_WARN,
+ IGT_LOG_NONE,
+};
+__attribute__((format(printf, 2, 3)))
+void igt_log(enum igt_log_level level, const char *format, ...);
+#define igt_debug(f...) igt_log(IGT_LOG_DEBUG, f)
+#define igt_info(f...) igt_log(IGT_LOG_INFO, f)
+#define igt_warn(f...) igt_log(IGT_LOG_WARN, f)
+extern enum igt_log_level igt_log_level;
+
+#define igt_warn_on(condition) do {\
+ if (condition) \
+ igt_warn("Warning on condition %s in fucntion %s, file %s:%i\n", \
+ #condition, __func__, __FILE__, __LINE__); \
+ } while (0)
+#define igt_warn_on_f(condition, f...) do {\
+ if (condition) {\
+ igt_warn("Warning on condition %s in fucntion %s, file %s:%i\n", \
+ #condition, __func__, __FILE__, __LINE__); \
+ igt_warn(f); \
+ } \
+ } while (0)
+
/* check functions which auto-skip tests by calling igt_skip() */
void gem_require_caching(int fd);
static inline void gem_require_ring(int fd, int ring_id)