Jakub Czapiga | 6f3fd63 | 2021-07-22 08:52:46 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <tests/lib/cbfs_util.h> |
| 4 | |
| 5 | TEST_REGION(cbfs_cache, TEST_CBFS_CACHE_SIZE); |
| 6 | |
Jakub Czapiga | c08b6a7 | 2022-01-10 13:36:47 +0000 | [diff] [blame] | 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)}; |
Jakub Czapiga | 6f3fd63 | 2021-07-22 08:52:46 +0200 | [diff] [blame] | 12 | |
Jakub Czapiga | c08b6a7 | 2022-01-10 13:36:47 +0000 | [diff] [blame] | 13 | const u8 good_hash[VB2_SHA256_DIGEST_SIZE] = {TEST_SHA256}; |
| 14 | const u8 bad_hash[VB2_SHA256_DIGEST_SIZE] = {INVALID_SHA256}; |
Jakub Czapiga | 6f3fd63 | 2021-07-22 08:52:46 +0200 | [diff] [blame] | 15 | |
| 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, |
| 19 | .attrs_and_data = { |
| 20 | TEST_DATA_1, |
| 21 | }, |
| 22 | }; |
| 23 | |
| 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, |
| 27 | .attrs_and_data = { |
| 28 | BE32(CBFS_FILE_ATTR_TAG_HASH), |
| 29 | BE32(HASH_ATTR_SIZE), |
| 30 | BE32(VB2_HASH_SHA256), |
| 31 | TEST_SHA256, |
| 32 | TEST_DATA_1, |
| 33 | }, |
| 34 | }; |
| 35 | |
| 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, |
| 39 | .attrs_and_data = { |
| 40 | BE32(CBFS_FILE_ATTR_TAG_HASH), |
| 41 | BE32(HASH_ATTR_SIZE), |
| 42 | BE32(VB2_HASH_SHA256), |
| 43 | INVALID_SHA256, |
| 44 | TEST_DATA_1, |
| 45 | }, |
| 46 | }; |
Jakub Czapiga | b20aa09 | 2021-07-27 17:04:11 +0200 | [diff] [blame] | 47 | |
| 48 | |
| 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, |
| 52 | .attrs_and_data = { |
| 53 | TEST_DATA_1, |
| 54 | }, |
| 55 | }; |
| 56 | |
| 57 | const struct cbfs_test_file test_file_2 = { |
| 58 | .header = HEADER_INITIALIZER(CBFS_TYPE_RAW, sizeof(struct cbfs_file_attr_compression), |
| 59 | TEST_DATA_2_SIZE), |
| 60 | .filename = TEST_DATA_2_FILENAME, |
| 61 | .attrs_and_data = { |
| 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), |
| 66 | TEST_DATA_2, |
| 67 | }, |
| 68 | }; |
| 69 | |
| 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, |
| 73 | .attrs_and_data = { |
| 74 | LE64(TEST_DATA_INT_1), |
| 75 | }, |
| 76 | }; |
| 77 | |
| 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, |
| 81 | .attrs_and_data = { |
| 82 | LE64(TEST_DATA_INT_2), |
| 83 | }, |
| 84 | }; |
| 85 | |
| 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, |
| 90 | .attrs_and_data = { |
| 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), |
| 96 | }, |
| 97 | }; |