tests: Add lib/cbfs-lookup-test test case
Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I2ebebba1468c19661741de8a8456605b1c5f56b6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/56813 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
parent
4095291808
commit
b20aa094cc
4 changed files with 1152 additions and 3 deletions
|
@ -14,6 +14,14 @@
|
|||
BE32(((be64) >> 32) & 0xFFFFFFFF), \
|
||||
BE32(((be64) >> 0) & 0xFFFFFFFF))
|
||||
|
||||
#define LE32(val32) EMPTY_WRAP(\
|
||||
((val32) >> 0) & 0xff, ((val32) >> 8) & 0xff, \
|
||||
((val32) >> 16) & 0xff, ((val32) >> 24) & 0xff)
|
||||
|
||||
#define LE64(val64) EMPTY_WRAP( \
|
||||
BE32(((val64) >> 0) & 0xFFFFFFFF), \
|
||||
BE32(((val64) >> 32) & 0xFFFFFFFF))
|
||||
|
||||
#define FILENAME_SIZE 16
|
||||
|
||||
struct cbfs_test_file {
|
||||
|
@ -98,5 +106,10 @@ extern const u8 bad_hash[VB2_SHA256_DIGEST_SIZE];
|
|||
extern const struct cbfs_test_file file_no_hash;
|
||||
extern const struct cbfs_test_file file_valid_hash;
|
||||
extern const struct cbfs_test_file file_broken_hash;
|
||||
extern const struct cbfs_test_file test_file_1;
|
||||
extern const struct cbfs_test_file test_file_2;
|
||||
extern const struct cbfs_test_file test_file_int_1;
|
||||
extern const struct cbfs_test_file test_file_int_2;
|
||||
extern const struct cbfs_test_file test_file_int_3;
|
||||
|
||||
#endif /* TESTS_LIB_CBFS_UTIL_H */
|
||||
|
|
|
@ -36,6 +36,8 @@ tests-y += cbfs-verification-no-sha512-test
|
|||
tests-y += cbfs-verification-has-sha512-test
|
||||
tests-y += cbfs-no-verification-no-sha512-test
|
||||
tests-y += cbfs-no-verification-has-sha512-test
|
||||
tests-y += cbfs-lookup-no-mcache-test
|
||||
tests-y += cbfs-lookup-has-mcache-test
|
||||
|
||||
string-test-srcs += tests/lib/string-test.c
|
||||
string-test-srcs += src/lib/string.c
|
||||
|
@ -208,3 +210,24 @@ cbfs-no-verification-no-sha512-test-config += CONFIG_CBFS_VERIFICATION=0
|
|||
$(call copy-test,cbfs-verification-no-sha512-test,cbfs-no-verification-has-sha512-test)
|
||||
cbfs-no-verification-has-sha512-test-config += CONFIG_CBFS_VERIFICATION=0 \
|
||||
VB2_SUPPORT_SHA512=1
|
||||
|
||||
cbfs-lookup-no-mcache-test-srcs = tests/lib/cbfs-lookup-test.c \
|
||||
tests/stubs/console.c \
|
||||
tests/stubs/die.c \
|
||||
tests/mock/cbfs_file_mock.c \
|
||||
src/lib/cbfs.c \
|
||||
src/commonlib/bsd/cbfs_private.c \
|
||||
src/commonlib/bsd/cbfs_mcache.c \
|
||||
src/commonlib/mem_pool.c \
|
||||
src/commonlib/region.c
|
||||
cbfs-lookup-no-mcache-test-mocks += cbfs_get_boot_device \
|
||||
cbfs_lookup \
|
||||
cbfs_mcache_lookup \
|
||||
mem_pool_alloc \
|
||||
mem_pool_free
|
||||
cbfs-lookup-no-mcache-test-config += CONFIG_ARCH_X86=0 \
|
||||
CONFIG_COLLECT_TIMESTAMPS=0 \
|
||||
CONFIG_NO_CBFS_MCACHE=1
|
||||
|
||||
$(call copy-test,cbfs-lookup-no-mcache-test,cbfs-lookup-has-mcache-test)
|
||||
cbfs-lookup-has-mcache-test-config += CONFIG_NO_CBFS_MCACHE=0
|
||||
|
|
1062
tests/lib/cbfs-lookup-test.c
Normal file
1062
tests/lib/cbfs-lookup-test.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -6,9 +6,9 @@ TEST_REGION(cbfs_cache, TEST_CBFS_CACHE_SIZE);
|
|||
|
||||
const u8 test_data_1[TEST_DATA_1_SIZE] = { TEST_DATA_1 };
|
||||
const u8 test_data_2[TEST_DATA_2_SIZE] = { TEST_DATA_2 };
|
||||
const u8 test_data_int_1[TEST_DATA_INT_1_SIZE] = { BE64(TEST_DATA_INT_1) };
|
||||
const u8 test_data_int_2[TEST_DATA_INT_2_SIZE] = { BE64(TEST_DATA_INT_2) };
|
||||
const u8 test_data_int_3[TEST_DATA_INT_3_SIZE] = { BE64(TEST_DATA_INT_3) };
|
||||
const u8 test_data_int_1[TEST_DATA_INT_1_SIZE] = { LE64(TEST_DATA_INT_1) };
|
||||
const u8 test_data_int_2[TEST_DATA_INT_2_SIZE] = { LE64(TEST_DATA_INT_2) };
|
||||
const u8 test_data_int_3[TEST_DATA_INT_3_SIZE] = { LE64(TEST_DATA_INT_3) };
|
||||
|
||||
const u8 good_hash[VB2_SHA256_DIGEST_SIZE] = { TEST_SHA256 };
|
||||
const u8 bad_hash[VB2_SHA256_DIGEST_SIZE] = { INVALID_SHA256 };
|
||||
|
@ -44,3 +44,54 @@ const struct cbfs_test_file file_broken_hash = {
|
|||
TEST_DATA_1,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
const struct cbfs_test_file test_file_1 = {
|
||||
.header = HEADER_INITIALIZER(CBFS_TYPE_RAW, 0, TEST_DATA_1_SIZE),
|
||||
.filename = TEST_DATA_1_FILENAME,
|
||||
.attrs_and_data = {
|
||||
TEST_DATA_1,
|
||||
},
|
||||
};
|
||||
|
||||
const struct cbfs_test_file test_file_2 = {
|
||||
.header = HEADER_INITIALIZER(CBFS_TYPE_RAW, sizeof(struct cbfs_file_attr_compression),
|
||||
TEST_DATA_2_SIZE),
|
||||
.filename = TEST_DATA_2_FILENAME,
|
||||
.attrs_and_data = {
|
||||
BE32(CBFS_FILE_ATTR_TAG_COMPRESSION),
|
||||
BE32(sizeof(struct cbfs_file_attr_compression)),
|
||||
BE32(CBFS_COMPRESS_LZMA),
|
||||
BE32(TEST_DATA_2_SIZE),
|
||||
TEST_DATA_2,
|
||||
},
|
||||
};
|
||||
|
||||
const struct cbfs_test_file test_file_int_1 = {
|
||||
.header = HEADER_INITIALIZER(CBFS_TYPE_RAW, 0, TEST_DATA_INT_1_SIZE),
|
||||
.filename = TEST_DATA_INT_1_FILENAME,
|
||||
.attrs_and_data = {
|
||||
LE64(TEST_DATA_INT_1),
|
||||
},
|
||||
};
|
||||
|
||||
const struct cbfs_test_file test_file_int_2 = {
|
||||
.header = HEADER_INITIALIZER(CBFS_TYPE_RAW, 0, TEST_DATA_INT_2_SIZE),
|
||||
.filename = TEST_DATA_INT_2_FILENAME,
|
||||
.attrs_and_data = {
|
||||
LE64(TEST_DATA_INT_2),
|
||||
},
|
||||
};
|
||||
|
||||
const struct cbfs_test_file test_file_int_3 = {
|
||||
.header = HEADER_INITIALIZER(CBFS_TYPE_RAW, sizeof(struct cbfs_file_attr_compression),
|
||||
TEST_DATA_INT_3_SIZE),
|
||||
.filename = TEST_DATA_INT_3_FILENAME,
|
||||
.attrs_and_data = {
|
||||
BE32(CBFS_FILE_ATTR_TAG_COMPRESSION),
|
||||
BE32(sizeof(struct cbfs_file_attr_compression)),
|
||||
BE32(CBFS_COMPRESS_LZ4),
|
||||
BE32(TEST_DATA_INT_3_SIZE),
|
||||
LE64(TEST_DATA_INT_3),
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue