aboutsummaryrefslogtreecommitdiffstats
path: root/tests/logging/logging_test.c
AgeCommit message (Collapse)AuthorFilesLines
2016-12-12show bug in logging: log_set_category_filter on DL* categoriesNeels Hofmeyr1-0/+6
Add a check to logging_test.c to show a bug: passing an internal DL* category constant to log_set_category_filter() results in a negative array index and undefined behavior. A sanitize build should catch this. The bug is confirmed by the fact that logging_test.err stays the same (hopefully) although a logging output should appear from this patch. The test could as well segfault or anything else, it's a bit of a gamble. This bug will be fixed along with the expectation in a subsequent patch. Change-Id: Ie2da77c642a84cafc0f528985930697ec167183b
2016-12-12show bug in logging: out-of-bounds check should end with user categoriesNeels Hofmeyr1-0/+4
In the background osmo_log_info array, the user's logging categories are enhanced by the library internal ones. So far logging category range checking only checked for the larger array bounds, although passing a logging category >= num_cat_user is already semantically unknown and should redirect to DLGLOBAL. Add a check to logging_test.c to show that this isn't happening. Instead of DLGLOBAL, a logging category that happens to be at that index is queried. The bug is confirmed by logging_test.err only showing "(e)" and not "(d)": "(e)" is shown because the first category after the user ones happens to be DLGLOBAL. "(d)" is omitted since it hits a category that's not on debug level. This bug will be fixed along with the expectation in a subsequent patch. Change-Id: I397278714018ee9a0ae5101515f31ddddf79c2ec
2016-12-12show bug in logging: erratic redirection to DLGLOBAL for first invalid categoryNeels Hofmeyr1-0/+1
Add a check to logging_test.c to show a bug: when a logging category value that is the first out-of-bounds value is passed to the logging system, the internal map_subsys() fails to redirect to DLGLOBAL due to a flawed conditional. This results in a too large array index and undefined behavior. A sanitize build should catch this. The bug is confirmed by the fact that logging_test.err stays the same (hopefully) although a logging output should appear from this patch. The test could as well segfault or anything else, it's a bit of a gamble. This bug will be fixed along with the expectation in a subsequent patch. Change-Id: I12bf38b6c1f85e2d7bf5a15f942dfe0beed41eba
2016-12-12show bug in logging: erratic redirection to DLGLOBAL for invalid categoriesNeels Hofmeyr1-0/+8
Add a check to logging_test.c to show a bug: when a logging category value that is out-of-bounds is passed to the logging system, the internal map_subsys() function should remap that to DLGLOBAL. But in fact DLGLOBAL is -1 and the function fails to map this to a proper positive array index, directly returning -1 instead. This results in a negative array index and undefined behavior. A sanitize build should catch this. The bug is confirmed by the fact that logging_test.err stays the same (hopefully) although a logging output should appear from this patch. The test could as well segfault or anything else, it's a bit of a gamble. This bug will be fixed along with the expectation in a subsequent patch. Note: osmo_log_info->num_cat + 0 is also out-of-bounds, but there is a separate bug there, so leaving this for another patch. Change-Id: I161b6550fa204a872bad1abefee1a6155393fafd
2016-12-12logging test: cosmetic: print target and don't print colorNeels Hofmeyr1-0/+2
Prepares for upcoming modifications of the logging test to show and fix bugs in the logging system. Change-Id: I9461b987adf85d87469a6af55de5f1aa478f6ebb
2016-02-29logging: Move the filter check up as wellHolger Hans Peter Freyther1-6/+13
There doesn't seem to be a reason not to check the filter. Update and extend the test. Currently the filter function will be called once for the log check and once for the output of it.
2016-02-29log/test: Extend test case for log_check_levelJacob Erlbeck1-0/+10
This commit adds OSMO_ASSERTs for mandatory conditions related to log_check_level, and fprintfs for optional conditions, since it is always safe for log_check_level to return != 0. Sponsored-by: On-Waves ehf
2013-12-29logging: Copy the filter_fn and fix the IMSI filter in OpenBSCHolger Hans Peter Freyther1-0/+17
The filter_fn has not been copied into the new structure breaking the imsi and other filters in OpenBSC. Looking at the code we should also introduce a callback for the reset of the context so we could use subscr_get/subscr_put on the subscriber structure.
2012-09-27logging: Modify the testcase to excercise Nico's fixHolger Hans Peter Freyther1-1/+1
2012-09-27logging: Move the logging test from OpenBSC into libosmocoreHolger Hans Peter Freyther1-0/+76
Add a testcase for the logging facility. The test is coming from the OpenBSC code.