summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <thibault.saunier@collabora.com>2012-06-29 13:29:14 -0400
committerThibault Saunier <thibault.saunier@collabora.com>2012-06-29 13:29:14 -0400
commitb6734d9f1e5444a344f595abcfc4b4b115ed4788 (patch)
tree549d946f3c6eecfce3ed57a0ad78c6f31b998f08
parent7e6a713a88ab6f513f3e6ffd76b9fd26d1745a86 (diff)
lib: Make debug level change between iterations of start/stop actually effective
-rw-r--r--lib/insanity-gst/insanitygsttest.c74
1 files changed, 72 insertions, 2 deletions
diff --git a/lib/insanity-gst/insanitygsttest.c b/lib/insanity-gst/insanitygsttest.c
index c3976b6..39ceb4d 100644
--- a/lib/insanity-gst/insanitygsttest.c
+++ b/lib/insanity-gst/insanitygsttest.c
@@ -58,6 +58,76 @@ init_gstreamer (void)
}
static gboolean
+parse_debug_category (gchar * str, const gchar ** category)
+{
+ if (!str)
+ return FALSE;
+
+ /* works in place */
+ g_strstrip (str);
+
+ if (str[0] != '\0') {
+ *category = str;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+parse_debug_level (gchar * str, GstDebugLevel * level)
+{
+ if (!str)
+ return FALSE;
+
+ /* works in place */
+ g_strstrip (str);
+
+ if (str[0] != '\0' && str[1] == '\0'
+ && str[0] >= '0' && str[0] < '0' + GST_LEVEL_COUNT) {
+ *level = (GstDebugLevel) (str[0] - '0');
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+parse_debug_list (const gchar * list)
+{
+ gchar **split;
+ gchar **walk;
+
+ g_assert (list);
+
+ split = g_strsplit (list, ",", 0);
+
+ for (walk = split; *walk; walk++) {
+ if (strchr (*walk, ':')) {
+ gchar **values = g_strsplit (*walk, ":", 2);
+
+ if (values[0] && values[1]) {
+ GstDebugLevel level;
+ const gchar *category;
+
+ if (parse_debug_category (values[0], &category)
+ && parse_debug_level (values[1], &level))
+ gst_debug_set_threshold_for_name (category, level);
+ }
+
+ g_strfreev (values);
+ } else {
+ GstDebugLevel level;
+
+ if (parse_debug_level (*walk, &level))
+ gst_debug_set_default_threshold (level);
+ }
+ }
+
+ g_strfreev (split);
+}
+
+static gboolean
insanity_gst_test_setup (InsanityTest * test)
{
const char *registry;
@@ -93,11 +163,11 @@ insanity_gst_test_start (InsanityTest * test)
insanity_test_get_string_argument (test, "gst-debug-level", &loglevel);
if (g_strcmp0 (loglevel, "-1") != 0)
- g_setenv ("GST_DEBUG", loglevel, TRUE);
+ parse_debug_list (loglevel);
else {
insanity_test_get_string_argument (test, "global-gst-debug-level",
&loglevel);
- g_setenv ("GST_DEBUG", loglevel, TRUE);
+ parse_debug_list (loglevel);
}
if (!INSANITY_TEST_CLASS (insanity_gst_test_parent_class)->start (test))