From 12f052b5604fffb852bf66250b89fec56641733c Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 1 Aug 2016 12:58:13 +0100 Subject: igt/gem_mmap_gtt/wc: Reduce test runtime Add a new iterator macro to run for a specified number of milliseconds. Signed-off-by: Chris Wilson --- lib/igt_aux.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/igt_aux.h') diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 5627cb04..7f5a7cfd 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -85,6 +85,19 @@ bool __igt_sigiter_continue(struct __igt_sigiter *iter, bool interrupt); #define igt_until_timeout(timeout) \ for (struct timespec t__={}; igt_seconds_elapsed(&t__) < (timeout); ) +/** + * igt_for_milliseconds: + * @time: how long to run the loop in milliseconds + * + * Convenience macro loop to run the provided code block in a loop until the + * target interval has expired. Of course when an individual execution takes + * too long, the actual execution time could be a lot longer. + * + * The code block will be executed at least once. + */ +#define igt_for_milliseconds(t) \ + for (struct timespec t__={}; igt_nsec_elapsed(&t__)>>20 < (t); ) + void igt_exchange_int(void *array, unsigned i, unsigned j); void igt_permute_array(void *array, unsigned size, void (*exchange_func)(void *array, -- cgit v1.2.3