first design mock func lists, imagine check expect call
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
gcc test/is_good.c src/ftest/ftest.c src/fmock/fmock.c src/tools_t/tools_t.c \
|
||||
src/permutation_t/permutation_t.c src/set_theoric_t/set_theoric_t.c \
|
||||
-I./src $1 -E > eEcomp
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
gcc test/is_good.c src/ftest/ftest.c src/tools_t/tools_t.c \
|
||||
gcc test/is_good.c src/ftest/ftest.c src/fmock/fmock.c src/tools_t/tools_t.c \
|
||||
src/permutation_t/permutation_t.c src/set_theoric_t/set_theoric_t.c \
|
||||
-I./src $1 -o launch_is_good_c #&& ./launch_is_good_c -h -p
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,93 @@
|
||||
#ifndef __MOCK_C_H__
|
||||
#define __MOCK_C_H__
|
||||
|
||||
#include "ftest/ftest.h"
|
||||
#include "tools_t/tools_t.h"
|
||||
|
||||
#define INFINITY -8
|
||||
#define INITSTATE -1
|
||||
#define DONOTHING 0
|
||||
|
||||
int parse_count_args_(char *input);
|
||||
|
||||
struct func_mock_info_struct{
|
||||
long id;
|
||||
void *struct_mock;/* contain returntype, namefunction, args... */
|
||||
int expect_call;/* 1 if EXPECT_MOCK_CALL and 0 if WILL_MOCK_CALL */
|
||||
long init_times_left;/* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */
|
||||
long times_left;
|
||||
struct func_mock_struct *next;
|
||||
};
|
||||
|
||||
#define MOCK_FUNC(returntype, namefunction, args_prototype_with_parenthesis, args_call_with_parenthesis)\
|
||||
/*typedef returntype FUNC_type_ ## namefunction args_prototype_with_parenthesis ;*/\
|
||||
/*typedef args_prototype_with_parenthesis args_ ## namefunction;*/\
|
||||
struct list_mock_return_ ## namefunction{\
|
||||
returntype (*run) args_prototype_with_parenthesis;\
|
||||
int expect_call;/* 1 if EXPECT_MOCK_CALL and 0 if WILL_MOCK_CALL */\
|
||||
int (*call_mock_condition) args_prototype_with_parenthesis ;/* to store condition */\
|
||||
/*int arg_count;*/\
|
||||
long init_times_left;/* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */\
|
||||
long times_left;/* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */\
|
||||
struct list_mock_return_ ## namefunction *next;\
|
||||
} list_mo_ ## namefunction;\
|
||||
__attribute__((constructor)) void init_list_m_ ## namefunction(void){\
|
||||
list_mo_ ## namefunction.times_left = INITSTATE;\
|
||||
/*list_mo_ ## namefunction.arg_count = parse_count_args_(#args_prototype_with_parenthesis);\
|
||||
list_mo_ ## namefunction.call_mock_condition = malloc(list_mo_ ## namefunction.arg_count * sizeof( int (*)(void*))) ;*/\
|
||||
list_mo_ ## namefunction.next = NULL;\
|
||||
}\
|
||||
returntype namefunction args_prototype_with_parenthesis {\
|
||||
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
||||
while(tmp_mock->next && tmp_mock->times_left == 0) tmp_mock = tmp_mock->next ;\
|
||||
/*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");*/\
|
||||
if ((tmp_mock->times_left <= INFINITY) || (tmp_mock->times_left > 0)){\
|
||||
--(tmp_mock->times_left);\
|
||||
if(1 == tmp_mock->call_mock_condition args_call_with_parenthesis){\
|
||||
return tmp_mock->run args_call_with_parenthesis;\
|
||||
}\
|
||||
else return (returntype)0;/* default return */\
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
#define ADD_RESPONSE(returntype, namefunction, args_prototype_with_parenthesis, condition_on_args_expression , repeat, f_expect_call, id)\
|
||||
/*FUNC_type_ ## namefunction CONCAT(run_ ## namefunction ## _ID_ , id);*/\
|
||||
returntype CONCAT(run_ ## namefunction ## _ID_ , id) args_prototype_with_parenthesis; \
|
||||
int CONCAT(namefunction ## _cond_ , id) args_prototype_with_parenthesis {LOG("cond:%d\n",condition_on_args_expression); return condition_on_args_expression;}\
|
||||
__attribute__((constructor)) void CONCAT(append_list_ ## namefunction , id)(void){\
|
||||
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
||||
if(tmp_mock->times_left == INITSTATE){/* init state */\
|
||||
tmp_mock->expect_call = f_expect_call;\
|
||||
tmp_mock->init_times_left = repeat;\
|
||||
tmp_mock->times_left = repeat;\
|
||||
tmp_mock->call_mock_condition = CONCAT(namefunction ## _cond_, id);\
|
||||
tmp_mock->run = CONCAT(run_ ## namefunction ## _ID_, id);\
|
||||
}\
|
||||
else{\
|
||||
while(tmp_mock->next) tmp_mock = tmp_mock->next;\
|
||||
tmp_mock->next = malloc(sizeof(list_mo_ ## namefunction));\
|
||||
(tmp_mock->next)->run = CONCAT(run_ ## namefunction ## _ID_, id);\
|
||||
(tmp_mock->next)->call_mock_condition = CONCAT(namefunction ## _cond_, id);\
|
||||
(tmp_mock->next)->expect_call = f_expect_call;\
|
||||
(tmp_mock->next)->init_times_left = repeat;\
|
||||
(tmp_mock->next)->times_left = repeat;\
|
||||
(tmp_mock->next)->next = NULL;\
|
||||
}\
|
||||
}\
|
||||
returntype CONCAT(run_ ## namefunction ## _ID_, id) args_prototype_with_parenthesis
|
||||
|
||||
|
||||
|
||||
|
||||
#define EXPECT_MOCK_CALL(returntype, namefunction, args_prototype_with_parenthesis, condition_on_args_expression ,repeat) \
|
||||
ADD_RESPONSE(returntype,namefunction, args_prototype_with_parenthesis, condition_on_args_expression, repeat, 1, __LINE__)
|
||||
|
||||
|
||||
#define WILL_MOCK_CALL(returntype, namefunction, args_prototype_with_parenthesis, condition_on_args_expression ,repeat) \
|
||||
ADD_RESPONSE(returntype,namefunction, args_prototype_with_parenthesis, condition_on_args_expression, repeat, 0, __LINE__)
|
||||
|
||||
|
||||
|
||||
#endif /* __MOCK_C_H__ */
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "fmock/fmock.h"
|
||||
|
||||
/*
|
||||
* 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){
|
||||
if(input[i]==',') ++val;
|
||||
}
|
||||
return val+1;
|
||||
}
|
||||
|
||||
struct func_mock_info_struct *f_mock_glist;
|
||||
|
||||
void append_fmock_to_listmock(struct func_mock_info_struct **f_mock_list, struct func_mock_info_struct *f_mock){
|
||||
if(*f_mock_list){
|
||||
struct func_mock_info_struct *tmp_fmock_info = *f_mock_list;
|
||||
while(tmp_fmock_info->next) tmp_fmock_info = tmp_fmock_info->next;
|
||||
tmp_fmock_info->next = f_mock;
|
||||
}
|
||||
else{
|
||||
//*f_mock_global = malloc(sizeof(struct func_mock_info_struct));
|
||||
*f_mock_list = f_mock;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
#ifndef __MOCK_C_H__
|
||||
#define __MOCK_C_H__
|
||||
|
||||
#include "ftest/ftest.h"
|
||||
#include "tools_t/tools_t.h"
|
||||
|
||||
#define INFINITY -8
|
||||
#define INITSTATE -1
|
||||
#define DONOTHING 0
|
||||
|
||||
struct func_mock_info_struct{
|
||||
long id;
|
||||
char *str_namefunc;
|
||||
char *str_conditions;
|
||||
int expect_call;/* 1 if EXPECT_MOCK_CALL and 0 if WILL_MOCK_CALL */
|
||||
long init_times_left;/* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */
|
||||
long times_left;/* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */
|
||||
struct func_mock_info_struct *next;
|
||||
};
|
||||
|
||||
int parse_count_args_(char *input);
|
||||
void append_fmock_to_listmock(struct func_mock_info_struct **f_mock_list, struct func_mock_info_struct *f_mock);
|
||||
|
||||
extern struct func_mock_info_struct *f_mock_glist;
|
||||
|
||||
#if 0
|
||||
int expect_call; /* 1 if EXPECT_MOCK_CALL and 0 if WILL_MOCK_CALL */\
|
||||
long init_times_left; /* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */\
|
||||
long times_left; /* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */\
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define MOCK_FUNC(returntype, namefunction, args_prototype_with_parenthesis, args_call_with_parenthesis)\
|
||||
/*typedef returntype FUNC_type_ ## namefunction args_prototype_with_parenthesis ;*/\
|
||||
/*typedef args_prototype_with_parenthesis args_ ## namefunction;*/\
|
||||
struct list_mock_return_ ## namefunction{\
|
||||
returntype (*run) args_prototype_with_parenthesis;\
|
||||
int (*call_mock_condition) args_prototype_with_parenthesis ;/* to store condition */\
|
||||
/*int arg_count;*/\
|
||||
struct func_mock_info_struct *info_mock;\
|
||||
struct list_mock_return_ ## namefunction *next;\
|
||||
} 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)->times_left = INITSTATE;\
|
||||
(list_mo_ ## namefunction.info_mock)->init_times_left = INITSTATE;\
|
||||
/*list_mo_ ## namefunction.arg_count = parse_count_args_(#args_prototype_with_parenthesis);\
|
||||
list_mo_ ## namefunction.call_mock_condition = malloc(list_mo_ ## namefunction.arg_count * sizeof( int (*)(void*))) ;*/\
|
||||
list_mo_ ## namefunction.next = NULL;\
|
||||
}\
|
||||
returntype namefunction args_prototype_with_parenthesis {\
|
||||
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
||||
while(tmp_mock->next && (tmp_mock->info_mock)->times_left == 0) tmp_mock = tmp_mock->next ;\
|
||||
/*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");*/\
|
||||
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_HK_C(RED_K,HK_TR," 1 argument check failed from %s \n",__func__); \
|
||||
}\
|
||||
if (((tmp_mock->info_mock)->times_left <= INFINITY) || ((tmp_mock->info_mock)->times_left > 0)){\
|
||||
--((tmp_mock->info_mock)->times_left);\
|
||||
if(1 == tmp_mock->call_mock_condition args_call_with_parenthesis){\
|
||||
return tmp_mock->run args_call_with_parenthesis;\
|
||||
}\
|
||||
else return (returntype)0;/* default return */\
|
||||
}\
|
||||
}
|
||||
|
||||
#if 0
|
||||
(tmp_mock->info_mock)->expect_call = f_expect_call;\
|
||||
(tmp_mock->info_mock)->init_times_left = repeat;\
|
||||
(tmp_mock->info_mock)->times_left = repeat;\
|
||||
(tmp_mock->info_mock)->next = NULL;\
|
||||
tmp_mock->call_mock_condition = CONCAT(namefunction ## _cond_, id);\
|
||||
tmp_mock->run = CONCAT(run_ ## namefunction ## _ID_, id);\
|
||||
|
||||
|
||||
|
||||
(tmp_mock->next)->run = CONCAT(run_ ## namefunction ## _ID_, id);\
|
||||
(tmp_mock->next)->call_mock_condition = CONCAT(namefunction ## _cond_, id);\
|
||||
(tmp_mock->next)->info_mock = malloc(sizeof(struct func_mock_info_struct));\
|
||||
((tmp_mock->next)->info_mock)->expect_call = f_expect_call;\
|
||||
((tmp_mock->next)->info_mock)->init_times_left = repeat;\
|
||||
((tmp_mock->next)->info_mock)->times_left = repeat;\
|
||||
((tmp_mock->next)->info_mock)->str_namefunc = malloc(strlen(#namefunction));\
|
||||
strcpy(((tmp_mock->next)->info_mock)->str_namefunc, #namefunction);\
|
||||
((tmp_mock->next)->info_mock)->str_conditions = malloc(strlen(#condition_on_args_expression));\
|
||||
strcpy(((tmp_mock->next)->info_mock)->str_conditions, #condition_on_args_expression;\
|
||||
((tmp_mock->next)->info_mock)->next = NULL;\
|
||||
(tmp_mock->next)->next = NULL;\
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define FILL_MOCK_INFO(tmp_new_mock, namefunction, condition_on_args_expression , repeat, f_expect_call, id) \
|
||||
(tmp_new_mock)->run = CONCAT(run_ ## namefunction ## _ID_, id);\
|
||||
(tmp_new_mock)->call_mock_condition = CONCAT(namefunction ## _cond_, id);\
|
||||
/*(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)->init_times_left = repeat;\
|
||||
((tmp_new_mock)->info_mock)->times_left = repeat;\
|
||||
((tmp_new_mock)->info_mock)->str_namefunc = malloc(strlen(#namefunction));\
|
||||
strcpy(((tmp_new_mock)->info_mock)->str_namefunc, #namefunction);\
|
||||
((tmp_new_mock)->info_mock)->str_conditions = malloc(strlen(#condition_on_args_expression));\
|
||||
strcpy(((tmp_new_mock)->info_mock)->str_conditions, #condition_on_args_expression);\
|
||||
((tmp_new_mock)->info_mock)->next = NULL;\
|
||||
(tmp_new_mock)->next = NULL;\
|
||||
append_fmock_to_listmock(&f_mock_glist, (tmp_new_mock)->info_mock);
|
||||
|
||||
|
||||
#define ADD_RESPONSE(returntype, namefunction, args_prototype_with_parenthesis, condition_on_args_expression , repeat, f_expect_call, id)\
|
||||
/*FUNC_type_ ## namefunction CONCAT(run_ ## namefunction ## _ID_ , id);*/\
|
||||
returntype CONCAT(run_ ## namefunction ## _ID_ , id) args_prototype_with_parenthesis; \
|
||||
int CONCAT(namefunction ## _cond_ , id) args_prototype_with_parenthesis {/*LOG("cond:%d\n",condition_on_args_expression);*/ return condition_on_args_expression;}\
|
||||
__attribute__((constructor)) void CONCAT(append_list_ ## namefunction , id)(void){\
|
||||
struct list_mock_return_ ## namefunction *tmp_mock = &list_mo_ ## namefunction;\
|
||||
if((tmp_mock->info_mock)->times_left == INITSTATE){/* init state */\
|
||||
FILL_MOCK_INFO(tmp_mock, namefunction, condition_on_args_expression , repeat, f_expect_call, id);\
|
||||
}\
|
||||
else{\
|
||||
while(tmp_mock->next) tmp_mock = tmp_mock->next;\
|
||||
tmp_mock->next = malloc(sizeof(list_mo_ ## namefunction));\
|
||||
(tmp_mock->next)->info_mock = malloc(sizeof(struct func_mock_info_struct));\
|
||||
FILL_MOCK_INFO(tmp_mock->next, namefunction, condition_on_args_expression , repeat, f_expect_call, id);\
|
||||
}\
|
||||
}\
|
||||
returntype CONCAT(run_ ## namefunction ## _ID_, id) args_prototype_with_parenthesis
|
||||
|
||||
|
||||
|
||||
|
||||
#define EXPECT_MOCK_CALL(returntype, namefunction, args_prototype_with_parenthesis, condition_on_args_expression ,repeat) \
|
||||
ADD_RESPONSE(returntype,namefunction, args_prototype_with_parenthesis, condition_on_args_expression, repeat, 1, __LINE__)
|
||||
|
||||
|
||||
#define WILL_MOCK_CALL(returntype, namefunction, args_prototype_with_parenthesis, condition_on_args_expression ,repeat) \
|
||||
ADD_RESPONSE(returntype,namefunction, args_prototype_with_parenthesis, condition_on_args_expression, repeat, 0, __LINE__)
|
||||
|
||||
|
||||
|
||||
#endif /* __MOCK_C_H__ */
|
||||
+41
-12
@@ -84,7 +84,7 @@ struct failed_lists{
|
||||
#define default_unicolour 0
|
||||
#define default_removelog 0
|
||||
#define default_parallel_nb 1
|
||||
#define default_width 1
|
||||
//#define default_width 1
|
||||
|
||||
|
||||
/*
|
||||
@@ -102,10 +102,10 @@ bool unicolour = 0;
|
||||
bool removelog = 0;
|
||||
char *timeunit="ms";
|
||||
char *savelog=NULL;
|
||||
char *defiault_timeunit="ms";
|
||||
char *default_timeunit="ms";
|
||||
char *default_savelog="log_all_tests";
|
||||
|
||||
size_t width = 80;
|
||||
//size_t width = 80;
|
||||
|
||||
bool some_tests_selected=0;
|
||||
|
||||
@@ -125,7 +125,7 @@ size_t parallel_nb = 0;
|
||||
*/
|
||||
|
||||
bool is_parallel_nb = 0;
|
||||
bool is_width=0;
|
||||
//bool is_width=0;
|
||||
bool progress = false;
|
||||
|
||||
FILE **f_ou_th;
|
||||
@@ -271,7 +271,7 @@ void usage(int argc, char **argv){
|
||||
printf("\t -o, --ordered\n\t\tthis option is usefull if you choose to use parallel tests,\n\t\tby default, each thread share the screen to print results,\n\t\tthis option create file to record log of each thread on file,\n\t\tand print on screen all results at the end of all tests\n\n");
|
||||
printf("\t -r , --remove\n\t\tif the option ordered is choosen if parallel tests,\n\t\tthis option remove the file logs of each thread after all tests.\n\n");
|
||||
printf("\t -s <file>, --savelog <file>, -s=file, --savelog=file\n\t\tthis option save the global ordered result in 'file',\n\t\tthis option active the option -o or --ordered. \n\n");
|
||||
printf("\t -w <WID>, --width <WID>, -w=WID, --savelog=WID\n\t\tthis option change the width of the progress bar to WID, by default, WID=80,\n\t\tex: -w100, or --width=100 or -wi 100\n\n");
|
||||
// printf("\t -w <WID>, --width <WID>, -w=WID, --savelog=WID\n\t\tthis option change the width of the progress bar to WID, by default, WID=80,\n\t\tex: -w100, or --width=100 or -wi 100\n\n");
|
||||
|
||||
printf("\t -n=<NUM1>,<NUM2> <NUM3>... ,--numtests=<NUM1>,<NUM2>...\n\t\tthis option allow to execute only the selected numbers of tests (in the order in file test)\n\t\tex: -n=0,6,3 8 to execute the tests 0,3,6,8 (if the number is less than the count of all tests)\n\n");
|
||||
printf("\t -l=<NAME1>,<NAME2> <NAME3>... ,--listests=<NAME1>,<NAME2>...<NAMEn>\n\t\tthis option allow to execute only the selected name of tests. It allows empty name by using '-l=,'\n\t\tex: -l=name0,,name2 : execute only (if they exist): TEST(name0),TEST(),TEST(name2)\n\n");
|
||||
@@ -499,7 +499,7 @@ void parse_options(int argc, char **argv){
|
||||
PRINT_DEBUG("argc=%d, argv[%d]=%s\n",argc,i,argv[i]);
|
||||
IF_OPTION_NO_ARG(help)
|
||||
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(timeunit)
|
||||
IF_OPTION_NO_ARG(ordered)
|
||||
@@ -1087,41 +1087,70 @@ void end_execute_func_parallel(char *fun_ame, struct timespec start_t, size_t id
|
||||
}
|
||||
|
||||
unsigned sleep(unsigned x) { time_t t0=time(0); while (difftime(time(0),t0)<x); return 0; }
|
||||
unsigned nnsleep(long long x) {
|
||||
struct timespec time_stop;
|
||||
struct timespec time_start;
|
||||
clock_gettime(CLOCK_REALTIME, &time_start);
|
||||
|
||||
long long diff;
|
||||
do{
|
||||
clock_gettime(CLOCK_REALTIME, &time_stop);
|
||||
|
||||
diff = 1.0e9 * (time_stop.tv_sec - time_start.tv_sec) + (time_stop.tv_nsec - time_start.tv_nsec);
|
||||
}while(diff < x);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void progress_test_(){
|
||||
struct func *tmp;
|
||||
size_t num_test=0;
|
||||
int cur = 0, len;
|
||||
//get_cursor_position(&col, &row);
|
||||
int width;
|
||||
long int chg=0;
|
||||
|
||||
char prgss[]="\\|/-";
|
||||
struct winsize w;
|
||||
//ioctl(1,TIOCGWINSZ, &w); // 1 =STDOUT_FILENO
|
||||
//printf ("lines %d\n", w.ws_row);
|
||||
//width = w.ws_col - 50;
|
||||
//printf ("columns %d vs width.choice: %d\n", w.ws_col, width);
|
||||
|
||||
char prgss[]="/ | --";
|
||||
len=strlen(prgss);
|
||||
|
||||
do{
|
||||
ioctl(1,TIOCGWINSZ, &w); // 1 =STDOUT_FILENO
|
||||
width = w.ws_col - 50;
|
||||
//LOCK(mut_current_test);
|
||||
tmp = current_fn;
|
||||
//UNLOCK(mut_current_test);
|
||||
if(tmp)
|
||||
num_test = extract_num__f(tmp->name);
|
||||
//gotoxy(13,0);
|
||||
printf("\r[");
|
||||
printf("\r(%c)[",prgss[cur]);
|
||||
|
||||
for(int i=0; i< width; ++i) {
|
||||
if(i<=(num_test+1)*width/count_tests){
|
||||
//usleep(20000);
|
||||
printf("#");
|
||||
}
|
||||
else printf(" ");
|
||||
else printf(".");
|
||||
}
|
||||
printf("|%ld%%, test N° %ld/%ld]",(num_test+1)*100/count_tests,num_test,count_tests-1);
|
||||
printf("|%3ld%%, test N° %ld/%ld]",(num_test+1)*100/count_tests,num_test,count_tests-1);
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
//printf("%c",prgss[cur]);
|
||||
//printf("\33[2K\r"); // remove current line and go to begin of the current line
|
||||
if(cur<len-1) ++cur;
|
||||
else cur=0;
|
||||
//if(chg==40000){
|
||||
chg=0;
|
||||
if(cur<len-1) ++cur;
|
||||
else cur=0;
|
||||
//}else ++chg;
|
||||
//printf("\n");
|
||||
//sleep(1);
|
||||
//usleep(500000);
|
||||
nnsleep(200000000);// 200 milliseconds
|
||||
}while(tmp);
|
||||
|
||||
printf("\n");
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
//#include <time.h>
|
||||
#include <pthread.h>
|
||||
//#include <unistd.h>
|
||||
#include <sys/ioctl.h> /* to have size of screen, for progress bar */
|
||||
|
||||
#include "tools_t/tools_t.h"
|
||||
|
||||
@@ -108,6 +109,8 @@ extern bool ordered;
|
||||
}\
|
||||
}while(0)
|
||||
|
||||
#define LOG(...) PRINTF(__VA_ARGS__)
|
||||
|
||||
#define PRINT_HK_C(color,hk,...)\
|
||||
do{ \
|
||||
if(ordered){\
|
||||
|
||||
+45
-4
@@ -10,6 +10,7 @@
|
||||
#endif
|
||||
|
||||
#include "ftest/ftest.h"
|
||||
#include "fmock/fmock.h"
|
||||
|
||||
#include "permutation_t/permutation_t.h"
|
||||
|
||||
@@ -138,10 +139,50 @@ TEST(lessThan){
|
||||
TEST(sleep){sleep(2);}
|
||||
TEST(sleep){sleep(2);}
|
||||
TEST(sleep){sleep(2);}
|
||||
TEST(sleep){sleep(2);}
|
||||
TEST(sleep){sleep(2);}
|
||||
TEST(sleep){sleep(2);}
|
||||
TEST(sleep){sleep(2);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
TEST(sleep){sleep(1);}
|
||||
|
||||
|
||||
MOCK_FUNC(int, f_mock, (), ())
|
||||
|
||||
EXPECT_MOCK_CALL(int,f_mock, (),1, 2) {return 12;}
|
||||
EXPECT_MOCK_CALL(int,f_mock, (),1, 0) {return 10;}
|
||||
|
||||
EXPECT_MOCK_CALL(int,f_mock, (),0, 1) {return 18;}
|
||||
EXPECT_MOCK_CALL(int,f_mock, (),1, INFINITY) {return -18;}
|
||||
|
||||
TEST(mock){
|
||||
for(int i = 0; i<8; ++i)
|
||||
LOG("call %d: ret:%d\n",i,f_mock());
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user