diff options
author | Paulo Zanoni <paulo.r.zanoni@intel.com> | 2014-12-03 16:12:49 -0200 |
---|---|---|
committer | Paulo Zanoni <paulo.r.zanoni@intel.com> | 2015-05-05 17:27:49 -0300 |
commit | 9bb04d3aa6a2b1b86e091967e312a19ce337df4d (patch) | |
tree | 4bc4ddc0b7f75b5c8156599f36dc08991b223811 /lib/igt_aux.c | |
parent | a734ac2058fd0cce842a4290335c0697d89b2d63 (diff) |
lib: add igt_wait()
Just a little helper for code that needs to wait for a certain
condition to happen. It has the nice advantage that it can survive the
signal helper.
Despite the callers added in this patch, there is another that will go
in a separate patch, and another in a new IGT test file that I plan to
push later.
v2: Check COND again before returning in case we hit the timeout.
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Diffstat (limited to 'lib/igt_aux.c')
-rw-r--r-- | lib/igt_aux.c | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/lib/igt_aux.c b/lib/igt_aux.c index e011ef4e..84b84e4a 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -606,29 +606,13 @@ enum igt_runtime_pm_status igt_get_runtime_pm_status(void) * Waits until for the driver to switch to into the desired runtime PM status, * with a 10 second timeout. * - * Some subtests call this function while the signal helper is active, so we - * can't assume each usleep() call will sleep for 100ms. - * * Returns: * True if the desired runtime PM status was attained, false if the operation * timed out. */ bool igt_wait_for_pm_status(enum igt_runtime_pm_status status) { - struct timeval start, end, diff; - - igt_assert(gettimeofday(&start, NULL) == 0); - do { - if (igt_get_runtime_pm_status() == status) - return true; - - usleep(100 * 1000); - - igt_assert(gettimeofday(&end, NULL) == 0); - timersub(&end, &start, &diff); - } while (diff.tv_sec < 10); - - return false; + return igt_wait(igt_get_runtime_pm_status() == status, 10000, 100); } /* Functions with prefix kmstest_ independent of cairo library are pulled out |