From d1a145e5e782d07140422b85da9f55dd4b35a206 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 12 Dec 2016 15:53:51 +0100 Subject: [PATCH] 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 --- tests/logging/logging_test.c | 4 ++++ tests/logging/logging_test.err | 1 + 2 files changed, 5 insertions(+) diff --git a/tests/logging/logging_test.c b/tests/logging/logging_test.c index 3cc6c5b2a..5ef214d86 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 273a852b9..f4e9c1f43 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)