diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-03-18 09:04:07 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-03-18 09:20:06 +0000 |
commit | dcb39b5270b5ff4d91a595ae05c9e74528bce546 (patch) | |
tree | b143137cbd6bd756d5d4fbf5656ef65a42faf101 /lib/igt_core.h | |
parent | 34098b71fa1b365ffb0c12fb84ebb7aa26c8f300 (diff) |
igt/gem_softpin: Repeat tests with signal interruptions
For the long running tests probing error conditions, throwing in the
signal interruptions is a good idea.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_core.h')
-rw-r--r-- | lib/igt_core.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/igt_core.h b/lib/igt_core.h index 9314ae94..124ae0d9 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -32,6 +32,7 @@ #include <setjmp.h> #include <stdbool.h> +#include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -775,6 +776,40 @@ extern enum igt_log_level igt_log_level; void igt_set_timeout(unsigned int seconds, const char *op); +/** + * igt_nsec_elapsed: + * @start: measure from this point in time + * + * Reports the difference in the monotonic clock from the start time + * in nanoseconds. On the first invocation, start should be zeroed and will + * be set by the call. + * + * Typical use would be: + * + * igt_subtest("test") { + * struct timespec start = {}; + * while (igt_nsec_elapsed(&start) < test_timeout_ns) + * do_test(); + * } + * + * A handy approximation is to use nsec >> 30 to convert to seconds, + * nsec >> 20 to convert to milliseconds - the error is about 8%, acceptable + * for test run times. + */ +uint64_t igt_nsec_elapsed(struct timespec *start); + +/** + * igt_seconds_elapsed: + * @start: measure from this point in time + * + * A wrapper around igt_nsec_elapsed that reports the approximate (8% error) + * number of seconds since the start point. + */ +static inline uint32_t igt_seconds_elapsed(struct timespec *start) +{ + return igt_nsec_elapsed(start) >> 30; +} + void igt_reset_timeout(void); FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir, |