d9b407e03b01cfcdcc5b2dbfef65cd62d9f9119c
[reactos.git] / lib / drivers / lwip / test / unit / udp / test_udp.c
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 */
11 static void
12 udp_remove_all(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
27 static void
28 udp_setup(void)
29 {
30 udp_remove_all();
31 }
32
33 static void
34 udp_teardown(void)
35 {
36 udp_remove_all();
37 }
38
39
40 /* Test functions */
41
42 START_TEST(test_udp_new_remove)
43 {
44 struct udp_pcb* pcb;
45 LWIP_UNUSED_ARG(_i);
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 }
57 END_TEST
58
59 START_TEST(test_udp_remove)
60 {
61 struct udp_pcb* pcb;
62 LWIP_UNUSED_ARG(_i);
63
64 pcb = NULL;
65 //pcb = udp_new();
66 //fail_unless(pcb != NULL);
67 }
68 END_TEST
69
70
71 /** Create the suite including all tests for this module */
72 Suite *
73 udp_suite(void)
74 {
75 TFun tests[] = {
76 test_udp_new_remove,
77 test_udp_remove
78 };
79 return create_suite("UDP", tests, sizeof(tests)/sizeof(TFun), udp_setup, udp_teardown);
80 }