Skip to content

Commit e47f987

Browse files
authored
break parts of umock in DECL and IMPL (#362)
* propagate anporumb/pchmock * propagate_all_repos anporumb/pchmock * propagate_all_repos anporumb/pchmock * propagate_all_repos anporumb/pchmock * propagate_all_repos anporumb/pchmock * propagate_all_repos anporumb/pchmock * propagate_all_repos anporumb/pchmock * added a function to umock_c * move temp build of mocks * introduced ENABLE_MOCKS_DECL and ENABLE_MOCKS_IMPL who don't do anything yet * renamed MOCKABLE_FUNCTION_INTERNAL_WITH_CODE to MOCKABLE_FUNCTION_INTERNAL_WITH_CODEd see if everything still compiles then it is not used * cannot, it is used in sf-c-util * added skeleton for umock_c_2_int which is clone of umock_c_int but with wanna be skeleton mocks in test_dependency_mock.h/c * revert to master inc/umock_c/umock_c_prod.h * probably split in umock_c_prod around ENABLE_MOCKS/DECL/IMPL. Doesn't compile * only commented out umock_c_2_int for propagation reasons * added some include guards that ENABLE_MOCKS/IMPL/DECL are not defined at the same time * revert inc/umock_c/umock_c_prod.h to master * rename umock_c_2_int to have "2" * first split in DECL/IMPL * does it propagate with 1st DECL/IMPL change * added 2 more DECL/IMPL * more * propagate_all_repos anporumb/pchmock * added explicit extern * propagate_all_repos anporumb/pchmock * work 2 * MU_C2(mock_call_args_metadata_,name) * propagate_all_repos anporumb/pchmock * MU_C2(mock_call_metadata_,name) * typedef void (*MU_C2(COPY_RETURN_VALUE_FUNC_TYPE, name))(return_type* dst, return_type src); \ moved * typedef struct MU_C2(_mock_call_modifier_,name) (*MU_C2(ignore_all_calls_func_type_,name))(void); " * made MU_C2(mock_call_modifier_,name) MU_C2(ignore_all_calls_func_,name)(void) unstatic * it all compiles on linux and windows now * it all builds (Again) * this also compiles. const MU_C2(validate_one_argument_func_type_,name) MU_C2(validate_one_argument_array_,name) * typedef struct MU_C2(_mock_call_, name) * more separation * maybe MOCKABLE_FUNCTION_UMOCK_INTERNAL_WITH_MOCK is now split * propagate_all_repos anporumb/pchmock * made the test project better * expectation is that it all compiles * AICI AM RAMAS * it all builds in Windowsz lang * eliminated ZZZ * now both linux and windows pass * remove __COUNTER__ usage * more COUNTER killing * added ignore all calls which doesn't seem to be used... ever... nowhere * moved some declaration in the same order as impl * added mockable_interface... to do something? * added mockable_interface... to do something? * added SOME implementation for the real functions... it needs to exist * made the declaration of MOCKABLE_INTERFACE static because fuck it * removed vld.h references and add explanation for why umock_c_2_int exists * propagate_all_repos anporumb/pchmock * use latest masters * added a clarification to istests/umock_c_2_int/CMakeLists.txt * i hate includewhatyouuse * don't build for vld.h on debug * exclude umock_c_2_int also from includewhatyouuse * also exclude it completely and run only from Windows * exlucde on_+erorr from umockc_c_interbnak.; * with int umock_c_add_actual_call(UMOCKCALL_HANDLE mock_call, UMOCKCALL_HANDLE* matched_call); in umock_c.h see what inckludewhatoyuduckinguse says * disable inckude what you use
1 parent 366cda3 commit e47f987

23 files changed

+3834
-244
lines changed

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ endif()
1010
#if ((NOT TARGET umock_c) AND (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/umock-c/CMakeLists.txt))
1111
# add_subdirectory(deps/umock-c)
1212
# include_directories(${UMOCK_C_INC_FOLDER})
13-
#endif()
13+
#endif()
1414

1515
if(TARGET umock_c)
1616
return()
@@ -59,27 +59,27 @@ set(run_reals_check OFF)
5959
if ((NOT TARGET c_build_tools) AND (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/c-build-tools/CMakeLists.txt))
6060
add_subdirectory(deps/c-build-tools)
6161
set_default_build_options()
62-
endif()
62+
endif()
6363

6464
if ((NOT TARGET macro_utils_c) AND (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/macro-utils-c/CMakeLists.txt))
6565
add_subdirectory(deps/macro-utils-c)
6666
include_directories(${MACRO_UTILS_INC_FOLDER})
67-
endif()
67+
endif()
6868

6969
if ((NOT TARGET c_logging) AND (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/c-logging/CMakeLists.txt))
7070
add_subdirectory(deps/c-logging)
7171
include_directories(deps/c-logging/v2/inc)
72-
endif()
72+
endif()
7373

7474
if ((NOT TARGET ctest) AND (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/ctest/CMakeLists.txt))
7575
add_subdirectory(deps/ctest)
7676
include_directories(${CTEST_INC_FOLDER})
77-
endif()
77+
endif()
7878

7979
if ((NOT TARGET testrunnerswitcher) AND (EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/c-testrunnerswitcher/CMakeLists.txt))
8080
add_subdirectory(deps/c-testrunnerswitcher)
8181
include_directories(${TESTRUNNERSWITCHER_INC_FOLDER})
82-
endif()
82+
endif()
8383

8484
set(run_e2e_tests ${original_run_e2e_tests})
8585
set(run_int_tests ${original_run_int_tests})

build/devops_gated.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,11 @@ jobs:
107107
workingDirectory: '$(Build.Repository.LocalPath)'
108108
displayName: 'git submodule update and clean'
109109
110-
- task: Bash@3
111-
displayName: 'Build with iwyu'
112-
inputs:
113-
targetType: filePath
114-
filePath: './build/linux/build_linux_iwyu.sh'
115-
arguments: '$(Build.Repository.LocalPath)'
116-
workingDirectory: '$(Build.Repository.LocalPath)'
110+
#re-enable with https://msazure.visualstudio.com/One/_workitems/edit/29593386
111+
# - task: Bash@3
112+
# displayName: 'Build with iwyu'
113+
# inputs:
114+
# targetType: filePath
115+
# filePath: './build/linux/build_linux_iwyu.sh'
116+
# arguments: '$(Build.Repository.LocalPath)'
117+
# workingDirectory: '$(Build.Repository.LocalPath)'

deps/macro-utils-c

inc/umock_c/umock_c.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ const char* umock_c_get_actual_calls(void);
106106
const char* umock_c_get_expected_calls(void);
107107
UMOCKCALLRECORDER_HANDLE umock_c_get_call_recorder(void);
108108
int umock_c_set_call_recorder(UMOCKCALLRECORDER_HANDLE umockc_call_recorder);
109+
int umock_c_add_actual_call(UMOCKCALL_HANDLE mock_call, UMOCKCALL_HANDLE* matched_call);
109110

110111
#ifdef __cplusplus
111112
}

