add func arg in ftest to debug parallel print, no solution when func test use pthread!
This commit is contained in:
+82
-33
@@ -118,7 +118,7 @@ int nb_worker=4;
|
|||||||
}
|
}
|
||||||
usleep(50000);
|
usleep(50000);
|
||||||
|
|
||||||
int nb_task=9;
|
int nb_task=59;
|
||||||
for(int i=0; i<nb_task;++i)
|
for(int i=0; i<nb_task;++i)
|
||||||
{
|
{
|
||||||
int *j=malloc(sizeof(int));
|
int *j=malloc(sizeof(int));
|
||||||
@@ -152,51 +152,100 @@ int nb_task=9;
|
|||||||
push_tasQ(argx->tasQ, taskCal);
|
push_tasQ(argx->tasQ, taskCal);
|
||||||
|
|
||||||
LOG(" +++++++++++++++++ task call dep created\n");
|
LOG(" +++++++++++++++++ task call dep created\n");
|
||||||
/*
|
|
||||||
for(int i=4; i<8; ++i){
|
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));
|
LOG("%d workers %ld created\n",4,(pw->arg->pworker->id));
|
||||||
//usleep(500);
|
//usleep(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("another %d workers created\n",4);
|
LOG("another %d workers created\n",4);
|
||||||
*/
|
|
||||||
usleep(600000);
|
usleep(2000000);
|
||||||
|
|
||||||
kill_all_workers(workers->begin_list->value->arg);
|
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);
|
// kill_all_workers(workers, argx);
|
||||||
|
|
||||||
/* pthread_mutex_destroy(mut_workers);
|
|
||||||
free(mut_workers);
|
|
||||||
*/
|
|
||||||
|
|
||||||
free_dependency_task(argDep);
|
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);
|
struct main_list_TYPE_PTR * list_arg = create_var_list_TYPE_PTR();
|
||||||
purge_list_ptr_y_WORKER_T(workers);
|
|
||||||
free_argExecTasQ(argx);
|
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; i<nb_worker; ++i){
|
||||||
|
|
||||||
|
struct y_worker_t *pw= create_ptr_y_WORKER_T(workers, list_arg, mut_workers, argx, GO_ON_WORKER, i);
|
||||||
|
|
||||||
|
LOG(" - / ----- -- / --- %d workers %ld created\n",nb_worker,(pw->arg->pworker->id));
|
||||||
|
//usleep(500);
|
||||||
|
}
|
||||||
|
usleep(50000);
|
||||||
|
|
||||||
|
int nb_task=59;
|
||||||
|
for(int i=0; i<nb_task;++i)
|
||||||
|
{
|
||||||
|
int *j=malloc(sizeof(int));
|
||||||
|
*j=i*100;
|
||||||
|
struct y_task_t task = {
|
||||||
|
.func=funcPrintSelf,
|
||||||
|
.arg=j,
|
||||||
|
.status=TASK_PENDING,
|
||||||
|
};
|
||||||
|
push_tasQ(argx->tasQ, 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){
|
int main(int argc, char **argv){
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ extern char *varHK_EQ, *varHK_TR, *varHK_RN, *varHK_DN, *varHK_OK, *varHK_FL, *v
|
|||||||
fprintf(stream, __VA_ARGS__); \
|
fprintf(stream, __VA_ARGS__); \
|
||||||
fflush(stream);\
|
fflush(stream);\
|
||||||
if(is_parallel_nb){\
|
if(is_parallel_nb){\
|
||||||
long int id_thread=id_of_thread_executed();\
|
long int id_thread=id_of_thread_executed(__func__);\
|
||||||
if(log_parallel){\
|
if(log_parallel){\
|
||||||
fprintf(F_OUT, "%s",buf);\
|
fprintf(F_OUT, "%s",buf);\
|
||||||
if(id_thread >= 0){\
|
if(id_thread >= 0){\
|
||||||
@@ -159,7 +159,7 @@ struct func {
|
|||||||
|
|
||||||
extern bool is_parallel_nb;
|
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);
|
void parse_options(int argc, char **argv);
|
||||||
|
|
||||||
@@ -833,7 +833,7 @@ do{
|
|||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
else{ \
|
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__)){ \
|
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); \
|
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{\
|
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__)){ \
|
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); \
|
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); \
|
||||||
} \
|
} \
|
||||||
|
|||||||
Binary file not shown.
@@ -97,7 +97,7 @@ extern char *varHK_EQ, *varHK_TR, *varHK_RN, *varHK_DN, *varHK_OK, *varHK_FL, *v
|
|||||||
fprintf(stream, __VA_ARGS__); \
|
fprintf(stream, __VA_ARGS__); \
|
||||||
fflush(stream);\
|
fflush(stream);\
|
||||||
if(is_parallel_nb){\
|
if(is_parallel_nb){\
|
||||||
long int id_thread=id_of_thread_executed();\
|
long int id_thread=id_of_thread_executed(__func__);\
|
||||||
if(log_parallel){\
|
if(log_parallel){\
|
||||||
fprintf(F_OUT, "%s",buf);\
|
fprintf(F_OUT, "%s",buf);\
|
||||||
if(id_thread >= 0){\
|
if(id_thread >= 0){\
|
||||||
@@ -159,7 +159,7 @@ struct func {
|
|||||||
|
|
||||||
extern bool is_parallel_nb;
|
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);
|
void parse_options(int argc, char **argv);
|
||||||
|
|
||||||
@@ -833,7 +833,7 @@ do{
|
|||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
else{ \
|
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__)){ \
|
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); \
|
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{\
|
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__)){ \
|
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); \
|
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); \
|
||||||
} \
|
} \
|
||||||
|
|||||||
@@ -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
|
* 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();
|
size_t id_from_self = pthread_self();
|
||||||
for(long int i=0; i<= parallel_nb; ++i){
|
for(long int i=0; i<= parallel_nb; ++i){
|
||||||
if(id_thread_self[i] == id_from_self)
|
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)
|
for(long int i=0; i<= parallel_nb; ++i)
|
||||||
PRINT_DEBUG(" id_thread_self[%ld] = %ld \n", i, id_thread_self[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;
|
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;
|
struct failed_lists *failed_lst = test_failed;
|
||||||
if(is_parallel_nb){
|
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 ){
|
if(id_thrd < 0 || id_thrd == parallel_nb ){
|
||||||
LISTE_ALL_FAILED_TEST_IN_F_OUT
|
LISTE_ALL_FAILED_TEST_IN_F_OUT
|
||||||
}else{
|
}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);
|
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], tab_hk_f[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, __func__);
|
||||||
PRINT_HK_C("","","\n%ld FAILED TESTS \n",count_fail_global);
|
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);
|
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], tab_hk_f[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], __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);
|
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], tab_hk_f[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, __func__);
|
||||||
PRINT_HK_C("","","\n%ld FAILED TESTS \n",count_fail_global);
|
PRINT_HK_C("","","\n%ld FAILED TESTS \n",count_fail_global);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user