diff options
author | Randall Spangler <rspangler@chromium.org> | 2017-06-07 13:20:46 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-06-20 17:24:20 -0700 |
commit | 3522e574a21a65ae4ef76ac396101c68e1c985a1 (patch) | |
tree | f2ab47fbd2045671f7bbe45f41679729b59772d6 /firmware | |
parent | 4007d6ff218110d55830c6dc2ca9822825afa0da (diff) | |
download | vboot-3522e574a21a65ae4ef76ac396101c68e1c985a1.tar.gz |
2lib: Add test_mockable attribute
Some tests mock library functions. This previously worked due to adding
CFLAGS += -Xlinker --allow-multiple-definition
to the test binaries. But the new version of binutils seems to need
the default implementation to be weak if compiled with -O2 in some
cases. Add test_mockable for use with functions where this is now
needed.
BUG=chromium:723906
BRANCH=none
TEST=Add CFLAGS += -O2 to the makefile, then make -j runtests
Tests break before this change with -O2, and work afterwards
Change-Id: I95996a3e1086251442055765295a75de4c20ee3c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/527601
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Rahul Chaudhry <rahulchaudhry@chromium.org>
Reviewed-by: Rahul Chaudhry <rahulchaudhry@chromium.org>
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/2lib/include/2common.h | 12 | ||||
-rw-r--r-- | firmware/include/vboot_api.h | 2 | ||||
-rw-r--r-- | firmware/lib20/packed_key.c | 1 |
3 files changed, 15 insertions, 0 deletions
diff --git a/firmware/2lib/include/2common.h b/firmware/2lib/include/2common.h index b08790a5..fa64c0f3 100644 --- a/firmware/2lib/include/2common.h +++ b/firmware/2lib/include/2common.h @@ -47,6 +47,18 @@ struct vb2_public_key; #endif /* + * Define test_mockable and for mocking functions when compiled for Chrome OS + * environment (that is, not for firmware). + */ +#ifndef test_mockable +#ifdef CHROMEOS_ENVIRONMENT +#define test_mockable __attribute__((weak)) +#else +#define test_mockable +#endif +#endif + +/* * Alignment for work buffer pointers/allocations should be useful for any * data type. When declaring workbuf buffers on the stack, the caller should * use explicit alignment to avoid run-time errors. For example: diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index d1c91c33..049ec90f 100644 --- a/firmware/include/vboot_api.h +++ b/firmware/include/vboot_api.h @@ -39,7 +39,9 @@ typedef uint32_t VbError_t; /* * Define test_mockable for mocking functions. */ +#ifndef test_mockable #define test_mockable __attribute__((weak)) +#endif /* * Predefined error numbers. Success is 0. Errors are non-zero, but differ diff --git a/firmware/lib20/packed_key.c b/firmware/lib20/packed_key.c index 48f11116..3cbaff24 100644 --- a/firmware/lib20/packed_key.c +++ b/firmware/lib20/packed_key.c @@ -23,6 +23,7 @@ int vb2_verify_packed_key_inside(const void *parent, key->key_offset, key->key_size); } +test_mockable int vb2_unpack_key_buffer(struct vb2_public_key *key, const uint8_t *buf, uint32_t size) |