summaryrefslogtreecommitdiff
path: root/lib/igt_core.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-03-18 09:04:07 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2016-03-18 09:20:06 +0000
commitdcb39b5270b5ff4d91a595ae05c9e74528bce546 (patch)
treeb143137cbd6bd756d5d4fbf5656ef65a42faf101 /lib/igt_core.c
parent34098b71fa1b365ffb0c12fb84ebb7aa26c8f300 (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.c')
-rw-r--r--lib/igt_core.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 4ade5491..3c092a5f 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -396,6 +396,23 @@ error:
return -errno;
}
+#define MSEC_PER_SEC (1000)
+#define USEC_PER_SEC (1000*MSEC_PER_SEC)
+#define NSEC_PER_SEC (1000*USEC_PER_SEC)
+uint64_t igt_nsec_elapsed(struct timespec *start)
+{
+ struct timespec now;
+
+ gettime(&now);
+ if ((start->tv_sec | start->tv_nsec) == 0) {
+ *start = now;
+ return 0;
+ }
+
+ return ((now.tv_nsec - start->tv_nsec) +
+ NSEC_PER_SEC*(now.tv_sec - start->tv_sec));
+}
+
bool __igt_fixture(void)
{
assert(!in_fixture);