memory: gst_memory_share may fail to exclusively lock the parent memory
[platform/upstream/gstreamer.git] / tests / check / gst / gstmemory.c
1 /* GStreamer
2  *
3  * unit test for GstMemory
4  *
5  * Copyright (C) <2012> Wim Taymans <wim.taymans at gmail.com>
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., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #endif
26
27 #ifdef HAVE_VALGRIND_H
28 # include <valgrind/valgrind.h>
29 #else
30 # define RUNNING_ON_VALGRIND FALSE
31 #endif
32
33 #include <gst/check/gstcheck.h>
34
35 GST_START_TEST (test_submemory)
36 {
37   GstMemory *memory, *sub;
38   GstMapInfo info, sinfo;
39
40   memory = gst_allocator_alloc (NULL, 4, NULL);
41
42   /* check sizes, memory starts out empty */
43   fail_unless (gst_memory_map (memory, &info, GST_MAP_WRITE));
44   fail_unless (info.size == 4, "memory has wrong size");
45   fail_unless (info.maxsize >= 4, "memory has wrong size");
46   memset (info.data, 0, 4);
47   gst_memory_unmap (memory, &info);
48
49   fail_unless (gst_memory_map (memory, &info, GST_MAP_READ));
50
51   sub = gst_memory_share (memory, 1, 2);
52   fail_if (sub == NULL, "share of memory returned NULL");
53
54   fail_unless (gst_memory_map (sub, &sinfo, GST_MAP_READ));
55   fail_unless (sinfo.size == 2, "submemory has wrong size");
56   fail_unless (memcmp (info.data + 1, sinfo.data, 2) == 0,
57       "submemory contains the wrong data");
58   ASSERT_MINI_OBJECT_REFCOUNT (sub, "submemory", 1);
59   gst_memory_unmap (sub, &sinfo);
60   gst_memory_unref (sub);
61
62   /* create a submemory of size 0 */
63   sub = gst_memory_share (memory, 1, 0);
64   fail_if (sub == NULL, "share memory returned NULL");
65   fail_unless (gst_memory_map (sub, &sinfo, GST_MAP_READ));
66   fail_unless (sinfo.size == 0, "submemory has wrong size");
67   fail_unless (memcmp (info.data + 1, sinfo.data, 0) == 0,
68       "submemory contains the wrong data");
69   ASSERT_MINI_OBJECT_REFCOUNT (sub, "submemory", 1);
70   gst_memory_unmap (sub, &sinfo);
71   gst_memory_unref (sub);
72
73   /* test if metadata is coppied, not a complete memory copy so only the
74    * timestamp and offset fields are copied. */
75   sub = gst_memory_share (memory, 0, 1);
76   fail_if (sub == NULL, "share of memory returned NULL");
77   fail_unless (gst_memory_get_sizes (sub, NULL, NULL) == 1,
78       "submemory has wrong size");
79   gst_memory_unref (sub);
80
81   /* test if metadata is coppied, a complete memory is copied so all the timing
82    * fields should be copied. */
83   sub = gst_memory_share (memory, 0, 4);
84   fail_if (sub == NULL, "share of memory returned NULL");
85   fail_unless (gst_memory_get_sizes (sub, NULL, NULL) == 4,
86       "submemory has wrong size");
87
88   /* clean up */
89   gst_memory_unref (sub);
90
91   gst_memory_unmap (memory, &info);
92
93   /* test write map + share failure */
94   fail_unless (gst_memory_map (memory, &info, GST_MAP_WRITE));
95   sub = gst_memory_share (memory, 0, 4);
96   fail_unless (sub == NULL, "share with a write map succeeded");
97
98   gst_memory_unmap (memory, &info);
99   gst_memory_unref (memory);
100 }
101
102 GST_END_TEST;
103
104 GST_START_TEST (test_is_span)
105 {
106   GstMemory *memory, *sub1, *sub2;
107
108   memory = gst_allocator_alloc (NULL, 4, NULL);
109
110   sub1 = gst_memory_share (memory, 0, 2);
111   fail_if (sub1 == NULL, "share of memory returned NULL");
112
113   sub2 = gst_memory_share (memory, 2, 2);
114   fail_if (sub2 == NULL, "share of memory returned NULL");
115
116   fail_if (gst_memory_is_span (memory, sub2, NULL) == TRUE,
117       "a parent memory can't be span");
118
119   fail_if (gst_memory_is_span (sub1, memory, NULL) == TRUE,
120       "a parent memory can't be span");
121
122   fail_if (gst_memory_is_span (sub1, sub2, NULL) == FALSE,
123       "two submemorys next to each other should be span");
124
125   /* clean up */
126   gst_memory_unref (sub1);
127   gst_memory_unref (sub2);
128   gst_memory_unref (memory);
129 }
130
131 GST_END_TEST;
132
133 static const char ro_memory[] = "abcdefghijklmnopqrstuvwxyz";
134
135 static GstMemory *
136 create_read_only_memory (void)
137 {
138   GstMemory *mem;
139
140   /* assign some read-only data to the new memory */
141   mem = gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
142       (gpointer) ro_memory, sizeof (ro_memory), 0, sizeof (ro_memory), NULL,
143       NULL);
144   fail_unless (GST_MEMORY_IS_READONLY (mem));
145
146   return mem;
147 }
148
149 GST_START_TEST (test_writable)
150 {
151   GstMemory *mem, *mem2;
152   GstMapInfo info;
153
154   /* create read-only memory and try to write */
155   mem = create_read_only_memory ();
156
157   fail_if (gst_memory_map (mem, &info, GST_MAP_WRITE));
158
159   /* Make sure mapping anxd unmapping it doesn't change it's locking state */
160   fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
161   gst_memory_unmap (mem, &info);
162
163   fail_if (gst_memory_map (mem, &info, GST_MAP_WRITE));
164
165   mem2 = gst_memory_copy (mem, 0, -1);
166   fail_unless (GST_MEMORY_IS_READONLY (mem));
167   fail_if (GST_MEMORY_IS_READONLY (mem2));
168
169   fail_unless (gst_memory_map (mem2, &info, GST_MAP_WRITE));
170   info.data[4] = 'a';
171   gst_memory_unmap (mem2, &info);
172
173   gst_memory_ref (mem2);
174   fail_if (gst_memory_map (mem, &info, GST_MAP_WRITE));
175   gst_memory_unref (mem2);
176
177   fail_unless (gst_memory_map (mem2, &info, GST_MAP_WRITE));
178   info.data[4] = 'a';
179   gst_memory_unmap (mem2, &info);
180   gst_memory_unref (mem2);
181
182   gst_memory_unref (mem);
183 }
184
185 GST_END_TEST;
186
187 GST_START_TEST (test_submemory_writable)
188 {
189   GstMemory *mem, *sub_mem;
190   GstMapInfo info;
191
192   /* create sub-memory of read-only memory and try to write */
193   mem = create_read_only_memory ();
194
195   sub_mem = gst_memory_share (mem, 0, 8);
196   fail_unless (GST_MEMORY_IS_READONLY (sub_mem));
197
198   fail_if (gst_memory_map (mem, &info, GST_MAP_WRITE));
199   fail_if (gst_memory_map (sub_mem, &info, GST_MAP_WRITE));
200
201   gst_memory_unref (sub_mem);
202   gst_memory_unref (mem);
203 }
204
205 GST_END_TEST;
206
207 GST_START_TEST (test_copy)
208 {
209   GstMemory *memory, *copy;
210   GstMapInfo info, sinfo;
211
212   memory = gst_allocator_alloc (NULL, 4, NULL);
213   ASSERT_MINI_OBJECT_REFCOUNT (memory, "memory", 1);
214
215   copy = gst_memory_copy (memory, 0, -1);
216   ASSERT_MINI_OBJECT_REFCOUNT (memory, "memory", 1);
217   ASSERT_MINI_OBJECT_REFCOUNT (copy, "copy", 1);
218   /* memorys are copied and must point to different memory */
219   fail_if (memory == copy);
220
221   fail_unless (gst_memory_map (memory, &info, GST_MAP_READ));
222   fail_unless (gst_memory_map (copy, &sinfo, GST_MAP_READ));
223
224   /* NOTE that data is refcounted */
225   fail_unless (info.size == sinfo.size);
226
227   gst_memory_unmap (copy, &sinfo);
228   gst_memory_unmap (memory, &info);
229
230   gst_memory_unref (copy);
231   gst_memory_unref (memory);
232
233   memory = gst_allocator_alloc (NULL, 0, NULL);
234   fail_unless (gst_memory_map (memory, &info, GST_MAP_READ));
235   fail_unless (info.size == 0);
236   gst_memory_unmap (memory, &info);
237
238   /* copying a 0-sized memory should not crash */
239   copy = gst_memory_copy (memory, 0, -1);
240   fail_unless (gst_memory_map (copy, &info, GST_MAP_READ));
241   fail_unless (info.size == 0);
242   gst_memory_unmap (copy, &info);
243
244   gst_memory_unref (copy);
245   gst_memory_unref (memory);
246 }
247
248 GST_END_TEST;
249
250 GST_START_TEST (test_try_new_and_alloc)
251 {
252   GstMemory *mem;
253   GstMapInfo info;
254   gsize size;
255
256   mem = gst_allocator_alloc (NULL, 0, NULL);
257   fail_unless (mem != NULL);
258   fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
259   fail_unless (info.size == 0);
260   gst_memory_unmap (mem, &info);
261   gst_memory_unref (mem);
262
263   /* normal alloc should still work */
264   size = 640 * 480 * 4;
265   mem = gst_allocator_alloc (NULL, size, NULL);
266   fail_unless (mem != NULL);
267   fail_unless (gst_memory_map (mem, &info, GST_MAP_WRITE));
268   fail_unless (info.data != NULL);
269   fail_unless (info.size == (640 * 480 * 4));
270   info.data[640 * 479 * 4 + 479] = 0xff;
271   gst_memory_unmap (mem, &info);
272
273   gst_memory_unref (mem);
274
275 #if 0
276   /* Disabled this part of the test, because it happily succeeds on 64-bit
277    * machines that have enough memory+swap, because the address space is large
278    * enough. There's not really any way to test the failure case except by
279    * allocating chunks of memory until it fails, which would suck. */
280
281   /* now this better fail (don't run in valgrind, it will abort
282    * or warn when passing silly arguments to malloc) */
283   if (!RUNNING_ON_VALGRIND) {
284     mem = gst_allocator_alloc (NULL, (guint) - 1, 0);
285     fail_unless (mem == NULL);
286   }
287 #endif
288 }
289
290 GST_END_TEST;
291
292 GST_START_TEST (test_resize)
293 {
294   GstMemory *mem;
295   gsize maxalloc;
296   gsize size, maxsize, offset;
297
298   /* one memory block */
299   mem = gst_allocator_alloc (NULL, 100, NULL);
300
301   size = gst_memory_get_sizes (mem, &offset, &maxalloc);
302   fail_unless (size == 100);
303   fail_unless (offset == 0);
304   fail_unless (maxalloc >= 100);
305
306   ASSERT_CRITICAL (gst_memory_resize (mem, 200, 50));
307   ASSERT_CRITICAL (gst_memory_resize (mem, 0, 150));
308   ASSERT_CRITICAL (gst_memory_resize (mem, 1, maxalloc));
309   ASSERT_CRITICAL (gst_memory_resize (mem, maxalloc, 1));
310
311   /* this does nothing */
312   gst_memory_resize (mem, 0, 100);
313
314   /* nothing should have changed */
315   size = gst_memory_get_sizes (mem, &offset, &maxsize);
316   fail_unless (size == 100);
317   fail_unless (offset == 0);
318   fail_unless (maxsize == maxalloc);
319
320   gst_memory_resize (mem, 0, 50);
321   size = gst_memory_get_sizes (mem, &offset, &maxsize);
322   fail_unless (size == 50);
323   fail_unless (offset == 0);
324   fail_unless (maxsize == maxalloc);
325
326   gst_memory_resize (mem, 0, 100);
327   size = gst_memory_get_sizes (mem, &offset, &maxsize);
328   fail_unless (size == 100);
329   fail_unless (offset == 0);
330   fail_unless (maxsize == maxalloc);
331
332   gst_memory_resize (mem, 1, 99);
333   size = gst_memory_get_sizes (mem, &offset, &maxsize);
334   fail_unless (size == 99);
335   fail_unless (offset == 1);
336   fail_unless (maxsize == maxalloc);
337
338   ASSERT_CRITICAL (gst_memory_resize (mem, 1, maxalloc - 1));
339
340   gst_memory_resize (mem, 0, 99);
341   size = gst_memory_get_sizes (mem, &offset, &maxsize);
342   fail_unless (size == 99);
343   fail_unless (offset == 1);
344   fail_unless (maxsize == maxalloc);
345
346   gst_memory_resize (mem, -1, 100);
347   size = gst_memory_get_sizes (mem, &offset, &maxsize);
348   fail_unless (size == 100);
349   fail_unless (offset == 0);
350   fail_unless (maxsize == maxalloc);
351
352   /* can't set offset below 0 */
353   ASSERT_CRITICAL (gst_memory_resize (mem, -1, 100));
354
355   gst_memory_resize (mem, 50, 40);
356   size = gst_memory_get_sizes (mem, &offset, &maxsize);
357   fail_unless (size == 40);
358   fail_unless (offset == 50);
359   fail_unless (maxsize == maxalloc);
360
361   gst_memory_resize (mem, -50, 100);
362   size = gst_memory_get_sizes (mem, &offset, &maxsize);
363   fail_unless (size == 100);
364   fail_unless (offset == 0);
365   fail_unless (maxsize == maxalloc);
366
367   gst_memory_resize (mem, 0, 0);
368   size = gst_memory_get_sizes (mem, &offset, &maxsize);
369   fail_unless (size == 0);
370   fail_unless (offset == 0);
371   fail_unless (maxsize == maxalloc);
372
373   gst_memory_resize (mem, 0, 100);
374   size = gst_memory_get_sizes (mem, &offset, &maxsize);
375   fail_unless (size == 100);
376   fail_unless (offset == 0);
377   fail_unless (maxsize == maxalloc);
378
379   gst_memory_resize (mem, 0, 100);
380   size = gst_memory_get_sizes (mem, &offset, &maxsize);
381   fail_unless (size == 100);
382   fail_unless (offset == 0);
383   fail_unless (maxsize == maxalloc);
384
385   gst_memory_unref (mem);
386 }
387
388 GST_END_TEST;
389
390 GST_START_TEST (test_map)
391 {
392   GstMemory *mem;
393   GstMapInfo info;
394   gsize maxalloc;
395   gsize size, offset;
396
397   /* one memory block */
398   mem = gst_allocator_alloc (NULL, 100, NULL);
399
400   size = gst_memory_get_sizes (mem, &offset, &maxalloc);
401   fail_unless (size == 100);
402   fail_unless (offset == 0);
403   fail_unless (maxalloc >= 100);
404
405   /* see if simply mapping works */
406   fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
407   fail_unless (info.data != NULL);
408   fail_unless (info.size == 100);
409   fail_unless (info.maxsize == maxalloc);
410
411   gst_memory_unmap (mem, &info);
412   gst_memory_unref (mem);
413 }
414
415 GST_END_TEST;
416
417 GST_START_TEST (test_map_nested)
418 {
419   GstMemory *mem;
420   GstMapInfo info1, info2;
421
422   mem = gst_allocator_alloc (NULL, 100, NULL);
423
424   /* nested mapping */
425   fail_unless (gst_memory_map (mem, &info1, GST_MAP_READ));
426   fail_unless (info1.data != NULL);
427   fail_unless (info1.size == 100);
428
429   fail_unless (gst_memory_map (mem, &info2, GST_MAP_READ));
430   fail_unless (info2.data == info1.data);
431   fail_unless (info2.size == 100);
432
433   /* unmap */
434   gst_memory_unmap (mem, &info2);
435   gst_memory_unmap (mem, &info1);
436
437   fail_unless (gst_memory_map (mem, &info1, GST_MAP_READ));
438   /* not allowed */
439   fail_if (gst_memory_map (mem, &info2, GST_MAP_WRITE));
440   fail_if (gst_memory_map (mem, &info2, GST_MAP_READWRITE));
441   fail_unless (gst_memory_map (mem, &info2, GST_MAP_READ));
442   gst_memory_unmap (mem, &info2);
443   gst_memory_unmap (mem, &info1);
444
445   fail_unless (gst_memory_map (mem, &info1, GST_MAP_WRITE));
446   /* not allowed */
447   fail_if (gst_memory_map (mem, &info2, GST_MAP_READ));
448   fail_if (gst_memory_map (mem, &info2, GST_MAP_READWRITE));
449   fail_unless (gst_memory_map (mem, &info2, GST_MAP_WRITE));
450   gst_memory_unmap (mem, &info1);
451   gst_memory_unmap (mem, &info2);
452   /* nothing was mapped */
453   ASSERT_CRITICAL (gst_memory_unmap (mem, &info2));
454
455   fail_unless (gst_memory_map (mem, &info1, GST_MAP_READWRITE));
456   fail_unless (gst_memory_map (mem, &info2, GST_MAP_READ));
457   gst_memory_unmap (mem, &info2);
458   fail_unless (gst_memory_map (mem, &info2, GST_MAP_WRITE));
459   gst_memory_unmap (mem, &info2);
460   gst_memory_unmap (mem, &info1);
461   /* nothing was mapped */
462   ASSERT_CRITICAL (gst_memory_unmap (mem, &info1));
463
464   gst_memory_unref (mem);
465 }
466
467 GST_END_TEST;
468
469 GST_START_TEST (test_map_resize)
470 {
471   GstMemory *mem;
472   GstMapInfo info;
473   gsize size, maxalloc, offset;
474
475   mem = gst_allocator_alloc (NULL, 100, NULL);
476
477   /* do mapping */
478   fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
479   fail_unless (info.data != NULL);
480   fail_unless (info.size == 100);
481
482   /* resize the buffer */
483   gst_memory_resize (mem, 1, info.size - 1);
484   size = gst_memory_get_sizes (mem, &offset, &maxalloc);
485   fail_unless (size == 99);
486   fail_unless (offset == 1);
487   fail_unless (maxalloc >= 100);
488   gst_memory_unmap (mem, &info);
489
490   size = gst_memory_get_sizes (mem, &offset, &maxalloc);
491   fail_unless (size == 99);
492   fail_unless (offset == 1);
493   fail_unless (maxalloc >= 100);
494
495   fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
496   fail_unless (info.data != NULL);
497   fail_unless (info.size == 99);
498   fail_unless (info.maxsize >= 100);
499   gst_memory_unmap (mem, &info);
500
501   /* and larger */
502   fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
503   gst_memory_resize (mem, -1, 100);
504   gst_memory_unmap (mem, &info);
505
506   size = gst_memory_get_sizes (mem, &offset, &maxalloc);
507   fail_unless (size == 100);
508   fail_unless (offset == 0);
509   fail_unless (maxalloc >= 100);
510
511   fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
512   gst_memory_unmap (mem, &info);
513   gst_memory_unref (mem);
514 }
515
516 GST_END_TEST;
517
518 GST_START_TEST (test_alloc_params)
519 {
520   GstMemory *mem;
521   GstMapInfo info;
522   gsize size, offset, maxalloc;
523   GstAllocationParams params;
524   guint8 arr[10];
525
526   memset (arr, 0, 10);
527
528   gst_allocation_params_init (&params);
529   params.padding = 10;
530   params.prefix = 10;
531   params.flags = GST_MEMORY_FLAG_ZERO_PREFIXED | GST_MEMORY_FLAG_ZERO_PADDED;
532   mem = gst_allocator_alloc (NULL, 100, &params);
533
534   /*Checking size and offset */
535   size = gst_memory_get_sizes (mem, &offset, &maxalloc);
536   fail_unless (size == 100);
537   fail_unless (offset == 10);
538   fail_unless (maxalloc >= 120);
539
540   fail_unless (GST_MEMORY_FLAG_IS_SET (mem, GST_MEMORY_FLAG_ZERO_PREFIXED));
541   fail_unless (GST_MEMORY_FLAG_IS_SET (mem, GST_MEMORY_FLAG_ZERO_PADDED));
542
543   fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
544   fail_unless (info.data != NULL);
545   fail_unless (info.size == 100);
546
547   /*Checking prefix */
548   fail_unless (memcmp (info.data - 10, arr, 10) == 0);
549
550   /*Checking padding */
551   fail_unless (memcmp (info.data + 100, arr, 10) == 0);
552
553
554   gst_memory_unmap (mem, &info);
555   gst_memory_unref (mem);
556 }
557
558 GST_END_TEST;
559
560 GST_START_TEST (test_lock)
561 {
562   GstMemory *mem;
563
564   mem = gst_allocator_alloc (NULL, 10, NULL);
565   fail_unless (mem != NULL);
566
567   /* test exclusivity */
568   fail_unless (gst_memory_lock (mem, GST_MAP_WRITE | GST_LOCK_FLAG_EXCLUSIVE));
569   fail_if (gst_memory_lock (mem, GST_LOCK_FLAG_EXCLUSIVE));
570   fail_unless (gst_memory_lock (mem, GST_MAP_WRITE));
571   gst_memory_unlock (mem, GST_MAP_WRITE | GST_LOCK_FLAG_EXCLUSIVE);
572   gst_memory_unlock (mem, GST_MAP_WRITE);
573
574   /* no lock here */
575
576   fail_unless (gst_memory_lock (mem, GST_MAP_READ | GST_LOCK_FLAG_EXCLUSIVE));
577   fail_unless (gst_memory_lock (mem, GST_MAP_READ | GST_LOCK_FLAG_EXCLUSIVE));
578   gst_memory_unlock (mem, GST_MAP_READ | GST_LOCK_FLAG_EXCLUSIVE);
579   gst_memory_unlock (mem, GST_MAP_READ | GST_LOCK_FLAG_EXCLUSIVE);
580
581   /* no lock here */
582
583   fail_unless (gst_memory_lock (mem,
584           GST_MAP_READWRITE | GST_LOCK_FLAG_EXCLUSIVE));
585   fail_unless (gst_memory_lock (mem, GST_MAP_READ));
586   fail_if (gst_memory_lock (mem, GST_MAP_READ | GST_LOCK_FLAG_EXCLUSIVE));
587   fail_if (gst_memory_lock (mem, GST_LOCK_FLAG_EXCLUSIVE));
588   fail_unless (gst_memory_lock (mem, GST_MAP_WRITE));
589   gst_memory_unlock (mem, GST_MAP_WRITE);
590   gst_memory_unlock (mem, GST_MAP_READ);
591   gst_memory_unlock (mem, GST_MAP_READWRITE | GST_LOCK_FLAG_EXCLUSIVE);
592
593   gst_memory_unref (mem);
594 }
595
596 GST_END_TEST;
597
598 static Suite *
599 gst_memory_suite (void)
600 {
601   Suite *s = suite_create ("GstMemory");
602   TCase *tc_chain = tcase_create ("general");
603
604   suite_add_tcase (s, tc_chain);
605   tcase_add_test (tc_chain, test_submemory);
606   tcase_add_test (tc_chain, test_submemory_writable);
607   tcase_add_test (tc_chain, test_writable);
608   tcase_add_test (tc_chain, test_is_span);
609   tcase_add_test (tc_chain, test_copy);
610   tcase_add_test (tc_chain, test_try_new_and_alloc);
611   tcase_add_test (tc_chain, test_resize);
612   tcase_add_test (tc_chain, test_map);
613   tcase_add_test (tc_chain, test_map_nested);
614   tcase_add_test (tc_chain, test_map_resize);
615   tcase_add_test (tc_chain, test_alloc_params);
616   tcase_add_test (tc_chain, test_lock);
617
618   return s;
619 }
620
621 GST_CHECK_MAIN (gst_memory);