libpayload: configs: Add new config.featuretest to broaden CI
[coreboot.git] / payloads / libpayload / tests / mocks / cbfs_file_mock.c
blob3ad078c7b075225966bb6e50e57808ad84c88dff
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <mocks/cbfs_util.h>
6 const u8 test_data_1[TEST_DATA_1_SIZE] = { TEST_DATA_1 };
7 const u8 test_data_2[TEST_DATA_2_SIZE] = { TEST_DATA_2 };
8 const u8 test_data_int_1[TEST_DATA_INT_1_SIZE] = { LE64(TEST_DATA_INT_1) };
9 const u8 test_data_int_2[TEST_DATA_INT_2_SIZE] = { LE64(TEST_DATA_INT_2) };
10 const u8 test_data_int_3[TEST_DATA_INT_3_SIZE] = { LE64(TEST_DATA_INT_3) };
12 const u8 good_hash[VB2_SHA256_DIGEST_SIZE] = { TEST_SHA256 };
13 const u8 bad_hash[VB2_SHA256_DIGEST_SIZE] = { INVALID_SHA256 };
15 const struct cbfs_test_file file_no_hash = {
16 .header = HEADER_INITIALIZER(CBFS_TYPE_RAW, 0, TEST_DATA_1_SIZE),
17 .filename = TEST_DATA_1_FILENAME,
18 .attrs_and_data = {
19 TEST_DATA_1,
23 const struct cbfs_test_file file_valid_hash = {
24 .header = HEADER_INITIALIZER(CBFS_TYPE_RAW, HASH_ATTR_SIZE, TEST_DATA_1_SIZE),
25 .filename = TEST_DATA_1_FILENAME,
26 .attrs_and_data = {
27 BE32(CBFS_FILE_ATTR_TAG_HASH),
28 BE32(HASH_ATTR_SIZE),
29 BE32(VB2_HASH_SHA256),
30 TEST_SHA256,
31 TEST_DATA_1,
35 const struct cbfs_test_file file_broken_hash = {
36 .header = HEADER_INITIALIZER(CBFS_TYPE_RAW, HASH_ATTR_SIZE, TEST_DATA_1_SIZE),
37 .filename = TEST_DATA_1_FILENAME,
38 .attrs_and_data = {
39 BE32(CBFS_FILE_ATTR_TAG_HASH),
40 BE32(HASH_ATTR_SIZE),
41 BE32(VB2_HASH_SHA256),
42 INVALID_SHA256,
43 TEST_DATA_1,
47 const struct cbfs_test_file test_file_1 = {
48 .header = HEADER_INITIALIZER(CBFS_TYPE_RAW, 0, TEST_DATA_1_SIZE),
49 .filename = TEST_DATA_1_FILENAME,
50 .attrs_and_data = {
51 TEST_DATA_1,
55 const struct cbfs_test_file test_file_2 = {
56 .header = HEADER_INITIALIZER(CBFS_TYPE_RAW, sizeof(struct cbfs_file_attr_compression),
57 TEST_DATA_2_SIZE),
58 .filename = TEST_DATA_2_FILENAME,
59 .attrs_and_data = {
60 BE32(CBFS_FILE_ATTR_TAG_COMPRESSION),
61 BE32(sizeof(struct cbfs_file_attr_compression)),
62 BE32(CBFS_COMPRESS_LZMA),
63 BE32(TEST_DATA_2_SIZE),
64 TEST_DATA_2,
68 const struct cbfs_test_file test_file_int_1 = {
69 .header = HEADER_INITIALIZER(CBFS_TYPE_RAW, 0, TEST_DATA_INT_1_SIZE),
70 .filename = TEST_DATA_INT_1_FILENAME,
71 .attrs_and_data = {
72 LE64(TEST_DATA_INT_1),
76 const struct cbfs_test_file test_file_int_2 = {
77 .header = HEADER_INITIALIZER(CBFS_TYPE_RAW, 0, TEST_DATA_INT_2_SIZE),
78 .filename = TEST_DATA_INT_2_FILENAME,
79 .attrs_and_data = {
80 LE64(TEST_DATA_INT_2),
84 const struct cbfs_test_file test_file_int_3 = {
85 .header = HEADER_INITIALIZER(CBFS_TYPE_RAW, sizeof(struct cbfs_file_attr_compression),
86 TEST_DATA_INT_3_SIZE),
87 .filename = TEST_DATA_INT_3_FILENAME,
88 .attrs_and_data = {
89 BE32(CBFS_FILE_ATTR_TAG_COMPRESSION),
90 BE32(sizeof(struct cbfs_file_attr_compression)),
91 BE32(CBFS_COMPRESS_LZ4),
92 BE32(TEST_DATA_INT_3_SIZE),
93 LE64(TEST_DATA_INT_3),