From a3b9a49f1848926d13eaf27f2868488601435bc8 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 26 Jan 2026 19:06:28 +0300 Subject: [PATCH] Replace printf with DEBUG_ macros in test_memory_pool_and_config.c --- tests/test_memory_pool_and_config.c | 38 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/tests/test_memory_pool_and_config.c b/tests/test_memory_pool_and_config.c index e11cc80..58dd2c1 100644 --- a/tests/test_memory_pool_and_config.c +++ b/tests/test_memory_pool_and_config.c @@ -26,21 +26,25 @@ static void test_waiter_callback(struct ll_queue* q, void* arg) { } int main() { - printf("=== Memory Pool and Config File Test ===\n"); + debug_config_init(); + debug_set_level(DEBUG_LEVEL_TRACE); + debug_set_categories(DEBUG_CATEGORY_ALL); + + DEBUG_INFO(DEBUG_CATEGORY_MEMORY, "=== Memory Pool and Config File Test ==="); // Test 1: Memory pool optimization - printf("Test 1: Memory pool optimization...\n"); + DEBUG_INFO(DEBUG_CATEGORY_MEMORY, "Test 1: Memory pool optimization..."); uasync_t* ua = uasync_create(); if (!ua) { - printf("Failed to create uasync\n"); + DEBUG_ERROR(DEBUG_CATEGORY_MEMORY, "Failed to create uasync"); return 1; } // Create queue with memory pools enabled struct ll_queue* queue = queue_new(ua, 0); if (!queue) { - printf("Failed to create queue with pools\n"); + DEBUG_ERROR(DEBUG_CATEGORY_MEMORY, "Failed to create queue with pools"); uasync_destroy(ua, 0); return 1; } @@ -75,17 +79,17 @@ int main() { // Get pool statistics size_t allocations, reuse_count; - printf("Pool statistics: allocations=%zu, reuse_count=%zu\n", allocations, reuse_count); - printf("Pool efficiency: %.1f%%\n", + DEBUG_INFO(DEBUG_CATEGORY_MEMORY, "Pool statistics: allocations=%zu, reuse_count=%zu", allocations, reuse_count); + DEBUG_INFO(DEBUG_CATEGORY_MEMORY, "Pool efficiency: %.1f%%", allocations > 0 ? (100.0 * reuse_count / allocations) : 0.0); queue_free(queue); uasync_destroy(ua, 0); - printf("Memory pool test: PASS\n\n"); + DEBUG_INFO(DEBUG_CATEGORY_MEMORY, "Memory pool test: PASS"); // Test 2: Configuration file support - printf("Test 2: Configuration file support...\n"); + DEBUG_INFO(DEBUG_CATEGORY_CONFIG, "Test 2: Configuration file support..."); // Create a test configuration file const char* config_file = "/tmp/debug_test.conf"; @@ -102,32 +106,32 @@ int main() { // Parse the configuration string (we don't have file parsing, so use string parsing) const char* config_string = "ll_queue:debug,uasync:info,memory:warn,etcp:error"; if (debug_parse_config(config_string) == 0) { - printf("Configuration parsed successfully\n"); + DEBUG_INFO(DEBUG_CATEGORY_CONFIG, "Configuration parsed successfully"); // Test that configuration was applied if (debug_should_output(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_LL_QUEUE)) { - printf("LL_QUEUE debug level correctly set\n"); + DEBUG_INFO(DEBUG_CATEGORY_LL_QUEUE, "LL_QUEUE debug level correctly set"); } if (debug_should_output(DEBUG_LEVEL_INFO, DEBUG_CATEGORY_UASYNC)) { - printf("UASYNC info level correctly set\n"); + DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "UASYNC info level correctly set"); } if (!debug_should_output(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_ETCP)) { - printf("ETCP correctly limited to error level\n"); + DEBUG_INFO(DEBUG_CATEGORY_ETCP, "ETCP correctly limited to error level"); } - printf("Note: Hot reload functionality not implemented in current debug system\n"); + DEBUG_INFO(DEBUG_CATEGORY_CONFIG, "Note: Hot reload functionality not implemented in current debug system"); } else { - printf("Failed to parse configuration\n"); + DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "Failed to parse configuration"); } unlink(config_file); } else { - printf("Failed to create test configuration file\n"); + DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "Failed to create test configuration file"); } - printf("Configuration file test: PASS\n"); + DEBUG_INFO(DEBUG_CATEGORY_CONFIG, "Configuration file test: PASS"); - printf("\n=== All tests completed successfully ===\n"); + DEBUG_INFO(DEBUG_CATEGORY_MEMORY, "=== All tests completed successfully ==="); return 0; } \ No newline at end of file