From 6aee4af0346dfc5054da5ec71f4fddbebd8b9305 Mon Sep 17 00:00:00 2001 From: Jason Litzinger Date: Wed, 22 Apr 2015 11:04:06 -0600 Subject: [PATCH] tests: info: add test case to reproduce infinite loop gst_debug_unset_threshold_for_name() used to go into an infinite loop when there was more than one category in the list. This test captures the problem by failing via timeout. https://bugzilla.gnome.org/show_bug.cgi?id=748321 --- tests/check/gst/gstinfo.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/check/gst/gstinfo.c b/tests/check/gst/gstinfo.c index 2f1ca72..f808d8e 100644 --- a/tests/check/gst/gstinfo.c +++ b/tests/check/gst/gstinfo.c @@ -330,6 +330,60 @@ GST_START_TEST (info_register_same_debug_category_twice) } GST_END_TEST; + +GST_START_TEST (info_set_and_unset_single) +{ + GstDebugLevel orig = gst_debug_get_default_threshold (); + GstDebugLevel cat1, cat2; + GstDebugCategory *states; + + GST_DEBUG_CATEGORY_GET (states, "GST_STATES"); + fail_unless (states != NULL); + + gst_debug_set_default_threshold (GST_LEVEL_WARNING); + + gst_debug_set_threshold_for_name ("GST_STATES", GST_LEVEL_DEBUG); + cat1 = gst_debug_category_get_threshold (states); + gst_debug_unset_threshold_for_name ("GST_STATES"); + cat2 = gst_debug_category_get_threshold (states); + + gst_debug_set_default_threshold (orig); + fail_unless (cat1 = GST_LEVEL_DEBUG); + fail_unless (cat2 = GST_LEVEL_WARNING); +} + +GST_END_TEST; + +GST_START_TEST (info_set_and_unset_multiple) +{ + GstDebugLevel orig = gst_debug_get_default_threshold (); + GstDebugLevel cat1, cat2, cat3; + GstDebugCategory *states; + GstDebugCategory *caps; + + 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_default_threshold (GST_LEVEL_WARNING); + + gst_debug_set_threshold_for_name ("GST_STATES", GST_LEVEL_DEBUG); + gst_debug_set_threshold_for_name ("GST_CAPS", GST_LEVEL_DEBUG); + cat1 = gst_debug_category_get_threshold (states); + gst_debug_unset_threshold_for_name ("GST_STATES"); + gst_debug_unset_threshold_for_name ("GST_CAPS"); + cat2 = gst_debug_category_get_threshold (states); + cat3 = gst_debug_category_get_threshold (caps); + + gst_debug_set_default_threshold (orig); + + fail_unless (cat1 = GST_LEVEL_DEBUG); + fail_unless (cat2 = GST_LEVEL_WARNING); + fail_unless (cat3 = GST_LEVEL_WARNING); +} + +GST_END_TEST; #endif GST_START_TEST (info_fourcc) @@ -367,6 +421,8 @@ gst_info_suite (void) tcase_add_test (tc_chain, info_fixme); tcase_add_test (tc_chain, info_old_printf_extensions); tcase_add_test (tc_chain, info_register_same_debug_category_twice); + tcase_add_test (tc_chain, info_set_and_unset_single); + tcase_add_test (tc_chain, info_set_and_unset_multiple); #endif return s; -- 2.7.4