summaryrefslogtreecommitdiff
path: root/lib/igt_core.c
diff options
context:
space:
mode:
authorTim Gore <tim.gore@intel.com>2014-09-29 13:34:30 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-09-29 16:57:49 +0200
commitf33fa71481caa308f141797033cd2bc6479630fc (patch)
tree4b493ccb19a71e9e6455b9030e5e4f5edffa9df2 /lib/igt_core.c
parent32a0308e2da1ed5871e21ca81822fc0c8aa73f9e (diff)
lib/igt_core: make single/simple tests use igt_exit
Currently tests that use igt_simple_main will simply call "exit()" if they pass, making it difficult to ensure that any required cleanup is done. At present this is not an issue, but it will be when I submit a patch to turn off the lowmemorykiller for all tests. Signed-off-by: Tim Gore <tim.gore@intel.com> [danvet: Also update api docs.] Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Diffstat (limited to 'lib/igt_core.c')
-rw-r--r--lib/igt_core.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 5d414683..1b893d06 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -641,7 +641,7 @@ bool igt_only_list_subtests(void)
static bool skipped_one = false;
static bool succeeded_one = false;
static bool failed_one = false;
-static int igt_exitcode;
+static int igt_exitcode = IGT_EXIT_SUCCESS;
static void exit_subtest(const char *) __attribute__((noreturn));
static void exit_subtest(const char *result)
@@ -692,7 +692,8 @@ void igt_skip(const char *f, ...)
assert(in_fixture);
__igt_fixture_end();
} else {
- exit(IGT_EXIT_SKIP);
+ igt_exitcode = IGT_EXIT_SKIP;
+ igt_exit();
}
}
@@ -786,7 +787,7 @@ void igt_fail(int exitcode)
__igt_fixture_end();
}
- exit(exitcode);
+ igt_exit();
}
}
@@ -838,10 +839,9 @@ void __igt_fail_assert(int exitcode, const char *file,
* everything has worked out. For subtests it also checks that at least one
* subtest has been run (save when only listing subtests.
*
- * It is an error to normally exit a test with subtests without calling
- * igt_exit() - without it the result reporting will be wrong. To avoid such
- * issues it is highly recommended to use #igt_main instead of a hand-rolled
- * main() function.
+ * It is an error to normally exit a test calling igt_exit() - without it the
+ * result reporting will be wrong. To avoid such issues it is highly recommended
+ * to use #igt_main or #igt_simple_main instead of a hand-rolled main() function.
*/
void igt_exit(void)
{
@@ -857,7 +857,7 @@ void igt_exit(void)
exit(IGT_EXIT_SUCCESS);
if (!test_with_subtests)
- exit(IGT_EXIT_SUCCESS);
+ exit(igt_exitcode);
/* Calling this without calling one of the above is a failure */
assert(skipped_one || succeeded_one || failed_one);