diff options
author | Prashant Gotarne <ps.gotarne@samsung.com> | 2015-04-22 11:44:00 +0530 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2015-04-23 13:41:27 +0100 |
commit | 6237314ee0c4fdaffa583fdb1c1174f65a32c9d0 (patch) | |
tree | a6199324945d8b4d67b2709beb21ab937b55dff8 /tests | |
parent | 6aee4af0346dfc5054da5ec71f4fddbebd8b9305 (diff) |
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
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check/gst/gstmemory.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/check/gst/gstmemory.c b/tests/check/gst/gstmemory.c index 486f6fe51..56b3020a8 100644 --- a/tests/check/gst/gstmemory.c +++ b/tests/check/gst/gstmemory.c @@ -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; } |