From 6237314ee0c4fdaffa583fdb1c1174f65a32c9d0 Mon Sep 17 00:00:00 2001 From: Prashant Gotarne Date: Wed, 22 Apr 2015 11:44:00 +0530 Subject: [PATCH] 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 --- tests/check/gst/gstmemory.c | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/check/gst/gstmemory.c b/tests/check/gst/gstmemory.c index 486f6fe51e..56b3020a8c 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; }