|
1 /* GStreamer |
|
2 * |
|
3 * unit test for data protocol |
|
4 * |
|
5 * Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org> |
|
6 * |
|
7 * This library is free software; you can redistribute it and/or |
|
8 * modify it under the terms of the GNU Library General Public |
|
9 * License as published by the Free Software Foundation; either |
|
10 * version 2 of the License, or (at your option) any later version. |
|
11 * |
|
12 * This library is distributed in the hope that it will be useful, |
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 * Library General Public License for more details. |
|
16 * |
|
17 * You should have received a copy of the GNU Library General Public |
|
18 * License along with this library; if not, write to the |
|
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
20 * Boston, MA 02111-1307, USA. |
|
21 */ |
|
22 |
|
23 #include <gst/gst_global.h> |
|
24 |
|
25 #include "libgstreamer_wsd_solution.h" |
|
26 |
|
27 #if EMULATOR |
|
28 static GET_GLOBAL_VAR_FROM_TLS(raised_critical,gstcheck,gboolean) |
|
29 #define _gst_check_raised_critical (*GET_GSTREAMER_WSD_VAR_NAME(raised_critical,gstcheck,g)()) |
|
30 #else |
|
31 extern gboolean _gst_check_raised_critical ; |
|
32 #endif |
|
33 //gboolean _gst_check_raised_warning = FALSE; |
|
34 #if EMULATOR |
|
35 static GET_GLOBAL_VAR_FROM_TLS(raised_warning,gstcheck,gboolean) |
|
36 #define _gst_check_raised_warning (*GET_GSTREAMER_WSD_VAR_NAME(raised_warning,gstcheck,g)()) |
|
37 #else |
|
38 extern gboolean _gst_check_raised_warning ; |
|
39 #endif |
|
40 //gboolean _gst_check_expecting_log = FALSE; |
|
41 #if EMULATOR |
|
42 static GET_GLOBAL_VAR_FROM_TLS(expecting_log,gstcheck,gboolean) |
|
43 #define _gst_check_expecting_log (*GET_GSTREAMER_WSD_VAR_NAME(expecting_log,gstcheck,g)()) |
|
44 #else |
|
45 extern gboolean _gst_check_expecting_log ; |
|
46 #endif |
|
47 |
|
48 //gboolean _gst_check_expecting_log = FALSE; |
|
49 #if EMULATOR |
|
50 static GET_GLOBAL_VAR_FROM_TLS(threads_running,gstcheck,gboolean) |
|
51 #define _gst_check_threads_running (*GET_GSTREAMER_WSD_VAR_NAME(threads_running,gstcheck,g)()) |
|
52 #else |
|
53 extern gboolean _gst_check_threads_running ; |
|
54 #endif |
|
55 |
|
56 |
|
57 #if EMULATOR |
|
58 GET_GLOBAL_VAR_FROM_TLS(buffers,gstcheck,GList*) |
|
59 #define buffers (*GET_GSTREAMER_WSD_VAR_NAME(buffers,gstcheck,g)()) |
|
60 #else |
|
61 extern GList *buffers; |
|
62 #endif |
|
63 |
|
64 |
|
65 #if EMULATOR |
|
66 GET_GLOBAL_VAR_FROM_TLS(thread_list,gstcheck,GList*) |
|
67 #define thread_list (*GET_GSTREAMER_WSD_VAR_NAME(thread_list,gstcheck,g)()) |
|
68 #else |
|
69 extern GList *thread_list; |
|
70 #endif |
|
71 |
|
72 //GMutex *mutex; |
|
73 #if EMULATOR |
|
74 GET_GLOBAL_VAR_FROM_TLS(mutex,gstcheck,GMutex*) |
|
75 #define mutex (*GET_GSTREAMER_WSD_VAR_NAME(mutex,gstcheck,g)()) |
|
76 #else |
|
77 extern GMutex *mutex; |
|
78 #endif |
|
79 |
|
80 //GCond *start_cond; /* used to notify main thread of thread startups */ |
|
81 #if EMULATOR |
|
82 GET_GLOBAL_VAR_FROM_TLS(start_cond,gstcheck,GCond*) |
|
83 #define start_cond (*GET_GSTREAMER_WSD_VAR_NAME(start_cond,gstcheck,g)()) |
|
84 #else |
|
85 extern GCond *start_cond; |
|
86 #endif |
|
87 |
|
88 //GCond *sync_cond; /* used to synchronize all threads and main thread */ |
|
89 #if EMULATOR |
|
90 GET_GLOBAL_VAR_FROM_TLS(sync_cond,gstcheck,GCond*) |
|
91 #define sync_cond (*GET_GSTREAMER_WSD_VAR_NAME(sync_cond,gstcheck,g)()) |
|
92 #else |
|
93 extern GCond *sync_cond; |
|
94 #endif |
|
95 |
|
96 #define LOG_FILE "c:\\logs\\gdp_logs.txt" |
|
97 #include "std_log_result.h" |
|
98 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
99 |
|
100 #include <gst/check/gstcheck.h> |
|
101 |
|
102 #ifndef GST_REMOVE_DEPRECATED |
|
103 #undef GST_DISABLE_DEPRECATED |
|
104 #endif |
|
105 |
|
106 #include "config.h" |
|
107 |
|
108 #include <gst/dataprotocol/dataprotocol.h> |
|
109 #include "libs/gst/dataprotocol/dp-private.h" /* private header */ |
|
110 |
|
111 |
|
112 |
|
113 //char* xmlfile = "collectpads"; |
|
114 |
|
115 void create_xml(int result) |
|
116 { |
|
117 if(result) |
|
118 assert_failed = 1; |
|
119 |
|
120 testResultXml(xmlfile); |
|
121 close_log_file(); |
|
122 } |
|
123 |
|
124 |
|
125 /* test our method of reading and writing headers using TO/FROM_BE */ |
|
126 void test_conversion() |
|
127 { |
|
128 guint8 array[9]; |
|
129 guint8 write_array[9]; |
|
130 guint16 read_two, expect_two; |
|
131 guint32 read_four, expect_four; |
|
132 guint64 read_eight, expect_eight; |
|
133 int i; |
|
134 |
|
135 xmlfile = "test_conversion"; |
|
136 std_log(LOG_FILENAME_LINE, "Test Started test_conversion"); |
|
137 |
|
138 for (i = 0; i < 9; ++i) { |
|
139 array[i] = i * 0x10; |
|
140 } |
|
141 |
|
142 /* read 8 16 bits */ |
|
143 for (i = 0; i < 8; ++i) { |
|
144 read_two = GST_READ_UINT16_BE (array + i); |
|
145 expect_two = array[i] * (1 << 8) + array[i + 1]; |
|
146 fail_unless (read_two == expect_two, |
|
147 "GST_READ_UINT16_BE %d: read %d != %d\n", i, read_two, expect_two); |
|
148 } |
|
149 |
|
150 /* write 8 16 bits */ |
|
151 for (i = 0; i < 8; ++i) { |
|
152 GST_WRITE_UINT16_BE (&write_array[i], read_two); |
|
153 fail_unless (memcmp (array + 7, write_array + i, 2) == 0, |
|
154 "GST_WRITE_UINT16_BE %d: memcmp failed", i); |
|
155 } |
|
156 |
|
157 /* read 5 32 bits */ |
|
158 for (i = 0; i < 5; ++i) { |
|
159 read_four = GST_READ_UINT32_BE (array + i); |
|
160 expect_four = array[i] * (1 << 24) + array[i + 1] * (1 << 16) |
|
161 + array[i + 2] * (1 << 8) + array[i + 3]; |
|
162 fail_unless (read_four == expect_four, |
|
163 "GST_READ_UINT32_BE %d: read %d != %d\n", i, read_four, expect_four); |
|
164 } |
|
165 |
|
166 /* read 2 64 bits */ |
|
167 for (i = 0; i < 2; ++i) { |
|
168 read_eight = GST_READ_UINT64_BE (array + i); |
|
169 expect_eight = array[i] * (1LL << 56) + array[i + 1] * (1LL << 48) |
|
170 + array[i + 2] * (1LL << 40) + array[i + 3] * (1LL << 32) |
|
171 + array[i + 4] * (1 << 24) + array[i + 5] * (1 << 16) |
|
172 + array[i + 6] * (1 << 8) + array[i + 7]; |
|
173 fail_unless (read_eight == expect_eight, |
|
174 "GST_READ_UINT64_BE %d: read %" G_GUINT64_FORMAT |
|
175 " != %" G_GUINT64_FORMAT "\n", i, read_eight, expect_eight); |
|
176 } |
|
177 |
|
178 /* write 1 64 bit */ |
|
179 GST_WRITE_UINT64_BE (&write_array[0], read_eight); |
|
180 fail_unless (memcmp (array + 1, write_array, 8) == 0, |
|
181 "GST_WRITE_UINT64_BE: memcmp failed"); |
|
182 |
|
183 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
184 create_xml(0); |
|
185 } |
|
186 |
|
187 |
|
188 |
|
189 #ifndef GST_REMOVE_DEPRECATED /* these tests use deprecated API, that we disable by default */ |
|
190 |
|
191 #ifndef HAVE_CPU_PPC64 /* this test doesn't work on PPC64. See #348114 */ |
|
192 |
|
193 /* test creation of header from buffer and back again */ |
|
194 void test_buffer() |
|
195 { |
|
196 GstBuffer *buffer; |
|
197 GstBuffer *newbuffer; |
|
198 |
|
199 guint header_length; |
|
200 guint8 *header; |
|
201 |
|
202 |
|
203 xmlfile = "test_buffer"; |
|
204 std_log(LOG_FILENAME_LINE, "Test Started test_buffer"); |
|
205 /* create buffer */ |
|
206 g_message ("Creating a new 8-byte buffer with ts 0.5 sec, dur 1 sec\n"); |
|
207 buffer = gst_buffer_new_and_alloc (8); |
|
208 GST_BUFFER_TIMESTAMP (buffer) = (GstClockTime) (GST_SECOND * 0.5); |
|
209 GST_BUFFER_DURATION (buffer) = (GstClockTime) GST_SECOND; |
|
210 GST_BUFFER_OFFSET (buffer) = (guint64) 10; |
|
211 GST_BUFFER_OFFSET_END (buffer) = (guint64) 19; |
|
212 GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_IN_CAPS); |
|
213 memmove (GST_BUFFER_DATA (buffer), "a buffer", 8); |
|
214 |
|
215 /* create a buffer with CRC checking */ |
|
216 fail_unless (gst_dp_header_from_buffer (buffer, GST_DP_HEADER_FLAG_CRC, |
|
217 &header_length, &header), "Could not create header from buffer."); |
|
218 |
|
219 /* validate the header */ |
|
220 fail_unless (gst_dp_validate_header (header_length, header), |
|
221 "Could not validate header"); |
|
222 /* create a new, empty buffer with the right size */ |
|
223 newbuffer = gst_dp_buffer_from_header (header_length, header); |
|
224 fail_unless (newbuffer != NULL, "Could not create a new buffer from header"); |
|
225 fail_unless (GST_IS_BUFFER (newbuffer), "Created buffer is not a GstBuffer"); |
|
226 /* read/copy the data */ |
|
227 memmove (GST_BUFFER_DATA (newbuffer), GST_BUFFER_DATA (buffer), |
|
228 GST_BUFFER_SIZE (buffer)); |
|
229 /* validate the buffer */ |
|
230 fail_unless (gst_dp_validate_payload (header_length, header, |
|
231 GST_BUFFER_DATA (newbuffer)), "Could not validate payload"); |
|
232 |
|
233 g_message ("new buffer timestamp: %" GST_TIME_FORMAT "\n", |
|
234 GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (newbuffer))); |
|
235 g_message ("new buffer duration: %" GST_TIME_FORMAT "\n", |
|
236 GST_TIME_ARGS (GST_BUFFER_DURATION (newbuffer))); |
|
237 g_message ("new buffer offset: %" G_GUINT64_FORMAT "\n", |
|
238 GST_BUFFER_OFFSET (newbuffer)); |
|
239 g_message ("new buffer offset_end: %" G_GUINT64_FORMAT "\n", |
|
240 GST_BUFFER_OFFSET_END (newbuffer)); |
|
241 fail_unless (GST_BUFFER_TIMESTAMP (newbuffer) == |
|
242 GST_BUFFER_TIMESTAMP (buffer), "Timestamps don't match !"); |
|
243 fail_unless (GST_BUFFER_DURATION (newbuffer) == GST_BUFFER_DURATION (buffer), |
|
244 "Durations don't match !"); |
|
245 fail_unless (GST_BUFFER_OFFSET (newbuffer) == GST_BUFFER_OFFSET (buffer), |
|
246 "Offsets don't match !"); |
|
247 fail_unless (GST_BUFFER_OFFSET_END (newbuffer) == |
|
248 GST_BUFFER_OFFSET_END (buffer), "Offset ends don't match !"); |
|
249 // fail_unless (GST_BUFFER_FLAG_IS_SET (newbuffer, GST_BUFFER_FLAG_IN_CAPS), |
|
250 // "GST_BUFFER_IN_CAPS flag should have been copied !"); |
|
251 |
|
252 /* clean up */ |
|
253 gst_buffer_unref (buffer); |
|
254 gst_buffer_unref (newbuffer); |
|
255 g_free (header); |
|
256 |
|
257 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
258 create_xml(0); |
|
259 } |
|
260 |
|
261 |
|
262 #endif |
|
263 |
|
264 void test_caps() |
|
265 { |
|
266 gchar *string, *newstring; |
|
267 GstCaps *caps, *newcaps; |
|
268 |
|
269 guint header_length; |
|
270 guint8 *header, *payload; |
|
271 |
|
272 |
|
273 xmlfile = "test_caps"; |
|
274 std_log(LOG_FILENAME_LINE, "Test Started test_caps"); |
|
275 |
|
276 caps = gst_caps_from_string ("audio/x-raw-float, " |
|
277 "rate = (int) [ 11025, 48000 ], " |
|
278 "channels = (int) [ 1, 2 ], " "endianness = (int) BYTE_ORDER, " |
|
279 "width = (int) 32, " "buffer-frames = (int) 0"); |
|
280 string = gst_caps_to_string (caps); |
|
281 g_message ("Created caps: %s\n", string); |
|
282 fail_unless (gst_dp_packet_from_caps (caps, 0, &header_length, &header, |
|
283 &payload), "Could not create packet from caps."); |
|
284 |
|
285 /* validate the packet */ |
|
286 fail_unless (gst_dp_validate_packet (header_length, header, payload), |
|
287 "Could not validate packet"); |
|
288 newcaps = gst_dp_caps_from_packet (header_length, header, payload); |
|
289 fail_unless (newcaps != NULL, "Could not create caps from packet"); |
|
290 fail_unless (GST_IS_CAPS (newcaps)); |
|
291 newstring = gst_caps_to_string (newcaps); |
|
292 g_message ("Received caps: %s\n", newstring); |
|
293 fail_unless (strcmp (string, newstring) == 0, |
|
294 "Created caps do not match original caps"); |
|
295 |
|
296 /* cleanup */ |
|
297 gst_caps_unref (caps); |
|
298 gst_caps_unref (newcaps); |
|
299 g_free (header); |
|
300 g_free (payload); |
|
301 g_free (string); |
|
302 g_free (newstring); |
|
303 |
|
304 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
305 create_xml(0); |
|
306 } |
|
307 |
|
308 |
|
309 |
|
310 void test_event() |
|
311 { |
|
312 GstEvent *send; |
|
313 GstEvent *receive; |
|
314 guint header_length; |
|
315 guint8 *header, *payload; |
|
316 |
|
317 xmlfile = "test_event"; |
|
318 std_log(LOG_FILENAME_LINE, "Test Started test_event"); |
|
319 |
|
320 g_message ("Testing EOS event at 1s\n"); |
|
321 send = gst_event_new_eos (); |
|
322 GST_EVENT_TIMESTAMP (send) = GST_SECOND; |
|
323 fail_unless (gst_dp_packet_from_event (send, GST_DP_HEADER_FLAG_CRC, |
|
324 &header_length, &header, &payload), |
|
325 "Could not create packet from eos event"); |
|
326 |
|
327 receive = gst_dp_event_from_packet (header_length, header, payload); |
|
328 |
|
329 g_message ("EOS, timestamp %" GST_TIME_FORMAT "\n", |
|
330 GST_TIME_ARGS (GST_EVENT_TIMESTAMP (receive))); |
|
331 fail_unless (GST_EVENT_TYPE (receive) == GST_EVENT_EOS, |
|
332 "Received event is not EOS"); |
|
333 fail_unless (GST_EVENT_TIMESTAMP (receive) == GST_SECOND, |
|
334 "EOS timestamp is not 1.0 sec"); |
|
335 |
|
336 /* clean up */ |
|
337 g_free (header); |
|
338 g_free (payload); |
|
339 gst_event_unref (send); |
|
340 gst_event_unref (receive); |
|
341 |
|
342 g_message ("Testing FLUSH event at 2s\n"); |
|
343 send = gst_event_new_flush_start (); |
|
344 GST_EVENT_TIMESTAMP (send) = GST_SECOND * 2; |
|
345 fail_unless (gst_dp_packet_from_event (send, GST_DP_HEADER_FLAG_CRC, |
|
346 &header_length, &header, &payload), |
|
347 "Could not create packet from flush event"); |
|
348 |
|
349 receive = gst_dp_event_from_packet (header_length, header, payload); |
|
350 |
|
351 g_message ("Flush, timestamp %" GST_TIME_FORMAT "\n", |
|
352 GST_TIME_ARGS (GST_EVENT_TIMESTAMP (receive))); |
|
353 fail_unless (GST_EVENT_TYPE (receive) == GST_EVENT_FLUSH_START, |
|
354 "Received event is not flush"); |
|
355 fail_unless (GST_EVENT_TIMESTAMP (receive) == GST_SECOND * 2, |
|
356 "Flush timestamp is not 2.0 sec"); |
|
357 |
|
358 /* clean up */ |
|
359 g_free (header); |
|
360 g_free (payload); |
|
361 gst_event_unref (send); |
|
362 gst_event_unref (receive); |
|
363 |
|
364 g_message ("Testing SEEK event with 1 second at 3 seconds\n"); |
|
365 send = |
|
366 gst_event_new_seek (1.0, GST_FORMAT_TIME, 0, GST_SEEK_TYPE_SET, |
|
367 GST_SECOND, GST_SEEK_TYPE_NONE, 0); |
|
368 GST_EVENT_TIMESTAMP (send) = GST_SECOND * 3; |
|
369 fail_unless (gst_dp_packet_from_event (send, GST_DP_HEADER_FLAG_CRC, |
|
370 &header_length, &header, &payload), |
|
371 "Could not create packet from seek event"); |
|
372 |
|
373 receive = gst_dp_event_from_packet (header_length, header, payload); |
|
374 |
|
375 { |
|
376 gdouble rate; |
|
377 GstFormat format; |
|
378 GstSeekFlags flags; |
|
379 GstSeekType cur_type, stop_type; |
|
380 gint64 cur, stop; |
|
381 |
|
382 gst_event_parse_seek (receive, &rate, &format, &flags, |
|
383 &cur_type, &cur, &stop_type, &stop); |
|
384 |
|
385 g_message ("Seek, timestamp %" GST_TIME_FORMAT ", to %" GST_TIME_FORMAT |
|
386 "\n", GST_TIME_ARGS (GST_EVENT_TIMESTAMP (receive)), |
|
387 GST_TIME_ARGS (cur)); |
|
388 fail_unless (GST_EVENT_TYPE (receive) == GST_EVENT_SEEK, |
|
389 "Returned event is not seek"); |
|
390 fail_unless (GST_EVENT_TIMESTAMP (receive) == GST_SECOND * 3, |
|
391 "Seek timestamp is not 3.0 sec"); |
|
392 fail_unless (format == GST_FORMAT_TIME, "Seek format is not time"); |
|
393 fail_unless (cur == GST_SECOND, "Seek cur is not 1.0 sec"); |
|
394 } |
|
395 |
|
396 /* clean up */ |
|
397 g_free (header); |
|
398 g_free (payload); |
|
399 gst_event_unref (send); |
|
400 gst_event_unref (receive); |
|
401 |
|
402 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
403 create_xml(0); |
|
404 } |
|
405 |
|
406 |
|
407 |
|
408 /* try to segfault the thing by passing NULLs, short headers, etc.. */ |
|
409 void test_memory() |
|
410 { |
|
411 guint8 foo[5]; |
|
412 GstBuffer *buffer; |
|
413 GstCaps *caps; |
|
414 GstEvent *event; |
|
415 guint length; |
|
416 guint8 *header; |
|
417 guint8 *payload; |
|
418 |
|
419 xmlfile = "test_memory"; |
|
420 std_log(LOG_FILENAME_LINE, "Test Started test_memory"); |
|
421 |
|
422 /* check 0 sized input, data pointer can be NULL or anything. CRC is always 0, |
|
423 * though. */ |
|
424 fail_if (gst_dp_crc (NULL, 0) != 0); |
|
425 fail_if (gst_dp_crc (foo, 0) != 0); |
|
426 |
|
427 /* this is very invalid input and gives a warning. */ |
|
428 ASSERT_CRITICAL (gst_dp_crc (NULL, 1)); |
|
429 ASSERT_CRITICAL (gst_dp_header_payload_length (NULL)); |
|
430 ASSERT_CRITICAL (gst_dp_header_payload_type (NULL)); |
|
431 |
|
432 /* wrong */ |
|
433 ASSERT_CRITICAL (gst_dp_header_from_buffer (NULL, 0, NULL, NULL)); |
|
434 |
|
435 /* empty buffer has NULL as data pointer */ |
|
436 buffer = gst_buffer_new_and_alloc (0); |
|
437 |
|
438 /* no place to store the length and/or header data */ |
|
439 ASSERT_CRITICAL (gst_dp_header_from_buffer (buffer, 0, NULL, NULL)); |
|
440 ASSERT_CRITICAL (gst_dp_header_from_buffer (buffer, 0, &length, NULL)); |
|
441 |
|
442 /* this should work fine */ |
|
443 fail_if (gst_dp_header_from_buffer (buffer, 0, &length, &header) != TRUE); |
|
444 fail_unless (length != 0); |
|
445 fail_unless (header != NULL); |
|
446 |
|
447 /* this should validate */ |
|
448 fail_if (gst_dp_validate_header (length, header) == FALSE); |
|
449 |
|
450 /* NULL header pointer */ |
|
451 ASSERT_CRITICAL (gst_dp_validate_header (length, NULL)); |
|
452 /* short header */ |
|
453 ASSERT_CRITICAL (gst_dp_validate_header (5, header)); |
|
454 |
|
455 g_free (header); |
|
456 |
|
457 /* this should work and not crash trying to calc a CRC on a 0 sized buffer */ |
|
458 fail_if (gst_dp_header_from_buffer (buffer, |
|
459 GST_DP_HEADER_FLAG_CRC_HEADER | GST_DP_HEADER_FLAG_CRC_PAYLOAD, |
|
460 &length, &header) != TRUE); |
|
461 |
|
462 /* this should validate */ |
|
463 fail_if (gst_dp_validate_header (length, header) == FALSE); |
|
464 |
|
465 /* there was no payload, NULL as payload data should validate the CRC |
|
466 * checks and all. */ |
|
467 fail_if (gst_dp_validate_payload (length, header, NULL) == FALSE); |
|
468 |
|
469 /* and the whole packet as well */ |
|
470 fail_if (gst_dp_validate_packet (length, header, NULL) == FALSE); |
|
471 |
|
472 /* some bogus length */ |
|
473 ASSERT_CRITICAL (gst_dp_validate_packet (5, header, NULL)); |
|
474 gst_buffer_unref (buffer); |
|
475 |
|
476 /* create buffer from header data, integrity tested elsewhere */ |
|
477 buffer = gst_dp_buffer_from_header (length, header); |
|
478 fail_if (buffer == NULL); |
|
479 gst_buffer_unref (buffer); |
|
480 g_free (header); |
|
481 |
|
482 ASSERT_CRITICAL (gst_dp_packet_from_caps (NULL, 0, NULL, NULL, NULL)); |
|
483 |
|
484 /* some caps stuff */ |
|
485 caps = gst_caps_new_empty (); |
|
486 ASSERT_CRITICAL (gst_dp_packet_from_caps (caps, 0, NULL, NULL, NULL)); |
|
487 ASSERT_CRITICAL (gst_dp_packet_from_caps (caps, 0, &length, NULL, NULL)); |
|
488 ASSERT_CRITICAL (gst_dp_packet_from_caps (caps, 0, &length, &header, NULL)); |
|
489 |
|
490 fail_if (gst_dp_packet_from_caps (caps, 0, &length, &header, |
|
491 &payload) != TRUE); |
|
492 fail_if (strcmp ((const gchar *) payload, "EMPTY") != 0); |
|
493 gst_caps_unref (caps); |
|
494 |
|
495 caps = gst_dp_caps_from_packet (length, header, payload); |
|
496 fail_if (caps == NULL); |
|
497 gst_caps_unref (caps); |
|
498 |
|
499 g_free (header); |
|
500 g_free (payload); |
|
501 |
|
502 /* some event stuff */ |
|
503 event = gst_event_new_eos (); |
|
504 ASSERT_CRITICAL (gst_dp_packet_from_event (event, 0, NULL, NULL, NULL)); |
|
505 ASSERT_CRITICAL (gst_dp_packet_from_event (event, 0, &length, NULL, NULL)); |
|
506 ASSERT_CRITICAL (gst_dp_packet_from_event (event, 0, &length, &header, NULL)); |
|
507 |
|
508 /* payload is not NULL from previous test and points to freed memory, very |
|
509 * invalid. */ |
|
510 fail_if (payload == NULL); |
|
511 fail_if (gst_dp_packet_from_event (event, 0, &length, &header, |
|
512 &payload) != TRUE); |
|
513 |
|
514 /* the EOS event has no payload */ |
|
515 fail_if (payload != NULL); |
|
516 gst_event_unref (event); |
|
517 |
|
518 event = gst_dp_event_from_packet (length, header, payload); |
|
519 fail_if (event == NULL); |
|
520 fail_if (GST_EVENT_TYPE (event) != GST_EVENT_EOS); |
|
521 gst_event_unref (event); |
|
522 |
|
523 g_free (header); |
|
524 g_free (payload); |
|
525 |
|
526 |
|
527 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
528 create_xml(0); |
|
529 } |
|
530 |
|
531 |
|
532 |
|
533 #endif |
|
534 |
|
535 //void |
|
536 //gst_dp_suite (void) |
|
537 //{ |
|
538 //test_conversion(); |
|
539 //test_buffer(); |
|
540 //test_caps(); |
|
541 //test_event(); |
|
542 //test_memory(); |
|
543 //} |
|
544 |
|
545 void (*fn[]) (void) = { |
|
546 test_conversion, |
|
547 test_buffer, |
|
548 test_caps, |
|
549 test_event, |
|
550 test_memory |
|
551 }; |
|
552 |
|
553 char *args[] = { |
|
554 "test_conversion", |
|
555 "test_buffer", |
|
556 "test_caps", |
|
557 "test_event", |
|
558 "test_memory" |
|
559 }; |
|
560 |
|
561 GST_CHECK_MAIN (gst_dp); |
|
562 #if 0 |
|
563 int main(int argc,char** argv) |
|
564 { |
|
565 int i; |
|
566 gst_check_init(&argc,&argv); |
|
567 for(i=0;i<5;i++) |
|
568 fn[i](); |
|
569 |
|
570 } |
|
571 #endif |