ReactOS 0.4.16-dev-297-gc569aee
lwip_unittests.c
Go to the documentation of this file.
1#include "lwip_check.h"
2
3#include "ip4/test_ip4.h"
4#include "ip6/test_ip6.h"
5#include "udp/test_udp.h"
6#include "tcp/test_tcp.h"
7#include "tcp/test_tcp_oos.h"
9#include "core/test_def.h"
10#include "core/test_dns.h"
11#include "core/test_mem.h"
12#include "core/test_netif.h"
13#include "core/test_pbuf.h"
14#include "core/test_timers.h"
15#include "etharp/test_etharp.h"
16#include "dhcp/test_dhcp.h"
17#include "mdns/test_mdns.h"
18#include "mqtt/test_mqtt.h"
19#include "api/test_sockets.h"
20#include "ppp/test_pppos.h"
21
22#include "lwip/init.h"
23#if !NO_SYS
24#include "lwip/tcpip.h"
25#endif
26
27/* This function is used for LWIP_RAND by some ports... */
28unsigned int
30{
31 return (unsigned int)rand();
32}
33
34Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown)
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}
49
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}
67
68#ifdef LWIP_UNITTESTS_LIB
69int lwip_unittests_run(void)
70#else
71int main(void)
72#endif
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 skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
GLdouble s
Definition: gl.h:2039
GLenum GLint GLuint mask
Definition: glext.h:6028
GLuint GLuint num
Definition: glext.h:9618
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
void lwip_init(void)
Definition: init.c:339
void tcpip_init(tcpip_init_done_fn initfunc, void *arg)
Definition: tcpip.c:650
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
#define EXIT_FAILURE
Definition: jerror.c:33
#define tcase_add_named_test(tc, tf)
Definition: lwip_check.h:25
#define SKIP_HEAP
Definition: lwip_check.h:49
Suite *() suite_getter_fn(void)
Definition: lwip_check.h:38
Suite * create_suite(const char *name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown)
int main(void)
void lwip_check_ensure_no_alloc(unsigned int skip)
unsigned int lwip_port_rand(void)
@ MEMP_MAX
Definition: memp.h:55
static struct test_info tests[]
static void teardown(void)
Definition: enum_files.c:130
static BOOL setup(void)
Definition: enum_files.c:97
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
Definition: name.c:39
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