u-boot/test/log/syslog_test.h
Simon Glass 52d3df7fef log: Allow LOG_DEBUG to always enable log output
At present if CONFIG_LOG enabled, putting LOG_DEBUG at the top of a file
(before log.h inclusion) causes _log() to be executed for every log()
call, regardless of the build- or run-time logging level.

However there is no guarantee that the log record will actually be
displayed. If the current log level is lower than LOGL_DEBUG then it will
not be.

Add a way to signal that the log record should always be displayed and
update log_passes_filters() to handle this.

With the new behaviour, log_debug() will always log if LOG_DEBUG is
enabled.

Move log_test_syslog_nodebug() into its own file since it cannot be made
to work where it is, with LOG_DEBUG defined.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-10 16:49:58 -04:00

50 lines
1.4 KiB
C

/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
*
* Header file for logging tests
*/
#ifndef __SYSLOG_TEST_H
#define __SYSLOG_TEST_H
#define LOGF_TEST (BIT(LOGF_FUNC) | BIT(LOGF_MSG))
/**
* struct sb_log_env - private data for sandbox ethernet driver
*
* This structure is used for the private data of the sandbox ethernet
* driver.
*
* @expected: string expected to be written by the syslog driver
* @uts: unit test state
*/
struct sb_log_env {
const char *expected;
struct unit_test_state *uts;
};
/**
* sb_log_tx_handler() - transmit callback function
*
* This callback function is invoked when a network package is sent using the
* sandbox Ethernet driver. The private data of the driver holds a sb_log_env
* structure with the unit test state and the expected UDP payload.
*
* The following checks are executed:
*
* * the Ethernet packet indicates a IP broadcast message
* * the IP header is for a local UDP broadcast message to port 514
* * the UDP payload matches the expected string
*
* After testing the pointer to the expected string is set to NULL to signal
* that the callback function has been called.
*
* @dev: sandbox ethernet device
* @packet: Ethernet packet
* @len: length of Ethernet packet
* Return: 0 = success
*/
int sb_log_tx_handler(struct udevice *dev, void *packet, unsigned int len);
#endif