ReactOS 0.4.16-dev-252-g9ccafe8
lwip_unittests.c File Reference
#include "lwip_check.h"
#include "ip4/test_ip4.h"
#include "ip6/test_ip6.h"
#include "udp/test_udp.h"
#include "tcp/test_tcp.h"
#include "tcp/test_tcp_oos.h"
#include "tcp/test_tcp_state.h"
#include "core/test_def.h"
#include "core/test_dns.h"
#include "core/test_mem.h"
#include "core/test_netif.h"
#include "core/test_pbuf.h"
#include "core/test_timers.h"
#include "etharp/test_etharp.h"
#include "dhcp/test_dhcp.h"
#include "mdns/test_mdns.h"
#include "mqtt/test_mqtt.h"
#include "api/test_sockets.h"
#include "ppp/test_pppos.h"
#include "lwip/init.h"
#include "lwip/tcpip.h"
Include dependency graph for lwip_unittests.c:

Go to the source code of this file.

Functions

unsigned int lwip_port_rand (void)
 
Suite * create_suite (const char *name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown)
 
void lwip_check_ensure_no_alloc (unsigned int skip)
 
int main (void)
 

Function Documentation

◆ create_suite()

Suite * create_suite ( const char name,
testfunc tests,
size_t  num_tests,
SFun  setup,
SFun  teardown 
)

Create a test suite

Definition at line 34 of file lwip_unittests.c.

35{
36 size_t i;
37 Suite *s = suite_create(name);
38
39 for(i = 0; i < num_tests; i++) {
40 TCase *tc_core = tcase_create(name);
41 if ((setup != NULL) || (teardown != NULL)) {
42 tcase_add_checked_fixture(tc_core, setup, teardown);
43 }
44 tcase_add_named_test(tc_core, tests[i]);
45 suite_add_tcase(s, tc_core);
46 }
47 return s;
48}
#define NULL
Definition: types.h:112
GLdouble s
Definition: gl.h:2039
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define tcase_add_named_test(tc, tf)
Definition: lwip_check.h:25
static struct test_info tests[]
static void teardown(void)
Definition: enum_files.c:130
static BOOL setup(void)
Definition: enum_files.c:97
Definition: name.c:39

Referenced by def_suite(), dhcp_suite(), dns_suite(), etharp_suite(), ip4_suite(), ip6_suite(), mdns_suite(), mem_suite(), mqtt_suite(), netif_suite(), pbuf_suite(), sockets_suite(), tcp_oos_suite(), tcp_state_suite(), tcp_suite(), timers_suite(), and udp_suite().

◆ lwip_check_ensure_no_alloc()

void lwip_check_ensure_no_alloc ( unsigned int  skip)

Definition at line 50 of file lwip_unittests.c.

51{
52 int i;
53 unsigned int mask;
54
55 if (!(skip & SKIP_HEAP)) {
56 fail_unless(lwip_stats.mem.used == 0,
57 "mem heap still has %d bytes allocated", lwip_stats.mem.used);
58 }
59 for (i = 0, mask = 1; i < MEMP_MAX; i++, mask <<= 1) {
60 if (!(skip & mask)) {
61 fail_unless(lwip_stats.memp[i]->used == 0,
62 "memp pool '%s' still has %d entries allocated",
63 lwip_stats.memp[i]->name, lwip_stats.memp[i]->used);
64 }
65 }
66}
#define skip(...)
Definition: atltest.h:64
GLenum GLint GLuint mask
Definition: glext.h:6028
#define SKIP_HEAP
Definition: lwip_check.h:49
@ MEMP_MAX
Definition: memp.h:55

Referenced by dhcp_setup(), dhcp_teardown(), etharp_setup(), etharp_teardown(), ip4_setup(), ip4_teardown(), mem_setup(), mem_teardown(), mqtt_setup(), mqtt_teardown(), netif_setup(), netif_teardown(), pbuf_setup(), pbuf_teardown(), sockets_setup(), sockets_teardown(), tcp_oos_setup(), tcp_oos_teardown(), tcp_setup(), tcp_state_setup(), tcp_state_teardown(), tcp_teardown(), udp_setup(), and udp_teardown().

◆ lwip_port_rand()

unsigned int lwip_port_rand ( void  )

Definition at line 29 of file lwip_unittests.c.

30{
31 return (unsigned int)rand();
32}
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10

◆ main()

int main ( void  )

Definition at line 71 of file lwip_unittests.c.

73{
74 int number_failed;
75 SRunner *sr;
76 size_t i;
77 suite_getter_fn* suites[] = {
95#if PPP_SUPPORT && PPPOS_SUPPORT
96 , pppos_suite
97#endif /* PPP_SUPPORT && PPPOS_SUPPORT */
98 };
99 size_t num = sizeof(suites)/sizeof(void*);
100 LWIP_ASSERT("No suites defined", num > 0);
101
102#if NO_SYS
103 lwip_init();
104#else
106#endif
107
108 sr = srunner_create((suites[0])());
109 srunner_set_xml(sr, "lwip_unittests.xml");
110 for(i = 1; i < num; i++) {
111 srunner_add_suite(sr, ((suite_getter_fn*)suites[i])());
112 }
113
114#ifdef LWIP_UNITTESTS_NOFORK
115 srunner_set_fork_status(sr, CK_NOFORK);
116#endif
117#ifdef LWIP_UNITTESTS_FORK
118 srunner_set_fork_status(sr, CK_FORK);
119#endif
120
121 srunner_run_all(sr, CK_NORMAL);
122 number_failed = srunner_ntests_failed(sr);
123 srunner_free(sr);
124 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
125}
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
GLuint GLuint num
Definition: glext.h:9618
void lwip_init(void)
Definition: init.c:339
void tcpip_init(tcpip_init_done_fn initfunc, void *arg)
Definition: tcpip.c:650
#define EXIT_FAILURE
Definition: jerror.c:33
Suite *() suite_getter_fn(void)
Definition: lwip_check.h:38
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
END_TEST Suite * def_suite(void)
Definition: test_def.c:78
END_TEST Suite * dhcp_suite(void)
Definition: test_dhcp.c:1093
END_TEST Suite * dns_suite(void)
Definition: test_dns.c:46
END_TEST Suite * etharp_suite(void)
Definition: test_etharp.c:267
END_TEST Suite * ip4_suite(void)
Definition: test_ip4.c:331
END_TEST Suite * ip6_suite(void)
Definition: test_ip6.c:462
END_TEST Suite * mdns_suite(void)
Definition: test_mdns.c:879
END_TEST Suite * mem_suite(void)
Definition: test_mem.c:212
END_TEST Suite * mqtt_suite(void)
Definition: test_mqtt.c:109
END_TEST Suite * netif_suite(void)
Definition: test_netif.c:277
END_TEST Suite * pbuf_suite(void)
Definition: test_pbuf.c:346
Suite * sockets_suite(void)
Definition: test_sockets.c:848
END_TEST Suite * tcp_suite(void)
Definition: test_tcp.c:1674
Suite * tcp_oos_suite(void)
Definition: test_tcp_oos.c:991
END_TEST Suite * tcp_state_suite(void)
END_TEST Suite * timers_suite(void)
Definition: test_timers.c:224
END_TEST Suite * udp_suite(void)
Definition: test_udp.c:464