include/assert.h: Use mock_assert() for ENV_TEST targets

Some tests have to be able to catch assertion errors.
Adding CMocka mock_assert() enables that.

Additionally fix test_imd_create_tiered_empty(),
test_full_stack() and test_incorrectly_initialized_stack()
by adding missing expect_assert_failure().

Signed-off-by: Jakub Czapiga <jacz@semihalf.com>
Change-Id: I5e8dd1b198ee6fab61e2be3f92baf1178f79bf18
Reviewed-on: https://review.coreboot.org/c/coreboot/+/51804
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
This commit is contained in:
Jakub Czapiga
2021-03-25 14:28:29 +01:00
committed by Patrick Georgi
parent 70fe2707ba
commit 45d37d5cb8
3 changed files with 20 additions and 5 deletions

View File

@ -176,9 +176,10 @@ static void test_imd_create_tiered_empty(void **state)
/* Fail when large region doesn't have capacity for more than 1 entry */
lg_region_wrong_size = sizeof(struct imd_root_pointer) + sizeof(struct imd_root) +
sizeof(struct imd_entry);
assert_int_equal(-1, imd_create_tiered_empty(&imd, lg_region_wrong_size,
LG_ENTRY_ALIGN, SM_ROOT_SIZE,
SM_ENTRY_ALIGN));
expect_assert_failure(
imd_create_tiered_empty(&imd, lg_region_wrong_size, LG_ENTRY_ALIGN,
SM_ROOT_SIZE, SM_ENTRY_ALIGN)
);
assert_int_equal(0, imd_create_tiered_empty(&imd, LG_ROOT_SIZE, LG_ENTRY_ALIGN,
SM_ROOT_SIZE, SM_ENTRY_ALIGN));