From fabf4890b8189f3a57f665e723c74680301f67f6 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 15 Mar 2015 16:41:21 +0100 Subject: [PATCH] allocators: add allocators test --- tests/check/Makefile.am | 11 ++++++ tests/check/libs/allocators.c | 90 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 tests/check/libs/allocators.c diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index e34037d..55f33c9 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -189,6 +189,7 @@ check_PROGRAMS = \ generic/clock-selection \ generic/states \ libs/libsabi \ + libs/allocators \ libs/audio \ libs/audiocdsrc \ libs/audiodecoder \ @@ -286,6 +287,16 @@ libs_libsabi_LDADD = \ $(GST_BASE_LIBS) \ $(LDADD) +libs_allocators_CFLAGS = \ + $(GST_PLUGINS_BASE_CFLAGS) \ + $(GST_BASE_CFLAGS) \ + $(AM_CFLAGS) + +libs_allocators_LDADD = \ + $(top_builddir)/gst-libs/gst/allocators/libgstallocators-@GST_API_VERSION@.la \ + $(GST_BASE_LIBS) \ + $(LDADD) + libs_audio_CFLAGS = \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ diff --git a/tests/check/libs/allocators.c b/tests/check/libs/allocators.c new file mode 100644 index 0000000..f2b92c7 --- /dev/null +++ b/tests/check/libs/allocators.c @@ -0,0 +1,90 @@ +/* GStreamer unit tests for the RTSP support library + * Copyright (C) 2010 Andy Wingo + * Copyright (C) 2015 Tim-Philipp Müller + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include +#include + +#define FILE_SIZE 4096 + + +GST_START_TEST (test_dmabuf) +{ + char tmpfilename[] = "/tmp/dmabuf-test.XXXXXX"; + int fd; + GstMemory *mem; + GstAllocator *alloc; + GstMapInfo info; + + fd = mkstemp (tmpfilename); + fail_unless (fd > 0); + fail_unless (g_unlink (tmpfilename) == 0); + + alloc = gst_dmabuf_allocator_new (); + + mem = gst_dmabuf_allocator_alloc (alloc, fd, FILE_SIZE); + + fail_unless (gst_memory_map (mem, &info, GST_MAP_READWRITE)); + fail_unless (info.flags == GST_MAP_READWRITE); + fail_unless (info.data != NULL); + fail_unless (info.size == FILE_SIZE); + fail_unless (info.maxsize == FILE_SIZE); + gst_memory_unmap (mem, &info); + + gst_memory_unref (mem); + g_object_unref (alloc); +} + +GST_END_TEST; + +static Suite * +allocators_suite (void) +{ + Suite *s = suite_create ("allocators"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_dmabuf); + + return s; +} + +int +main (int argc, char **argv) +{ + int nf; + + Suite *s = allocators_suite (); + SRunner *sr = srunner_create (s); + + gst_check_init (&argc, &argv); + + srunner_run_all (sr, CK_NORMAL); + nf = srunner_ntests_failed (sr); + srunner_free (sr); + + return nf; +} -- 2.7.4