[PATCH libinput 1/3] test: Handle 32 bit msec time overflows
Jonas Ådahl
jadahl at gmail.com
Fri Apr 8 07:51:26 UTC 2016
The libinput_*_get_time() returns a 32 bit unsigned integer, but in the
tests we compared them to a 64 bit unsigned integer. This means that
when the 32 bit integer overflowed, we'd still compare to a
non-overflowed 64 bit integer, causing the tests to fail.
This commit fixes this by always casting the millisecond 64 bit unsigned
integer to a 32 unsigned integer, triggering the same overflow.
Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---
test/gestures.c | 4 +++-
test/keyboard.c | 4 +++-
test/pointer.c | 4 +++-
test/tablet.c | 4 +++-
test/touch.c | 4 +++-
test/touchpad.c | 2 +-
6 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/test/gestures.c b/test/gestures.c
index 8140147..8ab01b6 100644
--- a/test/gestures.c
+++ b/test/gestures.c
@@ -1127,6 +1127,7 @@ START_TEST(gestures_time_usec)
struct libinput *li = dev->libinput;
struct libinput_event *event;
struct libinput_event_gesture *gevent;
+ uint64_t time_usec;
if (libevdev_get_num_slots(dev->evdev) < 3)
return;
@@ -1149,8 +1150,9 @@ START_TEST(gestures_time_usec)
gevent = litest_is_gesture_event(event,
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
3);
+ time_usec = libinput_event_gesture_get_time_usec(gevent);
ck_assert_int_eq(libinput_event_gesture_get_time(gevent),
- libinput_event_gesture_get_time_usec(gevent) / 1000);
+ (uint32_t) (time_usec / 1000));
libinput_event_destroy(event);
}
END_TEST
diff --git a/test/keyboard.c b/test/keyboard.c
index e9f3bcb..b2f9851 100644
--- a/test/keyboard.c
+++ b/test/keyboard.c
@@ -317,6 +317,7 @@ START_TEST(keyboard_time_usec)
struct libinput *li = dev->libinput;
struct libinput_event_keyboard *kev;
struct libinput_event *event;
+ uint64_t time_usec;
if (!libevdev_has_event_code(dev->evdev, EV_KEY, KEY_A))
return;
@@ -332,8 +333,9 @@ START_TEST(keyboard_time_usec)
KEY_A,
LIBINPUT_KEY_STATE_PRESSED);
+ time_usec = libinput_event_keyboard_get_time_usec(kev);
ck_assert_int_eq(libinput_event_keyboard_get_time(kev),
- libinput_event_keyboard_get_time_usec(kev) / 1000);
+ (uint32_t) (time_usec / 1000));
libinput_event_destroy(event);
litest_drain_events(dev->libinput);
diff --git a/test/pointer.c b/test/pointer.c
index d043fa8..32e3fd2 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -1559,6 +1559,7 @@ START_TEST(pointer_time_usec)
struct libinput *li = dev->libinput;
struct libinput_event_pointer *ptrev;
struct libinput_event *event;
+ uint64_t time_usec;
litest_drain_events(dev->libinput);
@@ -1571,8 +1572,9 @@ START_TEST(pointer_time_usec)
event = libinput_get_event(li);
ptrev = litest_is_motion_event(event);
+ time_usec = libinput_event_pointer_get_time_usec(ptrev);
ck_assert_int_eq(libinput_event_pointer_get_time(ptrev),
- libinput_event_pointer_get_time_usec(ptrev) / 1000);
+ (uint32_t) (time_usec / 1000));
libinput_event_destroy(event);
litest_drain_events(dev->libinput);
diff --git a/test/tablet.c b/test/tablet.c
index ad6ac45..28cf0da 100644
--- a/test/tablet.c
+++ b/test/tablet.c
@@ -2679,6 +2679,7 @@ START_TEST(tablet_time_usec)
{ ABS_PRESSURE, 0 },
{ -1, -1 }
};
+ uint64_t time_usec;
litest_drain_events(li);
@@ -2688,8 +2689,9 @@ START_TEST(tablet_time_usec)
event = libinput_get_event(li);
tev = litest_is_tablet_event(event,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+ time_usec = libinput_event_tablet_tool_get_time_usec(tev);
ck_assert_int_eq(libinput_event_tablet_tool_get_time(tev),
- libinput_event_tablet_tool_get_time_usec(tev) / 1000);
+ (uint32_t) (time_usec / 1000));
libinput_event_destroy(event);
}
END_TEST
diff --git a/test/touch.c b/test/touch.c
index eae8007..a2a506b 100644
--- a/test/touch.c
+++ b/test/touch.c
@@ -658,6 +658,7 @@ START_TEST(touch_time_usec)
struct libinput *li = dev->libinput;
struct libinput_event *event;
struct libinput_event_touch *tev;
+ uint64_t time_usec;
litest_drain_events(dev->libinput);
@@ -667,8 +668,9 @@ START_TEST(touch_time_usec)
event = libinput_get_event(li);
tev = litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_DOWN);
+ time_usec = libinput_event_touch_get_time_usec(tev);
ck_assert_int_eq(libinput_event_touch_get_time(tev),
- libinput_event_touch_get_time_usec(tev) / 1000);
+ (uint32_t) (time_usec / 1000));
libinput_event_destroy(event);
}
END_TEST
diff --git a/test/touchpad.c b/test/touchpad.c
index a58b337..45e0a6d 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -4017,7 +4017,7 @@ START_TEST(touchpad_time_usec)
utime = libinput_event_pointer_get_time_usec(ptrev);
ck_assert_int_eq(libinput_event_pointer_get_time(ptrev),
- utime / 1000);
+ (uint32_t) (utime / 1000));
libinput_event_destroy(event);
event = libinput_get_event(li);
}
--
2.4.3
More information about the wayland-devel
mailing list