[PATCH libevdev 5/5] Remove wrong libevdev clock test

Peter Hutterer peter.hutterer at who-t.net
Fri Oct 4 22:44:17 PDT 2013


On 5/10/13 04:37 , David Herrmann wrote:
> 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 | 1 -
>   1 file changed, 1 deletion(-)
>
> diff --git a/test/test-libevdev-init.c b/test/test-libevdev-init.c
> index 7d4376d..c6adc40 100644
> --- a/test/test-libevdev-init.c
> +++ b/test/test-libevdev-init.c
> @@ -343,7 +343,6 @@ START_TEST(test_clock_id_events)
>   	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);

IMO a better approach would be to calculate the full time as tv_sec * 
1000000 + tv_usec and then compare the two times.

Cheers,
   Peter


>
>   	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);
>



More information about the Input-tools mailing list