From de6e1864cbea7e0de15dbb6221ac4654a56dfe4a Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Mon, 26 Apr 2021 14:30:20 +0200 Subject: [PATCH] tests: logging: log_core: Remove cases moved to log_api suite Cleanup in the test suite since some tests were moved to log_api suite. Signed-off-by: Krzysztof Chruscinski --- .../logging/log_core/src/log_core_test.c | 262 +----------------- 1 file changed, 4 insertions(+), 258 deletions(-) diff --git a/tests/subsys/logging/log_core/src/log_core_test.c b/tests/subsys/logging/log_core/src/log_core_test.c index ac66281f514..56ccf67de0c 100644 --- a/tests/subsys/logging/log_core/src/log_core_test.c +++ b/tests/subsys/logging/log_core/src/log_core_test.c @@ -173,181 +173,6 @@ static void log_setup(bool backend2_enable) test_source_id = log_source_id_get(STRINGIFY(LOG_MODULE_NAME)); } -/* - * Test is using 2 backends and runtime filtering is enabled. After first call - * filtering for backend2 is reduced to warning. It is expected that next INFO - * level log message will be passed only to backend1. - */ -static void test_log_backend_runtime_filtering(void) -{ - log_setup(true); - - backend1_cb.check_timestamp = true; - backend2_cb.check_timestamp = true; - - backend1_cb.exp_timestamps[0] = 0U; - backend1_cb.exp_timestamps[1] = 1U; - backend1_cb.exp_timestamps[2] = 2U; - - /* Expect one less log message */ - backend2_cb.exp_timestamps[0] = 0U; - backend2_cb.exp_timestamps[1] = 2U; - - LOG_INF("test"); - while (log_process(false)) { - } - - log_filter_set(&backend2, - CONFIG_LOG_DOMAIN_ID, - test_source_id, - LOG_LEVEL_WRN); - - LOG_INF("test"); - LOG_WRN("test"); - - while (log_process(false)) { - } - - zassert_equal(3, - backend1_cb.counter, - "Unexpected amount of messages received by the backend."); - - zassert_equal(2, - backend2_cb.counter, - "Unexpected amount of messages received by the backend."); -} - -/* - * When LOG_MODE_OVERFLOW is enabled, logger should discard oldest messages when - * there is no room. However, if after discarding all messages there is still no - * room then current log is discarded. - */ -uint8_t data[CONFIG_LOG_BUFFER_SIZE]; -static void test_log_overflow(void) -{ - uint32_t msgs_in_buf = CONFIG_LOG_BUFFER_SIZE/sizeof(union log_msg_chunk); - uint32_t max_hexdump_len = LOG_MSG_HEXDUMP_BYTES_HEAD_CHUNK + - HEXDUMP_BYTES_CONT_MSG * (msgs_in_buf - 1); - uint32_t hexdump_len = max_hexdump_len - HEXDUMP_BYTES_CONT_MSG; - - - zassert_true(IS_ENABLED(CONFIG_LOG_MODE_OVERFLOW), - "Test requires that overflow mode is enabled"); - - log_setup(false); - backend1_cb.check_timestamp = true; - backend2_cb.check_timestamp = true; - - /* expect first message to be dropped */ - backend1_cb.exp_timestamps[0] = 1U; - backend1_cb.exp_timestamps[1] = 2U; - - LOG_INF("test"); - LOG_INF("test"); - LOG_HEXDUMP_INF(data, hexdump_len, "test"); - - while (log_process(false)) { - } - - /* Expect big message to be dropped because it does not fit in. - * First message is also dropped in the process of finding free space. - */ - backend1_cb.exp_timestamps[2] = 3U; - - LOG_INF("test"); - LOG_HEXDUMP_INF(data, max_hexdump_len+1, "test"); - - while (log_process(false)) { - } - - zassert_equal(2, - backend1_cb.counter, - "Unexpected amount of messages received by the backend."); -} - -/* - * Test checks if arguments are correctly processed by the logger. - * - * Log messages with supported number of messages are called. Test backend - * validates number of arguments and values. - */ -static void test_log_arguments(void) -{ - log_setup(false); - backend1_cb.check_args = true; - - backend1_cb.exp_nargs[0] = 10U; - backend1_cb.exp_nargs[1] = 1U; - backend1_cb.exp_nargs[2] = 2U; - backend1_cb.exp_nargs[3] = 3U; - backend1_cb.exp_nargs[4] = 4U; - backend1_cb.exp_nargs[5] = 5U; - backend1_cb.exp_nargs[6] = 6U; - backend1_cb.exp_nargs[7] = 7U; - backend1_cb.exp_nargs[8] = 8U; - backend1_cb.exp_nargs[9] = 9U; - backend1_cb.exp_nargs[10] = 10U; - backend1_cb.exp_nargs[11] = 11U; - backend1_cb.exp_nargs[12] = 12U; - backend1_cb.exp_nargs[13] = 13U; - backend1_cb.exp_nargs[14] = 14U; - - LOG_INF("test"); - LOG_INF("test %d", 1); - LOG_INF("test %d %d", 1, 2); - LOG_INF("test %d %d %d", 1, 2, 3); - LOG_INF("test %d %d %d %d", 1, 2, 3, 4); - /* to avoid messges drop */ - while (log_process(false)) { - } - LOG_INF("test %d %d %d %d %d", 1, 2, 3, 4, 5); - LOG_INF("test %d %d %d %d %d %d", 1, 2, 3, 4, 5, 6); - LOG_INF("test %d %d %d %d %d %d %d", 1, 2, 3, 4, 5, 6, 7); - LOG_INF("test %d %d %d %d %d %d %d %d", 1, 2, 3, 4, 5, 6, 7, 8); - LOG_INF("test %d %d %d %d %d %d %d %d %d", 1, 2, 3, 4, 5, 6, 7, 8, 9); - LOG_INF("test %d %d %d %d %d %d %d %d %d %d", - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - while (log_process(false)) { - } - LOG_INF("test %d %d %d %d %d %d %d %d %d %d %d", - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - LOG_INF("test %d %d %d %d %d %d %d %d %d %d %d %d", - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); - LOG_INF("test %d %d %d %d %d %d %d %d %d %d %d %d %d", - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13); - LOG_INF("test %d %d %d %d %d %d %d %d %d %d %d %d %d %d", - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14); - while (log_process(false)) { - } - - zassert_equal(15, - backend1_cb.counter, - "Unexpected amount of messages received by the backend."); -} - -/* Function comes from the file which is part of test module. It is - * expected that logs coming from it will have same source_id as current - * module (this file). - */ -static void test_log_from_declared_module(void) -{ - log_setup(false); - - /* Setup log backend to validate source_id of the message. */ - backend1_cb.check_id = true; - backend1_cb.exp_id[0] = LOG_CURRENT_MODULE_ID(); - backend1_cb.exp_id[1] = LOG_CURRENT_MODULE_ID(); - - test_func(); - test_inline_func(); - - while (log_process(false)) { - } - - zassert_equal(2, backend1_cb.counter, - "Unexpected amount of messages received by the backend."); -} - static void test_log_strdup_gc(void) { char test_str[] = "test string"; @@ -464,48 +289,6 @@ static void test_strdup_trimming(void) "Unexpected amount of messages received by the backend."); } -static void log_n_messages(uint32_t n_msg, uint32_t exp_dropped) -{ - int i; - - for (i = 0; i < n_msg; i++) { - LOG_INF("dummy"); - } - - while (log_process(false)) { - } - - zassert_equal(backend1_cb.total_drops, exp_dropped, - "Unexpected log msg dropped %d (expected %d)", - backend1_cb.total_drops, exp_dropped); - -} - -/* - * Test checks if backend receives notification about dropped messages. It - * first blocks threads to ensure full control of log processing time and - * then logs certain log messages, expecting dropped notification. - */ -static void test_log_msg_dropped_notification(void) -{ - __ASSERT_NO_MSG(CONFIG_LOG_MODE_OVERFLOW); - - uint32_t capacity = CONFIG_LOG_BUFFER_SIZE/sizeof(struct log_msg); - - log_setup(false); - - /* Ensure that log messages aren't processed */ - k_sched_lock(); - - log_n_messages(capacity, 0); - - /* Expect messages dropped when logger more than buffer capacity. */ - log_n_messages(capacity + 1, 1); - log_n_messages(capacity + 2, 3); - - k_sched_unlock(); -} - static void test_single_z_log_get_s_mask(const char *str, uint32_t nargs, uint32_t exp_mask) { @@ -522,52 +305,15 @@ static void test_z_log_get_s_mask(void) "%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%s", 32, 0x80000000); } -/* - * Test checks if panic is correctly executed. On panic logger should flush all - * messages and process logs in place (not in deferred way). - * - * NOTE: this test must be the last in the suite because after this test log - * is in panic mode. - */ -static void test_log_panic(void) -{ - log_setup(false); - - LOG_INF("test"); - LOG_INF("test"); - - /* logs should be flushed in panic */ - log_panic(); - in_panic = true; - - zassert_true(backend1_cb.panic, - "Expecting backend to receive panic notification."); - - zassert_equal(2, - backend1_cb.counter, - "Unexpected amount of messages received by the backend."); - - /* messages processed where called */ - LOG_INF("test"); - - zassert_equal(3, - backend1_cb.counter, - "Unexpected amount of messages received by the backend."); -} /*test case main entry*/ void test_main(void) { - ztest_test_suite(test_log_list, - ztest_unit_test(test_log_backend_runtime_filtering), - ztest_unit_test(test_log_overflow), - ztest_unit_test(test_log_arguments), - ztest_unit_test(test_log_from_declared_module), + ztest_test_suite(test_log_core, ztest_unit_test(test_log_strdup_gc), ztest_unit_test(test_log_strdup_detect_miss), ztest_unit_test(test_strdup_trimming), - ztest_unit_test(test_log_msg_dropped_notification), - ztest_unit_test(test_z_log_get_s_mask), - ztest_unit_test(test_log_panic)); - ztest_run_test_suite(test_log_list); + ztest_unit_test(test_z_log_get_s_mask) + ); + ztest_run_test_suite(test_log_core); }