ReactOS 0.4.15-dev-7889-g76290a6
test_udp.c
Go to the documentation of this file.
1#include "test_udp.h"
2
3#include "lwip/udp.h"
4#include "lwip/stats.h"
5
6#if !LWIP_STATS || !UDP_STATS || !MEMP_STATS
7#error "This tests needs UDP- and MEMP-statistics enabled"
8#endif
9
10/* Helper functions */
11static void
13{
14 struct udp_pcb *pcb = udp_pcbs;
15 struct udp_pcb *pcb2;
16
17 while(pcb != NULL) {
18 pcb2 = pcb;
19 pcb = pcb->next;
20 udp_remove(pcb2);
21 }
22 fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0);
23}
24
25/* Setups/teardown functions */
26
27static void
29{
31}
32
33static void
35{
37}
38
39
40/* Test functions */
41
42START_TEST(test_udp_new_remove)
43{
44 struct udp_pcb* pcb;
46
47 fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0);
48
49 pcb = udp_new();
50 fail_unless(pcb != NULL);
51 if (pcb != NULL) {
52 fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 1);
53 udp_remove(pcb);
54 fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0);
55 }
56}
57END_TEST
58
59
61Suite *
63{
64 TFun tests[] = {
65 test_udp_new_remove,
66 };
67 return create_suite("UDP", tests, sizeof(tests)/sizeof(TFun), udp_setup, udp_teardown);
68}
#define LWIP_UNUSED_ARG(x)
Definition: arch.h:73
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
static Suite * create_suite(const char *name, TFun *tests, size_t num_tests, SFun setup, SFun teardown)
Definition: lwip_check.h:20
static struct test_info tests[]
static void udp_setup(void)
Definition: test_udp.c:28
static void udp_teardown(void)
Definition: test_udp.c:34
static void udp_remove_all(void)
Definition: test_udp.c:12
END_TEST Suite * udp_suite(void)
Definition: test_udp.c:62