syslog_test.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #ifndef __SYSLOG_TEST_H
  8. #define __SYSLOG_TEST_H
  9. /**
  10. * struct sb_log_env - private data for sandbox ethernet driver
  11. *
  12. * This structure is used for the private data of the sandbox ethernet
  13. * driver.
  14. *
  15. * @expected: string expected to be written by the syslog driver
  16. * @uts: unit test state
  17. */
  18. struct sb_log_env {
  19. const char *expected;
  20. struct unit_test_state *uts;
  21. };
  22. /**
  23. * sb_log_tx_handler() - transmit callback function
  24. *
  25. * This callback function is invoked when a network package is sent using the
  26. * sandbox Ethernet driver. The private data of the driver holds a sb_log_env
  27. * structure with the unit test state and the expected UDP payload.
  28. *
  29. * The following checks are executed:
  30. *
  31. * * the Ethernet packet indicates a IP broadcast message
  32. * * the IP header is for a local UDP broadcast message to port 514
  33. * * the UDP payload matches the expected string
  34. *
  35. * After testing the pointer to the expected string is set to NULL to signal
  36. * that the callback function has been called.
  37. *
  38. * @dev: sandbox ethernet device
  39. * @packet: Ethernet packet
  40. * @len: length of Ethernet packet
  41. * Return: 0 = success
  42. */
  43. int sb_log_tx_handler(struct udevice *dev, void *packet, unsigned int len);
  44. /**
  45. * syslog_test_setup() - Enable syslog logging ready for tests
  46. *
  47. * @uts: Test state
  48. * @return 0 if OK, -ENOENT if the syslog log driver is not found
  49. */
  50. int syslog_test_setup(struct unit_test_state *uts);
  51. /**
  52. * syslog_test_finish() - Disable syslog logging after tests
  53. *
  54. * @uts: Test state
  55. * @return 0 if OK, -ENOENT if the syslog log driver is not found
  56. */
  57. int syslog_test_finish(struct unit_test_state *uts);
  58. #endif