1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <tests/lib/cbfs_util.h>
5 TEST_REGION(cbfs_cache
, TEST_CBFS_CACHE_SIZE
);
7 const u8 test_data_1
[TEST_DATA_1_SIZE
] = {TEST_DATA_1
};
8 const u8 test_data_2
[TEST_DATA_2_SIZE
] = {TEST_DATA_2
};
9 const u8 test_data_int_1
[TEST_DATA_INT_1_SIZE
] = {LE64(TEST_DATA_INT_1
)};
10 const u8 test_data_int_2
[TEST_DATA_INT_2_SIZE
] = {LE64(TEST_DATA_INT_2
)};
11 const u8 test_data_int_3
[TEST_DATA_INT_3_SIZE
] = {LE64(TEST_DATA_INT_3
)};
13 const u8 good_hash
[VB2_SHA256_DIGEST_SIZE
] = {TEST_SHA256
};
14 const u8 bad_hash
[VB2_SHA256_DIGEST_SIZE
] = {INVALID_SHA256
};
16 const struct cbfs_test_file file_no_hash
= {
17 .header
= HEADER_INITIALIZER(CBFS_TYPE_RAW
, 0, TEST_DATA_1_SIZE
),
18 .filename
= TEST_DATA_1_FILENAME
,
24 const struct cbfs_test_file file_valid_hash
= {
25 .header
= HEADER_INITIALIZER(CBFS_TYPE_RAW
, HASH_ATTR_SIZE
, TEST_DATA_1_SIZE
),
26 .filename
= TEST_DATA_1_FILENAME
,
28 BE32(CBFS_FILE_ATTR_TAG_HASH
),
30 BE32(VB2_HASH_SHA256
),
36 const struct cbfs_test_file file_broken_hash
= {
37 .header
= HEADER_INITIALIZER(CBFS_TYPE_RAW
, HASH_ATTR_SIZE
, TEST_DATA_1_SIZE
),
38 .filename
= TEST_DATA_1_FILENAME
,
40 BE32(CBFS_FILE_ATTR_TAG_HASH
),
42 BE32(VB2_HASH_SHA256
),
49 const struct cbfs_test_file test_file_1
= {
50 .header
= HEADER_INITIALIZER(CBFS_TYPE_RAW
, 0, TEST_DATA_1_SIZE
),
51 .filename
= TEST_DATA_1_FILENAME
,
57 const struct cbfs_test_file test_file_2
= {
58 .header
= HEADER_INITIALIZER(CBFS_TYPE_RAW
, sizeof(struct cbfs_file_attr_compression
),
60 .filename
= TEST_DATA_2_FILENAME
,
62 BE32(CBFS_FILE_ATTR_TAG_COMPRESSION
),
63 BE32(sizeof(struct cbfs_file_attr_compression
)),
64 BE32(CBFS_COMPRESS_LZMA
),
65 BE32(TEST_DATA_2_SIZE
),
70 const struct cbfs_test_file test_file_int_1
= {
71 .header
= HEADER_INITIALIZER(CBFS_TYPE_RAW
, 0, TEST_DATA_INT_1_SIZE
),
72 .filename
= TEST_DATA_INT_1_FILENAME
,
74 LE64(TEST_DATA_INT_1
),
78 const struct cbfs_test_file test_file_int_2
= {
79 .header
= HEADER_INITIALIZER(CBFS_TYPE_RAW
, 0, TEST_DATA_INT_2_SIZE
),
80 .filename
= TEST_DATA_INT_2_FILENAME
,
82 LE64(TEST_DATA_INT_2
),
86 const struct cbfs_test_file test_file_int_3
= {
87 .header
= HEADER_INITIALIZER(CBFS_TYPE_RAW
, sizeof(struct cbfs_file_attr_compression
),
88 TEST_DATA_INT_3_SIZE
),
89 .filename
= TEST_DATA_INT_3_FILENAME
,
91 BE32(CBFS_FILE_ATTR_TAG_COMPRESSION
),
92 BE32(sizeof(struct cbfs_file_attr_compression
)),
93 BE32(CBFS_COMPRESS_LZ4
),
94 BE32(TEST_DATA_INT_3_SIZE
),
95 LE64(TEST_DATA_INT_3
),