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

Function fmap_create_test

util/cbfstool/test.c:13–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11static enum test_status { pass = EXIT_SUCCESS, fail = EXIT_FAILURE } status;
12
13static struct fmap *fmap_create_test(void)
14{
15 struct fmap *fmap;
16 uint64_t base = 0;
17 uint32_t size = 0x100000;
18 char name[] = "test_fmap";
19
20 status = fail;
21
22 fmap = fmap_create(base, size, (uint8_t *)name);
23 if (!fmap)
24 return NULL;
25
26 if (memcmp(&fmap->signature, FMAP_SIGNATURE, strlen(FMAP_SIGNATURE))) {
27 printf("FAILURE: signature is incorrect\n");
28 goto fmap_create_test_exit;
29 }
30
31 if ((fmap->ver_major != FMAP_VER_MAJOR) ||
32 (fmap->ver_minor != FMAP_VER_MINOR)) {
33 printf("FAILURE: version is incorrect\n");
34 goto fmap_create_test_exit;
35 }
36
37 if (le64toh(fmap->base) != base) {
38 printf("FAILURE: base is incorrect\n");
39 goto fmap_create_test_exit;
40 }
41
42 if (le32toh(fmap->size) != 0x100000) {
43 printf("FAILURE: size is incorrect\n");
44 goto fmap_create_test_exit;
45 }
46
47 if (strcmp((char *)fmap->name, "test_fmap")) {
48 printf("FAILURE: name is incorrect\n");
49 goto fmap_create_test_exit;
50 }
51
52 if (le16toh(fmap->nareas) != 0) {
53 printf("FAILURE: number of areas is incorrect\n");
54 goto fmap_create_test_exit;
55 }
56
57 status = pass;
58fmap_create_test_exit:
59 /* preserve fmap if all went well */
60 if (status == fail) {
61 fmap_destroy(fmap);
62 fmap = NULL;
63 }
64 return fmap;
65}
66
67static int fmap_print_test(struct fmap *fmap)
68{

Callers 1

fmap_testFunction · 0.85

Calls 6

fmap_createFunction · 0.85
strlenFunction · 0.85
printfFunction · 0.85
fmap_destroyFunction · 0.85
memcmpFunction · 0.50
strcmpFunction · 0.50

Tested by

no test coverage detected