Skip to content

Commit

Permalink
tests: mocks: zephyr: update socket mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
joelguittet committed May 22, 2024
1 parent b9d7ba1 commit 23036a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions tests/mocks/zephyr/include/zephyr/net/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
#define TLS_HOSTNAME 2
#define TLS_PEER_VERIFY 5

struct addrinfo {
struct zsock_addrinfo {
int ai_family;
int ai_socktype;
int ai_protocol;
socklen_t ai_addrlen;
struct sockaddr *ai_addr;
};

int socket(int family, int type, int proto);
int connect(int sock, const struct sockaddr *addr, socklen_t addrlen);
int setsockopt(int sock, int level, int optname, const void *optval, socklen_t optlen);
int getaddrinfo(const char *host, const char *service, const struct addrinfo *hints, struct addrinfo **res);
void freeaddrinfo(struct addrinfo *ai);
int close(int sock);
int zsock_socket(int family, int type, int proto);
int zsock_connect(int sock, const struct sockaddr *addr, socklen_t addrlen);
int zsock_setsockopt(int sock, int level, int optname, const void *optval, socklen_t optlen);
int zsock_getaddrinfo(const char *host, const char *service, const struct zsock_addrinfo *hints, struct zsock_addrinfo **res);
void zsock_freeaddrinfo(struct zsock_addrinfo *ai);
int zsock_close(int sock);

#endif /* __SOCKET_H__ */
12 changes: 6 additions & 6 deletions tests/mocks/zephyr/src/socket.c
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#include <zephyr/net/socket.h>

int
socket(int family, int type, int proto) {
zsock_socket(int family, int type, int proto) {
return 0;
}

int
connect(int sock, const struct sockaddr *addr, socklen_t addrlen) {
zsock_connect(int sock, const struct sockaddr *addr, socklen_t addrlen) {
return 0;
}

int
setsockopt(int sock, int level, int optname, const void *optval, socklen_t optlen) {
zsock_setsockopt(int sock, int level, int optname, const void *optval, socklen_t optlen) {
return 0;
}

int
getaddrinfo(const char *host, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
zsock_getaddrinfo(const char *host, const char *service, const struct zsock_addrinfo *hints, struct zsock_addrinfo **res) {
return 0;
}

void
freeaddrinfo(struct addrinfo *ai) {
zsock_freeaddrinfo(struct zsock_addrinfo *ai) {
}

int
close(int sock) {
zsock_close(int sock) {
return 0;
}

0 comments on commit 23036a7

Please sign in to comment.