ReactOS 0.4.15-dev-7907-g95bf896
test_mem.c File Reference
#include "test_mem.h"
#include "lwip/mem.h"
#include "lwip/stats.h"
Include dependency graph for test_mem.c:

Go to the source code of this file.

Macros

#define SIZE1   16
 
#define SIZE1_2   12
 
#define SIZE2   16
 

Functions

static void mem_setup (void)
 
static void mem_teardown (void)
 
 START_TEST (test_mem_one)
 
END_TEST Suite * mem_suite (void)
 

Macro Definition Documentation

◆ SIZE1

#define SIZE1   16

◆ SIZE1_2

#define SIZE1_2   12

◆ SIZE2

#define SIZE2   16

Function Documentation

◆ mem_setup()

static void mem_setup ( void  )
static

Definition at line 16 of file test_mem.c.

17{
18}

Referenced by mem_suite().

◆ mem_suite()

END_TEST Suite * mem_suite ( void  )

Create the suite including all tests for this module

Definition at line 67 of file test_mem.c.

68{
69 TFun tests[] = {
70 test_mem_one
71 };
72 return create_suite("MEM", tests, sizeof(tests)/sizeof(TFun), mem_setup, mem_teardown);
73}
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 mem_teardown(void)
Definition: test_mem.c:21
static void mem_setup(void)
Definition: test_mem.c:16

Referenced by main().

◆ mem_teardown()

static void mem_teardown ( void  )
static

Definition at line 21 of file test_mem.c.

22{
23}

Referenced by mem_suite().

◆ START_TEST()

START_TEST ( test_mem_one  )

Call mem_malloc, mem_free and mem_trim and check stats

Definition at line 29 of file test_mem.c.

30{
31#define SIZE1 16
32#define SIZE1_2 12
33#define SIZE2 16
34 void *p1, *p2;
37
38#if LWIP_DNS
39 fail("This test needs DNS turned off (as it mallocs on init)");
40#endif
41
42 fail_unless(lwip_stats.mem.used == 0);
43
44 p1 = mem_malloc(SIZE1);
45 fail_unless(p1 != NULL);
46 fail_unless(lwip_stats.mem.used >= SIZE1);
47 s1 = lwip_stats.mem.used;
48
49 p2 = mem_malloc(SIZE2);
50 fail_unless(p2 != NULL);
51 fail_unless(lwip_stats.mem.used >= SIZE2 + s1);
52 s2 = lwip_stats.mem.used;
53
54 mem_trim(p1, SIZE1_2);
55
56 mem_free(p2);
57 fail_unless(lwip_stats.mem.used <= s2 - SIZE2);
58
59 mem_free(p1);
60 fail_unless(lwip_stats.mem.used == 0);
61}
#define LWIP_UNUSED_ARG(x)
Definition: arch.h:73
#define mem_free(ptr, bsize)
Definition: types.h:124
#define NULL
Definition: types.h:112
#define mem_trim(_m_, _s_)
Definition: cc.h:20
void * mem_malloc(mem_size_t size)
Definition: mem.c:494
u16_t mem_size_t
Definition: mem.h:76
struct S1 s1
struct S2 s2
#define SIZE2
#define SIZE1
#define SIZE1_2