commit 2154160a2484d852e4a0b509a5f046001d52fd11 Author: Andrea Shepard andrea@torproject.org Date: Thu Jun 30 05:35:46 2016 +0000
Add support for mocking functions declared with attributes without causing gcc warnings --- src/common/testsupport.h | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/src/common/testsupport.h b/src/common/testsupport.h index b98d701..9ad2ba7 100644 --- a/src/common/testsupport.h +++ b/src/common/testsupport.h @@ -62,6 +62,12 @@ #define MOCK_IMPL(rv, funcname, arglist) \ rv(*funcname) arglist = funcname ##__real; \ rv funcname ##__real arglist +#define MOCK_DECL_ATTR(rv, funcname, arglist, attr) \ + rv funcname ##__real arglist attr; \ + extern rv(*funcname) arglist +#define MOCK_IMPL(rv, funcname, arglist) \ + rv(*funcname) arglist = funcname ##__real; \ + rv funcname ##__real arglist #define MOCK(func, replacement) \ do { \ (func) = (replacement); \ @@ -73,6 +79,8 @@ #else #define MOCK_DECL(rv, funcname, arglist) \ rv funcname arglist +#define MOCK_DECL_ATTR(rv, funcname, arglist, attr) \ + rv funcname arglist attr #define MOCK_IMPL(rv, funcname, arglist) \ rv funcname arglist #endif
tor-commits@lists.torproject.org