[PATCH libevdev v2 1/5] Remove wrong libevdev clock test
David Herrmann
dh.herrmann at gmail.com
Mon Oct 28 17:16:43 CET 2013
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 at gmail.com>
---
test/test-libevdev-init.c | 7 +++++--
1 file 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);
--
1.8.4.1
More information about the Input-tools
mailing list