inc/umock_c/umock_c_internal.h

Lines changed: 371 additions & 209 deletions
Large diffs are not rendered by default.

inc/umock_c/umock_c_prod.h

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#undef MOCKABLE_INTERFACE
1414

1515
/* This header is meant to be included by production code headers, so that the MOCKABLE_FUNCTION gets enabled. */
16-
/*
16+
/*
1717
If you are porting to a new platform and do not want to build the tests, but only the production code,
18-
simply make sure that this file is in the include path (either by copying it to your inc folder or
18+
simply make sure that this file is in the include path (either by copying it to your inc folder or
1919
by adjusting the include paths).
2020
*/
2121

@@ -26,6 +26,7 @@
2626
#define UMOCK_C_PROD_IS_NOT_VOID(x) \
2727
MU_IF(MU_C2(UMOCK_C_PROD_TEST_,x), 1, 0)
2828

29+
2930
#ifdef ENABLE_MOCKS
3031

3132
#ifdef ENABLE_MOCK_FILTERING
@@ -43,6 +44,32 @@
4344
result modifiers function(MU_IF(MU_COUNT_ARG(__VA_ARGS__), , void) MU_FOR_EACH_2_COUNTED(UMOCK_C_PROD_ARG_IN_SIGNATURE, __VA_ARGS__)); \
4445
MU_IF(do_returns, MU_IF(UMOCK_C_PROD_IS_NOT_VOID(result), DO_NOTHING_WITH_RETURN_VALUES,), )
4546

