summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2012-07-02 10:44:00 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-07-02 10:44:00 +0200
commit7b6a9a7ece56d9e8ea12cdda9912434d8f6c1c65 (patch)
tree4fb24e9c5138516fec9ccee4c9d52e482b29d172
parente14d94772ec9f81647f62c660c7a299fd586a569 (diff)
parent4746ccff75418183816c77267983b817bddee368 (diff)
Merge remote-tracking branch 'origin/0.10'
-rw-r--r--lib/insanity-gst/insanitygsttest.c109
1 files changed, 103 insertions, 6 deletions
diff --git a/lib/insanity-gst/insanitygsttest.c b/lib/insanity-gst/insanitygsttest.c
index e0f1cf1..9bf4a01 100644
--- a/lib/insanity-gst/insanitygsttest.c
+++ b/lib/insanity-gst/insanitygsttest.c
@@ -58,16 +58,91 @@ 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 *debuglog, *registry;
+ const char *registry;
+ gchar *loglevel;
+ gboolean color;
if (!INSANITY_TEST_CLASS (insanity_gst_test_parent_class)->setup (test))
return FALSE;
- /* Set GST_DEBUG_FILE to the target filename */
- debuglog = insanity_test_get_output_filename (test, "gst-debug-log");
- g_setenv ("GST_DEBUG_FILE", debuglog, TRUE);
+ insanity_test_get_string_argument (test, "global-gst-debug-level", &loglevel);
+ g_setenv ("GST_DEBUG", loglevel, TRUE);
+
+ insanity_test_get_boolean_argument (test, "gst-debug-color", &color);
+ if (color == FALSE)
+ g_setenv ("GST_DEBUG_NO_COLOR", "1", TRUE);
/* Set GST_REGISTRY to the target filename */
registry = insanity_test_get_output_filename (test, "gst-registry");
@@ -89,6 +164,17 @@ insanity_gst_test_setup (InsanityTest * test)
static gboolean
insanity_gst_test_start (InsanityTest * test)
{
+ gchar *loglevel;
+
+ insanity_test_get_string_argument (test, "gst-debug-level", &loglevel);
+ if (g_strcmp0 (loglevel, "-1") != 0)
+ parse_debug_list (loglevel);
+ else {
+ insanity_test_get_string_argument (test, "global-gst-debug-level",
+ &loglevel);
+ parse_debug_list (loglevel);
+ }
+
if (!INSANITY_TEST_CLASS (insanity_gst_test_parent_class)->start (test))
return FALSE;
@@ -118,9 +204,20 @@ insanity_gst_test_init (InsanityGstTest * gsttest)
gsttest->priv = priv;
+ /* Add our argument */
+ insanity_test_add_string_argument (test, "global-gst-debug-level",
+ "Default GStreamer debug level to be used for the test",
+ "This argument is used when no debug log level has been specified"
+ " between the various iteration of start/stop", TRUE, "0");
+ insanity_test_add_boolean_argument (test, "gst-debug-color",
+ "Switch on colouring in GST_DEBUG output", NULL, TRUE, FALSE);
+ insanity_test_add_string_argument (test, "gst-debug-level",
+ "The GStreamer debug level to be used for the test",
+ "This argument is used when you need more control over the debug logs"
+ " and want to set it between iterations of start/stop ('-1' means that"
+ " 'global-gst-debug-level' should be used instead)", FALSE, "-1");
+
/* Add our own items, etc */
- insanity_test_add_output_file (test, "gst-debug-log",
- "The GStreamer debug log", TRUE);
insanity_test_add_output_file (test, "gst-registry",
"The GStreamer registry file", TRUE);
}