soc/intel/xeon_sp: Revise IIO domain ACPI name encoding
[coreboot2.git] / payloads / libpayload / tests / cbfs-x86-test.c
blob81029656fc7531458173ffd750d3caa5d798dbae
1 /* system headers */
2 #include <stdlib.h>
3 #include <stdio.h>
5 /* libpayload headers */
6 #include "cbfs.h"
8 int fail(const char* str)
10 fprintf(stderr, "%s", str);
11 exit(1);
14 int main(int argc, char** argv)
16 FILE *cbfs = fopen("data/cbfs-x86.bin", "rb");
17 if (!cbfs) fail("could not open test file\n");
18 if (fseek(cbfs, 0, SEEK_END) != 0) fail("seek to end failed\n");
20 long size = ftell(cbfs);
21 if (size == -1) fail("could not determine file size\n");
22 if (fseek(cbfs, 0, SEEK_SET) != 0) fail("seek to start failed\n");
24 void *data = malloc(size);
25 if (!data) fail("could not allocate buffer\n");
27 if (fread(data, size, 1, cbfs) != 1) fail("could not read data\n");
28 if (fclose(cbfs)) fail("could not close file\n");
30 if (setup_cbfs_from_ram(data, size) != 0) fail("could not setup CBFS in RAM\n");
31 struct cbfs_file *file = cbfs_find("foo");
32 if (file == NULL) fail("could not find file in CBFS\n");
33 exit(0);