another debug with valgrind in fmock and tensor

This commit is contained in:
2024-02-12 01:34:08 +01:00
parent 877891987a
commit 60e4b16308
12 changed files with 318 additions and 39 deletions
+8
View File
@@ -24,6 +24,7 @@ struct list_current_variable{
*/
struct func_mock_info_struct{
long id;
bool used;
char *str_namefunc;
char *str_conditions;
char *str_caller;
@@ -74,6 +75,7 @@ extern struct list_base_fmock *g_list_base_fmock;
(tmp__mock)->call_mock_condition = NULL;\
/*(tmp__mock)->str_print_current_variables = list_mo_ ## namefunction .str_print_current_variables;*/\
((tmp__mock)->info_mock)->expect_call = -1;\
((tmp__mock)->info_mock)->used = true;\
((tmp__mock)->info_mock)->call = 0;\
((tmp__mock)->info_mock)->failed_call = 0;\
((tmp__mock)->info_mock)->str_namefunc = malloc(strlen(#namefunction) + 43 + strlen(#pre_id));\
@@ -101,6 +103,7 @@ extern struct list_base_fmock *g_list_base_fmock;
} list_mo_ ## namefunction;\
__attribute__((constructor)) void init_list_m_ ## namefunction(void){\
list_mo_ ## namefunction.info_mock = malloc(sizeof(struct func_mock_info_struct));\
(list_mo_ ## namefunction.info_mock)->used = false;\
(list_mo_ ## namefunction.info_mock)->times_left = INITSTATE;\
(list_mo_ ## namefunction.info_mock)->init_times_left = INITSTATE;\
list_mo_ ## namefunction.str_print_current_variables = NULL;\
@@ -110,12 +113,16 @@ extern struct list_base_fmock *g_list_base_fmock;
__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;\
if((list_mo_ ## namefunction.info_mock)->used == false ){\
free(list_mo_ ## namefunction.info_mock);\
}\
while(tmp_nn){\
ttmp_nn = tmp_nn;\
tmp_nn = tmp_nn->next;\
/*free(ttmp_nn->info_mock);*/\
free(ttmp_nn);\
}\
PRINT_DEBUG(" purge list mo_ %s done!\n",#namefunction);\
\
}\
\
@@ -248,6 +255,7 @@ __attribute__((constructor)) void create_str_print_variables ## namefunction(){\
(tmp_new_mock)->str_print_current_variables = list_mo_ ## namefunction .str_print_current_variables;\
/*(tmp_new_mock)->info_mock = malloc(sizeof(struct func_mock_info_struct));*/\
((tmp_new_mock)->info_mock)->expect_call = f_expect_call;\
((tmp_new_mock)->info_mock)->used = true;\
((tmp_new_mock)->info_mock)->call = 0;\
((tmp_new_mock)->info_mock)->failed_call = 0;\
((tmp_new_mock)->info_mock)->init_times_left = repeat;\
+4 -8
View File
@@ -34,7 +34,6 @@ pthread_mutex_t mut_g_list_base_fmock;
* return the numbers of comas (,) +1 in the input string
*/
int parse_count_args_(char *input){
int val=0;
for(int i = 0; i< strlen(input); ++i){
@@ -90,6 +89,7 @@ void append_variable_current(struct list_current_variable **lcurrent_var, char *
}
}
void append_fmock_to_listmock(struct func_mock_info_struct **f_mock_list, struct func_mock_info_struct *f_mock){
INCREMENT_(count_f_mock_wished);
if(f_mock->expect_call) {
@@ -140,7 +140,6 @@ __attribute__((constructor))
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;
@@ -155,7 +154,6 @@ void clear_fmock_info_list(struct func_mock_info_struct **f_mock_list){
}
*f_mock_list = NULL;
}
}
void clear_list_base_fmock(struct list_base_fmock **l_fmock){
@@ -187,6 +185,7 @@ void clear_variable_current(struct list_current_variable **lcurrent_var){
}
/* destructor will be executed in inverse order of call/place in the file */
__attribute__((destructor))
void purge_fmock(){
@@ -197,11 +196,9 @@ __attribute__((destructor))
}
extern bool is_parallel_nb;
char * number_call_translate(long nb){
char *ret=malloc(250);
if(nb>1) sprintf(ret," be called %ld times",nb);
@@ -234,7 +231,6 @@ char * strprint_caller_(char *input){
PRINTF("\n");\
}while(0);
__attribute__((destructor))
@@ -256,7 +252,8 @@ __attribute__((destructor))
char *reader=malloc(w.ws_col+3);
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 );
PRINTF("%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 );
is_parallel_nb = 0; /* no longer parallel here */
@@ -417,6 +414,5 @@ __attribute__((destructor))
PRINT_DEBUG("%s\n","pthread_mutex_destroy done!");
PRINT_DEBUG("%s\n","check mock done!");
}