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

Function setup_test

tests/lib/memmove-test.c:24–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

mallocFunction · 0.50
freeFunction · 0.50
memsetFunction · 0.50

Tested by

no test coverage detected