summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOgnyan Tonchev <ognyan@axis.com>2013-10-09 15:19:12 +0200
committerSebastian Dröge <sebastian@centricular.com>2013-10-30 19:02:24 +0100
commitfa7898b0a61bed689cff7f57285be561d7ab5028 (patch)
tree8d087b0e2aebd0ee9bbe48b43be97a6928bd1520 /tests
parent78e5a9148e6ba8d80fd3f2e78043abd7a434ec23 (diff)
downloadgstreamer-fa7898b0a61bed689cff7f57285be561d7ab5028.tar.gz
thread-pool: Add unit test for the thread pools
https://bugzilla.gnome.org/show_bug.cgi?id=710228
Diffstat (limited to 'tests')
-rw-r--r--tests/check/Makefile.am3
-rw-r--r--tests/check/gst/threadpool.c90
2 files changed, 92 insertions, 1 deletions
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index ff17bbf2bf..54aa0df9e3 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -31,7 +31,8 @@ check_PROGRAMS = \
gst/mountpoints \
gst/mediafactory \
gst/media \
- gst/addresspool
+ gst/addresspool \
+ gst/threadpool
# these tests don't even pass
noinst_PROGRAMS =
diff --git a/tests/check/gst/threadpool.c b/tests/check/gst/threadpool.c
new file mode 100644
index 0000000000..735584a34c
--- /dev/null
+++ b/tests/check/gst/threadpool.c
@@ -0,0 +1,90 @@
+/* GStreamer
+ * unit tests for GstRTSPThreadPool
+ * Copyright (C) 2013 Axis Communications <dev-gstreamer at axis dot com>
+ * @author Ognyan Tonchev <ognyan at axis dot 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-thread-pool.h>
+
+GST_START_TEST (test_pool_get_thread)
+{
+ GstRTSPThreadPool *pool;
+ GstRTSPThread *thread;
+
+ pool = gst_rtsp_thread_pool_new ();
+ fail_unless (pool != NULL);
+
+ thread = gst_rtsp_thread_pool_get_thread (pool, GST_RTSP_THREAD_TYPE_CLIENT,
+ NULL);
+ fail_unless (thread != NULL);
+
+ gst_rtsp_thread_stop (thread);
+ g_object_unref (pool);
+ gst_rtsp_thread_pool_cleanup ();
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_pool_get_thread_reuse)
+{
+ GstRTSPThreadPool *pool;
+ GstRTSPThread *thread;
+ GstRTSPThread *thread2;
+
+ pool = gst_rtsp_thread_pool_new ();
+ fail_unless (pool != NULL);
+
+ gst_rtsp_thread_pool_set_max_threads (pool, 1);
+
+ thread = gst_rtsp_thread_pool_get_thread (pool, GST_RTSP_THREAD_TYPE_CLIENT,
+ NULL);
+ fail_unless (thread != NULL);
+
+ thread2 = gst_rtsp_thread_pool_get_thread (pool, GST_RTSP_THREAD_TYPE_CLIENT,
+ NULL);
+ fail_unless (thread2 != NULL);
+
+ fail_unless (thread == thread2);
+
+ gst_rtsp_thread_stop (thread);
+ gst_rtsp_thread_stop (thread2);
+ g_object_unref (pool);
+
+ gst_rtsp_thread_pool_cleanup ();
+}
+
+GST_END_TEST;
+
+
+static Suite *
+rtspthreadpool_suite (void)
+{
+ Suite *s = suite_create ("rtspthreadpool");
+ TCase *tc = tcase_create ("general");
+
+ suite_add_tcase (s, tc);
+ tcase_set_timeout (tc, 20);
+ tcase_add_test (tc, test_pool_get_thread);
+ tcase_add_test (tc, test_pool_get_thread_reuse);
+
+ return s;
+}
+
+GST_CHECK_MAIN (rtspthreadpool);