add debug and gtest hook like as option
This commit is contained in:
@@ -108,16 +108,16 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
PRINT_DEBUG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>count call of %s: %ld\n",#namefunction,count_call_f);\
|
PRINT_DEBUG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>count call of %s: %ld\n",#namefunction,count_call_f);\
|
||||||
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 ){\
|
if( (tmp_mock->info_mock)->times_left == INITSTATE ){\
|
||||||
PRINT_HK_C(colors_f[k_YELLOW],HK_TR," WARNING, %s, no EXPECT_MOCK_CALL or WILL_MOCK_CALL, but called %ld times.\n",#namefunction, count_call_f);\
|
PRINT_HK_C(colors_f[k_YELLOW],tab_hk_f[hk_TR]," WARNING, %s, no EXPECT_MOCK_CALL or WILL_MOCK_CALL, but called %ld times.\n",#namefunction, count_call_f);\
|
||||||
if(count_call_f==1){\
|
if(count_call_f==1){\
|
||||||
PRINT_HK_C(colors_f[k_YELLOW],HK_TR," For instance:\n"\
|
PRINT_HK_C(colors_f[k_YELLOW],tab_hk_f[hk_TR]," For instance:\n"\
|
||||||
"%s EXPECT_MOCK_CALL(%s,%s,%s,true,1){\n"\
|
"%s EXPECT_MOCK_CALL(%s,%s,%s,true,1){\n"\
|
||||||
"%s\t %s ret;\n%s \t ...do something with %s;\n"\
|
"%s\t %s ret;\n%s \t ...do something with %s;\n"\
|
||||||
"%s\t return ret;\n"\
|
"%s\t return ret;\n"\
|
||||||
"%s }\n"\
|
"%s }\n"\
|
||||||
"%s if call once and accept all args, the same args with WILL_MOCK_CALL \n\n",\
|
"%s if call once and accept all args, the same args with WILL_MOCK_CALL \n\n",\
|
||||||
HK_TR, #returntype, #namefunction,#args_prototype_with_parenthesis, HK_TR,#returntype, \
|
tab_hk_f[hk_TR], #returntype, #namefunction,#args_prototype_with_parenthesis, tab_hk_f[hk_TR],#returntype, \
|
||||||
HK_TR, #args_call_with_parenthesis, HK_TR, HK_TR, HK_TR ); \
|
tab_hk_f[hk_TR], #args_call_with_parenthesis, tab_hk_f[hk_TR], tab_hk_f[hk_TR], tab_hk_f[hk_TR] ); \
|
||||||
/*return (returntype)0;*/ \
|
/*return (returntype)0;*/ \
|
||||||
INIT_MOCK_INFO_IF_NO_(tmp_mock,namefunction, PRE_ID);\
|
INIT_MOCK_INFO_IF_NO_(tmp_mock,namefunction, PRE_ID);\
|
||||||
}/* to have log */\
|
}/* to have log */\
|
||||||
@@ -129,15 +129,15 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
append_variable_current(&((tmp_mock->info_mock)->l_current_var), tmp_mock->str_print_current_variables args_call_with_parenthesis);\
|
append_variable_current(&((tmp_mock->info_mock)->l_current_var), tmp_mock->str_print_current_variables args_call_with_parenthesis);\
|
||||||
}\
|
}\
|
||||||
else if(count_call_f == 1){\
|
else if(count_call_f == 1){\
|
||||||
PRINT_HK_C(colors_f[k_YELLOW],HK_TR," no printer variable function defined, to define it:\n"\
|
PRINT_HK_C(colors_f[k_YELLOW],tab_hk_f[hk_TR]," no printer variable function defined, to define it:\n"\
|
||||||
"%s STR_PRINT_CUR_VAR(%s,%s,%s){\n"\
|
"%s STR_PRINT_CUR_VAR(%s,%s,%s){\n"\
|
||||||
"%s\t char* ret=malloc(256);/*for instance*/;\n"\
|
"%s\t char* ret=malloc(256);/*for instance*/;\n"\
|
||||||
"%s\t ... sprintf(ret,...., %s);/*for instance*/ \n"\
|
"%s\t ... sprintf(ret,...., %s);/*for instance*/ \n"\
|
||||||
"%s\t return ret;\n"\
|
"%s\t return ret;\n"\
|
||||||
"%s }\n"\
|
"%s }\n"\
|
||||||
"%s same prototype as MOCK_FUNC whithout returntype which always char* i\n\n",\
|
"%s same prototype as MOCK_FUNC whithout returntype which always char* i\n\n",\
|
||||||
HK_TR, #namefunction,#args_prototype_with_parenthesis, #args_call_with_parenthesis, \
|
tab_hk_f[hk_TR], #namefunction,#args_prototype_with_parenthesis, #args_call_with_parenthesis, \
|
||||||
HK_TR, HK_TR, #args_call_with_parenthesis, HK_TR, HK_TR, HK_TR ); \
|
tab_hk_f[hk_TR], tab_hk_f[hk_TR], #args_call_with_parenthesis, tab_hk_f[hk_TR], tab_hk_f[hk_TR], tab_hk_f[hk_TR] ); \
|
||||||
}\
|
}\
|
||||||
/*LOG("condition_func:%d\n", tmp_mock->call_mock_condition args_call_with_parenthesis);*/ /*LOG("%s\n","failure condition");*/\
|
/*LOG("condition_func:%d\n", tmp_mock->call_mock_condition args_call_with_parenthesis);*/ /*LOG("%s\n","failure condition");*/\
|
||||||
/*EXPECT_EQ_TYPE_INT(1, tmp_mock->call_mock_condition args_call_with_parenthesis);*/ /*LOG("%s\n","failure condition");*/\
|
/*EXPECT_EQ_TYPE_INT(1, tmp_mock->call_mock_condition args_call_with_parenthesis);*/ /*LOG("%s\n","failure condition");*/\
|
||||||
@@ -145,13 +145,13 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
/*return (returntype)0;*//* default return */\
|
/*return (returntype)0;*//* default return */\
|
||||||
if( (tmp_mock->info_mock)->str_caller == NULL){ \
|
if( (tmp_mock->info_mock)->str_caller == NULL){ \
|
||||||
if(count_call_f == 1){\
|
if(count_call_f == 1){\
|
||||||
PRINT_HK_C(colors_f[k_YELLOW],HK_TR," WARNING, no INIT_CALLER_MOCK; you can put it like this: \n"\
|
PRINT_HK_C(colors_f[k_YELLOW],tab_hk_f[hk_TR]," WARNING, no INIT_CALLER_MOCK; you can put it like this: \n"\
|
||||||
"%s TEST(nametest){\n"\
|
"%s TEST(nametest){\n"\
|
||||||
"%s\t INIT_CALLER_MOCK(%s); \n"\
|
"%s\t INIT_CALLER_MOCK(%s); \n"\
|
||||||
"%s\t %s%s; \n"\
|
"%s\t %s%s; \n"\
|
||||||
"%s }\n"\
|
"%s }\n"\
|
||||||
"%s i.e before calling %s in this TEST, to have explicit logs\n",\
|
"%s i.e before calling %s in this TEST, to have explicit logs\n",\
|
||||||
HK_TR, HK_TR, #namefunction, HK_TR,#namefunction,#args_call_with_parenthesis, HK_TR, HK_TR, #namefunction);} \
|
tab_hk_f[hk_TR], tab_hk_f[hk_TR], #namefunction, tab_hk_f[hk_TR],#namefunction,#args_call_with_parenthesis, tab_hk_f[hk_TR], tab_hk_f[hk_TR], #namefunction);} \
|
||||||
/*return (returntype)0;*/ \
|
/*return (returntype)0;*/ \
|
||||||
}\
|
}\
|
||||||
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 )) {\
|
||||||
@@ -164,7 +164,7 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
}\
|
}\
|
||||||
/*if(0 == tmp_mock->call_mock_condition args_call_with_parenthesis){\
|
/*if(0 == tmp_mock->call_mock_condition args_call_with_parenthesis){\
|
||||||
PRINT_LOC("Failure, arguments not expected\ncondition ( %s ) not verified\n\n", (tmp_mock->info_mock)->str_conditions);\
|
PRINT_LOC("Failure, arguments not expected\ncondition ( %s ) not verified\n\n", (tmp_mock->info_mock)->str_conditions);\
|
||||||
PRINT_HK_C(RED_K,HK_TR," 1 argument check failed from %s \n",__func__); \
|
PRINT_HK_C(RED_K,tab_hk_f[hk_TR]," 1 argument check failed from %s \n",__func__); \
|
||||||
}*/\
|
}*/\
|
||||||
PRINT_DEBUG(" %*c VALUES: mock function:%s, conditions:%s t_left:%ld, init_left:%ld| args:%s\n",8,'^',(tmp_mock->info_mock)->str_namefunc, (tmp_mock->info_mock)->str_conditions, (tmp_mock->info_mock)->times_left,(tmp_mock->info_mock)->init_times_left, #args_call_with_parenthesis);\
|
PRINT_DEBUG(" %*c VALUES: mock function:%s, conditions:%s t_left:%ld, init_left:%ld| args:%s\n",8,'^',(tmp_mock->info_mock)->str_namefunc, (tmp_mock->info_mock)->str_conditions, (tmp_mock->info_mock)->times_left,(tmp_mock->info_mock)->init_times_left, #args_call_with_parenthesis);\
|
||||||
if (((tmp_mock->info_mock)->times_left <= INFINITY) || ((tmp_mock->info_mock)->times_left > 0)){\
|
if (((tmp_mock->info_mock)->times_left <= INFINITY) || ((tmp_mock->info_mock)->times_left > 0)){\
|
||||||
|
|||||||
@@ -27,16 +27,16 @@
|
|||||||
#define SZ_TAB_HK 8
|
#define SZ_TAB_HK 8
|
||||||
|
|
||||||
|
|
||||||
#ifdef HK
|
/*#ifdef HK*/
|
||||||
#define HK_EQ "[==========]"
|
#define gHK_EQ "[==========]"
|
||||||
#define HK_TR "[----------]"
|
#define gHK_TR "[----------]"
|
||||||
#define HK_RN "[RUN ]"
|
#define gHK_RN "[RUN ]"
|
||||||
#define HK_DN "[ DONE]"
|
#define gHK_DN "[ DONE]"
|
||||||
#define HK_OK "[ OK ]"
|
#define gHK_OK "[ OK ]"
|
||||||
#define HK_FL "[ FAILED ]"
|
#define gHK_FL "[ FAILED ]"
|
||||||
#define HK_PS "[ PASSED ]"
|
#define gHK_PS "[ PASSED ]"
|
||||||
#define HK_SK "[ SKIP ]"
|
#define gHK_SK "[ SKIP ]"
|
||||||
#else
|
/*#else*/
|
||||||
#define HK_EQ "=========="
|
#define HK_EQ "=========="
|
||||||
#define HK_TR "----------"
|
#define HK_TR "----------"
|
||||||
#define HK_RN "====== RUN"
|
#define HK_RN "====== RUN"
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
#define HK_FL "===== FAIL"
|
#define HK_FL "===== FAIL"
|
||||||
#define HK_PS "===== PASS"
|
#define HK_PS "===== PASS"
|
||||||
#define HK_SK "===== SKIP"
|
#define HK_SK "===== SKIP"
|
||||||
#endif /* HK */
|
/*#endif*/ /* HK */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* compare symbol
|
* compare symbol
|
||||||
@@ -59,9 +59,11 @@
|
|||||||
|
|
||||||
|
|
||||||
extern FILE **f_ou_th;
|
extern FILE **f_ou_th;
|
||||||
|
extern bool debug;
|
||||||
extern bool unicolour;
|
extern bool unicolour;
|
||||||
extern bool ordered;
|
extern bool ordered;
|
||||||
extern bool log_parallel;
|
extern bool log_parallel;
|
||||||
|
extern bool only_usage;
|
||||||
extern char *savelog;
|
extern char *savelog;
|
||||||
|
|
||||||
extern char *colors_f[];
|
extern char *colors_f[];
|
||||||
@@ -131,14 +133,15 @@ extern char *varHK_EQ, *varHK_TR, *varHK_RN, *varHK_DN, *varHK_OK, *varHK_FL, *v
|
|||||||
#define PRINT_HK_C(color,hk,fmt,...)\
|
#define PRINT_HK_C(color,hk,fmt,...)\
|
||||||
PRINTF("%s%s%s" fmt, color,hk,colors_f[k_DEFAULT],__VA_ARGS__)
|
PRINTF("%s%s%s" fmt, color,hk,colors_f[k_DEFAULT],__VA_ARGS__)
|
||||||
|
|
||||||
|
#define PRINT_DEBUG(fmt, ...)\
|
||||||
|
do{ if(debug) PRINT_LOC(fmt, __VA_ARGS__);} while(0)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* to skip the bloc test function
|
* to skip the bloc test function
|
||||||
*/
|
*/
|
||||||
#define SKIP(fmt,...)\
|
#define SKIP(fmt,...)\
|
||||||
PRINT_HK_C(colors_f[k_GREEN], HK_SK, fmt, ## __VA_ARGS__);\
|
PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_SK], fmt, ## __VA_ARGS__);\
|
||||||
PRINT_LOC("%s\n\n" DEFAULT_K," Skiped "); return;
|
PRINT_LOC("%s\n\n" DEFAULT_K," Skiped "); return;
|
||||||
|
|
||||||
|
|
||||||
@@ -307,26 +310,26 @@ GEN_EXPECTED_OP_TYPE_FUNC(NE, TYPE_STRING)
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb == 0){\
|
if(is_parallel_nb == 0){\
|
||||||
if(expected_##OP##_##type(var1, var2)){ \
|
if(expected_##OP##_##type(var1, var2)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 %s passed %s \n\n",name_f,msg_call); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 %s passed %s \n\n",name_f,msg_call); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 %s failed %s \n",name_f,msg_call); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 %s failed %s \n",name_f,msg_call); \
|
||||||
} \
|
} \
|
||||||
}else { \
|
}else { \
|
||||||
if(expected_##OP##_name_##type(var1, var2, name_f)){ \
|
if(expected_##OP##_name_##type(var1, var2, name_f)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 %s passed %s \n\n",name_f,msg_call); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 %s passed %s \n\n",name_f,msg_call); \
|
||||||
/*PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed %s \n\n",name_f);*/ \
|
/*PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed %s \n\n",name_f);*/ \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 %s failed %s \n",name_f,msg_call); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 %s failed %s \n",name_f,msg_call); \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
}while(0);
|
}while(0);
|
||||||
@@ -341,26 +344,26 @@ do{ \
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb == 0){\
|
if(is_parallel_nb == 0){\
|
||||||
if(expected_##OP##_##type(var1, var2)){ \
|
if(expected_##OP##_##type(var1, var2)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
if(is_assert) return; \
|
if(is_assert) return; \
|
||||||
} \
|
} \
|
||||||
}else { \
|
}else { \
|
||||||
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
if(is_assert) return; \
|
if(is_assert) return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
@@ -375,25 +378,25 @@ do{ \
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb == 0){\
|
if(is_parallel_nb == 0){\
|
||||||
if(expected_##OP##_##type(var1, var2)){ \
|
if(expected_##OP##_##type(var1, var2)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
} \
|
} \
|
||||||
}else { \
|
}else { \
|
||||||
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
}while(0);
|
}while(0);
|
||||||
@@ -402,26 +405,26 @@ do{ \
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb == 0){\
|
if(is_parallel_nb == 0){\
|
||||||
if(expected_##OP##_##type(var1, var2)){ \
|
if(expected_##OP##_##type(var1, var2)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
}else { \
|
}else { \
|
||||||
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
@@ -667,21 +670,21 @@ do{ \
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb==0){\
|
if(is_parallel_nb==0){\
|
||||||
if(expected_##expect##_f(var1)){ \
|
if(expected_##expect##_f(var1)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
if(is_assert) return; \
|
if(is_assert) return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
else{\
|
else{\
|
||||||
if(expected_##expect##_f_name(var1, __func__)){ \
|
if(expected_##expect##_f_name(var1, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
if(is_assert) return; \
|
if(is_assert) return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
@@ -695,21 +698,21 @@ do{
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb==0){ \
|
if(is_parallel_nb==0){ \
|
||||||
if(expected_##expect##_f(var1)){ \
|
if(expected_##expect##_f(var1)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
size_t id_thread=id_of_thread_executed(); \
|
size_t id_thread=id_of_thread_executed(); \
|
||||||
if(expected_##expect##_f_name(var1, __func__)){ \
|
if(expected_##expect##_f_name(var1, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
}while(0);
|
}while(0);
|
||||||
@@ -719,22 +722,22 @@ do{
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb==0){ \
|
if(is_parallel_nb==0){ \
|
||||||
if(expected_##expect##_f(var1)){ \
|
if(expected_##expect##_f(var1)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n\n",__func__); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
else{\
|
else{\
|
||||||
size_t id_thread=id_of_thread_executed(); \
|
size_t id_thread=id_of_thread_executed(); \
|
||||||
if(expected_##expect##_f_name(var1, __func__)){ \
|
if(expected_##expect##_f_name(var1, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s, on thread[%ld]\n\n",__func__, id_thread); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s, on thread[%ld]\n\n",__func__, id_thread); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
// to define DEBUG in gcc cli do: gcc -D DEBUG=1 or 0 if need!
|
// to define DEBUG in gcc cli do: gcc -D DEBUG=1 or 0 if need!
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
@@ -45,7 +46,7 @@ void gotoxy(int x, int y);
|
|||||||
do { if (DEBUG) fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
|
do { if (DEBUG) fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
|
||||||
__LINE__, __func__, __VA_ARGS__); } while (0)
|
__LINE__, __func__, __VA_ARGS__); } while (0)
|
||||||
|
|
||||||
#define PRINT_DEBUG(fmt, ...) \
|
#define PRINT_DEBUG_(fmt, ...) \
|
||||||
do { if (DEBUG) fprintf(F_ERR, "%s:%d:%s(): " fmt, __FILE__, \
|
do { if (DEBUG) fprintf(F_ERR, "%s:%d:%s(): " fmt, __FILE__, \
|
||||||
__LINE__, __func__, __VA_ARGS__); } while (0)
|
__LINE__, __func__, __VA_ARGS__); } while (0)
|
||||||
|
|
||||||
|
|||||||
BIN
Binary file not shown.
@@ -108,16 +108,16 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
PRINT_DEBUG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>count call of %s: %ld\n",#namefunction,count_call_f);\
|
PRINT_DEBUG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>count call of %s: %ld\n",#namefunction,count_call_f);\
|
||||||
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 ){\
|
if( (tmp_mock->info_mock)->times_left == INITSTATE ){\
|
||||||
PRINT_HK_C(colors_f[k_YELLOW],HK_TR," WARNING, %s, no EXPECT_MOCK_CALL or WILL_MOCK_CALL, but called %ld times.\n",#namefunction, count_call_f);\
|
PRINT_HK_C(colors_f[k_YELLOW],tab_hk_f[hk_TR]," WARNING, %s, no EXPECT_MOCK_CALL or WILL_MOCK_CALL, but called %ld times.\n",#namefunction, count_call_f);\
|
||||||
if(count_call_f==1){\
|
if(count_call_f==1){\
|
||||||
PRINT_HK_C(colors_f[k_YELLOW],HK_TR," For instance:\n"\
|
PRINT_HK_C(colors_f[k_YELLOW],tab_hk_f[hk_TR]," For instance:\n"\
|
||||||
"%s EXPECT_MOCK_CALL(%s,%s,%s,true,1){\n"\
|
"%s EXPECT_MOCK_CALL(%s,%s,%s,true,1){\n"\
|
||||||
"%s\t %s ret;\n%s \t ...do something with %s;\n"\
|
"%s\t %s ret;\n%s \t ...do something with %s;\n"\
|
||||||
"%s\t return ret;\n"\
|
"%s\t return ret;\n"\
|
||||||
"%s }\n"\
|
"%s }\n"\
|
||||||
"%s if call once and accept all args, the same args with WILL_MOCK_CALL \n\n",\
|
"%s if call once and accept all args, the same args with WILL_MOCK_CALL \n\n",\
|
||||||
HK_TR, #returntype, #namefunction,#args_prototype_with_parenthesis, HK_TR,#returntype, \
|
tab_hk_f[hk_TR], #returntype, #namefunction,#args_prototype_with_parenthesis, tab_hk_f[hk_TR],#returntype, \
|
||||||
HK_TR, #args_call_with_parenthesis, HK_TR, HK_TR, HK_TR ); \
|
tab_hk_f[hk_TR], #args_call_with_parenthesis, tab_hk_f[hk_TR], tab_hk_f[hk_TR], tab_hk_f[hk_TR] ); \
|
||||||
/*return (returntype)0;*/ \
|
/*return (returntype)0;*/ \
|
||||||
INIT_MOCK_INFO_IF_NO_(tmp_mock,namefunction, PRE_ID);\
|
INIT_MOCK_INFO_IF_NO_(tmp_mock,namefunction, PRE_ID);\
|
||||||
}/* to have log */\
|
}/* to have log */\
|
||||||
@@ -129,15 +129,15 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
append_variable_current(&((tmp_mock->info_mock)->l_current_var), tmp_mock->str_print_current_variables args_call_with_parenthesis);\
|
append_variable_current(&((tmp_mock->info_mock)->l_current_var), tmp_mock->str_print_current_variables args_call_with_parenthesis);\
|
||||||
}\
|
}\
|
||||||
else if(count_call_f == 1){\
|
else if(count_call_f == 1){\
|
||||||
PRINT_HK_C(colors_f[k_YELLOW],HK_TR," no printer variable function defined, to define it:\n"\
|
PRINT_HK_C(colors_f[k_YELLOW],tab_hk_f[hk_TR]," no printer variable function defined, to define it:\n"\
|
||||||
"%s STR_PRINT_CUR_VAR(%s,%s,%s){\n"\
|
"%s STR_PRINT_CUR_VAR(%s,%s,%s){\n"\
|
||||||
"%s\t char* ret=malloc(256);/*for instance*/;\n"\
|
"%s\t char* ret=malloc(256);/*for instance*/;\n"\
|
||||||
"%s\t ... sprintf(ret,...., %s);/*for instance*/ \n"\
|
"%s\t ... sprintf(ret,...., %s);/*for instance*/ \n"\
|
||||||
"%s\t return ret;\n"\
|
"%s\t return ret;\n"\
|
||||||
"%s }\n"\
|
"%s }\n"\
|
||||||
"%s same prototype as MOCK_FUNC whithout returntype which always char* i\n\n",\
|
"%s same prototype as MOCK_FUNC whithout returntype which always char* i\n\n",\
|
||||||
HK_TR, #namefunction,#args_prototype_with_parenthesis, #args_call_with_parenthesis, \
|
tab_hk_f[hk_TR], #namefunction,#args_prototype_with_parenthesis, #args_call_with_parenthesis, \
|
||||||
HK_TR, HK_TR, #args_call_with_parenthesis, HK_TR, HK_TR, HK_TR ); \
|
tab_hk_f[hk_TR], tab_hk_f[hk_TR], #args_call_with_parenthesis, tab_hk_f[hk_TR], tab_hk_f[hk_TR], tab_hk_f[hk_TR] ); \
|
||||||
}\
|
}\
|
||||||
/*LOG("condition_func:%d\n", tmp_mock->call_mock_condition args_call_with_parenthesis);*/ /*LOG("%s\n","failure condition");*/\
|
/*LOG("condition_func:%d\n", tmp_mock->call_mock_condition args_call_with_parenthesis);*/ /*LOG("%s\n","failure condition");*/\
|
||||||
/*EXPECT_EQ_TYPE_INT(1, tmp_mock->call_mock_condition args_call_with_parenthesis);*/ /*LOG("%s\n","failure condition");*/\
|
/*EXPECT_EQ_TYPE_INT(1, tmp_mock->call_mock_condition args_call_with_parenthesis);*/ /*LOG("%s\n","failure condition");*/\
|
||||||
@@ -145,13 +145,13 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
/*return (returntype)0;*//* default return */\
|
/*return (returntype)0;*//* default return */\
|
||||||
if( (tmp_mock->info_mock)->str_caller == NULL){ \
|
if( (tmp_mock->info_mock)->str_caller == NULL){ \
|
||||||
if(count_call_f == 1){\
|
if(count_call_f == 1){\
|
||||||
PRINT_HK_C(colors_f[k_YELLOW],HK_TR," WARNING, no INIT_CALLER_MOCK; you can put it like this: \n"\
|
PRINT_HK_C(colors_f[k_YELLOW],tab_hk_f[hk_TR]," WARNING, no INIT_CALLER_MOCK; you can put it like this: \n"\
|
||||||
"%s TEST(nametest){\n"\
|
"%s TEST(nametest){\n"\
|
||||||
"%s\t INIT_CALLER_MOCK(%s); \n"\
|
"%s\t INIT_CALLER_MOCK(%s); \n"\
|
||||||
"%s\t %s%s; \n"\
|
"%s\t %s%s; \n"\
|
||||||
"%s }\n"\
|
"%s }\n"\
|
||||||
"%s i.e before calling %s in this TEST, to have explicit logs\n",\
|
"%s i.e before calling %s in this TEST, to have explicit logs\n",\
|
||||||
HK_TR, HK_TR, #namefunction, HK_TR,#namefunction,#args_call_with_parenthesis, HK_TR, HK_TR, #namefunction);} \
|
tab_hk_f[hk_TR], tab_hk_f[hk_TR], #namefunction, tab_hk_f[hk_TR],#namefunction,#args_call_with_parenthesis, tab_hk_f[hk_TR], tab_hk_f[hk_TR], #namefunction);} \
|
||||||
/*return (returntype)0;*/ \
|
/*return (returntype)0;*/ \
|
||||||
}\
|
}\
|
||||||
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 )) {\
|
||||||
@@ -164,7 +164,7 @@ extern struct list_base_fmock *g_list_base_fmock;
|
|||||||
}\
|
}\
|
||||||
/*if(0 == tmp_mock->call_mock_condition args_call_with_parenthesis){\
|
/*if(0 == tmp_mock->call_mock_condition args_call_with_parenthesis){\
|
||||||
PRINT_LOC("Failure, arguments not expected\ncondition ( %s ) not verified\n\n", (tmp_mock->info_mock)->str_conditions);\
|
PRINT_LOC("Failure, arguments not expected\ncondition ( %s ) not verified\n\n", (tmp_mock->info_mock)->str_conditions);\
|
||||||
PRINT_HK_C(RED_K,HK_TR," 1 argument check failed from %s \n",__func__); \
|
PRINT_HK_C(RED_K,tab_hk_f[hk_TR]," 1 argument check failed from %s \n",__func__); \
|
||||||
}*/\
|
}*/\
|
||||||
PRINT_DEBUG(" %*c VALUES: mock function:%s, conditions:%s t_left:%ld, init_left:%ld| args:%s\n",8,'^',(tmp_mock->info_mock)->str_namefunc, (tmp_mock->info_mock)->str_conditions, (tmp_mock->info_mock)->times_left,(tmp_mock->info_mock)->init_times_left, #args_call_with_parenthesis);\
|
PRINT_DEBUG(" %*c VALUES: mock function:%s, conditions:%s t_left:%ld, init_left:%ld| args:%s\n",8,'^',(tmp_mock->info_mock)->str_namefunc, (tmp_mock->info_mock)->str_conditions, (tmp_mock->info_mock)->times_left,(tmp_mock->info_mock)->init_times_left, #args_call_with_parenthesis);\
|
||||||
if (((tmp_mock->info_mock)->times_left <= INFINITY) || ((tmp_mock->info_mock)->times_left > 0)){\
|
if (((tmp_mock->info_mock)->times_left <= INFINITY) || ((tmp_mock->info_mock)->times_left > 0)){\
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ char * strprint_caller_(char *input){
|
|||||||
|
|
||||||
#define PRINT_VAR_CUR(mockinfo)\
|
#define PRINT_VAR_CUR(mockinfo)\
|
||||||
do{\
|
do{\
|
||||||
PRINTF("\n%s list of variables when %s was called, with condition %s:\n\t\t",HK_EQ,mockinfo->str_namefunc,mockinfo->str_conditions);\
|
PRINTF("\n%s list of variables when %s was called, with condition %s:\n\t\t",tab_hk_f[hk_EQ],mockinfo->str_namefunc,mockinfo->str_conditions);\
|
||||||
size_t cal_cur=0;\
|
size_t cal_cur=0;\
|
||||||
struct list_current_variable *tmp_cur_v = mockinfo->l_current_var;\
|
struct list_current_variable *tmp_cur_v = mockinfo->l_current_var;\
|
||||||
while(tmp_cur_v){\
|
while(tmp_cur_v){\
|
||||||
@@ -187,7 +187,7 @@ __attribute__((destructor))
|
|||||||
//k_GREEN=k_NOTHING; k_RED=k_NOTHING; k_YELLOW=k_NOTHING; k_BLUE=k_NOTHING;
|
//k_GREEN=k_NOTHING; k_RED=k_NOTHING; k_YELLOW=k_NOTHING; k_BLUE=k_NOTHING;
|
||||||
//for(int i=0; i< Dk_NOTHING;++i) strcpy(colors_f[i]," ");
|
//for(int i=0; i< Dk_NOTHING;++i) strcpy(colors_f[i]," ");
|
||||||
//}
|
//}
|
||||||
|
if(only_usage) return; /* do nothing */
|
||||||
struct winsize w;
|
struct winsize w;
|
||||||
ioctl(1, TIOCGWINSZ, &w);
|
ioctl(1, TIOCGWINSZ, &w);
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ __attribute__((destructor))
|
|||||||
PRINT_DEBUG("**** STAT mock function:%s, conditions:%s t_left:%ld, init_left:%ld, failed_call:%ld\n",tmock->str_namefunc, tmock->str_conditions, tmock->times_left,tmock->init_times_left, tmock->failed_call);
|
PRINT_DEBUG("**** STAT mock function:%s, conditions:%s t_left:%ld, init_left:%ld, failed_call:%ld\n",tmock->str_namefunc, tmock->str_conditions, tmock->times_left,tmock->init_times_left, tmock->failed_call);
|
||||||
if(((tmock->expect_call) && (tmock->init_times_left == tmock->times_left)) || (tmock->failed_call)){
|
if(((tmock->expect_call) && (tmock->init_times_left == tmock->times_left)) || (tmock->failed_call)){
|
||||||
if(tmock->l_current_var){
|
if(tmock->l_current_var){
|
||||||
PRINTF("%s%s %s%s %s: expect %s, it was called %ld times and failed %ld times, with condition %s\n",colors_f[k_RED],HK_FL,colors_f[k_YELLOW],tmock->str_namefunc,DEFAULT_K,
|
PRINTF("%s%s %s%s %s: expect %s, it was called %ld times and failed %ld times, with condition %s\n",colors_f[k_RED],tab_hk_f[hk_FL],colors_f[k_YELLOW],tmock->str_namefunc,DEFAULT_K,
|
||||||
number_call_translate(tmock->init_times_left),
|
number_call_translate(tmock->init_times_left),
|
||||||
tmock->call/*tmock->failed_call + (tmock->init_times_left - tmock->times_left)*/,
|
tmock->call/*tmock->failed_call + (tmock->init_times_left - tmock->times_left)*/,
|
||||||
tmock->failed_call,
|
tmock->failed_call,
|
||||||
@@ -216,7 +216,7 @@ __attribute__((destructor))
|
|||||||
PRINT_VAR_CUR(tmock);
|
PRINT_VAR_CUR(tmock);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PRINTF("%s%s %s%s %s: expect %s, it was called %ld times and failed %ld times, with condition %s \n",colors_f[k_RED],HK_FL,colors_f[k_YELLOW],tmock->str_namefunc,DEFAULT_K,
|
PRINTF("%s%s %s%s %s: expect %s, it was called %ld times and failed %ld times, with condition %s \n",colors_f[k_RED],tab_hk_f[hk_FL],colors_f[k_YELLOW],tmock->str_namefunc,DEFAULT_K,
|
||||||
number_call_translate(tmock->init_times_left),
|
number_call_translate(tmock->init_times_left),
|
||||||
tmock->call/*tmock->failed_call + (tmock->init_times_left - tmock->times_left)*/,
|
tmock->call/*tmock->failed_call + (tmock->init_times_left - tmock->times_left)*/,
|
||||||
tmock->failed_call,
|
tmock->failed_call,
|
||||||
@@ -227,7 +227,7 @@ __attribute__((destructor))
|
|||||||
//free(tfree);
|
//free(tfree);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINTF("\n%s%s STAT MOCK : there are %ld mock functions, %ld wished responses, %ld expected responses, which are:\n\n",colors_f[k_GREEN],HK_EQ,count_f_mock, count_f_mock_wished, count_expect_mock);
|
PRINTF("\n%s%s STAT MOCK : there are %ld mock functions, %ld wished responses, %ld expected responses, which are:\n\n",colors_f[k_GREEN],tab_hk_f[hk_EQ],count_f_mock, count_f_mock_wished, count_expect_mock);
|
||||||
struct list_base_fmock *tmp_list_fm = g_list_base_fmock;
|
struct list_base_fmock *tmp_list_fm = g_list_base_fmock;
|
||||||
struct func_mock_info_struct *tmp_inf_mock;
|
struct func_mock_info_struct *tmp_inf_mock;
|
||||||
/* list each fmock an each calls */
|
/* list each fmock an each calls */
|
||||||
|
|||||||
@@ -27,16 +27,16 @@
|
|||||||
#define SZ_TAB_HK 8
|
#define SZ_TAB_HK 8
|
||||||
|
|
||||||
|
|
||||||
#ifdef HK
|
/*#ifdef HK*/
|
||||||
#define HK_EQ "[==========]"
|
#define gHK_EQ "[==========]"
|
||||||
#define HK_TR "[----------]"
|
#define gHK_TR "[----------]"
|
||||||
#define HK_RN "[RUN ]"
|
#define gHK_RN "[RUN ]"
|
||||||
#define HK_DN "[ DONE]"
|
#define gHK_DN "[ DONE]"
|
||||||
#define HK_OK "[ OK ]"
|
#define gHK_OK "[ OK ]"
|
||||||
#define HK_FL "[ FAILED ]"
|
#define gHK_FL "[ FAILED ]"
|
||||||
#define HK_PS "[ PASSED ]"
|
#define gHK_PS "[ PASSED ]"
|
||||||
#define HK_SK "[ SKIP ]"
|
#define gHK_SK "[ SKIP ]"
|
||||||
#else
|
/*#else*/
|
||||||
#define HK_EQ "=========="
|
#define HK_EQ "=========="
|
||||||
#define HK_TR "----------"
|
#define HK_TR "----------"
|
||||||
#define HK_RN "====== RUN"
|
#define HK_RN "====== RUN"
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
#define HK_FL "===== FAIL"
|
#define HK_FL "===== FAIL"
|
||||||
#define HK_PS "===== PASS"
|
#define HK_PS "===== PASS"
|
||||||
#define HK_SK "===== SKIP"
|
#define HK_SK "===== SKIP"
|
||||||
#endif /* HK */
|
/*#endif*/ /* HK */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* compare symbol
|
* compare symbol
|
||||||
@@ -59,9 +59,11 @@
|
|||||||
|
|
||||||
|
|
||||||
extern FILE **f_ou_th;
|
extern FILE **f_ou_th;
|
||||||
|
extern bool debug;
|
||||||
extern bool unicolour;
|
extern bool unicolour;
|
||||||
extern bool ordered;
|
extern bool ordered;
|
||||||
extern bool log_parallel;
|
extern bool log_parallel;
|
||||||
|
extern bool only_usage;
|
||||||
extern char *savelog;
|
extern char *savelog;
|
||||||
|
|
||||||
extern char *colors_f[];
|
extern char *colors_f[];
|
||||||
@@ -131,14 +133,15 @@ extern char *varHK_EQ, *varHK_TR, *varHK_RN, *varHK_DN, *varHK_OK, *varHK_FL, *v
|
|||||||
#define PRINT_HK_C(color,hk,fmt,...)\
|
#define PRINT_HK_C(color,hk,fmt,...)\
|
||||||
PRINTF("%s%s%s" fmt, color,hk,colors_f[k_DEFAULT],__VA_ARGS__)
|
PRINTF("%s%s%s" fmt, color,hk,colors_f[k_DEFAULT],__VA_ARGS__)
|
||||||
|
|
||||||
|
#define PRINT_DEBUG(fmt, ...)\
|
||||||
|
do{ if(debug) PRINT_LOC(fmt, __VA_ARGS__);} while(0)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* to skip the bloc test function
|
* to skip the bloc test function
|
||||||
*/
|
*/
|
||||||
#define SKIP(fmt,...)\
|
#define SKIP(fmt,...)\
|
||||||
PRINT_HK_C(colors_f[k_GREEN], HK_SK, fmt, ## __VA_ARGS__);\
|
PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_SK], fmt, ## __VA_ARGS__);\
|
||||||
PRINT_LOC("%s\n\n" DEFAULT_K," Skiped "); return;
|
PRINT_LOC("%s\n\n" DEFAULT_K," Skiped "); return;
|
||||||
|
|
||||||
|
|
||||||
@@ -307,26 +310,26 @@ GEN_EXPECTED_OP_TYPE_FUNC(NE, TYPE_STRING)
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb == 0){\
|
if(is_parallel_nb == 0){\
|
||||||
if(expected_##OP##_##type(var1, var2)){ \
|
if(expected_##OP##_##type(var1, var2)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 %s passed %s \n\n",name_f,msg_call); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 %s passed %s \n\n",name_f,msg_call); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 %s failed %s \n",name_f,msg_call); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 %s failed %s \n",name_f,msg_call); \
|
||||||
} \
|
} \
|
||||||
}else { \
|
}else { \
|
||||||
if(expected_##OP##_name_##type(var1, var2, name_f)){ \
|
if(expected_##OP##_name_##type(var1, var2, name_f)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 %s passed %s \n\n",name_f,msg_call); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 %s passed %s \n\n",name_f,msg_call); \
|
||||||
/*PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed %s \n\n",name_f);*/ \
|
/*PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed %s \n\n",name_f);*/ \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 %s failed %s \n",name_f,msg_call); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 %s failed %s \n",name_f,msg_call); \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
}while(0);
|
}while(0);
|
||||||
@@ -341,26 +344,26 @@ do{ \
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb == 0){\
|
if(is_parallel_nb == 0){\
|
||||||
if(expected_##OP##_##type(var1, var2)){ \
|
if(expected_##OP##_##type(var1, var2)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
if(is_assert) return; \
|
if(is_assert) return; \
|
||||||
} \
|
} \
|
||||||
}else { \
|
}else { \
|
||||||
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
if(is_assert) return; \
|
if(is_assert) return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
@@ -375,25 +378,25 @@ do{ \
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb == 0){\
|
if(is_parallel_nb == 0){\
|
||||||
if(expected_##OP##_##type(var1, var2)){ \
|
if(expected_##OP##_##type(var1, var2)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
} \
|
} \
|
||||||
}else { \
|
}else { \
|
||||||
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
}while(0);
|
}while(0);
|
||||||
@@ -402,26 +405,26 @@ do{ \
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb == 0){\
|
if(is_parallel_nb == 0){\
|
||||||
if(expected_##OP##_##type(var1, var2)){ \
|
if(expected_##OP##_##type(var1, var2)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
,DESCRIPTION_##OP,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); */ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
}else { \
|
}else { \
|
||||||
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
if(expected_##OP##_name_##type(var1, var2, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
/*PRINT_LOC("Failure\nExpected %s of these values:\n %s\n\tWhich is: %s\n %s\n\tWhich is: %s\n\n"\
|
||||||
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
,DESCRIPTION_##OP ,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2));*/ \
|
||||||
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
PRINT_LOC("Failure\nExpected: (%s) %s (%s) :\n Value of %s: %s \n Value of %s: %s\n\n"\
|
||||||
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
,#var1,STRFY(OP),#var2,#var1, type##_TO_STR(var1), #var2, type##_TO_STR(var2)); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
@@ -667,21 +670,21 @@ do{ \
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb==0){\
|
if(is_parallel_nb==0){\
|
||||||
if(expected_##expect##_f(var1)){ \
|
if(expected_##expect##_f(var1)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
if(is_assert) return; \
|
if(is_assert) return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
else{\
|
else{\
|
||||||
if(expected_##expect##_f_name(var1, __func__)){ \
|
if(expected_##expect##_f_name(var1, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n",__func__); \
|
||||||
if(is_assert) return; \
|
if(is_assert) return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
@@ -695,21 +698,21 @@ do{
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb==0){ \
|
if(is_parallel_nb==0){ \
|
||||||
if(expected_##expect##_f(var1)){ \
|
if(expected_##expect##_f(var1)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
size_t id_thread=id_of_thread_executed(); \
|
size_t id_thread=id_of_thread_executed(); \
|
||||||
if(expected_##expect##_f_name(var1, __func__)){ \
|
if(expected_##expect##_f_name(var1, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
}while(0);
|
}while(0);
|
||||||
@@ -719,22 +722,22 @@ do{
|
|||||||
do{ \
|
do{ \
|
||||||
if(is_parallel_nb==0){ \
|
if(is_parallel_nb==0){ \
|
||||||
if(expected_##expect##_f(var1)){ \
|
if(expected_##expect##_f(var1)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s \n\n",__func__); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n", #var1, #not_expect, #expect); \
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s \n\n",__func__); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s \n\n",__func__); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
else{\
|
else{\
|
||||||
size_t id_thread=id_of_thread_executed(); \
|
size_t id_thread=id_of_thread_executed(); \
|
||||||
if(expected_##expect##_f_name(var1, __func__)){ \
|
if(expected_##expect##_f_name(var1, __func__)){ \
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_TR," 1 test passed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_TR]," 1 test passed from %s, on thread[%ld]\n\n",__func__,id_thread); \
|
||||||
} \
|
} \
|
||||||
else{ \
|
else{ \
|
||||||
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
PRINT_LOC("Failure\nValue of: %s\nActual: %s\nExpected: %s\n\n", #var1, #not_expect, #expect);\
|
||||||
PRINT_HK_C(colors_f[k_RED],HK_TR," 1 test failed from %s, on thread[%ld]\n\n",__func__, id_thread); \
|
PRINT_HK_C(colors_f[k_RED],tab_hk_f[hk_TR]," 1 test failed from %s, on thread[%ld]\n\n",__func__, id_thread); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
}\
|
}\
|
||||||
|
|||||||
+49
-36
@@ -55,6 +55,8 @@ bool some_thing_wrong = 0;
|
|||||||
bool help=0;
|
bool help=0;
|
||||||
bool only_usage=0;
|
bool only_usage=0;
|
||||||
bool ordered= 0;
|
bool ordered= 0;
|
||||||
|
bool gtestlike=0;
|
||||||
|
bool debug=0;
|
||||||
bool unicolour = 0;
|
bool unicolour = 0;
|
||||||
bool removelog = 0;
|
bool removelog = 0;
|
||||||
char *timeunit="ms";
|
char *timeunit="ms";
|
||||||
@@ -69,9 +71,10 @@ char *colors_f[]={DEFAULT_K, GREEN_K, RED_K, YELLOW_K, BLUE_K, ""};
|
|||||||
int k_DEFAULT=0, k_GREEN=1, k_RED=2, k_YELLOW=3, k_BLUE=4, k_NOTHING=Dknothing;
|
int k_DEFAULT=0, k_GREEN=1, k_RED=2, k_YELLOW=3, k_BLUE=4, k_NOTHING=Dknothing;
|
||||||
|
|
||||||
char *tab_hk_f[]={ HK_EQ, HK_TR, HK_RN, HK_DN, HK_OK, HK_FL, HK_PS, HK_SK };
|
char *tab_hk_f[]={ HK_EQ, HK_TR, HK_RN, HK_DN, HK_OK, HK_FL, HK_PS, HK_SK };
|
||||||
|
char *g_tab_hk_f[]={ gHK_EQ, gHK_TR, gHK_RN, gHK_DN, gHK_OK, gHK_FL, gHK_PS, gHK_SK };
|
||||||
int hk_EQ=0, hk_TR=1, hk_RN=2, hk_DN=3, hk_OK=4, hk_FL=5, hk_PS=6, hk_SK=7 ;
|
int hk_EQ=0, hk_TR=1, hk_RN=2, hk_DN=3, hk_OK=4, hk_FL=5, hk_PS=6, hk_SK=7 ;
|
||||||
|
|
||||||
char *varHK_EQ=HK_EQ, *varHK_TR=HK_TR, *varHK_RN=HK_RN, *varHK_DN=HK_DN, *varHK_OK=HK_OK, *varHK_FL=HK_FL, *varHK_PS=HK_PS, *varHK_SK=HK_SK;
|
//char *varHK_EQ=HK_EQ, *varHK_TR=HK_TR, *varHK_RN=HK_RN, *varHK_DN=HK_DN, *varHK_OK=HK_OK, *varHK_FL=HK_FL, *varHK_PS=HK_PS, *varHK_SK=HK_SK;
|
||||||
|
|
||||||
bool some_tests_selected=0;
|
bool some_tests_selected=0;
|
||||||
|
|
||||||
@@ -270,6 +273,11 @@ void setup_variables_before_exec(){
|
|||||||
default_bar_progress=tmp_bp;
|
default_bar_progress=tmp_bp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(gtestlike){
|
||||||
|
for(int i=0; i<=hk_SK; ++i)
|
||||||
|
tab_hk_f[i]=g_tab_hk_f[i];
|
||||||
|
}
|
||||||
|
|
||||||
/*if(savelog){
|
/*if(savelog){
|
||||||
f_savelog=fopen(savelog, "w+");
|
f_savelog=fopen(savelog, "w+");
|
||||||
@@ -283,6 +291,8 @@ void usage(int argc, char **argv){
|
|||||||
printf("usage: %s [OPTIONS] [<ARGS>] \n\n or : %s [OPTIONS]=[<ARGS>]\n\n",argv[0],argv[0]);
|
printf("usage: %s [OPTIONS] [<ARGS>] \n\n or : %s [OPTIONS]=[<ARGS>]\n\n",argv[0],argv[0]);
|
||||||
printf("OPTIONS\n");
|
printf("OPTIONS\n");
|
||||||
printf("\t -h, --help \n\t\tprint help, options variables\n\n");
|
printf("\t -h, --help \n\t\tprint help, options variables\n\n");
|
||||||
|
printf("\t -d, --debug \n\t\tto print debug by using PRINT_DEBUG, by default PRINT_DEBUG is off\n\n");
|
||||||
|
printf("\t -g, --gtestlike \n\t\tto have gtest hook like!\n\n");
|
||||||
printf("\t -p <NB>, --parallel <NB>, -p=<NB>, --parallel=<NB>\n\t\tby default the program ran in sequantial all test, \n\t\tif this option is set, the program run tests on NB threads.\n\t\tEach thread pull up one test out the list of all test not yet executed,\n\t\tand execute it, until the list is empty \n\n");
|
printf("\t -p <NB>, --parallel <NB>, -p=<NB>, --parallel=<NB>\n\t\tby default the program ran in sequantial all test, \n\t\tif this option is set, the program run tests on NB threads.\n\t\tEach thread pull up one test out the list of all test not yet executed,\n\t\tand execute it, until the list is empty \n\n");
|
||||||
printf("\t -t <unit>, --time <unit>, -t=<unit>, --time=<unit> \n\t\tby default unit is millisecons ms, the other of unit are choices are second (or s), and nanosecond (or ns)\n\t\tex: -t ns or -t=nanosecond or --time=n to set nanosecond unit\n\n");
|
printf("\t -t <unit>, --time <unit>, -t=<unit>, --time=<unit> \n\t\tby default unit is millisecons ms, the other of unit are choices are second (or s), and nanosecond (or ns)\n\t\tex: -t ns or -t=nanosecond or --time=n to set nanosecond unit\n\n");
|
||||||
printf("\t -u , --unicolour\n\t\tby default, the result is colored, if you choice this option, it prints with default color\n\n");
|
printf("\t -u , --unicolour\n\t\tby default, the result is colored, if you choice this option, it prints with default color\n\n");
|
||||||
@@ -557,6 +567,8 @@ void parse_options(int argc, char **argv){
|
|||||||
for(int i=1; i<argc; ++i){
|
for(int i=1; i<argc; ++i){
|
||||||
PRINT_DEBUG("argc=%d, argv[%d]=%s\n",argc,i,argv[i]);
|
PRINT_DEBUG("argc=%d, argv[%d]=%s\n",argc,i,argv[i]);
|
||||||
IF_OPTION_NO_ARG(help)
|
IF_OPTION_NO_ARG(help)
|
||||||
|
IF_OPTION_NO_ARG(debug)
|
||||||
|
IF_OPTION_NO_ARG(gtestlike)
|
||||||
IF_OPTION_WITH_ARG_NUM(parallel_nb)
|
IF_OPTION_WITH_ARG_NUM(parallel_nb)
|
||||||
//IF_OPTION_WITH_ARG_NUM(width)
|
//IF_OPTION_WITH_ARG_NUM(width)
|
||||||
IF_OPTION_WITH_ARG_STR(savelog)
|
IF_OPTION_WITH_ARG_STR(savelog)
|
||||||
@@ -583,7 +595,7 @@ void parse_options(int argc, char **argv){
|
|||||||
|
|
||||||
#define LISTE_ALL_FAILED_TEST_IN_F_OUT\
|
#define LISTE_ALL_FAILED_TEST_IN_F_OUT\
|
||||||
while(failed_lst){\
|
while(failed_lst){\
|
||||||
PRINT_HK_C(colors_f[k_RED], HK_FL," %s\n",failed_lst->name);\
|
PRINT_HK_C(colors_f[k_RED], tab_hk_f[hk_FL]," %s\n",failed_lst->name);\
|
||||||
failed_lst = failed_lst->next;\
|
failed_lst = failed_lst->next;\
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,7 +608,7 @@ void list_failed_test(struct failed_lists *test_failed){
|
|||||||
LISTE_ALL_FAILED_TEST_IN_F_OUT
|
LISTE_ALL_FAILED_TEST_IN_F_OUT
|
||||||
}else{
|
}else{
|
||||||
while(failed_lst){
|
while(failed_lst){
|
||||||
PRINT_HK_C(colors_f[k_RED], HK_FL," %s, on thread[%ld]\n",failed_lst->name,id_thrd);
|
PRINT_HK_C(colors_f[k_RED], tab_hk_f[hk_FL]," %s, on thread[%ld]\n",failed_lst->name,id_thrd);
|
||||||
failed_lst = failed_lst->next;
|
failed_lst = failed_lst->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -604,7 +616,7 @@ void list_failed_test(struct failed_lists *test_failed){
|
|||||||
else{
|
else{
|
||||||
LISTE_ALL_FAILED_TEST_IN_F_OUT
|
LISTE_ALL_FAILED_TEST_IN_F_OUT
|
||||||
}
|
}
|
||||||
PRINT_HK_C(colors_f[k_DEFAULT], HK_EQ,"%s\n","");
|
PRINT_HK_C(colors_f[k_DEFAULT], tab_hk_f[hk_EQ],"%s\n","");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -820,22 +832,22 @@ append_func(void (*run)(void), char *name){
|
|||||||
|
|
||||||
void begin_execute_func(char *fun_ame, struct timespec *start_t){
|
void begin_execute_func(char *fun_ame, struct timespec *start_t){
|
||||||
clock_gettime(CLOCK_REALTIME, start_t);
|
clock_gettime(CLOCK_REALTIME, start_t);
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_RN," %s\n", fun_ame);
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_RN]," %s\n", fun_ame);
|
||||||
count_pass_local = 0;
|
count_pass_local = 0;
|
||||||
count_fail_local = 0;
|
count_fail_local = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PRINT_TIMESTAMP_STAT(color)\
|
#define PRINT_TIMESTAMP_STAT(color)\
|
||||||
if(SECOND) PRINT_HK_C(color,HK_DN," %lu tests passed from %s (%lf s)\n\n",count_pass_local,fun_ame, diff_timespec_seconds(end_t, start_t));\
|
if(SECOND) PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%lf s)\n\n",count_pass_local,fun_ame, diff_timespec_seconds(end_t, start_t));\
|
||||||
else if(NANOSECOND) PRINT_HK_C(color,HK_DN," %lu tests passed from %s (%ld ns)\n\n",count_pass_local,fun_ame, diff_timespec_nanoseconds(end_t, start_t));\
|
else if(NANOSECOND) PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%ld ns)\n\n",count_pass_local,fun_ame, diff_timespec_nanoseconds(end_t, start_t));\
|
||||||
else PRINT_HK_C(color,HK_DN," %lu tests passed from %s (%lf ms)\n\n",count_pass_local,fun_ame, diff_timespec_milliseconds(end_t, start_t));
|
else PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%lf ms)\n\n",count_pass_local,fun_ame, diff_timespec_milliseconds(end_t, start_t));
|
||||||
|
|
||||||
void end_execute_func(char *fun_ame, struct timespec start_t){
|
void end_execute_func(char *fun_ame, struct timespec start_t){
|
||||||
struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t);
|
struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t);
|
||||||
if(count_fail_local){
|
if(count_fail_local){
|
||||||
INCREMENT(count_fail_global); /*++count_fail_global*/
|
INCREMENT(count_fail_global); /*++count_fail_global*/
|
||||||
append_failed_list(&failed_l, fun_ame);
|
append_failed_list(&failed_l, fun_ame);
|
||||||
PRINT_HK_C(colors_f[k_RED], HK_FL, " %lu tests failed from %s\n",count_fail_local,fun_ame);
|
PRINT_HK_C(colors_f[k_RED], tab_hk_f[hk_FL], " %lu tests failed from %s\n",count_fail_local,fun_ame);
|
||||||
PRINT_TIMESTAMP_STAT(colors_f[k_RED]);
|
PRINT_TIMESTAMP_STAT(colors_f[k_RED]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -849,8 +861,8 @@ void end_execute_func(char *fun_ame, struct timespec start_t){
|
|||||||
*/
|
*/
|
||||||
void head_run(size_t nbtest, struct timespec *start_t){
|
void head_run(size_t nbtest, struct timespec *start_t){
|
||||||
clock_gettime(CLOCK_REALTIME, start_t);
|
clock_gettime(CLOCK_REALTIME, start_t);
|
||||||
if(cur_array_TYPE_SIZE_T || cur_array_TYPE_STRING) PRINT_HK_C(colors_f[k_GREEN], HK_EQ,"%s"," Running tests.\n");
|
if(cur_array_TYPE_SIZE_T || cur_array_TYPE_STRING) PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ],"%s"," Running tests.\n");
|
||||||
else PRINT_HK_C(colors_f[k_GREEN], HK_EQ," Running %lu tests.\n",nbtest);
|
else PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," Running %lu tests.\n",nbtest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -860,13 +872,13 @@ void
|
|||||||
stat_end_run(size_t ntst, struct timespec start_t){
|
stat_end_run(size_t ntst, struct timespec start_t){
|
||||||
struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t);
|
struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t);
|
||||||
|
|
||||||
if(SECOND) PRINT_HK_C(colors_f[k_GREEN], HK_EQ," %lu tests ran. (%lf s total)\n",ntst, diff_timespec_seconds(end_t, start_t));
|
if(SECOND) PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," %lu tests ran. (%lf s total)\n",ntst, diff_timespec_seconds(end_t, start_t));
|
||||||
else if(NANOSECOND) PRINT_HK_C(colors_f[k_GREEN], HK_EQ," %lu tests ran. (%ld ns total)\n",ntst, diff_timespec_nanoseconds(end_t, start_t));
|
else if(NANOSECOND) PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," %lu tests ran. (%ld ns total)\n",ntst, diff_timespec_nanoseconds(end_t, start_t));
|
||||||
else PRINT_HK_C(colors_f[k_GREEN], HK_EQ," %lu tests ran. (%lf ms total)\n",ntst, diff_timespec_milliseconds(end_t, start_t));
|
else PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," %lu tests ran. (%lf ms total)\n",ntst, diff_timespec_milliseconds(end_t, start_t));
|
||||||
|
|
||||||
PRINT_HK_C(colors_f[k_GREEN], HK_PS," %lu tests\n", count_pass_global);
|
PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_PS]," %lu tests\n", count_pass_global);
|
||||||
if(failed_l != NULL){
|
if(failed_l != NULL){
|
||||||
PRINT_HK_C(colors_f[k_RED], HK_FL," %lu tests, listed below:\n",count_fail_global);
|
PRINT_HK_C(colors_f[k_RED], tab_hk_f[hk_FL]," %lu tests, listed below:\n",count_fail_global);
|
||||||
list_failed_test(failed_l);
|
list_failed_test(failed_l);
|
||||||
PRINT_HK_C("","","\n%ld FAILED TESTS \n",count_fail_global);
|
PRINT_HK_C("","","\n%ld FAILED TESTS \n",count_fail_global);
|
||||||
}
|
}
|
||||||
@@ -957,7 +969,7 @@ void execute_all(struct func *fun){
|
|||||||
size_t num_f;
|
size_t num_f;
|
||||||
char *name_test=NULL;
|
char *name_test=NULL;
|
||||||
bool exec_test=0;
|
bool exec_test=0;
|
||||||
//PRINT_HK_C(colors_f[k_GREEN], HK_EQ," Running %lu tests.\n",count_tests);
|
//PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," Running %lu tests.\n",count_tests);
|
||||||
while(tmp){
|
while(tmp){
|
||||||
current_fn = tmp;
|
current_fn = tmp;
|
||||||
CHECK_IF_SELECTED_TEST(tmp->name)
|
CHECK_IF_SELECTED_TEST(tmp->name)
|
||||||
@@ -1000,8 +1012,8 @@ run_all_tests()
|
|||||||
*/
|
*/
|
||||||
void head_all_parallel_run(struct timespec *start_t){
|
void head_all_parallel_run(struct timespec *start_t){
|
||||||
clock_gettime(CLOCK_REALTIME, start_t);
|
clock_gettime(CLOCK_REALTIME, start_t);
|
||||||
if (cur_array_TYPE_SIZE_T || cur_array_TYPE_STRING) PRINT_HK_C(colors_f[k_GREEN], HK_EQ," Running tests on %ld threads\n", parallel_nb);
|
if (cur_array_TYPE_SIZE_T || cur_array_TYPE_STRING) PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," Running tests on %ld threads\n", parallel_nb);
|
||||||
else PRINT_HK_C(colors_f[k_GREEN], HK_EQ," Running %ld tests on %ld threads\n",count_tests, parallel_nb);
|
else PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," Running %ld tests on %ld threads\n",count_tests, parallel_nb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1011,7 +1023,7 @@ void head_parallel_run(struct timespec *start_t, size_t id_thrd){
|
|||||||
sprintf(log_name_file_thrd[id_thrd],"log_thread_%ld_id_%ld",id_thrd,pthread_self());
|
sprintf(log_name_file_thrd[id_thrd],"log_thread_%ld_id_%ld",id_thrd,pthread_self());
|
||||||
f_ou_th[id_thrd] = fopen(log_name_file_thrd[id_thrd], "w+");
|
f_ou_th[id_thrd] = fopen(log_name_file_thrd[id_thrd], "w+");
|
||||||
clock_gettime(CLOCK_REALTIME, start_t);
|
clock_gettime(CLOCK_REALTIME, start_t);
|
||||||
PRINT_HK_C(colors_f[k_GREEN], HK_EQ," Running tests on thread[%ld] ========== ==threadID== %ld \n", id_thrd,pthread_self());
|
PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," Running tests on thread[%ld] ========== ==threadID== %ld \n", id_thrd,pthread_self());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1021,13 +1033,13 @@ void
|
|||||||
stat_end_parallel_run(size_t ntst, struct timespec start_t, size_t id_thrd){
|
stat_end_parallel_run(size_t ntst, struct timespec start_t, size_t id_thrd){
|
||||||
struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t);
|
struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t);
|
||||||
|
|
||||||
if(SECOND) PRINT_HK_C(colors_f[k_GREEN], HK_EQ," %lu tests ran on thread[%ld]. (%lf s total) \n",ntst, id_thrd, diff_timespec_seconds(end_t, start_t));
|
if(SECOND) PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," %lu tests ran on thread[%ld]. (%lf s total) \n",ntst, id_thrd, diff_timespec_seconds(end_t, start_t));
|
||||||
else if(NANOSECOND) PRINT_HK_C(colors_f[k_GREEN], HK_EQ," %lu tests ran on thread[%ld]. (%ld ns total)\n",ntst, id_thrd, diff_timespec_nanoseconds(end_t, start_t));
|
else if(NANOSECOND) PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," %lu tests ran on thread[%ld]. (%ld ns total)\n",ntst, id_thrd, diff_timespec_nanoseconds(end_t, start_t));
|
||||||
else PRINT_HK_C(colors_f[k_GREEN], HK_EQ," %lu tests ran on thread[%ld]. (%lf ms total)\n",ntst, id_thrd, diff_timespec_milliseconds(end_t, start_t));
|
else PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," %lu tests ran on thread[%ld]. (%lf ms total)\n",ntst, id_thrd, diff_timespec_milliseconds(end_t, start_t));
|
||||||
|
|
||||||
PRINT_HK_C(colors_f[k_GREEN], HK_PS," %lu tests passed on thread[%ld]\n", count_pass_thread[id_thrd], id_thrd);
|
PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_PS]," %lu tests passed on thread[%ld]\n", count_pass_thread[id_thrd], id_thrd);
|
||||||
if(thread_test_failed_l[id_thrd] != NULL){
|
if(thread_test_failed_l[id_thrd] != NULL){
|
||||||
PRINT_HK_C(colors_f[k_RED], HK_FL," %lu tests failed on thread[%ld], listed below:\n",count_fail_thread[id_thrd],id_thrd);
|
PRINT_HK_C(colors_f[k_RED], tab_hk_f[hk_FL]," %lu tests failed on thread[%ld], listed below:\n",count_fail_thread[id_thrd],id_thrd);
|
||||||
list_failed_test(thread_test_failed_l[id_thrd]);
|
list_failed_test(thread_test_failed_l[id_thrd]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1039,15 +1051,15 @@ void
|
|||||||
stat_end_all_parallel_run(size_t ntst, struct timespec start_t){
|
stat_end_all_parallel_run(size_t ntst, struct timespec start_t){
|
||||||
struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t);
|
struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t);
|
||||||
|
|
||||||
//PRINT_HK_C(colors_f[k_DEFAULT], HK_EQ," %s: all parallel tests done\n\n",__FILE__);
|
//PRINT_HK_C(colors_f[k_DEFAULT], tab_hk_f[hk_EQ]," %s: all parallel tests done\n\n",__FILE__);
|
||||||
|
|
||||||
if(SECOND) PRINT_HK_C(colors_f[k_GREEN], HK_EQ," %lu tests ran on %ld threads. (%lf s total) \n",ntst, parallel_nb, diff_timespec_seconds(end_t, start_t));
|
if(SECOND) PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," %lu tests ran on %ld threads. (%lf s total) \n",ntst, parallel_nb, diff_timespec_seconds(end_t, start_t));
|
||||||
else if(NANOSECOND) PRINT_HK_C(colors_f[k_GREEN], HK_EQ," %lu tests ran on %ld threads. (%ld ns total)\n",ntst, parallel_nb, diff_timespec_nanoseconds(end_t, start_t));
|
else if(NANOSECOND) PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," %lu tests ran on %ld threads. (%ld ns total)\n",ntst, parallel_nb, diff_timespec_nanoseconds(end_t, start_t));
|
||||||
else PRINT_HK_C(colors_f[k_GREEN], HK_EQ," %lu tests ran on %ld threads. (%lf ms total)\n",ntst, parallel_nb, diff_timespec_milliseconds(end_t, start_t));
|
else PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_EQ]," %lu tests ran on %ld threads. (%lf ms total)\n",ntst, parallel_nb, diff_timespec_milliseconds(end_t, start_t));
|
||||||
|
|
||||||
PRINT_HK_C(colors_f[k_GREEN], HK_PS," %lu tests\n", count_pass_global);
|
PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_PS]," %lu tests\n", count_pass_global);
|
||||||
if(failed_l != NULL){
|
if(failed_l != NULL){
|
||||||
PRINT_HK_C(colors_f[k_RED], HK_FL," %lu tests, listed below:\n",count_fail_global);
|
PRINT_HK_C(colors_f[k_RED], tab_hk_f[hk_FL]," %lu tests, listed below:\n",count_fail_global);
|
||||||
list_failed_test(failed_l);
|
list_failed_test(failed_l);
|
||||||
PRINT_HK_C("","","\n%ld FAILED TESTS \n",count_fail_global);
|
PRINT_HK_C("","","\n%ld FAILED TESTS \n",count_fail_global);
|
||||||
}
|
}
|
||||||
@@ -1057,13 +1069,13 @@ stat_end_all_parallel_run(size_t ntst, struct timespec start_t){
|
|||||||
|
|
||||||
void begin_execute_func_parallel(char *fun_ame, struct timespec *start_t, size_t id_thrd){
|
void begin_execute_func_parallel(char *fun_ame, struct timespec *start_t, size_t id_thrd){
|
||||||
clock_gettime(CLOCK_REALTIME, start_t);
|
clock_gettime(CLOCK_REALTIME, start_t);
|
||||||
PRINT_HK_C(colors_f[k_GREEN],HK_RN," %s on thread[%ld]\n", fun_ame, id_thrd);
|
PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_RN]," %s on thread[%ld]\n", fun_ame, id_thrd);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PRINT_TIMESTAMP_STAT_PARALLEL(color)\
|
#define PRINT_TIMESTAMP_STAT_PARALLEL(color)\
|
||||||
if(SECOND) PRINT_HK_C(color,HK_DN," %lu tests passed from %s (%lf s), on thread[%ld]\n\n",count_pass_test[num_test],fun_ame, diff_timespec_seconds(end_t, start_t),id_thrd);\
|
if(SECOND) PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%lf s), on thread[%ld]\n\n",count_pass_test[num_test],fun_ame, diff_timespec_seconds(end_t, start_t),id_thrd);\
|
||||||
else if(NANOSECOND) PRINT_HK_C(color,HK_DN," %lu tests passed from %s (%ld ns), on thread[%ld]\n\n",count_pass_test[num_test],fun_ame, diff_timespec_nanoseconds(end_t, start_t),id_thrd);\
|
else if(NANOSECOND) PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%ld ns), on thread[%ld]\n\n",count_pass_test[num_test],fun_ame, diff_timespec_nanoseconds(end_t, start_t),id_thrd);\
|
||||||
else PRINT_HK_C(color,HK_DN," %lu tests passed from %s (%lf ms), on thread[%ld]\n\n",count_pass_test[num_test],fun_ame, diff_timespec_milliseconds(end_t, start_t),id_thrd);
|
else PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%lf ms), on thread[%ld]\n\n",count_pass_test[num_test],fun_ame, diff_timespec_milliseconds(end_t, start_t),id_thrd);
|
||||||
|
|
||||||
void end_execute_func_parallel(char *fun_ame, struct timespec start_t, size_t id_thrd){
|
void end_execute_func_parallel(char *fun_ame, struct timespec start_t, size_t id_thrd){
|
||||||
struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t);
|
struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t);
|
||||||
@@ -1076,7 +1088,7 @@ void end_execute_func_parallel(char *fun_ame, struct timespec start_t, size_t id
|
|||||||
LOCK(mut_global_list_fail);
|
LOCK(mut_global_list_fail);
|
||||||
append_failed_list(&failed_l, fun_ame);
|
append_failed_list(&failed_l, fun_ame);
|
||||||
UNLOCK(mut_global_list_fail);
|
UNLOCK(mut_global_list_fail);
|
||||||
PRINT_HK_C(colors_f[k_RED], HK_FL, " %lu tests failed from %s on thread[%ld], %ld tests failed on thread[%ld]\n",count_fail_test[num_test],fun_ame, id_thrd,count_fail_thread[id_thrd],id_thrd);
|
PRINT_HK_C(colors_f[k_RED], tab_hk_f[hk_FL], " %lu tests failed from %s on thread[%ld], %ld tests failed on thread[%ld]\n",count_fail_test[num_test],fun_ame, id_thrd,count_fail_thread[id_thrd],id_thrd);
|
||||||
PRINT_TIMESTAMP_STAT_PARALLEL(colors_f[k_RED]);
|
PRINT_TIMESTAMP_STAT_PARALLEL(colors_f[k_RED]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1193,6 +1205,7 @@ init_parallel_test_()
|
|||||||
void
|
void
|
||||||
final_parallel_test_()
|
final_parallel_test_()
|
||||||
{
|
{
|
||||||
|
is_parallel_nb = 0; /* to avoid issue when print debug afer removing log_ of each thread if removelog is active */
|
||||||
|
|
||||||
free(count_pass_test);
|
free(count_pass_test);
|
||||||
free(count_fail_test);
|
free(count_fail_test);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
// to define DEBUG in gcc cli do: gcc -D DEBUG=1 or 0 if need!
|
// to define DEBUG in gcc cli do: gcc -D DEBUG=1 or 0 if need!
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
@@ -45,7 +46,7 @@ void gotoxy(int x, int y);
|
|||||||
do { if (DEBUG) fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
|
do { if (DEBUG) fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
|
||||||
__LINE__, __func__, __VA_ARGS__); } while (0)
|
__LINE__, __func__, __VA_ARGS__); } while (0)
|
||||||
|
|
||||||
#define PRINT_DEBUG(fmt, ...) \
|
#define PRINT_DEBUG_(fmt, ...) \
|
||||||
do { if (DEBUG) fprintf(F_ERR, "%s:%d:%s(): " fmt, __FILE__, \
|
do { if (DEBUG) fprintf(F_ERR, "%s:%d:%s(): " fmt, __FILE__, \
|
||||||
__LINE__, __func__, __VA_ARGS__); } while (0)
|
__LINE__, __func__, __VA_ARGS__); } while (0)
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ TYPE_STRING TYPE_STRING_TO_STR(TYPE_STRING var){
|
|||||||
#define GENERATE_FUNCTION_NUMERIC(type)\
|
#define GENERATE_FUNCTION_NUMERIC(type)\
|
||||||
int COMPARE_N_##type(const void *a, const void *b){ \
|
int COMPARE_N_##type(const void *a, const void *b){ \
|
||||||
type diff = (*(type*)a - *(type*)b)*PRECISION_##type; \
|
type diff = (*(type*)a - *(type*)b)*PRECISION_##type; \
|
||||||
PRINT_DEBUG(" diff = %s a=%s b=%s \n",type##_TO_STR(diff),type##_TO_STR(*(type*)a), type##_TO_STR(*(type*)b));\
|
PRINT_DEBUG_(" diff = %s a=%s b=%s \n",type##_TO_STR(diff),type##_TO_STR(*(type*)a), type##_TO_STR(*(type*)b));\
|
||||||
if ((diff < 1) && (diff > -1) ) return 0; \
|
if ((diff < 1) && (diff > -1) ) return 0; \
|
||||||
return diff; \
|
return diff; \
|
||||||
} \
|
} \
|
||||||
@@ -102,7 +102,7 @@ TYPE_STRING TYPE_STRING_TO_STR(TYPE_STRING var){
|
|||||||
int
|
int
|
||||||
COMPARE_N_TYPE_STRING(const void *a,const void* b)
|
COMPARE_N_TYPE_STRING(const void *a,const void* b)
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("a=%s, b=%s\n",(char*)a, (char*)b);
|
PRINT_DEBUG_("a=%s, b=%s\n",(char*)a, (char*)b);
|
||||||
return strcmp(( char*)a,( char*)b);
|
return strcmp(( char*)a,( char*)b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,17 +172,17 @@ GENERATE_FUNCTION_ALL(TYPE_STRING)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
double diff_timespec_seconds(struct timespec time_stop, struct timespec time_start){
|
double diff_timespec_seconds(struct timespec time_stop, struct timespec time_start){
|
||||||
//PRINT_DEBUG("\n\nstop.sec:%ld, start.sec:%ld, stop.nsec:%ld, start.nsec:%ld\n\n", time_stop.tv_sec , time_start.tv_sec, time_stop.tv_nsec , time_start.tv_nsec);
|
//PRINT_DEBUG_("\n\nstop.sec:%ld, start.sec:%ld, stop.nsec:%ld, start.nsec:%ld\n\n", time_stop.tv_sec , time_start.tv_sec, time_stop.tv_nsec , time_start.tv_nsec);
|
||||||
return (time_stop.tv_sec - time_start.tv_sec) + 1.0e-9 * (time_stop.tv_nsec - time_start.tv_nsec);
|
return (time_stop.tv_sec - time_start.tv_sec) + 1.0e-9 * (time_stop.tv_nsec - time_start.tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
double diff_timespec_milliseconds(struct timespec time_stop, struct timespec time_start){
|
double diff_timespec_milliseconds(struct timespec time_stop, struct timespec time_start){
|
||||||
//PRINT_DEBUG("\n\nstop.sec:%ld, start.sec:%ld, stop.nsec:%ld, start.nsec:%ld\n\n", time_stop.tv_sec , time_start.tv_sec, time_stop.tv_nsec , time_start.tv_nsec);
|
//PRINT_DEBUG_("\n\nstop.sec:%ld, start.sec:%ld, stop.nsec:%ld, start.nsec:%ld\n\n", time_stop.tv_sec , time_start.tv_sec, time_stop.tv_nsec , time_start.tv_nsec);
|
||||||
return 1.0e3 * (time_stop.tv_sec - time_start.tv_sec) + 1.0e-6 * (time_stop.tv_nsec - time_start.tv_nsec);
|
return 1.0e3 * (time_stop.tv_sec - time_start.tv_sec) + 1.0e-6 * (time_stop.tv_nsec - time_start.tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
long diff_timespec_nanoseconds(struct timespec time_stop, struct timespec time_start){
|
long diff_timespec_nanoseconds(struct timespec time_stop, struct timespec time_start){
|
||||||
//PRINT_DEBUG("\n\nstop.sec:%ld, start.sec:%ld, stop.nsec:%ld, start.nsec:%ld\n\n", time_stop.tv_sec , time_start.tv_sec, time_stop.tv_nsec , time_start.tv_nsec);
|
//PRINT_DEBUG_("\n\nstop.sec:%ld, start.sec:%ld, stop.nsec:%ld, start.nsec:%ld\n\n", time_stop.tv_sec , time_start.tv_sec, time_stop.tv_nsec , time_start.tv_nsec);
|
||||||
return 1.0e9 * (time_stop.tv_sec - time_start.tv_sec) + (time_stop.tv_nsec - time_start.tv_nsec);
|
return 1.0e9 * (time_stop.tv_sec - time_start.tv_sec) + (time_stop.tv_nsec - time_start.tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,119 +0,0 @@
|
|||||||
#ifndef __TOOLS_T_C_H__
|
|
||||||
#define __TOOLS_T_C_H__
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
// to define DEBUG in gcc cli do: gcc -D DEBUG=1 or 0 if need!
|
|
||||||
#ifndef DEBUG
|
|
||||||
#define DEBUG 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// F_OUT file (stream) to log
|
|
||||||
#ifndef F_OUT
|
|
||||||
#define F_OUT stdout
|
|
||||||
#endif
|
|
||||||
// F_ERR file (stream) to log
|
|
||||||
#ifndef F_ERR
|
|
||||||
#define F_ERR stderr
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
#ifndef SECOND
|
|
||||||
#define SECOND 0
|
|
||||||
#endif
|
|
||||||
#ifndef NANOSECOND
|
|
||||||
#define NANOSECOND 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
double diff_timespec_seconds(struct timespec time_stop, struct timespec time_start);
|
|
||||||
double diff_timespec_milliseconds(struct timespec time_stop, struct timespec time_start);
|
|
||||||
long diff_timespec_nanoseconds(struct timespec time_stop, struct timespec time_start);
|
|
||||||
*/
|
|
||||||
|
|
||||||
void gotoxy(int x, int y);
|
|
||||||
//void get_cursor_position(int *col, int *rows);
|
|
||||||
|
|
||||||
|
|
||||||
#define debug_print(fmt, ...) \
|
|
||||||
do { if (DEBUG) fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
|
|
||||||
__LINE__, __func__, __VA_ARGS__); } while (0)
|
|
||||||
|
|
||||||
#define PRINT_DEBUG(fmt, ...) \
|
|
||||||
do { if (DEBUG) fprintf(F_ERR, "%s:%d:%s(): " fmt, __FILE__, \
|
|
||||||
__LINE__, __func__, __VA_ARGS__); } while (0)
|
|
||||||
|
|
||||||
|
|
||||||
#define error_print(fmt, ...) \
|
|
||||||
fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
|
|
||||||
__LINE__, __func__, __VA_ARGS__);
|
|
||||||
|
|
||||||
#define PRINT_ERROR(fmt, ...) \
|
|
||||||
fprintf(F_ERR, "%s:%d:%s(): " fmt, __FILE__, \
|
|
||||||
__LINE__, __func__, __VA_ARGS__);
|
|
||||||
|
|
||||||
#define PRINT_LOC_T(fmt, ...) \
|
|
||||||
fprintf(F_OUT, "%s:%d:%s(): " fmt, __FILE__, \
|
|
||||||
__LINE__, __func__, __VA_ARGS__);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define TYPE_CHAR char
|
|
||||||
#define TYPE_U_CHAR unsigned char
|
|
||||||
#define TYPE_INT int
|
|
||||||
#define TYPE_U_INT unsigned int
|
|
||||||
#define TYPE_L_INT long int
|
|
||||||
#define TYPE_U_L_INT unsigned long int
|
|
||||||
#define TYPE_SIZE_T size_t
|
|
||||||
#define TYPE_FLOAT float
|
|
||||||
#define TYPE_DOUBLE double
|
|
||||||
#define TYPE_L_DOUBLE long double
|
|
||||||
#define TYPE_STRING char*
|
|
||||||
|
|
||||||
#define FREE(x) { free((x)); (x) = NULL;}
|
|
||||||
|
|
||||||
#define FOREACH(array, size, function)\
|
|
||||||
for(size_t _ind = 0; _ind < size; ++_ind) function(array[_ind]);
|
|
||||||
|
|
||||||
|
|
||||||
#define GENERATE_ALL(type)\
|
|
||||||
int COMPARE_N_##type(const void *,const void*);\
|
|
||||||
void COPY_ARRAY_##type(type* dst, const type* src, size_t size);\
|
|
||||||
type MAX_ARRAY_##type(const type *array, size_t size);\
|
|
||||||
size_t ARG_MAX_ARRAY_##type(const type *array, size_t size);\
|
|
||||||
type MIN_ARRAY_##type(const type *array, size_t size);\
|
|
||||||
size_t ARG_MIN_ARRAY_##type(const type *array, size_t size);\
|
|
||||||
TYPE_STRING type##_TO_STR(type var);\
|
|
||||||
|
|
||||||
|
|
||||||
GENERATE_ALL(TYPE_CHAR)
|
|
||||||
GENERATE_ALL(TYPE_U_CHAR)
|
|
||||||
GENERATE_ALL(TYPE_INT)
|
|
||||||
GENERATE_ALL(TYPE_U_INT)
|
|
||||||
GENERATE_ALL(TYPE_L_INT)
|
|
||||||
GENERATE_ALL(TYPE_U_L_INT)
|
|
||||||
GENERATE_ALL(TYPE_SIZE_T)
|
|
||||||
GENERATE_ALL(TYPE_FLOAT)
|
|
||||||
GENERATE_ALL(TYPE_DOUBLE)
|
|
||||||
GENERATE_ALL(TYPE_L_DOUBLE)
|
|
||||||
GENERATE_ALL(TYPE_STRING)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* time calucl
|
|
||||||
*/
|
|
||||||
double diff_timespec_seconds(struct timespec time_stop, struct timespec time_start);
|
|
||||||
|
|
||||||
double diff_timespec_milliseconds(struct timespec time_stop, struct timespec time_start);
|
|
||||||
|
|
||||||
long diff_timespec_nanoseconds(struct timespec time_stop, struct timespec time_start);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /*__TOOLS_T_C_H__*/
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user