summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2013-11-12 16:52:35 +0100
committerWim Taymans <wim.taymans@gmail.com>2013-11-12 16:54:59 +0100
commitb2bc84cdbf7d08c5cb94da435637bc1c7188c918 (patch)
treee3b67e43045b101f192887bce39f61f1a278b100 /tests
parentadc02db975d8bf615dda3e33efcb0feb490f5e83 (diff)
address-pool: fix address increment
Use a guint instead of guint8 to increment the address. It's still not completely correct because a guint might not be able to hold the complete address range, but that's an enhacement for later. Add unit test to test improved behaviour. https://bugzilla.gnome.org/show_bug.cgi?id=708237
Diffstat (limited to 'tests')
-rw-r--r--tests/check/gst/addresspool.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/check/gst/addresspool.c b/tests/check/gst/addresspool.c
index b3ca24d..9a0ff54 100644
--- a/tests/check/gst/addresspool.c
+++ b/tests/check/gst/addresspool.c
@@ -236,6 +236,34 @@ GST_START_TEST (test_pool)
fail_unless (!strcmp (addr->address, "192.168.1.1"));
gst_rtsp_address_free (addr);
+ fail_unless (gst_rtsp_address_pool_add_range (pool,
+ GST_RTSP_ADDRESS_POOL_ANY_IPV4, GST_RTSP_ADDRESS_POOL_ANY_IPV4, 5000,
+ 5001, 0));
+ res =
+ gst_rtsp_address_pool_reserve_address (pool, "192.168.0.1", 5000, 1, 0,
+ &addr);
+ fail_unless (res == GST_RTSP_ADDRESS_POOL_ERANGE);
+ res =
+ gst_rtsp_address_pool_reserve_address (pool, "0.0.0.0", 5000, 1, 0,
+ &addr);
+ fail_unless (res == GST_RTSP_ADDRESS_POOL_OK);
+ gst_rtsp_address_free (addr);
+ gst_rtsp_address_pool_clear (pool);
+
+ /* Error case 2. Using ANY as min address makes it possible to allocate the
+ * same address twice */
+ fail_unless (gst_rtsp_address_pool_add_range (pool,
+ GST_RTSP_ADDRESS_POOL_ANY_IPV4, "255.255.255.255", 5000, 5001, 0));
+ res =
+ gst_rtsp_address_pool_reserve_address (pool, "192.168.0.1", 5000, 1, 0,
+ &addr);
+ fail_unless (res == GST_RTSP_ADDRESS_POOL_OK);
+ res =
+ gst_rtsp_address_pool_reserve_address (pool, "192.168.0.1", 5000, 1, 0,
+ &addr2);
+ fail_unless (res == GST_RTSP_ADDRESS_POOL_ERESERVED);
+ gst_rtsp_address_free (addr);
+ gst_rtsp_address_pool_clear (pool);
g_object_unref (pool);
}