tests: gstinfo: Test set_threshold_from_string's new reset behavior
authorJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>
Tue, 1 Sep 2020 14:01:08 +0000 (16:01 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 7 Nov 2022 14:49:45 +0000 (14:49 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/605>

subprojects/gstreamer/tests/check/gst/gstinfo.c

index cf53527..dba7d63 100644 (file)
@@ -514,6 +514,50 @@ GST_START_TEST (info_post_gst_init_category_registration)
 
 GST_END_TEST;
 
 
 GST_END_TEST;
 
+GST_START_TEST (info_set_and_reset_string)
+{
+  GstDebugCategory *states;
+  GstDebugCategory *caps;
+  GstDebugLevel cat;
+
+  GST_DEBUG_CATEGORY_GET (states, "GST_STATES");
+  GST_DEBUG_CATEGORY_GET (caps, "GST_CAPS");
+  fail_unless (states != NULL);
+  fail_unless (caps != NULL);
+
+  gst_debug_set_threshold_from_string ("WARNING,GST_CAPS:DEBUG", TRUE);
+  cat = gst_debug_category_get_threshold (states);
+  fail_unless_equals_int (cat, GST_LEVEL_WARNING);
+  cat = gst_debug_category_get_threshold (caps);
+  fail_unless_equals_int (cat, GST_LEVEL_DEBUG);
+
+  gst_debug_set_threshold_from_string ("GST_STATES:TRACE", FALSE);
+  cat = gst_debug_category_get_threshold (states);
+  fail_unless_equals_int (cat, GST_LEVEL_TRACE);
+  cat = gst_debug_category_get_threshold (caps);
+  fail_unless_equals_int (cat, GST_LEVEL_DEBUG);
+
+  gst_debug_set_threshold_from_string ("INFO,GST_CAPS:FIXME", FALSE);
+  cat = gst_debug_category_get_threshold (states);
+  fail_unless_equals_int (cat, GST_LEVEL_TRACE);
+  cat = gst_debug_category_get_threshold (caps);
+  fail_unless_equals_int (cat, GST_LEVEL_FIXME);
+
+  gst_debug_set_threshold_from_string ("INFO,GST_CAPS:FIXME", TRUE);
+  cat = gst_debug_category_get_threshold (states);
+  fail_unless_equals_int (cat, GST_LEVEL_INFO);
+  cat = gst_debug_category_get_threshold (caps);
+  fail_unless_equals_int (cat, GST_LEVEL_FIXME);
+
+  gst_debug_set_threshold_from_string ("", TRUE);
+  cat = gst_debug_category_get_threshold (states);
+  fail_unless_equals_int (cat, GST_LEVEL_DEFAULT);
+  cat = gst_debug_category_get_threshold (caps);
+  fail_unless_equals_int (cat, GST_LEVEL_DEFAULT);
+}
+
+GST_END_TEST;
+
 static Suite *
 gst_info_suite (void)
 {
 static Suite *
 gst_info_suite (void)
 {
@@ -536,6 +580,7 @@ gst_info_suite (void)
   tcase_add_test (tc_chain, info_set_and_unset_single);
   tcase_add_test (tc_chain, info_set_and_unset_multiple);
   tcase_add_test (tc_chain, info_post_gst_init_category_registration);
   tcase_add_test (tc_chain, info_set_and_unset_single);
   tcase_add_test (tc_chain, info_set_and_unset_multiple);
   tcase_add_test (tc_chain, info_post_gst_init_category_registration);
+  tcase_add_test (tc_chain, info_set_and_reset_string);
 #endif
 
   return s;
 #endif
 
   return s;