summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Wood <thomas.wood@intel.com>2014-05-13 15:22:52 +0100
committerThomas Wood <thomas.wood@intel.com>2014-05-14 12:33:02 +0100
commit17eb062661e02a3cea97c4893d373ce8124a0b94 (patch)
tree5388fc2aa8b9e29d3773820b417aa06f17cd7267
parentc03d58595e23d155aa470e60e6debaa0ee357a1b (diff)
lib: add exit status defines
Add defines for success, skip and timeout exit statuses. Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
-rw-r--r--lib/igt_core.c24
-rw-r--r--lib/igt_core.h22
-rw-r--r--tests/gem_alive.c4
-rw-r--r--tests/igt_simulation.c28
4 files changed, 50 insertions, 28 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 54f87c0f..05bc19bc 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -564,7 +564,7 @@ void igt_skip(const char *f, ...)
assert(in_fixture);
__igt_fixture_end();
} else {
- exit(77);
+ exit(IGT_EXIT_SKIP);
}
}
@@ -630,7 +630,7 @@ void igt_success(void)
*/
void igt_fail(int exitcode)
{
- assert(exitcode != 0 && exitcode != 77);
+ assert(exitcode != IGT_EXIT_SUCCESS && exitcode != IGT_EXIT_SKIP);
if (!failed_one)
igt_exitcode = exitcode;
@@ -642,7 +642,7 @@ void igt_fail(int exitcode)
exit(exitcode);
if (in_subtest) {
- if (exitcode == 78)
+ if (exitcode == IGT_EXIT_TIMEOUT)
exit_subtest("TIMEOUT");
else
exit_subtest("FAIL");
@@ -710,10 +710,10 @@ void igt_exit(void)
igt_exit_called = true;
if (igt_only_list_subtests())
- exit(0);
+ exit(IGT_EXIT_SUCCESS);
if (!test_with_subtests)
- exit(0);
+ exit(IGT_EXIT_SUCCESS);
/* Calling this without calling one of the above is a failure */
assert(skipped_one || succeeded_one || failed_one);
@@ -721,9 +721,9 @@ void igt_exit(void)
if (failed_one)
exit(igt_exitcode);
else if (succeeded_one)
- exit(0);
+ exit(IGT_EXIT_SUCCESS);
else
- exit(77);
+ exit(IGT_EXIT_SKIP);
}
/* fork support code */
@@ -1233,8 +1233,8 @@ static void igt_alarm_handler(int signal)
/* subsequent tests are skipped */
skip_subtests_henceforth = SKIP;
- /* exit with status 78 to indicate timeout */
- igt_fail(78);
+ /* exit with timeout status */
+ igt_fail(IGT_EXIT_TIMEOUT);
}
/**
@@ -1242,9 +1242,9 @@ static void igt_alarm_handler(int signal)
* @seconds: number of seconds before timeout
*
* Stop the current test and skip any subsequent tests after the specified
- * number of seconds have elapsed. The test will exit with "timeout" status
- * (78). Any previous timer is cancelled and no timeout is scheduled if @seconds
- * is zero.
+ * number of seconds have elapsed. The test will exit with #IGT_EXIT_TIMEOUT
+ * status. Any previous timer is cancelled and no timeout is scheduled if
+ * @seconds is zero.
*
*/
void igt_set_timeout(unsigned int seconds)
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 3a6ee1a4..f7f7015a 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -37,6 +37,28 @@
#include <sys/types.h>
#include <stdarg.h>
+/**
+ * IGT_EXIT_TIMEOUT:
+ *
+ * Exit status indicating a timeout occurred.
+ */
+#define IGT_EXIT_TIMEOUT 78
+
+/**
+ * IGT_EXIT_SKIP:
+ *
+ * Exit status indicating the test was skipped.
+ */
+#define IGT_EXIT_SKIP 77
+
+/**
+ * IGT_EXIT_SUCCESS
+ *
+ * Exit status indicating the test executed successfully.
+ */
+#define IGT_EXIT_SUCCESS 0
+
+
bool __igt_fixture(void);
void __igt_fixture_complete(void);
void __igt_fixture_end(void) __attribute__((noreturn));
diff --git a/tests/gem_alive.c b/tests/gem_alive.c
index 776db07a..f87b1cbb 100644
--- a/tests/gem_alive.c
+++ b/tests/gem_alive.c
@@ -16,11 +16,11 @@ int main(void)
fd = drm_open_any();
if (fd < 0)
- return 77;
+ return IGT_EXIT_SKIP;
alarm(1);
if (ioctl(fd, DRM_IOCTL_I915_GEM_SW_FINISH, &arg) == 0)
- return 77;
+ return IGT_EXIT_SKIP;
switch (errno) {
case ENOENT:
diff --git a/tests/igt_simulation.c b/tests/igt_simulation.c
index 6c076ff3..15cbe642 100644
--- a/tests/igt_simulation.c
+++ b/tests/igt_simulation.c
@@ -95,10 +95,10 @@ int main(int argc, char **argv)
/* simple tests */
simple = true;
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
- assert(do_fork() == 77);
+ assert(do_fork() == IGT_EXIT_SKIP);
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
- assert(do_fork() == 0);
+ assert(do_fork() == IGT_EXIT_SUCCESS);
/* subtests, list mode */
simple = false;
@@ -106,25 +106,25 @@ int main(int argc, char **argv)
in_fixture = false;
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
- assert(do_fork() == 0);
+ assert(do_fork() == IGT_EXIT_SUCCESS);
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
- assert(do_fork() == 0);
+ assert(do_fork() == IGT_EXIT_SUCCESS);
in_fixture = true;
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
- assert(do_fork() == 0);
+ assert(do_fork() == IGT_EXIT_SUCCESS);
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
- assert(do_fork() == 0);
+ assert(do_fork() == IGT_EXIT_SUCCESS);
in_fixture = false;
in_subtest = true;
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
- assert(do_fork() == 0);
+ assert(do_fork() == IGT_EXIT_SUCCESS);
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
- assert(do_fork() == 0);
+ assert(do_fork() == IGT_EXIT_SUCCESS);
/* subtest, run mode */
simple = false;
@@ -132,25 +132,25 @@ int main(int argc, char **argv)
in_fixture = false;
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
- assert(do_fork() == 77);
+ assert(do_fork() == IGT_EXIT_SKIP);
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
- assert(do_fork() == 0);
+ assert(do_fork() == IGT_EXIT_SUCCESS);
in_fixture = true;
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
- assert(do_fork() == 77);
+ assert(do_fork() == IGT_EXIT_SKIP);
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
- assert(do_fork() == 0);
+ assert(do_fork() == IGT_EXIT_SUCCESS);
in_fixture = false;
in_subtest = true;
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
- assert(do_fork() == 77);
+ assert(do_fork() == IGT_EXIT_SKIP);
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
- assert(do_fork() == 0);
+ assert(do_fork() == IGT_EXIT_SUCCESS);
return 0;
}