From 7484b4f095e3bf7c16fc2f91dc1a78f04397bf01 Mon Sep 17 00:00:00 2001 From: Lane Kolbly Date: Wed, 23 Feb 2022 17:04:48 -0600 Subject: host: test: Add UHD_UNITTEST_LOG_LEVEL override --- host/tests/rfnoc_block_tests/x4xx_radio_mock.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'host/tests') diff --git a/host/tests/rfnoc_block_tests/x4xx_radio_mock.hpp b/host/tests/rfnoc_block_tests/x4xx_radio_mock.hpp index 21b8529cc..80492773b 100644 --- a/host/tests/rfnoc_block_tests/x4xx_radio_mock.hpp +++ b/host/tests/rfnoc_block_tests/x4xx_radio_mock.hpp @@ -211,12 +211,23 @@ public: */ constexpr size_t DEFAULT_MTU = 8000; -//! Helper class to make sure we get the most logging regardless of environment -// settings +//! Helper class to make sure we get the most logging. The logging level can be +// overridden using a special test-specific environment variable, +// `UHD_UNITTEST_LOG_LEVEL`. struct uhd_log_enabler { uhd_log_enabler(uhd::log::severity_level level) { + const char* env_p = std::getenv("UHD_UNITTEST_LOG_LEVEL"); + if (env_p) { + auto parsed_level = uhd::log::parse_log_level_from_string(env_p); + if (parsed_level) { + level = *parsed_level; + } else { + std::cout << "Unable to parse UHD_UNITTEST_LOG_LEVEL " << env_p << std::endl; + } + } + std::cout << "Setting log level to " << level << "..." << std::endl; uhd::log::set_log_level(level); uhd::log::set_console_level(level); -- cgit v1.2.3