mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
test: memory: Added test to verify the allocation params
New test added to verify the allocation params for the memory https://bugzilla.gnome.org/show_bug.cgi?id=748277
This commit is contained in:
parent
6aee4af034
commit
6237314ee0
1 changed files with 43 additions and 0 deletions
|
@ -508,6 +508,48 @@ GST_START_TEST (test_map_resize)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_alloc_params)
|
||||
{
|
||||
GstMemory *mem;
|
||||
GstMapInfo info;
|
||||
gsize size, offset, maxalloc;
|
||||
GstAllocationParams params;
|
||||
guint8 arr[10];
|
||||
|
||||
memset (arr, 0, 10);
|
||||
|
||||
gst_allocation_params_init (¶ms);
|
||||
params.padding = 10;
|
||||
params.prefix = 10;
|
||||
params.flags = GST_MEMORY_FLAG_ZERO_PREFIXED | GST_MEMORY_FLAG_ZERO_PADDED;
|
||||
mem = gst_allocator_alloc (NULL, 100, ¶ms);
|
||||
|
||||
/*Checking size and offset */
|
||||
size = gst_memory_get_sizes (mem, &offset, &maxalloc);
|
||||
fail_unless (size == 100);
|
||||
fail_unless (offset == 10);
|
||||
fail_unless (maxalloc >= 120);
|
||||
|
||||
fail_unless (GST_MEMORY_FLAG_IS_SET (mem, GST_MEMORY_FLAG_ZERO_PREFIXED));
|
||||
fail_unless (GST_MEMORY_FLAG_IS_SET (mem, GST_MEMORY_FLAG_ZERO_PADDED));
|
||||
|
||||
fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
|
||||
fail_unless (info.data != NULL);
|
||||
fail_unless (info.size == 100);
|
||||
|
||||
/*Checking prefix */
|
||||
fail_unless (memcmp (info.data - 10, arr, 10) == 0);
|
||||
|
||||
/*Checking padding */
|
||||
fail_unless (memcmp (info.data + 100, arr, 10) == 0);
|
||||
|
||||
|
||||
gst_memory_unmap (mem, &info);
|
||||
gst_memory_unref (mem);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
|
||||
static Suite *
|
||||
gst_memory_suite (void)
|
||||
|
@ -526,6 +568,7 @@ gst_memory_suite (void)
|
|||
tcase_add_test (tc_chain, test_map);
|
||||
tcase_add_test (tc_chain, test_map_nested);
|
||||
tcase_add_test (tc_chain, test_map_resize);
|
||||
tcase_add_test (tc_chain, test_alloc_params);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue