summaryrefslogtreecommitdiff
path: root/lib/igt_core.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-05-03 11:04:00 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2016-05-03 12:12:37 +0100
commitf201495575a36b2c2202a45c34dd304cb40d7d3f (patch)
tree27866cef2e3318dc346a65823afc1b3f8715c980 /lib/igt_core.c
parent9f2621e1b5301f33c676a99c52879d3c6984b524 (diff)
lib: compute exitcode first
Before we print the exitcode to the debug/kmsg logs, we should inspect what its final value will be. For example, in the case of running multiple subtests which all happen to be skipped, igt_exitcode is 0, but the final exit code will be 77. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Tested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'lib/igt_core.c')
-rw-r--r--lib/igt_core.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 4f23b12d..56061c3a 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1153,10 +1153,22 @@ void igt_exit(void)
exit(IGT_EXIT_INVALID);
}
-
if (igt_only_list_subtests())
exit(IGT_EXIT_SUCCESS);
+ /* Calling this without calling one of the above is a failure */
+ assert(!test_with_subtests ||
+ skipped_one ||
+ succeeded_one ||
+ failed_one);
+
+ if (test_with_subtests && !failed_one) {
+ if (succeeded_one)
+ igt_exitcode = IGT_EXIT_SUCCESS;
+ else
+ igt_exitcode = IGT_EXIT_SKIP;
+ }
+
kmsg(KERN_INFO "%s: exiting, ret=%d\n", command_str, igt_exitcode);
igt_debug("Exiting with status code %d\n", igt_exitcode);
@@ -1183,19 +1195,11 @@ void igt_exit(void)
result = "FAIL";
}
- printf("%s (%.3fs)\n", result, time_elapsed(&subtest_time, &now));
- exit(igt_exitcode);
+ printf("%s (%.3fs)\n",
+ result, time_elapsed(&subtest_time, &now));
}
- /* Calling this without calling one of the above is a failure */
- assert(skipped_one || succeeded_one || failed_one);
-
- if (failed_one)
- exit(igt_exitcode);
- else if (succeeded_one)
- exit(IGT_EXIT_SUCCESS);
- else
- exit(IGT_EXIT_SKIP);
+ exit(igt_exitcode);
}
/* fork support code */