4 #include "lwip/stats.h"
6 #if !LWIP_STATS || !MEM_STATS
7 #error "This tests needs MEM-statistics enabled"
9 #if LWIP_SNMP || LWIP_DNS
10 #error "This test needs SNMP and DNS turned off (as they malloc on init)"
13 /* Setups/teardown functions */
28 /** Call mem_malloc, mem_free and mem_realloc and check stats */
29 START_TEST(test_mem_one)
34 void *p1, *p2, *p3, *p4, *p5;
38 fail_unless(lwip_stats.mem.used == 0);
40 p1 = mem_malloc(SIZE1);
41 fail_unless(p1 != NULL);
42 fail_unless(lwip_stats.mem.used >= SIZE1);
43 s1 = lwip_stats.mem.used;
45 p2 = mem_malloc(SIZE2);
46 fail_unless(p2 != NULL);
47 fail_unless(lwip_stats.mem.used >= SIZE2 + s1);
48 s2 = lwip_stats.mem.used;
50 mem_realloc(p1, SIZE1_2);
53 fail_unless(lwip_stats.mem.used <= s2 - SIZE2);
56 fail_unless(lwip_stats.mem.used == 0);
61 /** Create the suite including all tests for this module */
68 return create_suite("MEM", tests, sizeof(tests)/sizeof(TFun), mem_setup, mem_teardown);