xref: /openbmc/libmctp/tests/test-utils.h (revision 5c5673b5)
1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2 
3 #ifndef _MCTP_TESTS_TEST_UTILS_H
4 #define _MCTP_TESTS_TEST_UTILS_H
5 
6 #include <libmctp.h>
7 
8 #ifndef container_of
9 #define container_of(ptr, type, member) \
10     (type *)((char *)(ptr) - (char *)&((type *)0)->member)
11 #endif
12 
13 /* test binding implementation */
14 
15 /* standard binding interface */
16 struct mctp_binding_test *mctp_binding_test_init(void);
17 void mctp_binding_test_destroy(struct mctp_binding_test *test);
18 void mctp_binding_test_register_bus(struct mctp_binding_test *binding,
19 		struct mctp *mctp, mctp_eid_t eid);
20 
21 /* internal test binding interface */
22 void 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 */
28 void 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 */
33