MCPcopy Create free account
hub / github.com/coreboot/coreboot / setup_test

Function setup_test

tests/lib/memcpy-test.c:25–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23};
24
25int setup_test(void **state)
26{
27 struct test_memcpy_data *s = malloc(sizeof(struct test_memcpy_data));
28
29 if (!s)
30 return -1;
31
32 s->buffer_from = malloc(MEMCPY_BUFFER_SZ);
33 s->buffer_to = malloc(MEMCPY_BUFFER_SZ);
34 s->helper_buffer = malloc(MEMCPY_BUFFER_SZ);
35
36 if (!s->buffer_from || !s->buffer_to || !s->helper_buffer) {
37 free(s->buffer_from);
38 free(s->buffer_to);
39 free(s->helper_buffer);
40 free(s);
41 return -1;
42 }
43
44 /* Fill buffers with different values (other than zero) to make them distinguishable.
45 The helper buffer is often used as a backup of destination buffer so it has the
46 same value. */
47 memset(s->buffer_from, 0xAB, MEMCPY_BUFFER_SZ);
48 memset(s->buffer_to, 0xBC, MEMCPY_BUFFER_SZ);
49 memset(s->helper_buffer, 0xBC, MEMCPY_BUFFER_SZ);
50
51 *state = s;
52
53 return 0;
54}
55
56int teardown_test(void **state)
57{

Callers

nothing calls this directly

Calls 3

mallocFunction · 0.50
freeFunction · 0.50
memsetFunction · 0.50

Tested by

no test coverage detected