mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-24 15:14:06 +00:00
tried to fix sockets unit tests; fix configuration to run with any NO_SYS setting and with/without IPv6 (IPv4 is required)
This commit is contained in:
parent
a42d1678eb
commit
b0444a63b0
@ -7,15 +7,10 @@
|
||||
|
||||
|
||||
/* Setups/teardown functions */
|
||||
static int tcpip_init_called;
|
||||
|
||||
static void
|
||||
sockets_setup(void)
|
||||
{
|
||||
if (!tcpip_init_called) {
|
||||
tcpip_init_called = 1;
|
||||
tcpip_init(NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -27,6 +22,7 @@ sockets_teardown(void)
|
||||
#define NUM_SOCKETS MEMP_NUM_NETCONN
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET
|
||||
static int
|
||||
test_sockets_alloc_socket_nonblocking(int domain, int type)
|
||||
{
|
||||
@ -95,10 +91,14 @@ static void test_sockets_allfunctions_basic_domain(int domain)
|
||||
if (domain == AF_INET) {
|
||||
#if LWIP_IPV4
|
||||
struct sockaddr_in *addr4 = (struct sockaddr_in *)&addr;
|
||||
addr4->sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
addr4->sin_addr.s_addr = PP_HTONL(INADDR_LOOPBACK);
|
||||
#endif
|
||||
} else {
|
||||
#if LWIP_IPV6
|
||||
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&addr;
|
||||
struct in6_addr lo6 = IN6ADDR_LOOPBACK_INIT;
|
||||
addr6->sin6_addr = lo6;
|
||||
//addr6->sin6_family = AF_INET6; /* TODO: fixme! */
|
||||
#endif
|
||||
}
|
||||
ret = lwip_connect(s2, (struct sockaddr*)&addr, addrlen);
|
||||
@ -208,6 +208,9 @@ static void test_sockets_sendmsg_udp(int domain)
|
||||
}
|
||||
break;
|
||||
#endif /* LWIP_IPV4 */
|
||||
default:
|
||||
fail();
|
||||
break;
|
||||
}
|
||||
|
||||
s = test_sockets_alloc_socket_nonblocking(domain, SOCK_DGRAM);
|
||||
@ -230,6 +233,9 @@ static void test_sockets_sendmsg_udp(int domain)
|
||||
fail_unless(addr_size == sizeof(struct sockaddr_in));
|
||||
break;
|
||||
#endif /* LWIP_IPV6 */
|
||||
default:
|
||||
fail();
|
||||
break;
|
||||
}
|
||||
|
||||
msg.msg_iov = iovs;
|
||||
@ -280,3 +286,12 @@ sockets_suite(void)
|
||||
};
|
||||
return create_suite("SOCKETS", tests, sizeof(tests)/sizeof(testfunc), sockets_setup, sockets_teardown);
|
||||
}
|
||||
|
||||
#else /* LWIP_SOCKET */
|
||||
|
||||
Suite *
|
||||
sockets_suite(void)
|
||||
{
|
||||
return create_suite("SOCKETS", NULL, 0, NULL, NULL);
|
||||
}
|
||||
#endif /* LWIP_SOCKET */
|
||||
|
@ -33,20 +33,12 @@
|
||||
|
||||
#include <lwip/opt.h>
|
||||
#include <lwip/arch.h>
|
||||
#include "sys_arch.h"
|
||||
#include <lwip/stats.h>
|
||||
#include <lwip/debug.h>
|
||||
#include <lwip/sys.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
test_sys_arch_waiting_fn the_waiting_fn;
|
||||
|
||||
void test_sys_arch_wait_callback(test_sys_arch_waiting_fn waiting_fn)
|
||||
{
|
||||
the_waiting_fn = waiting_fn;
|
||||
}
|
||||
|
||||
u32_t sys_jiffies(void)
|
||||
{
|
||||
return (u32_t)0; /* todo */
|
||||
@ -62,6 +54,14 @@ void sys_init(void)
|
||||
}
|
||||
|
||||
#if !NO_SYS
|
||||
#include "sys_arch.h"
|
||||
|
||||
test_sys_arch_waiting_fn the_waiting_fn;
|
||||
|
||||
void test_sys_arch_wait_callback(test_sys_arch_waiting_fn waiting_fn)
|
||||
{
|
||||
the_waiting_fn = waiting_fn;
|
||||
}
|
||||
|
||||
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
|
||||
{
|
||||
|
@ -11,6 +11,9 @@
|
||||
#include "api/test_sockets.h"
|
||||
|
||||
#include "lwip/init.h"
|
||||
#if !NO_SYS
|
||||
#include "lwip/tcpip.h"
|
||||
#endif
|
||||
|
||||
Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown)
|
||||
{
|
||||
@ -51,7 +54,11 @@ int main(void)
|
||||
size_t num = sizeof(suites)/sizeof(void*);
|
||||
LWIP_ASSERT("No suites defined", num > 0);
|
||||
|
||||
#if NO_SYS
|
||||
lwip_init();
|
||||
#else
|
||||
tcpip_init(NULL, NULL);
|
||||
#endif
|
||||
|
||||
sr = srunner_create((suites[0])());
|
||||
for(i = 1; i < num; i++) {
|
||||
|
@ -32,12 +32,14 @@
|
||||
#ifndef LWIP_HDR_LWIPOPTS_H
|
||||
#define LWIP_HDR_LWIPOPTS_H
|
||||
|
||||
#define LWIP_IPV6 1
|
||||
|
||||
/* We link to special sys_arch.c (for basic non-waiting API layers unit tests) */
|
||||
#define NO_SYS 0
|
||||
#define SYS_LIGHTWEIGHT_PROT 0
|
||||
#define LWIP_NETCONN 1
|
||||
#define LWIP_SOCKET 1
|
||||
#define LWIP_NETCONN_FULLDUPLEX 1
|
||||
#define LWIP_NETCONN !NO_SYS
|
||||
#define LWIP_SOCKET !NO_SYS
|
||||
#define LWIP_NETCONN_FULLDUPLEX LWIP_SOCKET
|
||||
#define LWIP_HAVE_LOOPIF 1
|
||||
#define TCPIP_THREAD_TEST
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user