3 * Common code for GStreamer unittests
5 * Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 GST_DEBUG_CATEGORY (check_debug);
27 /* logging function for tests
28 * a test uses g_message() to log a debug line
29 * a gst unit test can be run with GST_TEST_DEBUG env var set to see the
33 gboolean _gst_check_threads_running = FALSE;
34 GList *thread_list = NULL;
36 GCond *start_cond; /* used to notify main thread of thread startups */
37 GCond *sync_cond; /* used to synchronize all threads and main thread */
39 gboolean _gst_check_debug = FALSE;
40 gboolean _gst_check_raised_critical = FALSE;
41 gboolean _gst_check_expecting_log = FALSE;
43 void gst_check_log_message_func
44 (const gchar * log_domain, GLogLevelFlags log_level,
45 const gchar * message, gpointer user_data)
47 if (_gst_check_debug) {
52 void gst_check_log_critical_func
53 (const gchar * log_domain, GLogLevelFlags log_level,
54 const gchar * message, gpointer user_data)
56 if (!_gst_check_expecting_log) {
57 g_print ("\n\nUnexpected critical/warning: %s\n", message);
58 fail ("Unexpected critical/warning: %s", message);
61 if (_gst_check_debug) {
62 g_print ("\nExpected critical/warning: %s\n", message);
65 if (log_level & G_LOG_LEVEL_CRITICAL)
66 _gst_check_raised_critical = TRUE;
69 /* initialize GStreamer testing */
71 gst_check_init (int *argc, char **argv[])
73 gst_init (argc, argv);
75 GST_DEBUG_CATEGORY_INIT (check_debug, "check", 0, "check regression tests");
77 if (g_getenv ("GST_TEST_DEBUG"))
78 _gst_check_debug = TRUE;
80 g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, gst_check_log_message_func,
82 g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
83 gst_check_log_critical_func, NULL);
84 g_log_set_handler ("GStreamer", G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
85 gst_check_log_critical_func, NULL);
86 g_log_set_handler ("GLib-GObject", G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
87 gst_check_log_critical_func, NULL);