From: Thomas Wood Date: Tue, 13 May 2014 14:22:52 +0000 (+0100) Subject: lib: add exit status defines X-Git-Tag: intel-gpu-tools-1.7~81 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=17eb062661e02a3cea97c4893d373ce8124a0b94;p=profile%2Fextras%2Fintel-gpu-tools.git lib: add exit status defines Add defines for success, skip and timeout exit statuses. Suggested-by: Daniel Vetter Signed-off-by: Thomas Wood --- diff --git a/lib/igt_core.c b/lib/igt_core.c index 54f87c0..05bc19b 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 3a6ee1a..f7f7015 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -37,6 +37,28 @@ #include #include +/** + * 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 776db07..f87b1cb 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 6c076ff..15cbe64 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; }