diff --git a/y_worker_t/test/is_good.c b/y_worker_t/test/is_good.c index 475969a..e3ce3bd 100644 --- a/y_worker_t/test/is_good.c +++ b/y_worker_t/test/is_good.c @@ -118,7 +118,7 @@ int nb_worker=4; } usleep(50000); -int nb_task=9; +int nb_task=59; for(int i=0; itasQ, taskCal); LOG(" +++++++++++++++++ task call dep created\n"); -/* + for(int i=4; i<8; ++i){ - struct y_worker_t *pw= create_ptr_y_WORKER_T(workers, mut_workers, argx, GO_ON_WORKER, i); + struct y_worker_t *pw= create_ptr_y_WORKER_T(workers, list_arg, mut_workers, argx, GO_ON_WORKER, i); + //struct y_worker_t *pw= create_ptr_y_WORKER_T(workers, mut_workers, argx, GO_ON_WORKER, i); LOG("%d workers %ld created\n",4,(pw->arg->pworker->id)); //usleep(500); } LOG("another %d workers created\n",4); -*/ - usleep(600000); + + usleep(2000000); kill_all_workers(workers->begin_list->value->arg); -// kill_all_workers(workers, argx); -// wait_workers(workers); -//usleep(50000); -// free_workers_and_argx(workers, argx); - -// free_argExecTasQ(argx); -// pthread_mutex_destroy(mut_workers); -// free(mut_workers); - -/* - - purge_ptr_y_WORKER_T_in_list(workers); - free_all_var_list_ptr_y_WORKER_T(workers); - - free_argExecTasQ(argx); -*/ - // kill_all_workers(workers, argx); - -/* pthread_mutex_destroy(mut_workers); - free(mut_workers); -*/ + free_dependency_task(argDep); - -// purge_TYPE_PTR_in_list(void_list_arg); -// free_all_var_list_TYPE_PTR(void_list_arg); +} + +TEST(thread1){ + + + srand(time(NULL)); + struct main_list_ptr_y_WORKER_T * workers = create_var_list_ptr_y_WORKER_T(); -/* purge_list_TYPE_PTR(list_arg); - purge_list_ptr_y_WORKER_T(workers); - free_argExecTasQ(argx); - */ + struct main_list_TYPE_PTR * list_arg = create_var_list_TYPE_PTR(); + + struct argExecTasQ *argx = create_argExecTasQ(); + pthread_mutex_t *mut_workers = malloc(sizeof(pthread_mutex_t)); + pthread_mutex_init(mut_workers, NULL); + +int nb_worker=4; + for(int i=0; iarg->pworker->id)); +//usleep(500); + } +usleep(50000); + +int nb_task=59; + for(int i=0; itasQ, task); + push_back_list_TYPE_PTR(list_arg, j); +// usleep(10000); + } + LOG("%d tasks created\n",nb_task); + + struct dependency_task * argDep = create_dependency_task(); + struct y_task_t taskR = { + .func=funcDepRel, + .arg=argDep, + .status=TASK_PENDING, + }; + push_tasQ(argx->tasQ, taskR); + LOG(" +++++++++++++++++ task rel dep created\n"); + + + struct y_task_t taskCal = { + .func=funcDepCall, + .arg=argDep, + .status=TASK_PENDING, + }; + push_tasQ(argx->tasQ, taskCal); + + LOG(" +++++++++++++++++ task call dep created\n"); + + for(int i=4; i<8; ++i){ + struct y_worker_t *pw= create_ptr_y_WORKER_T(workers, list_arg, mut_workers, argx, GO_ON_WORKER, i); + //struct y_worker_t *pw= create_ptr_y_WORKER_T(workers, mut_workers, argx, GO_ON_WORKER, i); + LOG("%d workers %ld created\n",4,(pw->arg->pworker->id)); +//usleep(500); + } + + LOG("another %d workers created\n",4); + + usleep(2000000); + + kill_all_workers(workers->begin_list->value->arg); + +// kill_all_workers(workers, argx); + + +free_dependency_task(argDep); } int main(int argc, char **argv){ diff --git a/ytest_t/include_ytest/include/ftest/ftest.h b/ytest_t/include_ytest/include/ftest/ftest.h index 501bf63..ac77c0c 100644 --- a/ytest_t/include_ytest/include/ftest/ftest.h +++ b/ytest_t/include_ytest/include/ftest/ftest.h @@ -97,7 +97,7 @@ extern char *varHK_EQ, *varHK_TR, *varHK_RN, *varHK_DN, *varHK_OK, *varHK_FL, *v fprintf(stream, __VA_ARGS__); \ fflush(stream);\ if(is_parallel_nb){\ - long int id_thread=id_of_thread_executed();\ + long int id_thread=id_of_thread_executed(__func__);\ if(log_parallel){\ fprintf(F_OUT, "%s",buf);\ if(id_thread >= 0){\ @@ -159,7 +159,7 @@ struct func { extern bool is_parallel_nb; -long int id_of_thread_executed(void); +long int id_of_thread_executed(const char *func_call_name); void parse_options(int argc, char **argv); @@ -833,7 +833,7 @@ do{ } \ } \ else{ \ - size_t id_thread=id_of_thread_executed(); \ + size_t id_thread=id_of_thread_executed(__func__); \ if(expected_##expect##_f_name(var1, __func__)){ \ 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); \ } \ @@ -858,7 +858,7 @@ do{ } \ }\ else{\ - size_t id_thread=id_of_thread_executed(); \ + size_t id_thread=id_of_thread_executed(__func__); \ if(expected_##expect##_f_name(var1, __func__)){ \ 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); \ } \ diff --git a/ytest_t/libytest.so b/ytest_t/libytest.so index b81140c..7136b91 100755 Binary files a/ytest_t/libytest.so and b/ytest_t/libytest.so differ diff --git a/ytest_t/yftest/include/ftest/ftest.h b/ytest_t/yftest/include/ftest/ftest.h index 501bf63..ac77c0c 100644 --- a/ytest_t/yftest/include/ftest/ftest.h +++ b/ytest_t/yftest/include/ftest/ftest.h @@ -97,7 +97,7 @@ extern char *varHK_EQ, *varHK_TR, *varHK_RN, *varHK_DN, *varHK_OK, *varHK_FL, *v fprintf(stream, __VA_ARGS__); \ fflush(stream);\ if(is_parallel_nb){\ - long int id_thread=id_of_thread_executed();\ + long int id_thread=id_of_thread_executed(__func__);\ if(log_parallel){\ fprintf(F_OUT, "%s",buf);\ if(id_thread >= 0){\ @@ -159,7 +159,7 @@ struct func { extern bool is_parallel_nb; -long int id_of_thread_executed(void); +long int id_of_thread_executed(const char *func_call_name); void parse_options(int argc, char **argv); @@ -833,7 +833,7 @@ do{ } \ } \ else{ \ - size_t id_thread=id_of_thread_executed(); \ + size_t id_thread=id_of_thread_executed(__func__); \ if(expected_##expect##_f_name(var1, __func__)){ \ 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); \ } \ @@ -858,7 +858,7 @@ do{ } \ }\ else{\ - size_t id_thread=id_of_thread_executed(); \ + size_t id_thread=id_of_thread_executed(__func__); \ if(expected_##expect##_f_name(var1, __func__)){ \ 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); \ } \ diff --git a/ytest_t/yftest/src/ftest/ftest.c b/ytest_t/yftest/src/ftest/ftest.c index 2f4e0b0..05b6560 100644 --- a/ytest_t/yftest/src/ftest/ftest.c +++ b/ytest_t/yftest/src/ftest/ftest.c @@ -207,7 +207,7 @@ void append_failed_list(struct failed_lists **fn_failed_list ,const char *name_f /* * match the id global (gives by OS) of the thread with the local (the program) id of thread */ -long int id_of_thread_executed(void){ +long int id_of_thread_executed(const char * func_call_name){ size_t id_from_self = pthread_self(); for(long int i=0; i<= parallel_nb; ++i){ if(id_thread_self[i] == id_from_self) @@ -217,7 +217,7 @@ long int id_of_thread_executed(void){ for(long int i=0; i<= parallel_nb; ++i) PRINT_DEBUG(" id_thread_self[%ld] = %ld \n", i, id_thread_self[i]); }*/ - PRINT_ERROR("\nsomething wrong on %s, id_from_self: %ld\n",__func__,id_from_self); + PRINT_ERROR("\nsomething wrong on %s, called by <%s>, id_from_self: %ld\n",__func__, func_call_name,id_from_self); return -1; } @@ -666,10 +666,10 @@ void parse_options(int argc, char **argv){ } -void list_failed_test(struct failed_lists *test_failed){ +void list_failed_test(struct failed_lists *test_failed, const char * func_call_name){ struct failed_lists *failed_lst = test_failed; if(is_parallel_nb){ - long int id_thrd = id_of_thread_executed(); + long int id_thrd = id_of_thread_executed(func_call_name); if(id_thrd < 0 || id_thrd == parallel_nb ){ LISTE_ALL_FAILED_TEST_IN_F_OUT }else{ @@ -997,7 +997,7 @@ stat_end_run(size_t ntst, struct timespec start_t){ PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_PS]," %lu tests\n", count_pass_global); if(failed_l != NULL){ 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, __func__); PRINT_HK_C("","","\n%ld FAILED TESTS \n",count_fail_global); } } @@ -1168,7 +1168,7 @@ stat_end_parallel_run(size_t ntst, struct timespec start_t, size_t 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){ 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], __func__); } } /* @@ -1188,7 +1188,7 @@ stat_end_all_parallel_run(size_t ntst, struct timespec start_t){ PRINT_HK_C(colors_f[k_GREEN], tab_hk_f[hk_PS]," %lu tests\n", count_pass_global); if(failed_l != NULL){ 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, __func__); PRINT_HK_C("","","\n%ld FAILED TESTS \n",count_fail_global); } }