summaryrefslogtreecommitdiffstats
path: root/tests/lib/spd_cache-test.c
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2021-06-09 18:37:42 +0200
committerPatrick Georgi <pgeorgi@google.com>2021-06-10 19:26:46 +0000
commitce55ca2fcaab23010b2f7e310c921f65b037034d (patch)
treeab160de356ce394bded5e4406096eba7dc278d20 /tests/lib/spd_cache-test.c
parent36c90179f0c7ef0d11ca78a109bd563b3ec0e0a9 (diff)
downloadcoreboot-ce55ca2fcaab23010b2f7e310c921f65b037034d.tar.gz
coreboot-ce55ca2fcaab23010b2f7e310c921f65b037034d.tar.bz2
coreboot-ce55ca2fcaab23010b2f7e310c921f65b037034d.zip
tests: Rework mocking facility
Using the linker's --wrap feature has the downside that it only covers references across object files: If foo.c defines a() and b(), with b calling a, --wrap=a does nothing to that call. Instead, use objcopy to mark a weak and global so it can be overridden by another implementation, but only for files originating in src/. That way mocks - implemented in tests/ - become the source of truth. TEST=Had such an issue with get_log_level() in a follow-up commit, and the mock now takes over. Also, all existing unit tests still pass. Change-Id: I99c6d6e44ecfc73366bf464d9c51c7da3f8db388 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/55360 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jakub Czapiga <jacz@semihalf.com>
Diffstat (limited to 'tests/lib/spd_cache-test.c')
-rw-r--r--tests/lib/spd_cache-test.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/lib/spd_cache-test.c b/tests/lib/spd_cache-test.c
index ef0f6ef5acb2..4bc0a3dcfe93 100644
--- a/tests/lib/spd_cache-test.c
+++ b/tests/lib/spd_cache-test.c
@@ -42,14 +42,14 @@ static int teardown_spd_cache(void **state)
}
-int __wrap_fmap_locate_area_as_rdev(const char *name, struct region_device *area)
+int fmap_locate_area_as_rdev(const char *name, struct region_device *area)
{
return rdev_chain(area, &flash_rdev_rw, 0, flash_buffer_size);
}
/* This test verifies if load_spd_cache() correctly loads spd_cache pointer and size
- from provided region_device. Memory region device is returned by
- __wrap_fmap_locate_area_as_rdev() */
+ from provided region_device. Memory region device is returned by our
+ fmap_locate_area_as_rdev() override. */
static void test_load_spd_cache(void **state)
{
uint8_t *spd_cache;