diff --git a/isgood b/isgood index 58888fe..5d8a4b6 100644 Binary files a/isgood and b/isgood differ diff --git a/src/test_t/is_good.c b/src/test_t/is_good.c index b77dbc5..d6d675a 100644 --- a/src/test_t/is_good.c +++ b/src/test_t/is_good.c @@ -133,6 +133,14 @@ 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);} + int main(){ //run_all_tests(); diff --git a/src/test_t/test_t.c b/src/test_t/test_t.c index af2cf46..ad26c36 100644 --- a/src/test_t/test_t.c +++ b/src/test_t/test_t.c @@ -26,8 +26,19 @@ #define NANOSECOND 0 #endif +#ifndef PROGRESS + #define PROGRESS 0 +#endif - +#if 0 +#ifndef SAVE_LOG +#define SAVE_LOG 0 +#else +#ifndef ORDER_LOG + #define ORDER_LOG 1 +#endif +#endif +#endif #if 0 #ifndef PARALLEL @@ -70,6 +81,8 @@ struct failed_lists{ * global variables not exported * only exist in test_t.c */ + +bool progress = false; bool is_parallel = 0; FILE **f_ou_th; @@ -102,7 +115,7 @@ size_t *count_pass_thread = NULL; size_t *count_fail_thread = NULL; size_t *id_thread_self = NULL; - +char **log_name_file_thrd = NULL; /* * the first instance of the func struct, * it containis the first test @@ -188,7 +201,9 @@ long int id_of_thread_executed(void){ /* - * format name of TEST(name_f) is: TEST_name_f____NUM, we extract NUM here + * format name of TEST(name_f) is: 'TEST_name_f____NUM', + * and name attribute is 'TEST(name_f): test N° NUM!' (! at the end is random): + * we extract NUM here * to have hash_table of the count when parallel test! */ size_t extract_num_test__f(const char *name_f){ @@ -200,7 +215,7 @@ size_t extract_num_test__f(const char *name_f){ val += p * (name_f[i]-'0'); p *= 10; } - else break; + else if( name_f[i] == ' ' || name_f[i] == '_' ) break; } return val; } @@ -214,7 +229,7 @@ size_t extract_num_test__f(const char *name_f){ void list_failed_test(struct failed_lists *test_failed){ struct failed_lists *failed_lst = test_failed; long int id_thrd = id_of_thread_executed(); - if(id_thrd < 0){ + if(id_thrd < 0 || id_thrd == parallel_nb ){ while(failed_lst){ PRINT_HK_C(RED_K, HK_FL," %s\n",failed_lst->name); failed_lst = failed_lst->next; @@ -625,9 +640,8 @@ void head_all_parallel_run(struct timespec *start_t){ * print on the top of test in parallel */ void head_parallel_run(struct timespec *start_t, size_t id_thrd){ - char name_file_output[256]; - sprintf(name_file_output,"log_thread_%ld_id_%ld",id_thrd,pthread_self()); - f_ou_th[id_thrd] = fopen(name_file_output, "w+"); + 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+"); clock_gettime(CLOCK_REALTIME, start_t); PRINT_HK_C(GREEN_K, HK_EQ," Running tests on thread[%ld] ========== ==threadID== %ld \n", id_thrd,pthread_self()); } @@ -705,6 +719,42 @@ void end_execute_func_parallel(char *fun_ame, struct timespec start_t, size_t id } } +#if 1 +void progress_test_(int max_colon){ + struct func *tmp; + size_t num_test=0; + int cur = 0, len; + //get_cursor_position(&col, &row); + + char prgss[]="/ | --"; + len=strlen(prgss); + do{ + LOCK(mut_current_test); + tmp = current_fn; + UNLOCK(mut_current_test); + if(tmp) + num_test = extract_num_test__f(tmp->name); + gotoxy(13,0); + for(int i=0; i<(num_test*max_colon/count_tests); ++i) printf("#"); + //printf("%c",prgss[cur]); + printf("\33[2K\r"); /* remove current line and go to begin of the current line */ + if(cur= 48 && buf[i] <= 57) + { + if (a == 0) + *rows = atoi(&buf[i]) - 1; + else + *col = atoi(&buf[i]) - 1; + a++; + } + i++; + } +} +*/ /* double diff_timespec_seconds(struct timespec time_stop, struct timespec time_start){ diff --git a/src/tools_t/tools_t.h b/src/tools_t/tools_t.h index a716ce9..f4a2535 100644 --- a/src/tools_t/tools_t.h +++ b/src/tools_t/tools_t.h @@ -39,6 +39,10 @@ double diff_timespec_milliseconds(struct timespec time_stop, struct timespec tim 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)