shared: Add timespec_eq helper function

Add a helper function to check if two struct timespec values are equal.
This helper function will be used in upcoming commits that implement the
input_timestamps_unstable_v1 protocol.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Alexandros Frantzis
2018-02-16 18:44:14 +02:00
committed by Pekka Paalanen
parent 2d8331c4b7
commit 7a93bb2f17
2 changed files with 25 additions and 0 deletions
+12
View File
@@ -294,3 +294,15 @@ ZUC_TEST(timespec_test, timespec_is_zero)
ZUC_ASSERT_FALSE(timespec_is_zero(&non_zero_nsec));
ZUC_ASSERT_FALSE(timespec_is_zero(&non_zero_sec));
}
ZUC_TEST(timespec_test, timespec_eq)
{
struct timespec a = { .tv_sec = 2, .tv_nsec = 1 };
struct timespec b = { .tv_sec = -1, .tv_nsec = 2 };
ZUC_ASSERT_TRUE(timespec_eq(&a, &a));
ZUC_ASSERT_TRUE(timespec_eq(&b, &b));
ZUC_ASSERT_FALSE(timespec_eq(&a, &b));
ZUC_ASSERT_FALSE(timespec_eq(&b, &a));
}