From 637ff03502f3511d90e8d79cc1c52b3be01d6cd3 Mon Sep 17 00:00:00 2001 From: Yunlian Jiang Date: Tue, 9 Jun 2015 16:21:56 -0700 Subject: [PATCH] vboot_reference: fix unittest when building with clang. When linking vboot_api_kernel4_tests, there are two VbBootNormal() available, the gcc chooses the one in vboot_api_kernel4_tests.c and the test passes, the clang chooses the one in vboot_api_kernel.c and make the unittest fail. This CL makes the one in vboot_api_kernel.c a weak symbol so that clang can choose the one in vboot_api_kernel4_tests.c BUG=chromium:498469 BRANCH=none TEST=CC=x86_64-cros-linux-gnu-clang FEATURES='test' emerge-amd64-generic vboot_reference Change-Id: Ibcb78ee055fc9485dbc2bcc1d1cf98144a1a3b64 Reviewed-on: https://chromium-review.googlesource.com/276504 Reviewed-by: Randall Spangler Commit-Queue: Yunlian Jiang Tested-by: Yunlian Jiang --- firmware/include/vboot_api.h | 5 +++++ firmware/lib/vboot_api_kernel.c | 3 ++- firmware/stub/vboot_api_stub_init.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index 5310540775..7e94773ed3 100644 --- a/firmware/include/vboot_api.h +++ b/firmware/include/vboot_api.h @@ -36,6 +36,11 @@ */ typedef uint32_t VbError_t; +/* + * Define test_mockable for mocking functions. + */ +#define test_mockable __attribute__((weak)) + /* * Predefined error numbers. Success is 0. Errors are non-zero, but differ * between functions. For example, the TPM functions may pass through TPM diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 0fd1fa3e2e..312014bd3b 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -238,7 +238,8 @@ int VbUserConfirms(VbCommonParams *cparams, uint32_t confirm_flags) return -1; } -VbError_t VbBootNormal(VbCommonParams *cparams, LoadKernelParams *p) +VbError_t test_mockable +VbBootNormal(VbCommonParams *cparams, LoadKernelParams *p) { /* Boot from fixed disk only */ VBDEBUG(("Entering %s()\n", __func__)); diff --git a/firmware/stub/vboot_api_stub_init.c b/firmware/stub/vboot_api_stub_init.c index 9e4f63706d..34387837d7 100644 --- a/firmware/stub/vboot_api_stub_init.c +++ b/firmware/stub/vboot_api_stub_init.c @@ -61,7 +61,7 @@ uint64_t VbExGetTimer(void) return (uint64_t)tv.tv_sec * 1000000 + (uint64_t)tv.tv_usec; } -VbError_t VbExNvStorageRead(uint8_t *buf) +VbError_t test_mockable VbExNvStorageRead(uint8_t *buf) { return VBERROR_SUCCESS; }