1 /* 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 
11 /**
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  */
20 struct 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  */
46 int sb_log_tx_handler(struct udevice *dev, void *packet, unsigned int len);
47 
48 /**
49  * syslog_test_setup() - Enable syslog logging ready for tests
50  *
51  * @uts: Test state
52  * @return 0 if OK, -ENOENT if the syslog log driver is not found
53  */
54 int syslog_test_setup(struct unit_test_state *uts);
55 
56 /**
57  * syslog_test_finish() - Disable syslog logging after tests
58  *
59  * @uts: Test state
60  * @return 0 if OK, -ENOENT if the syslog log driver is not found
61  */
62 int syslog_test_finish(struct unit_test_state *uts);
63 
64 #endif
65