u-boot-brain/test/log/syslog_test.h
Sean Anderson 62ef81891d test: log: Convert log_test from python to C
When rebasing this series I had to renumber all my log tests because
someone made another log test in the meantime. This involved updaing a
number in several places (C and python), and it wasn't checked by the
compiler. So I though "how hard could it be to just rewrite in C?" And
though it wasn't hard, it *was* tedious. Tests are numbered the same as
before to allow for easier review.

A note that if a test fails, everything after it will probably also fail.
This is because that test won't clean up its filters.  There's no easy way
to do the cleanup, except perhaps removing all filters in a wrapper
function.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2020-10-30 10:55:26 -04:00

65 lines
1.7 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
/**
* 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