diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2022-06-15 03:15:19 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-06-15 20:29:39 +0000 |
commit | cc752f8f4d4db97dfbad8f6d5ffc7b2c5ac1fd10 (patch) | |
tree | a5f9d001f38a1ff63a119037d6d6287b4cde8e3e | |
parent | c941561bac06c1fe6164947995535cc4a5b9e8a6 (diff) | |
download | chrome-ec-cc752f8f4d4db97dfbad8f6d5ffc7b2c5ac1fd10.tar.gz |
test: Relocate test_mockable for better compatibility
test_mockable macros are placed after config.h. This causes header
files included indirectly by common.h not to be able to use the macros.
This patch places test_mockable macros before config.h in common.h so
that the macros will be defined for aforementioned header files.
BUG=None
BRANCH=None
TEST=buildall
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Change-Id: I05716931bc7aedd3171569189ae228d2e9052b13
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3704267
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
-rw-r--r-- | include/common.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/include/common.h b/include/common.h index 33c9ab97c2..02989c692b 100644 --- a/include/common.h +++ b/include/common.h @@ -238,6 +238,22 @@ return error; \ } while (0) +/* + * Define test_mockable and test_mockable_static for mocking + * functions. + */ +#ifdef TEST_BUILD +#define test_mockable __attribute__((weak)) +#define test_mockable_static __attribute__((weak)) +#define test_mockable_static_inline __attribute__((weak)) +#define test_export_static +#else +#define test_mockable +#define test_mockable_static static +#define test_mockable_static_inline static inline +#define test_export_static static +#endif + /* Include top-level configuration file */ #include "config.h" @@ -336,22 +352,6 @@ enum ec_error_list { }; /* - * Define test_mockable and test_mockable_static for mocking - * functions. - */ -#ifdef TEST_BUILD -#define test_mockable __attribute__((weak)) -#define test_mockable_static __attribute__((weak)) -#define test_mockable_static_inline __attribute__((weak)) -#define test_export_static -#else -#define test_mockable -#define test_mockable_static static -#define test_mockable_static_inline static inline -#define test_export_static static -#endif - -/* * Attribute to define functions to only be used in test code, causing * a compiler error if used without TEST_BUILD defined. * |