diff options
author | Mark Brown <broonie@kernel.org> | 2020-12-28 14:20:00 +0000 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-12-28 14:20:00 +0000 |
commit | 2ae6f64ce1ce304b502461fdfe0b96c8171ae2cc (patch) | |
tree | 88e987c447daf2c29e2d4c15e58d1029b0cc78c2 /tools/testing/selftests/kvm/lib/test_util.c | |
parent | 3b66e4a8e58a85af3212c7117d7a29c9ef6679a2 (diff) | |
parent | 5c8fe583cce542aa0b84adc939ce85293de36e5e (diff) |
Merge tag 'v5.11-rc1' into regulator-5.11
Linux 5.11-rc1
Diffstat (limited to 'tools/testing/selftests/kvm/lib/test_util.c')
-rw-r--r-- | tools/testing/selftests/kvm/lib/test_util.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/selftests/kvm/lib/test_util.c index 689e97c27ee2..8e04c0b1608e 100644 --- a/tools/testing/selftests/kvm/lib/test_util.c +++ b/tools/testing/selftests/kvm/lib/test_util.c @@ -4,10 +4,13 @@ * * Copyright (C) 2020, Google LLC. */ -#include <stdlib.h> + +#include <assert.h> #include <ctype.h> #include <limits.h> -#include <assert.h> +#include <stdlib.h> +#include <time.h> + #include "test_util.h" /* @@ -81,6 +84,21 @@ struct timespec timespec_sub(struct timespec ts1, struct timespec ts2) return timespec_add_ns((struct timespec){0}, ns1 - ns2); } +struct timespec timespec_diff_now(struct timespec start) +{ + struct timespec end; + + clock_gettime(CLOCK_MONOTONIC, &end); + return timespec_sub(end, start); +} + +struct timespec timespec_div(struct timespec ts, int divisor) +{ + int64_t ns = timespec_to_ns(ts) / divisor; + + return timespec_add_ns((struct timespec){0}, ns); +} + void print_skip(const char *fmt, ...) { va_list ap; |