summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlexandros Frantzis <alexandros.frantzis@collabora.com>2017-12-13 13:27:53 +0200
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2017-12-18 11:27:43 +0200
commit787fa611de1b7c4144b7491260c513a5ec0a4728 (patch)
tree8417d4dfcf7f13ce9c2b18ada1400ef7105b5a2c /tests
parentc83fdaa55568b1177f8f4752a5ce352fd0c32a69 (diff)
shared: Add timespec_from_proto helper function
Add helper function to convert tv_sec_hi, tv_sec_lo, tv_nsec triplets, used for sending high-resolution timestamp data over the wayland protocol, to struct timespec values. Replace existing conversion code with the helper function. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'tests')
-rw-r--r--tests/presentation-test.c9
-rw-r--r--tests/timespec-test.c17
2 files changed, 18 insertions, 8 deletions
diff --git a/tests/presentation-test.c b/tests/presentation-test.c
index f12f8eef..f6ffe480 100644
--- a/tests/presentation-test.c
+++ b/tests/presentation-test.c
@@ -34,6 +34,7 @@
#include "shared/helpers.h"
#include "shared/xalloc.h"
+#include "shared/timespec-util.h"
#include "weston-test-client-helper.h"
#include "presentation-time-client-protocol.h"
@@ -86,14 +87,6 @@ struct feedback {
};
static void
-timespec_from_proto(struct timespec *tm, uint32_t tv_sec_hi,
- uint32_t tv_sec_lo, uint32_t tv_nsec)
-{
- tm->tv_sec = ((uint64_t)tv_sec_hi << 32) + tv_sec_lo;
- tm->tv_nsec = tv_nsec;
-}
-
-static void
feedback_sync_output(void *data,
struct wp_presentation_feedback *presentation_feedback,
struct wl_output *output)
diff --git a/tests/timespec-test.c b/tests/timespec-test.c
index f10ed76c..a4d8dcfb 100644
--- a/tests/timespec-test.c
+++ b/tests/timespec-test.c
@@ -238,6 +238,23 @@ ZUC_TEST(timespec_test, timespec_from_msec)
ZUC_ASSERT_EQ(1000000, a.tv_nsec);
}
+ZUC_TEST(timespec_test, timespec_from_proto)
+{
+ struct timespec a;
+
+ timespec_from_proto(&a, 0, 0, 0);
+ ZUC_ASSERT_EQ(0, a.tv_sec);
+ ZUC_ASSERT_EQ(0, a.tv_nsec);
+
+ timespec_from_proto(&a, 0, 1234, 9999);
+ ZUC_ASSERT_EQ(1234, a.tv_sec);
+ ZUC_ASSERT_EQ(9999, a.tv_nsec);
+
+ timespec_from_proto(&a, 0x1234, 0x5678, 1);
+ ZUC_ASSERT_EQ((time_t)0x0000123400005678LL, a.tv_sec);
+ ZUC_ASSERT_EQ(1, a.tv_nsec);
+}
+
ZUC_TEST(timespec_test, timespec_is_zero)
{
struct timespec zero = { 0 };