mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-11 18:06:13 +00:00
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>
This commit is contained in:
parent
c03d58595e
commit
17eb062661
@ -564,7 +564,7 @@ void igt_skip(const char *f, ...)
|
|||||||
assert(in_fixture);
|
assert(in_fixture);
|
||||||
__igt_fixture_end();
|
__igt_fixture_end();
|
||||||
} else {
|
} else {
|
||||||
exit(77);
|
exit(IGT_EXIT_SKIP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,7 +630,7 @@ void igt_success(void)
|
|||||||
*/
|
*/
|
||||||
void igt_fail(int exitcode)
|
void igt_fail(int exitcode)
|
||||||
{
|
{
|
||||||
assert(exitcode != 0 && exitcode != 77);
|
assert(exitcode != IGT_EXIT_SUCCESS && exitcode != IGT_EXIT_SKIP);
|
||||||
|
|
||||||
if (!failed_one)
|
if (!failed_one)
|
||||||
igt_exitcode = exitcode;
|
igt_exitcode = exitcode;
|
||||||
@ -642,7 +642,7 @@ void igt_fail(int exitcode)
|
|||||||
exit(exitcode);
|
exit(exitcode);
|
||||||
|
|
||||||
if (in_subtest) {
|
if (in_subtest) {
|
||||||
if (exitcode == 78)
|
if (exitcode == IGT_EXIT_TIMEOUT)
|
||||||
exit_subtest("TIMEOUT");
|
exit_subtest("TIMEOUT");
|
||||||
else
|
else
|
||||||
exit_subtest("FAIL");
|
exit_subtest("FAIL");
|
||||||
@ -710,10 +710,10 @@ void igt_exit(void)
|
|||||||
igt_exit_called = true;
|
igt_exit_called = true;
|
||||||
|
|
||||||
if (igt_only_list_subtests())
|
if (igt_only_list_subtests())
|
||||||
exit(0);
|
exit(IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
if (!test_with_subtests)
|
if (!test_with_subtests)
|
||||||
exit(0);
|
exit(IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
/* Calling this without calling one of the above is a failure */
|
/* Calling this without calling one of the above is a failure */
|
||||||
assert(skipped_one || succeeded_one || failed_one);
|
assert(skipped_one || succeeded_one || failed_one);
|
||||||
@ -721,9 +721,9 @@ void igt_exit(void)
|
|||||||
if (failed_one)
|
if (failed_one)
|
||||||
exit(igt_exitcode);
|
exit(igt_exitcode);
|
||||||
else if (succeeded_one)
|
else if (succeeded_one)
|
||||||
exit(0);
|
exit(IGT_EXIT_SUCCESS);
|
||||||
else
|
else
|
||||||
exit(77);
|
exit(IGT_EXIT_SKIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fork support code */
|
/* fork support code */
|
||||||
@ -1233,8 +1233,8 @@ static void igt_alarm_handler(int signal)
|
|||||||
/* subsequent tests are skipped */
|
/* subsequent tests are skipped */
|
||||||
skip_subtests_henceforth = SKIP;
|
skip_subtests_henceforth = SKIP;
|
||||||
|
|
||||||
/* exit with status 78 to indicate timeout */
|
/* exit with timeout status */
|
||||||
igt_fail(78);
|
igt_fail(IGT_EXIT_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1242,9 +1242,9 @@ static void igt_alarm_handler(int signal)
|
|||||||
* @seconds: number of seconds before timeout
|
* @seconds: number of seconds before timeout
|
||||||
*
|
*
|
||||||
* Stop the current test and skip any subsequent tests after the specified
|
* Stop the current test and skip any subsequent tests after the specified
|
||||||
* number of seconds have elapsed. The test will exit with "timeout" status
|
* number of seconds have elapsed. The test will exit with #IGT_EXIT_TIMEOUT
|
||||||
* (78). Any previous timer is cancelled and no timeout is scheduled if @seconds
|
* status. Any previous timer is cancelled and no timeout is scheduled if
|
||||||
* is zero.
|
* @seconds is zero.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void igt_set_timeout(unsigned int seconds)
|
void igt_set_timeout(unsigned int seconds)
|
||||||
|
@ -37,6 +37,28 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdarg.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);
|
bool __igt_fixture(void);
|
||||||
void __igt_fixture_complete(void);
|
void __igt_fixture_complete(void);
|
||||||
void __igt_fixture_end(void) __attribute__((noreturn));
|
void __igt_fixture_end(void) __attribute__((noreturn));
|
||||||
|
@ -16,11 +16,11 @@ int main(void)
|
|||||||
|
|
||||||
fd = drm_open_any();
|
fd = drm_open_any();
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return 77;
|
return IGT_EXIT_SKIP;
|
||||||
|
|
||||||
alarm(1);
|
alarm(1);
|
||||||
if (ioctl(fd, DRM_IOCTL_I915_GEM_SW_FINISH, &arg) == 0)
|
if (ioctl(fd, DRM_IOCTL_I915_GEM_SW_FINISH, &arg) == 0)
|
||||||
return 77;
|
return IGT_EXIT_SKIP;
|
||||||
|
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
case ENOENT:
|
case ENOENT:
|
||||||
|
@ -95,10 +95,10 @@ int main(int argc, char **argv)
|
|||||||
/* simple tests */
|
/* simple tests */
|
||||||
simple = true;
|
simple = true;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
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(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == 0);
|
assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
/* subtests, list mode */
|
/* subtests, list mode */
|
||||||
simple = false;
|
simple = false;
|
||||||
@ -106,25 +106,25 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
in_fixture = false;
|
in_fixture = false;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
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(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == 0);
|
assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
in_fixture = true;
|
in_fixture = true;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
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(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == 0);
|
assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
in_fixture = false;
|
in_fixture = false;
|
||||||
in_subtest = true;
|
in_subtest = true;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
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(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == 0);
|
assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
/* subtest, run mode */
|
/* subtest, run mode */
|
||||||
simple = false;
|
simple = false;
|
||||||
@ -132,25 +132,25 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
in_fixture = false;
|
in_fixture = false;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
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(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == 0);
|
assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
in_fixture = true;
|
in_fixture = true;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
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(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == 0);
|
assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
in_fixture = false;
|
in_fixture = false;
|
||||||
in_subtest = true;
|
in_subtest = true;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
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(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == 0);
|
assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user