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
This commit is contained in:
Jason Litzinger 2015-04-22 11:04:06 -06:00 committed by Tim-Philipp Müller
parent 1b881ecc26
commit 6aee4af034

View file

@ -329,6 +329,60 @@ GST_START_TEST (info_register_same_debug_category_twice)
"Going once");
}
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
@ -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;