47+
#ifdef ENABLE_MOCKS_DECL
48+
49+
/* Codes_SRS_UMOCK_C_LIB_01_001: [MOCKABLE_FUNCTION shall be used to wrap function definition allowing the user to declare a function that can be mocked.]*/
50+
#define MOCKABLE_FUNCTION(modifiers, result, function, ...) \
51+
MU_IF(ENABLE_MOCK_FILTERING_SWITCH, \
52+
MU_IF(MU_C2(please_mock_, function), \
53+
MOCKABLE_FUNCTION_DISABLED, \
54+
MOCKABLE_FUNCTION_UMOCK_INTERNAL_WITH_MOCK_DECL \
55+
), \
56+
MOCKABLE_FUNCTION_UMOCK_INTERNAL_WITH_MOCK_DECL) (0, 0, modifiers, result, function, __VA_ARGS__)
57+
58+
/* Codes_SRS_UMOCK_C_LIB_01_212: [ MOCKABLE_FUNCTION_WITH_RETURNS shall be used to wrap function definitions, allowing the user to declare a function that can be mocked and aditionally declares the values that are to be returned in case of success and failure. ]*/
59+
#define MOCKABLE_FUNCTION_WITH_RETURNS(modifiers, result, function, ...) \
60+
MU_IF(ENABLE_MOCK_FILTERING_SWITCH, \
61+
MU_IF(MU_C2(please_mock_, function), \
62+
MOCKABLE_FUNCTION_DISABLED, \
63+
MOCKABLE_FUNCTION_UMOCK_INTERNAL_WITH_MOCK_DECL \
64+
), \
65+
MOCKABLE_FUNCTION_UMOCK_INTERNAL_WITH_MOCK_DECL) (1, 1, modifiers, result, function, __VA_ARGS__)
66+
67+
#define MOCKABLE_INTERFACE(interface_name, ...) \
68+
MU_FOR_EACH_1(EXPAND_ENTRY, __VA_ARGS__) \
69+
static void MU_C2(register_reals_, interface_name)(void);
70+
71+
#else /*ENABLE_MOCKS_DECL*/
72+
4673
/* Codes_SRS_UMOCK_C_LIB_01_001: [MOCKABLE_FUNCTION shall be used to wrap function definition allowing the user to declare a function that can be mocked.]*/
4774
#define MOCKABLE_FUNCTION(modifiers, result, function, ...) \
4875
MU_IF(ENABLE_MOCK_FILTERING_SWITCH,MU_IF(MU_C2(please_mock_, function),MOCKABLE_FUNCTION_DISABLED,MOCKABLE_FUNCTION_UMOCK_INTERNAL_WITH_MOCK), MOCKABLE_FUNCTION_UMOCK_INTERNAL_WITH_MOCK) (0, modifiers, result, function, __VA_ARGS__)
@@ -51,6 +78,17 @@
5178
#define MOCKABLE_FUNCTION_WITH_RETURNS(modifiers, result, function, ...) \
5279
MU_IF(ENABLE_MOCK_FILTERING_SWITCH,MU_IF(MU_C2(please_mock_, function),MOCKABLE_FUNCTION_DISABLED,MOCKABLE_FUNCTION_UMOCK_INTERNAL_WITH_MOCK), MOCKABLE_FUNCTION_UMOCK_INTERNAL_WITH_MOCK) (1, modifiers, result, function, __VA_ARGS__)
5380

81+
#define MOCKABLE_INTERFACE(interface_name, ...) \
82+
MU_FOR_EACH_1(EXPAND_ENTRY, __VA_ARGS__) \
83+
static void MU_C2(register_reals_, interface_name)(void) \
84+
{ \
85+
MU_FOR_EACH_1(REGISTER_GLOBAL_MOCK_REAL, __VA_ARGS__); \
86+
} \
87+
88+
#endif /*ENABLE_MOCKS_DECL*/
89+
90+
91+
5492
// The below MOCKABLE_FUNCTION_WITH_CODE macros are a temporary solution and should not be used for long term
5593
// They will be removed once the real support is in umock_c
5694
#define MOCKABLE_FUNCTION_WITH_CODE(modifiers, result, function, ...) \
@@ -74,16 +112,11 @@
74112

75113
/* Codes_SRS_UMOCK_C_LIB_01_215: [ Each item in ... shall be an entry for one mockable function. ]*/
76114
/* Codes_SRS_UMOCK_C_LIB_01_216: [ Each item in ... shall be defined using a macro called FUNCTION, which shall be an alias for MOCKABLE_FUNCTION. ]*/
77-
#define MOCKABLE_INTERFACE(interface_name, ...) \
78-
MU_FOR_EACH_1(EXPAND_ENTRY, __VA_ARGS__) \
79-
static void MU_C2(register_reals_, interface_name)(void) \
80-
{ \
81-
MU_FOR_EACH_1(REGISTER_GLOBAL_MOCK_REAL, __VA_ARGS__); \
82-
} \
115+
83116

84117
#include "umock_c/umock_c.h"
85118

86-
#else
119+
#else /*ENABLE_MOCKS*/
87120

88121
#define UMOCK_C_PROD_ARG_IN_SIGNATURE(count, arg_type, arg_name) arg_type arg_name MU_IFCOMMA(count)
89122

@@ -107,7 +140,7 @@
107140
result modifiers function(MU_IF(MU_COUNT_ARG(__VA_ARGS__),,void) MU_FOR_EACH_2_COUNTED(UMOCK_C_PROD_ARG_IN_SIGNATURE, __VA_ARGS__)); \
108141
MU_IF(UMOCK_C_PROD_IS_NOT_VOID(result), DO_NOTHING_WITH_RETURN_VALUES,)
109142

110-
#define UMOCK_C_PROD_ARG_IN_SIGNATURE_2(count, arg_type, arg_name)
143+
#define UMOCK_C_PROD_ARG_IN_SIGNATURE_2(count, arg_type, arg_name)
111144

112145
// The below MOCKABLE_FUNCTION_WITH_CODE macros are a temporary solution and should not be used for long term
113146
// They will be removed once the real support is in umock_c

0 commit comments

Comments
 (0)