summaryrefslogtreecommitdiff
path: root/test/log/syslog_test.h
blob: 39cce4ed498550dbc16bc64ddf39613e914d1700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* 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

/**
 * 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);

/**
 * syslog_test_setup() - Enable syslog logging ready for tests
 *
 * @uts: Test state
 * Return: 0 if OK, -ENOENT if the syslog log driver is not found
 */
int syslog_test_setup(struct unit_test_state *uts);

/**
 * syslog_test_finish() - Disable syslog logging after tests
 *
 * @uts: Test state
 * Return: 0 if OK, -ENOENT if the syslog log driver is not found
 */
int syslog_test_finish(struct unit_test_state *uts);

#endif