another debug with valgrind in fmock and tensor
This commit is contained in:
+1
-1
@@ -40,7 +40,7 @@ $(SUBDIRS):
|
||||
$(MAKE) -C $@ $(MAKECMDGOALS)
|
||||
|
||||
update_headers: $(PROJECT_LIB)
|
||||
for file_h in $(SUBDIRS); do cp -r "$$file_h/include" include_ytest/; done
|
||||
for file_h in $(SUBDIRS); do cp -r "$$file_h/include/" include_ytest/; done
|
||||
|
||||
.PHONY: $(TOPTARGETS) $(SUBDIRS)
|
||||
|
||||
|
||||
@@ -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;\
|
||||
|
||||
Binary file not shown.
@@ -13,11 +13,13 @@
|
||||
#include "fmock/fmock.h"
|
||||
|
||||
#if 1
|
||||
|
||||
TEST(true__){
|
||||
PRINTF("another test again false\n");
|
||||
bool val_bool = false;
|
||||
ASSERT_TRUE(val_bool);
|
||||
}
|
||||
|
||||
TEST(test)
|
||||
{
|
||||
PRINTF("test test\n");
|
||||
@@ -25,6 +27,7 @@ TEST(test)
|
||||
ASSERT_FALSE(val_bool);
|
||||
|
||||
}
|
||||
|
||||
TEST(float_equal){
|
||||
PRINTF("another test float\n");
|
||||
ASSERT_TRUE(true);
|
||||
@@ -184,6 +187,8 @@ TEST(mockf1){
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if 1
|
||||
|
||||
MOCK_FUNC(int, f2_mock,(int a,int b),(a,b))
|
||||
@@ -349,6 +354,7 @@ TEST(f7_mock_test){
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
|
||||
//run_all_tests();
|
||||
|
||||
@@ -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;\
|
||||
|
||||
@@ -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!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -213,7 +213,11 @@ long int id_of_thread_executed(void){
|
||||
if(id_thread_self[i] == id_from_self)
|
||||
return i;
|
||||
}
|
||||
PRINT_ERROR("something wrong on %s, id_from_self: %ld\n",__func__,id_from_self);
|
||||
/*if(id_thread_self){
|
||||
for(long int i=0; i<= parallel_nb; ++i)
|
||||
PRINT_DEBUG(" id_thread_self[%ld] = %ld \n", i, id_thread_self[i]);
|
||||
}*/
|
||||
PRINT_ERROR("\nsomething wrong on %s, id_from_self: %ld\n",__func__,id_from_self);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1007,10 +1011,10 @@ stat_end_run(size_t ntst, struct timespec start_t){
|
||||
bool is_in_array_##type(type *array, type val){\
|
||||
bool found = false;\
|
||||
for(size_t i = 0; i < cur_array_##type; ++i){\
|
||||
/*char * strarr = type##_TO_STR(array[i]), *strval = type##_TO_STR(val);\
|
||||
char * strarr = type##_TO_STR(array[i]), *strval = type##_TO_STR(val);\
|
||||
PRINT_DEBUG("compare |%s| in array and val: |%s|\n",strarr, strval);\
|
||||
free(strarr);free(strval);\
|
||||
*/PRINT_DEBUG("compare |%s| in array and val: |%s|\n",type##_TO_STR(array[i]), type##_TO_STR(val));\
|
||||
/*PRINT_DEBUG("compare |%s| in array and val: |%s|\n",type##_TO_STR(array[i]), type##_TO_STR(val));*/\
|
||||
if(COMPARE_N_##type((void*)(array[i]),(void*)val ) == 0 ){\
|
||||
found = true;\
|
||||
break;\
|
||||
@@ -1024,10 +1028,10 @@ bool is_in_array_##type(type *array, type val){\
|
||||
bool is_in_array_##type(type *array, type val){\
|
||||
bool found = false;\
|
||||
for(size_t i = 0; i < cur_array_##type; ++i){\
|
||||
/*char * strarr = type##_TO_STR(array[i]), *strval = type##_TO_STR(val);\
|
||||
char * strarr = type##_TO_STR(array[i]), *strval = type##_TO_STR(val);\
|
||||
PRINT_DEBUG("compare |%s| in array and val: |%s|\n",strarr, strval);\
|
||||
free(strarr);free(strval);*/\
|
||||
PRINT_DEBUG("compare |%s| in array and val: |%s|\n",type##_TO_STR(array[i]), type##_TO_STR(val));\
|
||||
free(strarr);free(strval);\
|
||||
/*PRINT_DEBUG("compare |%s| in array and val: |%s|\n",type##_TO_STR(array[i]), type##_TO_STR(val));*/\
|
||||
if(COMPARE_N_##type((void*)(&array[i]),(void*)&val ) == 0 ){\
|
||||
found = true;\
|
||||
break;\
|
||||
@@ -1312,6 +1316,7 @@ init_parallel_test_()
|
||||
thread_test_failed_l[i] = NULL;
|
||||
count_pass_thread[i] = 0;
|
||||
count_fail_thread[i] = 0;
|
||||
id_thread_self[i]=0; /* have to initialize because if some threads not yetr run we have warning with valgrind : non initialize value, beause real value is provide by each thread */
|
||||
}
|
||||
|
||||
current_fn = f_beging;
|
||||
@@ -1336,6 +1341,9 @@ final_parallel_test_()
|
||||
free(count_pass_thread);
|
||||
free(count_fail_thread);
|
||||
|
||||
free(id_thread_self);
|
||||
//id_thread_self = NULL;
|
||||
|
||||
for(size_t i=0; i< parallel_nb; ++i)
|
||||
clear_all_falied_list(&thread_test_failed_l[i]);
|
||||
|
||||
@@ -1377,17 +1385,20 @@ final_parallel_test_()
|
||||
fclose(f_ou_th[id_thrd]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free(f_ou_th);
|
||||
|
||||
if(removelog){
|
||||
for(size_t i=0; i<=parallel_nb; ++i){
|
||||
remove(log_name_file_thrd[i]);
|
||||
PRINT_DEBUG("file log of treard[%ld] removed\n",i);
|
||||
free(log_name_file_thrd[i]);
|
||||
}
|
||||
free(log_name_file_thrd);
|
||||
}
|
||||
|
||||
for(size_t i=0; i<=parallel_nb; ++i)
|
||||
free(log_name_file_thrd[i]);
|
||||
|
||||
free(log_name_file_thrd);
|
||||
}
|
||||
|
||||
void run_all_tests_parallel(size_t parallel /*, int max_col*/)
|
||||
|
||||
Reference in New Issue
Block a user