blob: e8c74f1780b1c9e5b925a0d6054657a23a67002c [file] [log] [blame]
Jeremy Kerr3d36ee22019-05-30 11:15:37 +08001/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2
Jeremy Kerr18925112019-03-13 15:43:08 +08003#ifndef _MCTP_TESTS_TEST_UTILS_H
4#define _MCTP_TESTS_TEST_UTILS_H
5
6#include <libmctp.h>
7
Jeremy Kerr1a4ec3c2019-09-03 11:01:50 +08008#ifndef container_of
9#define container_of(ptr, type, member) \
10 (type *)((char *)(ptr) - (char *)&((type *)0)->member)
11#endif
12
Jeremy Kerr18925112019-03-13 15:43:08 +080013/* test binding implementation */
14
15/* standard binding interface */
16struct mctp_binding_test *mctp_binding_test_init(void);
Andrew Jeffery5c5673b2020-03-10 23:23:58 +103017void mctp_binding_test_destroy(struct mctp_binding_test *test);
Jeremy Kerr18925112019-03-13 15:43:08 +080018void mctp_binding_test_register_bus(struct mctp_binding_test *binding,
19 struct mctp *mctp, mctp_eid_t eid);
20
21/* internal test binding interface */
22void mctp_binding_test_rx_raw(struct mctp_binding_test *test,
23 void *buf, size_t len);
24
25/* gerneral utility functions */
26
27/* create a MCTP stack, and add a test binding, using the specified EID */
28void mctp_test_stack_init(struct mctp **mctp,
29 struct mctp_binding_test **binding,
30 mctp_eid_t eid);
31
32#endif /* _MCTP_TESTS_TEST_UTILS_H */