summaryrefslogtreecommitdiffstats
path: root/tests/logging
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-12-12 15:53:51 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-12-12 16:09:14 +0100
commitd1a145e5e782d07140422b85da9f55dd4b35a206 (patch)
treea6441cee4ee45a189fed1ed14aa5610cacab0a8b /tests/logging
parentca13574ba4eeb2c9e3ad865a570e6b5d3f05a3b6 (diff)
show bug in logging: out-of-bounds check should end with user categories
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
Diffstat (limited to 'tests/logging')
-rw-r--r--tests/logging/logging_test.c4
-rw-r--r--tests/logging/logging_test.err1
2 files changed, 5 insertions, 0 deletions
diff --git a/tests/logging/logging_test.c b/tests/logging/logging_test.c
index 3cc6c5b2..5ef214d8 100644
--- a/tests/logging/logging_test.c
+++ b/tests/logging/logging_test.c
@@ -113,9 +113,13 @@ int main(int argc, char **argv)
/* Make sure out-of-bounds category maps to DLGLOBAL */
log_parse_category_mask(stderr_target, "DLGLOBAL,1");
+ /* For IDs out of bounds of the overall osmo_log_info array */
DEBUGP(osmo_log_info->num_cat + 1, "You should see this on DLGLOBAL (a)\n");
DEBUGP(osmo_log_info->num_cat + 100, "You should see this on DLGLOBAL (b)\n");
DEBUGP(osmo_log_info->num_cat, "You should see this on DLGLOBAL (c)\n");
+ /* For IDs out of bounds of the user categories part */
+ DEBUGP(log_info.num_cat + 1, "You should see this on DLGLOBAL (d)\n");
+ DEBUGP(log_info.num_cat, "You should see this on DLGLOBAL (e)\n");
return 0;
}
diff --git a/tests/logging/logging_test.err b/tests/logging/logging_test.err
index 273a852b..f4e9c1f4 100644
--- a/tests/logging/logging_test.err
+++ b/tests/logging/logging_test.err
@@ -4,3 +4,4 @@ DRLL You should see this
DLGLOBAL You should see this on DLGLOBAL (a)
DLGLOBAL You should see this on DLGLOBAL (b)
DLGLOBAL You should see this on DLGLOBAL (c)
+DLGLOBAL You should see this on DLGLOBAL (e)