diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-10-28 17:16:43 +0100 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-10-31 11:23:13 +1000 |
commit | 639a5a9b56644c5c6f3d83bac661f5d97e39d1a9 (patch) | |
tree | 41cf909b466d52875b859e13b14446df39c57b99 | |
parent | 34d52e143d179067d9e0cf35bf6983974f71d731 (diff) |
Fix wrong libevdev clock test
We can rely on CLOCK_MONOTONIC and CLOCK_REALTIME to be different at any
time. However, this does not apply to the ms/us/ns parts of the current
time. Both may be in sync regarding the current micro-seconds state. So
remove the wrong clock us-comparison.
I was able to trigger this on my machine. Chances that both are in sync
are very low so I assume my RTC only provides low granularity and thus
both clocks are sync during boot for higher granularity.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | test/test-libevdev-init.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test/test-libevdev-init.c b/test/test-libevdev-init.c index 7d4376d..bf0b874 100644 --- a/test/test-libevdev-init.c +++ b/test/test-libevdev-init.c @@ -22,6 +22,7 @@ #include <config.h> #include <errno.h> +#include <inttypes.h> #include <unistd.h> #include <time.h> #include <sys/types.h> @@ -304,6 +305,7 @@ START_TEST(test_clock_id_events) struct input_event ev1, ev2; struct timespec t1_real, t2_real; struct timespec t1_mono, t2_mono; + int64_t t1, t2; rc = test_create_device(&uidev, &dev, EV_SYN, SYN_REPORT, @@ -342,8 +344,9 @@ START_TEST(test_clock_id_events) ck_assert_int_eq(ev1.code, ev2.code); ck_assert_int_eq(ev1.value, ev2.value); - ck_assert_int_ne(ev1.time.tv_sec, ev2.time.tv_sec); - ck_assert_int_ne(ev1.time.tv_usec, ev2.time.tv_usec); + t1 = ev1.time.tv_sec * 1000000LL + ev1.time.tv_usec; + t2 = ev2.time.tv_sec * 1000000LL + ev2.time.tv_usec; + ck_assert_int_ne(t1, t2); ck_assert_int_ge(ev1.time.tv_sec, t1_real.tv_sec); ck_assert_int_ge(ev1.time.tv_usec, t1_real.tv_nsec/1000); |