debug leak mem in fmock
This commit is contained in:
@@ -52,6 +52,10 @@ void append_fmock_to_listmock(struct func_mock_info_struct **f_mock_list, struc
|
|||||||
void append_list_base_fmock(struct list_base_fmock **l_fmock, struct func_mock_info_struct *f_mock);
|
void append_list_base_fmock(struct list_base_fmock **l_fmock, struct func_mock_info_struct *f_mock);
|
||||||
void append_variable_current(struct list_current_variable **lcurrent_var, char *current_var);
|
void append_variable_current(struct list_current_variable **lcurrent_var, char *current_var);
|
||||||
|
|
||||||
|
void clear_fmock_info_list(struct func_mock_info_struct **f_mock_list);
|
||||||
|
void clear_list_base_fmock(struct list_base_fmock **l_fmock);
|
||||||
|
void clear_variable_current(struct list_current_variable **lcurrent_var);
|
||||||
|
|
||||||
// if input == functioname___line_NBLINE return functioname, else it return the input
|
// if input == functioname___line_NBLINE return functioname, else it return the input
|
||||||
//char* extract_name_func_mock(char *input);
|
//char* extract_name_func_mock(char *input);
|
||||||
|
|
||||||
@@ -72,7 +76,7 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
((tmp__mock)->info_mock)->expect_call = -1;\
|
((tmp__mock)->info_mock)->expect_call = -1;\
|
||||||
((tmp__mock)->info_mock)->call = 0;\
|
((tmp__mock)->info_mock)->call = 0;\
|
||||||
((tmp__mock)->info_mock)->failed_call = 0;\
|
((tmp__mock)->info_mock)->failed_call = 0;\
|
||||||
((tmp__mock)->info_mock)->str_namefunc = malloc(strlen(#namefunction) + 32 + strlen(#pre_id));\
|
((tmp__mock)->info_mock)->str_namefunc = malloc(strlen(#namefunction) + 43 + strlen(#pre_id));\
|
||||||
sprintf(((tmp__mock)->info_mock)->str_namefunc,"%s%s%d",#namefunction,#pre_id,id);\
|
sprintf(((tmp__mock)->info_mock)->str_namefunc,"%s%s%d",#namefunction,#pre_id,id);\
|
||||||
((tmp__mock)->info_mock)->str_conditions = NULL;\
|
((tmp__mock)->info_mock)->str_conditions = NULL;\
|
||||||
((tmp__mock)->info_mock)->str_caller = NULL;\
|
((tmp__mock)->info_mock)->str_caller = NULL;\
|
||||||
@@ -102,6 +106,19 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
list_mo_ ## namefunction.str_print_current_variables = NULL;\
|
list_mo_ ## namefunction.str_print_current_variables = NULL;\
|
||||||
list_mo_ ## namefunction.next = NULL;\
|
list_mo_ ## namefunction.next = NULL;\
|
||||||
}\
|
}\
|
||||||
|
\
|
||||||
|
__attribute__((destructor)) void destruct_list_m_ ## namefunction(void){ \
|
||||||
|
/*free(list_mo_ ## namefunction.info_mock);*/ \
|
||||||
|
struct list_mock_return_ ## namefunction *tmp_nn = list_mo_ ## namefunction.next, *ttmp_nn;\
|
||||||
|
while(tmp_nn){\
|
||||||
|
ttmp_nn = tmp_nn;\
|
||||||
|
tmp_nn = tmp_nn->next;\
|
||||||
|
/*free(ttmp_nn->info_mock);*/\
|
||||||
|
free(ttmp_nn);\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
}\
|
||||||
|
\
|
||||||
returntype namefunction args_prototype_with_parenthesis {\
|
returntype namefunction args_prototype_with_parenthesis {\
|
||||||
static size_t count_call_f=0;\
|
static size_t count_call_f=0;\
|
||||||
++count_call_f;\
|
++count_call_f;\
|
||||||
@@ -157,7 +174,7 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
else if (((tmp_mock->info_mock)->times_left != 0) && ((tmp_mock->info_mock)->times_left != INITSTATE )) {\
|
else if (((tmp_mock->info_mock)->times_left != 0) && ((tmp_mock->info_mock)->times_left != INITSTATE )) {\
|
||||||
size_t len0 = strlen((tmp_mock->info_mock)->str_conditions);\
|
size_t len0 = strlen((tmp_mock->info_mock)->str_conditions);\
|
||||||
size_t len1 = strlen("when checking condition call: aa");\
|
size_t len1 = strlen("when checking condition call: aa");\
|
||||||
char *msg_call=malloc(len0 + len1 + strlen(__func__));\
|
char *msg_call=malloc(len0 + len1 + strlen(__func__)+1);\
|
||||||
sprintf(msg_call,"when checking %s condition call: %s",__func__,(tmp_mock->info_mock)->str_conditions);\
|
sprintf(msg_call,"when checking %s condition call: %s",__func__,(tmp_mock->info_mock)->str_conditions);\
|
||||||
HANDLE_OP_EXPECT_NAME(EQ,TYPE_INT,1, tmp_mock->call_mock_condition args_call_with_parenthesis, (tmp_mock->info_mock)->str_caller, msg_call); /*LOG("%s\n","failure condition");*/\
|
HANDLE_OP_EXPECT_NAME(EQ,TYPE_INT,1, tmp_mock->call_mock_condition args_call_with_parenthesis, (tmp_mock->info_mock)->str_caller, msg_call); /*LOG("%s\n","failure condition");*/\
|
||||||
free(msg_call);\
|
free(msg_call);\
|
||||||
@@ -201,7 +218,7 @@ char* extract_name_func_mock(char *input);
|
|||||||
do{\
|
do{\
|
||||||
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
||||||
while(tmp_mock){\
|
while(tmp_mock){\
|
||||||
(tmp_mock->info_mock)->str_caller=malloc(strlen(__func__));\
|
(tmp_mock->info_mock)->str_caller=malloc(strlen(__func__)+1);\
|
||||||
strcpy((tmp_mock->info_mock)->str_caller,__func__);\
|
strcpy((tmp_mock->info_mock)->str_caller,__func__);\
|
||||||
tmp_mock = tmp_mock->next;\
|
tmp_mock = tmp_mock->next;\
|
||||||
}\
|
}\
|
||||||
@@ -235,9 +252,9 @@ __attribute__((constructor)) void create_str_print_variables ## namefunction(){\
|
|||||||
((tmp_new_mock)->info_mock)->failed_call = 0;\
|
((tmp_new_mock)->info_mock)->failed_call = 0;\
|
||||||
((tmp_new_mock)->info_mock)->init_times_left = repeat;\
|
((tmp_new_mock)->info_mock)->init_times_left = repeat;\
|
||||||
((tmp_new_mock)->info_mock)->times_left = repeat;\
|
((tmp_new_mock)->info_mock)->times_left = repeat;\
|
||||||
((tmp_new_mock)->info_mock)->str_namefunc = malloc(strlen(#namefunction) + 32 + strlen(#pre_id));\
|
((tmp_new_mock)->info_mock)->str_namefunc = malloc(strlen(#namefunction) + 43 + strlen(#pre_id));\
|
||||||
sprintf(((tmp_new_mock)->info_mock)->str_namefunc,"%s%s%d",#namefunction,#pre_id,id);\
|
sprintf(((tmp_new_mock)->info_mock)->str_namefunc,"%s%s%d",#namefunction,#pre_id,id);\
|
||||||
((tmp_new_mock)->info_mock)->str_conditions = malloc(strlen(#condition_on_args_expression));\
|
((tmp_new_mock)->info_mock)->str_conditions = malloc(strlen(#condition_on_args_expression)+1);\
|
||||||
strcpy(((tmp_new_mock)->info_mock)->str_conditions, #condition_on_args_expression);\
|
strcpy(((tmp_new_mock)->info_mock)->str_conditions, #condition_on_args_expression);\
|
||||||
((tmp_new_mock)->info_mock)->str_caller = NULL;\
|
((tmp_new_mock)->info_mock)->str_caller = NULL;\
|
||||||
((tmp_new_mock)->info_mock)->l_current_var= NULL;\
|
((tmp_new_mock)->info_mock)->l_current_var= NULL;\
|
||||||
@@ -251,6 +268,7 @@ __attribute__((constructor)) void create_str_print_variables ## namefunction(){\
|
|||||||
returntype CONCAT(run_ ## namefunction ## pre_id , id) args_prototype_with_parenthesis; \
|
returntype CONCAT(run_ ## namefunction ## pre_id , id) args_prototype_with_parenthesis; \
|
||||||
int CONCAT(namefunction ## _cond_ , id) args_prototype_with_parenthesis {/*LOG("cond:%d\n",condition_on_args_expression);*/ return condition_on_args_expression;}\
|
int CONCAT(namefunction ## _cond_ , id) args_prototype_with_parenthesis {/*LOG("cond:%d\n",condition_on_args_expression);*/ return condition_on_args_expression;}\
|
||||||
__attribute__((constructor)) void CONCAT(append_list_ ## namefunction , id)(void){\
|
__attribute__((constructor)) void CONCAT(append_list_ ## namefunction , id)(void){\
|
||||||
|
PRINT_DEBUG(" in constructor fmock : func :%s\n",#namefunction);\
|
||||||
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
||||||
if((tmp_mock->info_mock)->times_left == INITSTATE){/* init state */\
|
if((tmp_mock->info_mock)->times_left == INITSTATE){/* init state */\
|
||||||
FILL_MOCK_INFO(tmp_mock, namefunction, condition_on_args_expression , repeat, f_expect_call, pre_id, id, true);\
|
FILL_MOCK_INFO(tmp_mock, namefunction, condition_on_args_expression , repeat, f_expect_call, pre_id, id, true);\
|
||||||
|
|||||||
Binary file not shown.
+14
-1
@@ -12,6 +12,7 @@
|
|||||||
#include "ftest/ftest.h"
|
#include "ftest/ftest.h"
|
||||||
#include "fmock/fmock.h"
|
#include "fmock/fmock.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
TEST(true__){
|
TEST(true__){
|
||||||
PRINTF("another test again false\n");
|
PRINTF("another test again false\n");
|
||||||
bool val_bool = false;
|
bool val_bool = false;
|
||||||
@@ -100,6 +101,9 @@ TEST(lessThan){
|
|||||||
EXPECT_LT_TYPE_DOUBLE(da,db);
|
EXPECT_LT_TYPE_DOUBLE(da,db);
|
||||||
EXPECT_LT_TYPE_DOUBLE(db,da);
|
EXPECT_LT_TYPE_DOUBLE(db,da);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
TEST(sleep){sleep(2);}
|
TEST(sleep){sleep(2);}
|
||||||
TEST(sleep){sleep(2);}
|
TEST(sleep){sleep(2);}
|
||||||
@@ -148,7 +152,10 @@ TEST(sleep){sleep(1);}
|
|||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
MOCK_FUNC(int, f_mock, (), ())
|
MOCK_FUNC(int, f_mock, (), ())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EXPECT_MOCK_CALL(int,f_mock, (),false, 2) {
|
EXPECT_MOCK_CALL(int,f_mock, (),false, 2) {
|
||||||
EXPECT_EQ_IN_MOCKF(21,21,f_mock);
|
EXPECT_EQ_IN_MOCKF(21,21,f_mock);
|
||||||
EXPECT_EQ(1,3);
|
EXPECT_EQ(1,3);
|
||||||
@@ -159,6 +166,7 @@ EXPECT_MOCK_CALL(int,f_mock, (),1, 1) { EXPECT_EQ_IN_MOCKF(23,21,f_mock);return
|
|||||||
EXPECT_MOCK_CALL(int,f_mock, (),1==2||2<1, 1) {return 18;}
|
EXPECT_MOCK_CALL(int,f_mock, (),1==2||2<1, 1) {return 18;}
|
||||||
EXPECT_MOCK_CALL(int,f_mock, (),1, INFINITY) {return -18;}
|
EXPECT_MOCK_CALL(int,f_mock, (),1, INFINITY) {return -18;}
|
||||||
|
|
||||||
|
|
||||||
TEST(mockf1){
|
TEST(mockf1){
|
||||||
INIT_CALLER_MOCK(f_mock);
|
INIT_CALLER_MOCK(f_mock);
|
||||||
|
|
||||||
@@ -171,6 +179,11 @@ TEST(mockf1){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
MOCK_FUNC(int, f2_mock,(int a,int b),(a,b))
|
MOCK_FUNC(int, f2_mock,(int a,int b),(a,b))
|
||||||
|
|
||||||
STR_PRINT_CUR_VAR(f2_mock, (int a,int b),(a,b)){
|
STR_PRINT_CUR_VAR(f2_mock, (int a,int b),(a,b)){
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ void append_fmock_to_listmock(struct func_mock_info_struct **f_mock_list, struc
|
|||||||
void append_list_base_fmock(struct list_base_fmock **l_fmock, struct func_mock_info_struct *f_mock);
|
void append_list_base_fmock(struct list_base_fmock **l_fmock, struct func_mock_info_struct *f_mock);
|
||||||
void append_variable_current(struct list_current_variable **lcurrent_var, char *current_var);
|
void append_variable_current(struct list_current_variable **lcurrent_var, char *current_var);
|
||||||
|
|
||||||
|
void clear_fmock_info_list(struct func_mock_info_struct **f_mock_list);
|
||||||
|
void clear_list_base_fmock(struct list_base_fmock **l_fmock);
|
||||||
|
void clear_variable_current(struct list_current_variable **lcurrent_var);
|
||||||
|
|
||||||
// if input == functioname___line_NBLINE return functioname, else it return the input
|
// if input == functioname___line_NBLINE return functioname, else it return the input
|
||||||
//char* extract_name_func_mock(char *input);
|
//char* extract_name_func_mock(char *input);
|
||||||
|
|
||||||
@@ -72,7 +76,7 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
((tmp__mock)->info_mock)->expect_call = -1;\
|
((tmp__mock)->info_mock)->expect_call = -1;\
|
||||||
((tmp__mock)->info_mock)->call = 0;\
|
((tmp__mock)->info_mock)->call = 0;\
|
||||||
((tmp__mock)->info_mock)->failed_call = 0;\
|
((tmp__mock)->info_mock)->failed_call = 0;\
|
||||||
((tmp__mock)->info_mock)->str_namefunc = malloc(strlen(#namefunction) + 32 + strlen(#pre_id));\
|
((tmp__mock)->info_mock)->str_namefunc = malloc(strlen(#namefunction) + 43 + strlen(#pre_id));\
|
||||||
sprintf(((tmp__mock)->info_mock)->str_namefunc,"%s%s%d",#namefunction,#pre_id,id);\
|
sprintf(((tmp__mock)->info_mock)->str_namefunc,"%s%s%d",#namefunction,#pre_id,id);\
|
||||||
((tmp__mock)->info_mock)->str_conditions = NULL;\
|
((tmp__mock)->info_mock)->str_conditions = NULL;\
|
||||||
((tmp__mock)->info_mock)->str_caller = NULL;\
|
((tmp__mock)->info_mock)->str_caller = NULL;\
|
||||||
@@ -102,6 +106,19 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
list_mo_ ## namefunction.str_print_current_variables = NULL;\
|
list_mo_ ## namefunction.str_print_current_variables = NULL;\
|
||||||
list_mo_ ## namefunction.next = NULL;\
|
list_mo_ ## namefunction.next = NULL;\
|
||||||
}\
|
}\
|
||||||
|
\
|
||||||
|
__attribute__((destructor)) void destruct_list_m_ ## namefunction(void){ \
|
||||||
|
/*free(list_mo_ ## namefunction.info_mock);*/ \
|
||||||
|
struct list_mock_return_ ## namefunction *tmp_nn = list_mo_ ## namefunction.next, *ttmp_nn;\
|
||||||
|
while(tmp_nn){\
|
||||||
|
ttmp_nn = tmp_nn;\
|
||||||
|
tmp_nn = tmp_nn->next;\
|
||||||
|
/*free(ttmp_nn->info_mock);*/\
|
||||||
|
free(ttmp_nn);\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
}\
|
||||||
|
\
|
||||||
returntype namefunction args_prototype_with_parenthesis {\
|
returntype namefunction args_prototype_with_parenthesis {\
|
||||||
static size_t count_call_f=0;\
|
static size_t count_call_f=0;\
|
||||||
++count_call_f;\
|
++count_call_f;\
|
||||||
@@ -157,7 +174,7 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
else if (((tmp_mock->info_mock)->times_left != 0) && ((tmp_mock->info_mock)->times_left != INITSTATE )) {\
|
else if (((tmp_mock->info_mock)->times_left != 0) && ((tmp_mock->info_mock)->times_left != INITSTATE )) {\
|
||||||
size_t len0 = strlen((tmp_mock->info_mock)->str_conditions);\
|
size_t len0 = strlen((tmp_mock->info_mock)->str_conditions);\
|
||||||
size_t len1 = strlen("when checking condition call: aa");\
|
size_t len1 = strlen("when checking condition call: aa");\
|
||||||
char *msg_call=malloc(len0 + len1 + strlen(__func__));\
|
char *msg_call=malloc(len0 + len1 + strlen(__func__)+1);\
|
||||||
sprintf(msg_call,"when checking %s condition call: %s",__func__,(tmp_mock->info_mock)->str_conditions);\
|
sprintf(msg_call,"when checking %s condition call: %s",__func__,(tmp_mock->info_mock)->str_conditions);\
|
||||||
HANDLE_OP_EXPECT_NAME(EQ,TYPE_INT,1, tmp_mock->call_mock_condition args_call_with_parenthesis, (tmp_mock->info_mock)->str_caller, msg_call); /*LOG("%s\n","failure condition");*/\
|
HANDLE_OP_EXPECT_NAME(EQ,TYPE_INT,1, tmp_mock->call_mock_condition args_call_with_parenthesis, (tmp_mock->info_mock)->str_caller, msg_call); /*LOG("%s\n","failure condition");*/\
|
||||||
free(msg_call);\
|
free(msg_call);\
|
||||||
@@ -201,7 +218,7 @@ char* extract_name_func_mock(char *input);
|
|||||||
do{\
|
do{\
|
||||||
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
||||||
while(tmp_mock){\
|
while(tmp_mock){\
|
||||||
(tmp_mock->info_mock)->str_caller=malloc(strlen(__func__));\
|
(tmp_mock->info_mock)->str_caller=malloc(strlen(__func__)+1);\
|
||||||
strcpy((tmp_mock->info_mock)->str_caller,__func__);\
|
strcpy((tmp_mock->info_mock)->str_caller,__func__);\
|
||||||
tmp_mock = tmp_mock->next;\
|
tmp_mock = tmp_mock->next;\
|
||||||
}\
|
}\
|
||||||
@@ -235,9 +252,9 @@ __attribute__((constructor)) void create_str_print_variables ## namefunction(){\
|
|||||||
((tmp_new_mock)->info_mock)->failed_call = 0;\
|
((tmp_new_mock)->info_mock)->failed_call = 0;\
|
||||||
((tmp_new_mock)->info_mock)->init_times_left = repeat;\
|
((tmp_new_mock)->info_mock)->init_times_left = repeat;\
|
||||||
((tmp_new_mock)->info_mock)->times_left = repeat;\
|
((tmp_new_mock)->info_mock)->times_left = repeat;\
|
||||||
((tmp_new_mock)->info_mock)->str_namefunc = malloc(strlen(#namefunction) + 32 + strlen(#pre_id));\
|
((tmp_new_mock)->info_mock)->str_namefunc = malloc(strlen(#namefunction) + 43 + strlen(#pre_id));\
|
||||||
sprintf(((tmp_new_mock)->info_mock)->str_namefunc,"%s%s%d",#namefunction,#pre_id,id);\
|
sprintf(((tmp_new_mock)->info_mock)->str_namefunc,"%s%s%d",#namefunction,#pre_id,id);\
|
||||||
((tmp_new_mock)->info_mock)->str_conditions = malloc(strlen(#condition_on_args_expression));\
|
((tmp_new_mock)->info_mock)->str_conditions = malloc(strlen(#condition_on_args_expression)+1);\
|
||||||
strcpy(((tmp_new_mock)->info_mock)->str_conditions, #condition_on_args_expression);\
|
strcpy(((tmp_new_mock)->info_mock)->str_conditions, #condition_on_args_expression);\
|
||||||
((tmp_new_mock)->info_mock)->str_caller = NULL;\
|
((tmp_new_mock)->info_mock)->str_caller = NULL;\
|
||||||
((tmp_new_mock)->info_mock)->l_current_var= NULL;\
|
((tmp_new_mock)->info_mock)->l_current_var= NULL;\
|
||||||
@@ -251,6 +268,7 @@ __attribute__((constructor)) void create_str_print_variables ## namefunction(){\
|
|||||||
returntype CONCAT(run_ ## namefunction ## pre_id , id) args_prototype_with_parenthesis; \
|
returntype CONCAT(run_ ## namefunction ## pre_id , id) args_prototype_with_parenthesis; \
|
||||||
int CONCAT(namefunction ## _cond_ , id) args_prototype_with_parenthesis {/*LOG("cond:%d\n",condition_on_args_expression);*/ return condition_on_args_expression;}\
|
int CONCAT(namefunction ## _cond_ , id) args_prototype_with_parenthesis {/*LOG("cond:%d\n",condition_on_args_expression);*/ return condition_on_args_expression;}\
|
||||||
__attribute__((constructor)) void CONCAT(append_list_ ## namefunction , id)(void){\
|
__attribute__((constructor)) void CONCAT(append_list_ ## namefunction , id)(void){\
|
||||||
|
PRINT_DEBUG(" in constructor fmock : func :%s\n",#namefunction);\
|
||||||
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
||||||
if((tmp_mock->info_mock)->times_left == INITSTATE){/* init state */\
|
if((tmp_mock->info_mock)->times_left == INITSTATE){/* init state */\
|
||||||
FILL_MOCK_INFO(tmp_mock, namefunction, condition_on_args_expression , repeat, f_expect_call, pre_id, id, true);\
|
FILL_MOCK_INFO(tmp_mock, namefunction, condition_on_args_expression , repeat, f_expect_call, pre_id, id, true);\
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ void append_list_base_fmock(struct list_base_fmock **l_fmock, struct func_mock_i
|
|||||||
else{
|
else{
|
||||||
*l_fmock = malloc(sizeof(struct list_base_fmock));
|
*l_fmock = malloc(sizeof(struct list_base_fmock));
|
||||||
(*l_fmock)->info_mock = f_mock;
|
(*l_fmock)->info_mock = f_mock;
|
||||||
|
(*l_fmock)->next = NULL;
|
||||||
}
|
}
|
||||||
UNLOCK(mut_g_list_base_fmock);
|
UNLOCK(mut_g_list_base_fmock);
|
||||||
}
|
}
|
||||||
@@ -113,7 +114,7 @@ void append_fmock_to_listmock(struct func_mock_info_struct **f_mock_list, struc
|
|||||||
#define SSTRFY(x) STRFY(x)
|
#define SSTRFY(x) STRFY(x)
|
||||||
|
|
||||||
char* extract_name_func_mock(char *input){
|
char* extract_name_func_mock(char *input){
|
||||||
char * ret=malloc(strlen(input));
|
char * ret=malloc(strlen(input) + 1);
|
||||||
strcpy(ret,input);
|
strcpy(ret,input);
|
||||||
char * pre_id_ = SSTRFY(PRE_ID);
|
char * pre_id_ = SSTRFY(PRE_ID);
|
||||||
size_t len_pre_id_ = strlen(pre_id_);
|
size_t len_pre_id_ = strlen(pre_id_);
|
||||||
@@ -156,7 +157,7 @@ char * number_call_translate(long nb){
|
|||||||
char * strprint_caller_(char *input){
|
char * strprint_caller_(char *input){
|
||||||
if(input==NULL) { return "";}
|
if(input==NULL) { return "";}
|
||||||
char *called_in=",\t called in ";
|
char *called_in=",\t called in ";
|
||||||
char *ret = malloc(strlen(called_in)+strlen(input)+1);
|
char *ret = malloc(strlen(called_in) + strlen(input) + 1);
|
||||||
sprintf(ret,"%s%s",called_in,input);
|
sprintf(ret,"%s%s",called_in,input);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -192,7 +193,7 @@ __attribute__((destructor))
|
|||||||
struct winsize w;
|
struct winsize w;
|
||||||
ioctl(1, TIOCGWINSZ, &w);
|
ioctl(1, TIOCGWINSZ, &w);
|
||||||
|
|
||||||
char *reader=malloc(w.ws_col);
|
char *reader=malloc(w.ws_col+1);
|
||||||
strcpy(reader,"STAT OF MOCK FUNCTIONS");
|
strcpy(reader,"STAT OF MOCK FUNCTIONS");
|
||||||
|
|
||||||
fprintf(F_OUT,"%s\n\n%0*d\n %*s \n%0*d %s\n\n", colors_f[k_YELLOW] ,w.ws_col,0, (int)(w.ws_col+strlen(reader))/2, reader,w.ws_col,0, DEFAULT_K );
|
fprintf(F_OUT,"%s\n\n%0*d\n %*s \n%0*d %s\n\n", colors_f[k_YELLOW] ,w.ws_col,0, (int)(w.ws_col+strlen(reader))/2, reader,w.ws_col,0, DEFAULT_K );
|
||||||
@@ -237,7 +238,9 @@ __attribute__((destructor))
|
|||||||
memset(reader,'=',w.ws_col);
|
memset(reader,'=',w.ws_col);
|
||||||
reader[w.ws_col-1]='\0';
|
reader[w.ws_col-1]='\0';
|
||||||
char *caller="";
|
char *caller="";
|
||||||
if(tmp_inf_mock->str_caller) caller = extract_func_edited_TEST_from_exec_func_name(tmp_inf_mock->str_caller);
|
if(tmp_inf_mock->str_caller){
|
||||||
|
caller = extract_func_edited_TEST_from_exec_func_name(tmp_inf_mock->str_caller);
|
||||||
|
}
|
||||||
size_t len_caller = strlen(caller);
|
size_t len_caller = strlen(caller);
|
||||||
|
|
||||||
char *nameff=extract_name_func_mock(tmp_inf_mock->str_namefunc);
|
char *nameff=extract_name_func_mock(tmp_inf_mock->str_namefunc);
|
||||||
@@ -319,3 +322,59 @@ __attribute__((destructor))
|
|||||||
PRINT_DEBUG("%s\n","pthread_mutex_destroy done!");
|
PRINT_DEBUG("%s\n","pthread_mutex_destroy done!");
|
||||||
PRINT_DEBUG("%s\n","check mock done!");
|
PRINT_DEBUG("%s\n","check mock done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void clear_fmock_info_list(struct func_mock_info_struct **f_mock_list){
|
||||||
|
if(*f_mock_list){
|
||||||
|
struct func_mock_info_struct *tmp_fmock_info = *f_mock_list, *ttmp_fmock_info;
|
||||||
|
while(tmp_fmock_info){
|
||||||
|
ttmp_fmock_info = tmp_fmock_info;
|
||||||
|
tmp_fmock_info = tmp_fmock_info->next;
|
||||||
|
free(ttmp_fmock_info->str_namefunc);
|
||||||
|
free(ttmp_fmock_info->str_conditions);
|
||||||
|
free(ttmp_fmock_info->str_caller);
|
||||||
|
clear_variable_current(&(ttmp_fmock_info->l_current_var));
|
||||||
|
free(ttmp_fmock_info);
|
||||||
|
}
|
||||||
|
*f_mock_list = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear_list_base_fmock(struct list_base_fmock **l_fmock){
|
||||||
|
if(*l_fmock){
|
||||||
|
struct list_base_fmock *tmp_l_n = *l_fmock, *ttmp_l_n;
|
||||||
|
while(tmp_l_n){
|
||||||
|
ttmp_l_n = tmp_l_n;
|
||||||
|
tmp_l_n = tmp_l_n->next;
|
||||||
|
//clear_fmock_info_list(&((ttmp_l_n->next)->info_mock));
|
||||||
|
free(ttmp_l_n);
|
||||||
|
}
|
||||||
|
*l_fmock=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear_variable_current(struct list_current_variable **lcurrent_var){
|
||||||
|
if(*lcurrent_var){
|
||||||
|
struct list_current_variable *tmp_lcv = *lcurrent_var, *ttmp_lcv;
|
||||||
|
while(tmp_lcv){
|
||||||
|
ttmp_lcv = tmp_lcv;
|
||||||
|
tmp_lcv = tmp_lcv->next;
|
||||||
|
|
||||||
|
free(ttmp_lcv->str_current_variables);
|
||||||
|
free(ttmp_lcv);
|
||||||
|
}
|
||||||
|
*lcurrent_var=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((constructor))
|
||||||
|
void purge_fmock(){
|
||||||
|
|
||||||
|
clear_fmock_info_list(&f_mock_glist);
|
||||||
|
PRINT_DEBUG("purge f_mock_glist %s\n","done");
|
||||||
|
//clear_list_base_fmock(&g_list_base_fmock);
|
||||||
|
//PRINT_DEBUG("purge g_list_base_fmock %s\n","done");
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user