mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 04:45:36 +00:00
tests: add addresspool unit test
This commit is contained in:
parent
b30202b174
commit
d6fcf92601
2 changed files with 95 additions and 21 deletions
|
@ -26,35 +26,26 @@ $(CHECK_REGISTRY):
|
|||
TESTS = $(check_PROGRAMS)
|
||||
|
||||
check_PROGRAMS = \
|
||||
gst/rtspserver
|
||||
gst/rtspserver \
|
||||
gst/addresspool
|
||||
|
||||
# these tests don't even pass
|
||||
noinst_PROGRAMS =
|
||||
|
||||
AM_CFLAGS = $(GST_CFLAGS) $(GST_CHECK_CFLAGS) \
|
||||
AM_CFLAGS = -I$(top_srcdir)/gst/rtsp-server \
|
||||
$(GST_PLUGINS_BASE_CFLAGS) \
|
||||
$(GST_BASE_CFLAGS) \
|
||||
$(GIO_CFLAGS) \
|
||||
$(GST_CFLAGS) \
|
||||
$(GST_CHECK_CFLAGS) \
|
||||
-DGST_TEST_FILES_PATH="\"$(TEST_FILES_DIRECTORY)\"" \
|
||||
-UG_DISABLE_ASSERT -UG_DISABLE_CAST_CHECKS
|
||||
AM_CXXFLAGS = $(GST_CXXFLAGS) $(GST_CHECK_CFLAGS) \
|
||||
-DGST_TEST_FILES_PATH="\"$(TEST_FILES_DIRECTORY)\"" \
|
||||
-UG_DISABLE_ASSERT -UG_DISABLE_CAST_CHECKS
|
||||
LDADD = $(GST_LIBS) $(GST_CHECK_LIBS) $(GST_RTSP_SERVER_LIBS)
|
||||
|
||||
SUPPRESSIONS = $(top_srcdir)/common/gst.supp
|
||||
|
||||
gst_rtspserver_SOURCES = gst/rtspserver.c \
|
||||
$(top_srcdir)/gst/rtsp-server/rtsp-server.h
|
||||
|
||||
gst_rtspserver_CFLAGS = \
|
||||
-I$(top_srcdir)/gst/rtsp-server \
|
||||
$(GST_PLUGINS_GOOD_CFLAGS) \
|
||||
$(GST_PLUGINS_BASE_CFLAGS) \
|
||||
$(GST_BASE_CFLAGS) \
|
||||
$(GIO_CFLAGS) \
|
||||
$(AM_CFLAGS)
|
||||
|
||||
gst_rtspserver_LDADD = \
|
||||
$(top_builddir)/gst/rtsp-server/libgstrtspserver-@GST_API_VERSION@.la \
|
||||
$(GST_PLUGINS_GOOD_LIBS) \
|
||||
LDADD = $(top_builddir)/gst/rtsp-server/libgstrtspserver-@GST_API_VERSION@.la \
|
||||
$(GST_BASE_LIBS) -lgstrtsp-@GST_API_VERSION@ -lgstsdp-@GST_API_VERSION@ \
|
||||
$(GIO_LIBS) \
|
||||
$(LDADD)
|
||||
$(GST_LIBS) $(GST_CHECK_LIBS) $(GST_RTSP_SERVER_LIBS)
|
||||
|
||||
SUPPRESSIONS = $(top_srcdir)/common/gst.supp
|
||||
|
|
83
tests/check/gst/addresspool.c
Normal file
83
tests/check/gst/addresspool.c
Normal file
|
@ -0,0 +1,83 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2012 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <gst/check/gstcheck.h>
|
||||
|
||||
#include <rtsp-address-pool.h>
|
||||
|
||||
GST_START_TEST (test_pool)
|
||||
{
|
||||
gpointer id;
|
||||
GstRTSPAddressPool *pool;
|
||||
gchar *address;
|
||||
guint16 port;
|
||||
guint8 ttl;
|
||||
|
||||
pool = gst_rtsp_address_pool_new ();
|
||||
|
||||
fail_if (gst_rtsp_address_pool_add_range (pool,
|
||||
"233.252.0.1", "233.252.0.0", 5000, 5010, 1));
|
||||
ASSERT_CRITICAL (gst_rtsp_address_pool_add_range (pool,
|
||||
"233.252.0.0", "233.252.0.1", 5010, 5000, 1));
|
||||
|
||||
fail_unless (gst_rtsp_address_pool_add_range (pool,
|
||||
"233.252.0.0", "233.252.0.255", 5000, 5010, 1));
|
||||
fail_unless (gst_rtsp_address_pool_add_range (pool,
|
||||
"233.255.0.0", "233.255.0.0", 5000, 5010, 1));
|
||||
fail_unless (gst_rtsp_address_pool_add_range (pool,
|
||||
"233.255.0.0", "233.255.0.0", 5020, 5020, 1));
|
||||
|
||||
/* should fail, we can't allocate a block of 256 ports */
|
||||
id = gst_rtsp_address_pool_acquire_address (pool,
|
||||
0, 256, &address, &port, &ttl);
|
||||
fail_unless (id == NULL);
|
||||
|
||||
id = gst_rtsp_address_pool_acquire_address (pool,
|
||||
0, 2, &address, &port, &ttl);
|
||||
fail_unless (id != NULL);
|
||||
|
||||
gst_rtsp_address_pool_release_address (pool, id);
|
||||
g_free (address);
|
||||
|
||||
id = gst_rtsp_address_pool_acquire_address (pool,
|
||||
0, 4, &address, &port, &ttl);
|
||||
fail_unless (id != NULL);
|
||||
|
||||
gst_rtsp_address_pool_release_address (pool, id);
|
||||
g_free (address);
|
||||
|
||||
g_object_unref (pool);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
rtspaddresspool_suite (void)
|
||||
{
|
||||
Suite *s = suite_create ("rtspaddresspool");
|
||||
TCase *tc = tcase_create ("general");
|
||||
|
||||
suite_add_tcase (s, tc);
|
||||
tcase_set_timeout (tc, 20);
|
||||
tcase_add_test (tc, test_pool);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
GST_CHECK_MAIN (rtspaddresspool);
|
Loading…
Reference in a new issue