1 /* 2 * Copyright (c) 2023 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef STUBS_H 8 #define STUBS_H 9 10 #include <stdbool.h> 11 #include <stdint.h> 12 13 #include <zephyr/fff.h> 14 #include <zephyr/ztest.h> 15 16 #include <zephyr/net/coap_client.h> 17 18 19 /* Copy from zephyr/include/zephyr/net/socket.h */ 20 /** 21 * @name Options for poll() 22 * @{ 23 */ 24 /* ZSOCK_POLL* values are compatible with Linux */ 25 /** zsock_poll: Poll for readability */ 26 #define ZSOCK_POLLIN 1 27 /** zsock_poll: Poll for exceptional condition */ 28 #define ZSOCK_POLLPRI 2 29 /** zsock_poll: Poll for writability */ 30 #define ZSOCK_POLLOUT 4 31 /** zsock_poll: Poll results in error condition (output value only) */ 32 #define ZSOCK_POLLERR 8 33 /** zsock_poll: Poll detected closed connection (output value only) */ 34 #define ZSOCK_POLLHUP 0x10 35 /** zsock_poll: Invalid socket (output value only) */ 36 #define ZSOCK_POLLNVAL 0x20 37 /** @} */ 38 39 #define NUM_FD 2 40 41 void set_socket_events(int fd, short events); 42 void clear_socket_events(int fd, short events); 43 44 DECLARE_FAKE_VALUE_FUNC(uint32_t, z_impl_sys_rand32_get); 45 DECLARE_FAKE_VALUE_FUNC(ssize_t, z_impl_zsock_recvfrom, int, void *, size_t, int, struct sockaddr *, 46 socklen_t *); 47 DECLARE_FAKE_VALUE_FUNC(ssize_t, z_impl_zsock_sendto, int, void*, size_t, int, 48 const struct sockaddr *, socklen_t); 49 50 #define DO_FOREACH_FAKE(FUNC) \ 51 do { \ 52 FUNC(z_impl_sys_rand32_get) \ 53 FUNC(z_impl_zsock_recvfrom) \ 54 FUNC(z_impl_zsock_sendto) \ 55 } while (0) 56 57 #endif /* STUBS_H */ 58