summaryrefslogtreecommitdiff
path: root/lib/igt_core.h
diff options
context:
space:
mode:
authorArkadiusz Hiler <arkadiusz.hiler@intel.com>2020-02-25 18:55:10 +0200
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2020-03-23 15:47:34 +0200
commitcf80b710838c2bdb48c629ab85cd295ed74423c6 (patch)
tree9bd4ba75898fdbb743d79de90e1df53a68e0526f /lib/igt_core.h
parentdc8911099bbf2894da2f04a6dcfe0499320666d9 (diff)
lib: Make it possible to abort the whole execution from inside of a test
igt_abort_on_f() is introduced which does very little cleanup and causes a hard exit() of the test binary with a unique exit code (IGT_EXIT_ABORT). The exit code informs the monitoring process that there is a critical issue with the testing environment which may have an impact on the results if testing continues. v2: Add a meta_test Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'lib/igt_core.h')
-rw-r--r--lib/igt_core.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/igt_core.h b/lib/igt_core.h
index fae5f59e..b97fa2fa 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -123,6 +123,14 @@ struct _GKeyFile *igt_load_igtrc(void);
*/
#define IGT_EXIT_FAILURE 98
+/**
+ * IGT_EXIT_ABORT
+ *
+ * Exit status indicating a severe test/enviroment failure, any continued
+ * testing past this point can yeild unexpected reasults and is not recommended
+ */
+#define IGT_EXIT_ABORT 112
+
bool __igt_fixture(void);
void __igt_fixture_complete(void);
void __igt_fixture_end(void) __attribute__((noreturn));
@@ -499,6 +507,11 @@ void __igt_fail_assert(const char *domain, const char *file,
const int line, const char *func, const char *assertion,
const char *format, ...)
__attribute__((noreturn));
+__attribute__((format(printf, 6, 7)))
+void __igt_abort(const char *domain, const char *file, const int line,
+ const char *func, const char *expression,
+ const char *f, ...)
+ __attribute__((noreturn));
void igt_exit(void) __attribute__((noreturn));
void igt_fatal_error(void) __attribute__((noreturn));
@@ -1027,6 +1040,22 @@ void igt_describe_f(const char *fmt, ...);
else igt_debug("Test requirement passed: !(%s)\n", #expr); \
} while (0)
+
+/**
+ * igt_abort_on_f:
+ * @expr: condition to test
+ * @...: format string and optional arguments
+ *
+ * Aborts current execution if a condition is met.
+ *
+ * Should be used only when there is a serious issue with the environment and
+ * any further testing may be affected by it.
+ */
+#define igt_abort_on_f(expr, f...) \
+ do { if ((expr)) \
+ __igt_abort(IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, #expr , f); \
+ } while (0)
+
/* fork support code */
bool __igt_fork(void);