1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de> 4 * 5 * Logging function tests for CONFIG_LOG_SYSLOG=y. 6 * 7 * Invoke the test with: ./u-boot -d arch/sandbox/dts/test.dtb 8 */ 9 10 #include <common.h> 11 #include <asm/global_data.h> 12 #include <dm/device.h> 13 #include <hexdump.h> 14 #include <test/log.h> 15 #include <test/test.h> 16 #include <test/suites.h> 17 #include <test/ut.h> 18 #include <asm/eth.h> 19 #include "syslog_test.h" 20 21 DECLARE_GLOBAL_DATA_PTR; 22 23 /** 24 * log_test_syslog_nodebug() - test logging level filter 25 * 26 * Verify that log_debug() does not lead to a log message if the logging level 27 * is set to LOGL_INFO. 28 * 29 * @uts: unit test state 30 * Return: 0 = success 31 */ log_test_syslog_nodebug(struct unit_test_state * uts)32static int log_test_syslog_nodebug(struct unit_test_state *uts) 33 { 34 int old_log_level = gd->default_log_level; 35 struct sb_log_env env; 36 37 ut_assertok(syslog_test_setup(uts)); 38 gd->log_fmt = LOGF_TEST; 39 gd->default_log_level = LOGL_INFO; 40 env_set("ethact", "eth@10002000"); 41 env_set("log_hostname", "sandbox"); 42 env.expected = "<7>sandbox uboot: log_test_syslog_nodebug() " 43 "testing log_debug\n"; 44 env.uts = uts; 45 sandbox_eth_set_tx_handler(0, sb_log_tx_handler); 46 /* Used by ut_assert macros in the tx_handler */ 47 sandbox_eth_set_priv(0, &env); 48 log_debug("testing %s\n", "log_debug"); 49 sandbox_eth_set_tx_handler(0, NULL); 50 /* Check that the callback function was not called */ 51 ut_assertnonnull(env.expected); 52 gd->default_log_level = old_log_level; 53 gd->log_fmt = log_get_default_format(); 54 ut_assertok(syslog_test_finish(uts)); 55 56 return 0; 57 } 58 LOG_TEST(log_test_syslog_nodebug); 59