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
,
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
,
27 BE32(CBFS_FILE_ATTR_TAG_HASH
),
29 BE32(VB2_HASH_SHA256
),
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
,
39 BE32(CBFS_FILE_ATTR_TAG_HASH
),
41 BE32(VB2_HASH_SHA256
),
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
,
55 const struct cbfs_test_file test_file_2
= {
56 .header
= HEADER_INITIALIZER(CBFS_TYPE_RAW
, sizeof(struct cbfs_file_attr_compression
),
58 .filename
= TEST_DATA_2_FILENAME
,
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
),
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
,
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
,
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
,
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
),