blob: 39cce4ed498550dbc16bc64ddf39613e914d1700 [file] [log] [blame]
Simon Glass9c83cac2020-09-12 11:13:34 -06001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
4 *
5 * Header file for logging tests
6 */
7
8#ifndef __SYSLOG_TEST_H
9#define __SYSLOG_TEST_H
10
Simon Glass9c83cac2020-09-12 11:13:34 -060011/**
12 * struct sb_log_env - private data for sandbox ethernet driver
13 *
14 * This structure is used for the private data of the sandbox ethernet
15 * driver.
16 *
17 * @expected: string expected to be written by the syslog driver
18 * @uts: unit test state
19 */
20struct sb_log_env {
21 const char *expected;
22 struct unit_test_state *uts;
23};
24
25/**
26 * sb_log_tx_handler() - transmit callback function
27 *
28 * This callback function is invoked when a network package is sent using the
29 * sandbox Ethernet driver. The private data of the driver holds a sb_log_env
30 * structure with the unit test state and the expected UDP payload.
31 *
32 * The following checks are executed:
33 *
34 * * the Ethernet packet indicates a IP broadcast message
35 * * the IP header is for a local UDP broadcast message to port 514
36 * * the UDP payload matches the expected string
37 *
38 * After testing the pointer to the expected string is set to NULL to signal
39 * that the callback function has been called.
40 *
41 * @dev: sandbox ethernet device
42 * @packet: Ethernet packet
43 * @len: length of Ethernet packet
44 * Return: 0 = success
45 */
46int sb_log_tx_handler(struct udevice *dev, void *packet, unsigned int len);
47
Simon Glasse2cd0fa2020-09-12 12:28:50 -060048/**
49 * syslog_test_setup() - Enable syslog logging ready for tests
50 *
51 * @uts: Test state
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010052 * Return: 0 if OK, -ENOENT if the syslog log driver is not found
Simon Glasse2cd0fa2020-09-12 12:28:50 -060053 */
54int syslog_test_setup(struct unit_test_state *uts);
55
56/**
57 * syslog_test_finish() - Disable syslog logging after tests
58 *
59 * @uts: Test state
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010060 * Return: 0 if OK, -ENOENT if the syslog log driver is not found
Simon Glasse2cd0fa2020-09-12 12:28:50 -060061 */
62int syslog_test_finish(struct unit_test_state *uts);
63
Simon Glass9c83cac2020-09-12 11:13:34 -060064#endif