log/test: Extend test case for log_check_level

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
This commit is contained in:
Jacob Erlbeck 2015-11-17 11:52:26 +01:00 committed by Holger Hans Peter Freyther
parent a89d22c0f0
commit 64e0eb56fd
2 changed files with 11 additions and 1 deletions

View File

@ -78,16 +78,26 @@ int main(int argc, char **argv)
log_parse_category_mask(stderr_target, "DRLL:DCC");
log_parse_category_mask(stderr_target, "DRLL");
DEBUGP(DCC, "You should not see this\n");
if (log_check_level(DMM, LOGL_DEBUG) != 0)
fprintf(stderr, "log_check_level did not catch this case\n");
log_parse_category_mask(stderr_target, "DRLL:DCC");
DEBUGP(DRLL, "You should see this\n");
OSMO_ASSERT(log_check_level(DRLL, LOGL_DEBUG) != 0);
DEBUGP(DCC, "You should see this\n");
OSMO_ASSERT(log_check_level(DCC, LOGL_DEBUG) != 0);
DEBUGP(DMM, "You should not see this\n");
if (log_check_level(DMM, LOGL_DEBUG) != 0)
fprintf(stderr, "log_check_level did not catch this case\n");
OSMO_ASSERT(filter_called == 0);
log_set_all_filter(stderr_target, 0);
DEBUGP(DRLL, "You should not see this and filter is called\n");
OSMO_ASSERT(filter_called == 1);
if (log_check_level(DRLL, LOGL_DEBUG) != 0)
fprintf(stderr,
"log_check_level did not catch this case (filter)\n");
return 0;
}

View File

@ -1,3 +1,3 @@
You should see this
You should see this

log_check_level did not catch this case (filter)