1 /*
2 * GStreamer AVTP Plugin
3 * Copyright (C) 2019 Intel Corporation
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later
9 * version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
20 */
21
22 #include <gst/check/gstcheck.h>
23 #include <gst/check/gstharness.h>
24
GST_START_TEST(test_clock_select_tai_clock)25 GST_START_TEST (test_clock_select_tai_clock)
26 {
27 GstHarness *h;
28 GstElement *element;
29 GstClock *clock;
30 guint clock_type;
31
32 h = gst_harness_new_parse ("clockselect clock-id=tai");
33
34 /* Check if element provides right clock */
35 element = gst_harness_find_element (h, "clockselect");
36 clock = gst_element_provide_clock (element);
37
38 fail_unless (GST_IS_SYSTEM_CLOCK (clock));
39 g_object_get (G_OBJECT (clock), "clock-type", &clock_type, NULL);
40 fail_unless_equals_uint64 (clock_type, GST_CLOCK_TYPE_TAI);
41
42 gst_object_unref (element);
43 gst_object_unref (clock);
44 gst_harness_teardown (h);
45 }
46
47 GST_END_TEST;
48
GST_START_TEST(test_clock_select_realtime_clock)49 GST_START_TEST (test_clock_select_realtime_clock)
50 {
51 GstHarness *h;
52 GstElement *element;
53 GstClock *clock;
54 guint clock_type;
55
56 h = gst_harness_new_parse ("clockselect clock-id=realtime");
57
58 /* Check if element provides right clock */
59 element = gst_harness_find_element (h, "clockselect");
60 clock = gst_element_provide_clock (element);
61
62 fail_unless (GST_IS_SYSTEM_CLOCK (clock));
63 g_object_get (G_OBJECT (clock), "clock-type", &clock_type, NULL);
64 fail_unless_equals_uint64 (clock_type, GST_CLOCK_TYPE_REALTIME);
65
66 gst_object_unref (element);
67 gst_object_unref (clock);
68 gst_harness_teardown (h);
69 }
70
71 GST_END_TEST;
72
GST_START_TEST(test_clock_select_monotonic_clock)73 GST_START_TEST (test_clock_select_monotonic_clock)
74 {
75 GstHarness *h;
76 GstElement *element;
77 GstClock *clock;
78 guint clock_type;
79
80 h = gst_harness_new_parse ("clockselect clock-id=monotonic");
81
82 /* Check if element provides right clock */
83 element = gst_harness_find_element (h, "clockselect");
84 clock = gst_element_provide_clock (element);
85
86 fail_unless (GST_IS_SYSTEM_CLOCK (clock));
87 g_object_get (G_OBJECT (clock), "clock-type", &clock_type, NULL);
88 fail_unless_equals_uint64 (clock_type, GST_CLOCK_TYPE_MONOTONIC);
89
90 gst_object_unref (element);
91 gst_object_unref (clock);
92 gst_harness_teardown (h);
93 }
94
95 GST_END_TEST;
96
GST_START_TEST(test_clock_select_properties)97 GST_START_TEST (test_clock_select_properties)
98 {
99 GstHarness *h;
100 GstElement *element;
101 guint clock_id, domain;
102
103 h = gst_harness_new_parse ("clockselect clock-id=ptp ptp-domain=2");
104
105 /* Check if all properties were properly set up */
106 element = gst_harness_find_element (h, "clockselect");
107 g_object_get (G_OBJECT (element), "clock-id", &clock_id, NULL);
108 fail_unless_equals_uint64 (clock_id, 3);
109
110 g_object_get (G_OBJECT (element), "ptp-domain", &domain, NULL);
111 fail_unless_equals_uint64 (domain, 2);
112
113 gst_object_unref (element);
114 gst_harness_teardown (h);
115 }
116
117 GST_END_TEST;
118
119 static Suite *
clock_select_suite(void)120 clock_select_suite (void)
121 {
122 Suite *s = suite_create ("clockselect");
123 TCase *tc_chain = tcase_create ("general");
124
125 suite_add_tcase (s, tc_chain);
126 tcase_add_test (tc_chain, test_clock_select_properties);
127 tcase_add_test (tc_chain, test_clock_select_monotonic_clock);
128 tcase_add_test (tc_chain, test_clock_select_realtime_clock);
129 tcase_add_test (tc_chain, test_clock_select_tai_clock);
130
131 return s;
132 }
133
134 GST_CHECK_MAIN (clock_select);
135