BadVPN – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 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(MEMP_STATS_GET(used, MEMP_UDP_PCB) == 0); |
||
23 | } |
||
24 | |||
25 | /* Setups/teardown functions */ |
||
26 | |||
27 | static void |
||
28 | udp_setup(void) |
||
29 | { |
||
30 | udp_remove_all(); |
||
31 | lwip_check_ensure_no_alloc(SKIP_POOL(MEMP_SYS_TIMEOUT)); |
||
32 | } |
||
33 | |||
34 | static void |
||
35 | udp_teardown(void) |
||
36 | { |
||
37 | udp_remove_all(); |
||
38 | lwip_check_ensure_no_alloc(SKIP_POOL(MEMP_SYS_TIMEOUT)); |
||
39 | } |
||
40 | |||
41 | |||
42 | /* Test functions */ |
||
43 | |||
44 | START_TEST(test_udp_new_remove) |
||
45 | { |
||
46 | struct udp_pcb* pcb; |
||
47 | LWIP_UNUSED_ARG(_i); |
||
48 | |||
49 | fail_unless(MEMP_STATS_GET(used, MEMP_UDP_PCB) == 0); |
||
50 | |||
51 | pcb = udp_new(); |
||
52 | fail_unless(pcb != NULL); |
||
53 | if (pcb != NULL) { |
||
54 | fail_unless(MEMP_STATS_GET(used, MEMP_UDP_PCB) == 1); |
||
55 | udp_remove(pcb); |
||
56 | fail_unless(MEMP_STATS_GET(used, MEMP_UDP_PCB) == 0); |
||
57 | } |
||
58 | } |
||
59 | END_TEST |
||
60 | |||
61 | |||
62 | /** Create the suite including all tests for this module */ |
||
63 | Suite * |
||
64 | udp_suite(void) |
||
65 | { |
||
66 | testfunc tests[] = { |
||
67 | TESTFUNC(test_udp_new_remove), |
||
68 | }; |
||
69 | return create_suite("UDP", tests, sizeof(tests)/sizeof(testfunc), udp_setup, udp_teardown); |
||
70 | } |