[PATCH 3/3] log/test: Extend test case for log_check_level

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Tue Nov 17 10:52:26 UTC 2015


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
---
 tests/logging/logging_test.c   | 10 ++++++++++
 tests/logging/logging_test.err |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tests/logging/logging_test.c b/tests/logging/logging_test.c
index b263f90..3c8bac4 100644
--- a/tests/logging/logging_test.c
+++ b/tests/logging/logging_test.c
@@ -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;
 }
diff --git a/tests/logging/logging_test.err b/tests/logging/logging_test.err
index b59d2e8..c3b67cc 100644
--- a/tests/logging/logging_test.err
+++ b/tests/logging/logging_test.err
@@ -1,3 +1,3 @@
 You should see this
 You should see this
-
\ No newline at end of file
+log_check_level did not catch this case (filter)
-- 
1.9.1




More information about the OpenBSC mailing list