Now, we can rec results of each thread in separate files, and print all results at the end of all tests

This commit is contained in:
2023-08-23 23:36:46 +02:00
parent 106bc32731
commit afde84236e
10 changed files with 185 additions and 255 deletions
BIN
View File
Binary file not shown.
-211
View File
@@ -1,211 +0,0 @@
In file included from ./src/permutation_t/permutation_t.h:5,
from src/permutation_t/permutation_t.c:1:
./src/set_theoric_t/set_theoric_t.h:13:18: warning: parameter names (without types) in function declaration
13 | typedef struct SET_THEORIC_##type SET_THEORIC_##type; \
| ^~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:17:1: note: in expansion of macro GENERATE_UNSIGNED_SET_THEORIC
17 | GENERATE_UNSIGNED_SET_THEORIC(TYPE_U_CHAR)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:13:18: warning: parameter names (without types) in function declaration
13 | typedef struct SET_THEORIC_##type SET_THEORIC_##type; \
| ^~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:18:1: note: in expansion of macro GENERATE_UNSIGNED_SET_THEORIC
18 | GENERATE_UNSIGNED_SET_THEORIC(TYPE_U_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:13:18: warning: parameter names (without types) in function declaration
13 | typedef struct SET_THEORIC_##type SET_THEORIC_##type; \
| ^~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:19:1: note: in expansion of macro GENERATE_UNSIGNED_SET_THEORIC
19 | GENERATE_UNSIGNED_SET_THEORIC(TYPE_U_L_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:13:18: warning: parameter names (without types) in function declaration
13 | typedef struct SET_THEORIC_##type SET_THEORIC_##type; \
| ^~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:20:1: note: in expansion of macro GENERATE_UNSIGNED_SET_THEORIC
20 | GENERATE_UNSIGNED_SET_THEORIC(TYPE_SIZE_T)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function IS_PERMUTATION_TYPE_CHAR:
src/permutation_t/permutation_t.c:60:75: warning: passing argument 1 of TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_CHAR discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
60 | PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\
| ^
src/permutation_t/permutation_t.c:67:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
67 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_CHAR)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c:33:88: note: expected PERMUTATION_TYPE_CHAR * but argument is of type const PERMUTATION_TYPE_CHAR *
33 | PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\
| ~~~~~~~~~~~~~~~~~~~~^
src/permutation_t/permutation_t.c:67:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
67 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_CHAR)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function IS_PERMUTATION_TYPE_U_CHAR:
src/permutation_t/permutation_t.c:60:75: warning: passing argument 1 of TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_U_CHAR discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
60 | PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\
| ^
src/permutation_t/permutation_t.c:68:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
68 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_U_CHAR)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c:33:88: note: expected PERMUTATION_TYPE_U_CHAR * but argument is of type const PERMUTATION_TYPE_U_CHAR *
33 | PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\
| ~~~~~~~~~~~~~~~~~~~~^
src/permutation_t/permutation_t.c:68:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
68 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_U_CHAR)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function IS_PERMUTATION_TYPE_INT:
src/permutation_t/permutation_t.c:60:75: warning: passing argument 1 of TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_INT discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
60 | PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\
| ^
src/permutation_t/permutation_t.c:69:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
69 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c:33:88: note: expected PERMUTATION_TYPE_INT * but argument is of type const PERMUTATION_TYPE_INT *
33 | PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\
| ~~~~~~~~~~~~~~~~~~~~^
src/permutation_t/permutation_t.c:69:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
69 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function IS_PERMUTATION_TYPE_U_INT:
src/permutation_t/permutation_t.c:60:75: warning: passing argument 1 of TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_U_INT discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
60 | PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\
| ^
src/permutation_t/permutation_t.c:70:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
70 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_U_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c:33:88: note: expected PERMUTATION_TYPE_U_INT * but argument is of type const PERMUTATION_TYPE_U_INT *
33 | PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\
| ~~~~~~~~~~~~~~~~~~~~^
src/permutation_t/permutation_t.c:70:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
70 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_U_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function IS_PERMUTATION_TYPE_L_INT:
src/permutation_t/permutation_t.c:60:75: warning: passing argument 1 of TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_L_INT discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
60 | PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\
| ^
src/permutation_t/permutation_t.c:71:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
71 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_L_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c:33:88: note: expected PERMUTATION_TYPE_L_INT * but argument is of type const PERMUTATION_TYPE_L_INT *
33 | PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\
| ~~~~~~~~~~~~~~~~~~~~^
src/permutation_t/permutation_t.c:71:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
71 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_L_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function IS_PERMUTATION_TYPE_U_L_INT:
src/permutation_t/permutation_t.c:60:75: warning: passing argument 1 of TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_U_L_INT discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
60 | PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\
| ^
src/permutation_t/permutation_t.c:72:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
72 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_U_L_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c:33:88: note: expected PERMUTATION_TYPE_U_L_INT * but argument is of type const PERMUTATION_TYPE_U_L_INT *
33 | PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\
| ~~~~~~~~~~~~~~~~~~~~^
src/permutation_t/permutation_t.c:72:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
72 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_U_L_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function IS_PERMUTATION_TYPE_SIZE_T:
src/permutation_t/permutation_t.c:60:75: warning: passing argument 1 of TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_SIZE_T discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
60 | PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\
| ^
src/permutation_t/permutation_t.c:73:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
73 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_SIZE_T)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c:33:88: note: expected PERMUTATION_TYPE_SIZE_T * but argument is of type const PERMUTATION_TYPE_SIZE_T *
33 | PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\
| ~~~~~~~~~~~~~~~~~~~~^
src/permutation_t/permutation_t.c:73:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
73 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_SIZE_T)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function IS_PERMUTATION_TYPE_FLOAT:
src/permutation_t/permutation_t.c:60:75: warning: passing argument 1 of TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_FLOAT discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
60 | PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\
| ^
src/permutation_t/permutation_t.c:74:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
74 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_FLOAT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c:33:88: note: expected PERMUTATION_TYPE_FLOAT * but argument is of type const PERMUTATION_TYPE_FLOAT *
33 | PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\
| ~~~~~~~~~~~~~~~~~~~~^
src/permutation_t/permutation_t.c:74:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
74 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_FLOAT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function IS_PERMUTATION_TYPE_DOUBLE:
src/permutation_t/permutation_t.c:60:75: warning: passing argument 1 of TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_DOUBLE discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
60 | PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\
| ^
src/permutation_t/permutation_t.c:75:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
75 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_DOUBLE)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c:33:88: note: expected PERMUTATION_TYPE_DOUBLE * but argument is of type const PERMUTATION_TYPE_DOUBLE *
33 | PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\
| ~~~~~~~~~~~~~~~~~~~~^
src/permutation_t/permutation_t.c:75:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
75 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_DOUBLE)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function IS_PERMUTATION_TYPE_L_DOUBLE:
src/permutation_t/permutation_t.c:60:75: warning: passing argument 1 of TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_L_DOUBLE discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
60 | PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\
| ^
src/permutation_t/permutation_t.c:76:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
76 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_L_DOUBLE)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c:33:88: note: expected PERMUTATION_TYPE_L_DOUBLE * but argument is of type const PERMUTATION_TYPE_L_DOUBLE *
33 | PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\
| ~~~~~~~~~~~~~~~~~~~~^
src/permutation_t/permutation_t.c:76:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
76 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_L_DOUBLE)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_STRING:
src/permutation_t/permutation_t.c:39:37: warning: passing argument 2 of COPY_ARRAY_TYPE_STRING from incompatible pointer type [-Wincompatible-pointer-types]
39 | COPY_ARRAY_##type(sorted_perm, p->perm, size);\
| ~^~~~~~
| |
| char **
src/permutation_t/permutation_t.c:77:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
77 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_STRING)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./src/permutation_t/permutation_t.h:4,
from src/permutation_t/permutation_t.c:1:
./src/tools_t/tools_t.h:29:49: note: expected const char ** but argument is of type char **
29 | void COPY_ARRAY_##type(type* dst, const type* src, size_t size);\
| ~~~~~~~~~~~~^~~
./src/tools_t/tools_t.h:46:1: note: in expansion of macro GENERATE_ALL
46 | GENERATE_ALL(TYPE_STRING)
| ^~~~~~~~~~~~
src/permutation_t/permutation_t.c: In function IS_PERMUTATION_TYPE_STRING:
src/permutation_t/permutation_t.c:60:75: warning: passing argument 1 of TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_STRING discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
60 | PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\
| ^
src/permutation_t/permutation_t.c:77:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
77 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_STRING)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/permutation_t/permutation_t.c:33:88: note: expected PERMUTATION_TYPE_STRING * but argument is of type const PERMUTATION_TYPE_STRING *
33 | PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\
| ~~~~~~~~~~~~~~~~~~~~^
src/permutation_t/permutation_t.c:77:1: note: in expansion of macro GENERATE_PERMUTATION_FUNCTIONS
77 | GENERATE_PERMUTATION_FUNCTIONS(TYPE_STRING)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/set_theoric_t/set_theoric_t.c:2:
./src/set_theoric_t/set_theoric_t.h:13:18: warning: parameter names (without types) in function declaration
13 | typedef struct SET_THEORIC_##type SET_THEORIC_##type; \
| ^~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:17:1: note: in expansion of macro GENERATE_UNSIGNED_SET_THEORIC
17 | GENERATE_UNSIGNED_SET_THEORIC(TYPE_U_CHAR)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:13:18: warning: parameter names (without types) in function declaration
13 | typedef struct SET_THEORIC_##type SET_THEORIC_##type; \
| ^~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:18:1: note: in expansion of macro GENERATE_UNSIGNED_SET_THEORIC
18 | GENERATE_UNSIGNED_SET_THEORIC(TYPE_U_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:13:18: warning: parameter names (without types) in function declaration
13 | typedef struct SET_THEORIC_##type SET_THEORIC_##type; \
| ^~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:19:1: note: in expansion of macro GENERATE_UNSIGNED_SET_THEORIC
19 | GENERATE_UNSIGNED_SET_THEORIC(TYPE_U_L_INT)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:13:18: warning: parameter names (without types) in function declaration
13 | typedef struct SET_THEORIC_##type SET_THEORIC_##type; \
| ^~~~~~~~~~~~
./src/set_theoric_t/set_theoric_t.h:20:1: note: in expansion of macro GENERATE_UNSIGNED_SET_THEORIC
20 | GENERATE_UNSIGNED_SET_THEORIC(TYPE_SIZE_T)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+11 -5
View File
@@ -30,13 +30,14 @@ GENERATE_PERMUTATION_FUNCTIONS_UNSIGNED(TYPE_SIZE_T)
p->perm = malloc(size * sizeof(type));\ p->perm = malloc(size * sizeof(type));\
return p; }\ return p; }\
\ \
PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(PERMUTATION_##type *p ){\ PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(const PERMUTATION_##type *p ){\
if (p == NULL) return NULL;\ if (p == NULL) return NULL;\
PERMUTATION_TYPE_SIZE_T *t_p = malloc(sizeof(PERMUTATION_TYPE_SIZE_T));\ PERMUTATION_TYPE_SIZE_T *t_p = malloc(sizeof(PERMUTATION_TYPE_SIZE_T));\
size_t size = p->size;\ size_t size = p->size;\
t_p->size = size;\
t_p->perm = malloc(size * sizeof(TYPE_SIZE_T));\ t_p->perm = malloc(size * sizeof(TYPE_SIZE_T));\
type *sorted_perm = malloc(size * sizeof(type));\ type *sorted_perm = malloc(size * sizeof(type));\
COPY_ARRAY_##type(sorted_perm, p->perm, size);\ COPY_ARRAY_##type(sorted_perm,(const type*)p->perm, size);\
qsort(sorted_perm, size, sizeof(type), COMPARE_N_##type);\ qsort(sorted_perm, size, sizeof(type), COMPARE_N_##type);\
size_t *rec_index_visited = malloc(size * sizeof(size_t));\ size_t *rec_index_visited = malloc(size * sizeof(size_t));\
size_t cur_rec = 0; bool found_rec;\ size_t cur_rec = 0; bool found_rec;\
@@ -48,12 +49,17 @@ GENERATE_PERMUTATION_FUNCTIONS_UNSIGNED(TYPE_SIZE_T)
if(rec_index_visited[k] == j){\ if(rec_index_visited[k] == j){\
found_rec == true; break; } } \ found_rec == true; break; } } \
if(found_rec == false){\ if(found_rec == false){\
t_p->perm[i] = j;\ /*t_p->perm[i] = j;*/\
t_p->perm[j] = i;\
rec_index_visited[cur_rec++] = j; \ rec_index_visited[cur_rec++] = j; \
break; } } } } \ break; }\
}\
}\
}\
free(rec_index_visited);\ free(rec_index_visited);\
free(sorted_perm);\ free(sorted_perm);\
return t_p; }\ return t_p; \
}\
\ \
bool IS_PERMUTATION_##type(const PERMUTATION_##type *p){\ bool IS_PERMUTATION_##type(const PERMUTATION_##type *p){\
if(p == NULL) return false;\ if(p == NULL) return false;\
+2 -2
View File
@@ -17,16 +17,16 @@
\ \
typedef struct PERMUTATION_##type PERMUTATION_##type;\ typedef struct PERMUTATION_##type PERMUTATION_##type;\
PERMUTATION_##type * CREATE_PERMUTATION_##type(size_t size);\ PERMUTATION_##type * CREATE_PERMUTATION_##type(size_t size);\
PERMUTATION_TYPE_SIZE_T * TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(const PERMUTATION_##type *p );\
GENERATE_PERMUTATION(TYPE_SIZE_T)
GENERATE_PERMUTATION(TYPE_CHAR) GENERATE_PERMUTATION(TYPE_CHAR)
GENERATE_PERMUTATION(TYPE_U_CHAR) GENERATE_PERMUTATION(TYPE_U_CHAR)
GENERATE_PERMUTATION(TYPE_INT) GENERATE_PERMUTATION(TYPE_INT)
GENERATE_PERMUTATION(TYPE_U_INT) GENERATE_PERMUTATION(TYPE_U_INT)
GENERATE_PERMUTATION(TYPE_L_INT) GENERATE_PERMUTATION(TYPE_L_INT)
GENERATE_PERMUTATION(TYPE_U_L_INT) GENERATE_PERMUTATION(TYPE_U_L_INT)
GENERATE_PERMUTATION(TYPE_SIZE_T)
GENERATE_PERMUTATION(TYPE_FLOAT) GENERATE_PERMUTATION(TYPE_FLOAT)
GENERATE_PERMUTATION(TYPE_DOUBLE) GENERATE_PERMUTATION(TYPE_DOUBLE)
GENERATE_PERMUTATION(TYPE_L_DOUBLE) GENERATE_PERMUTATION(TYPE_L_DOUBLE)
+1 -1
View File
@@ -11,7 +11,7 @@
type *set; \ type *set; \
}; \ }; \
typedef struct SET_THEORIC_##type SET_THEORIC_##type; \ typedef struct SET_THEORIC_##type SET_THEORIC_##type; \
SET_THEORIC_##type * CREATE_SET_THEORIC_##type(TYPE_##type); \ SET_THEORIC_##type * CREATE_SET_THEORIC_##type(size_t id/*TYPE_##type*/); \
bool IS_SET_THEORIC_##type(SET_THEORIC_##type *st); \ bool IS_SET_THEORIC_##type(SET_THEORIC_##type *st); \
GENERATE_UNSIGNED_SET_THEORIC(TYPE_U_CHAR) GENERATE_UNSIGNED_SET_THEORIC(TYPE_U_CHAR)
+27 -17
View File
@@ -11,43 +11,41 @@
#include "src/test_t/test_t.h" #include "src/test_t/test_t.h"
//#include "src/permutation_t/permutation_t.h" #include "src/permutation_t/permutation_t.h"
TEST(size_permutation2){ TEST(size_permutation2){
printf("another size_permutation2 again\n"); PRINTF("another size_permutation2 again\n");
ASSERT_TRUE(false); ASSERT_TRUE(false);
} }
TEST(size_permutation) TEST(size_permutation)
{ {
/*
PERMUTATION_TYPE_CHAR *p = CREATE_PERMUTATION_TYPE_CHAR(3); PERMUTATION_TYPE_CHAR *p = CREATE_PERMUTATION_TYPE_CHAR(3);
printf(" size = %u \n",p->size); PRINTF(" size = %lu \n",p->size);
if(p->size == 3) print_OK_with_msg_endl(" FF yeah GOOD test size passed "); EXPECT_EQ(p->size, 3);
else print_KO_with_msg_endl("NOT GOOD test size not passed "); PRINTF("test size_permutation2\n");
*/
printf("test size_permutation2\n");
} }
TEST(size_permutation2){ TEST(size_permutation2){
printf("another size_permutation2 again false\n"); PRINTF("another size_permutation2 again false\n");
bool val_bool = false; bool val_bool = false;
ASSERT_TRUE(val_bool); ASSERT_TRUE(val_bool);
} }
TEST(size_permutation2) TEST(size_permutation2)
{ {
printf("test size_permutation2\n"); PRINTF("test size_permutation2\n");
bool val_bool = true; bool val_bool = true;
ASSERT_FALSE(val_bool); ASSERT_FALSE(val_bool);
/* /*
PERMUTATION_TYPE_CHAR *p = CREATE_PERMUTATION_TYPE_CHAR(3); PERMUTATION_TYPE_CHAR *p = CREATE_PERMUTATION_TYPE_CHAR(3);
printf(" size = %u \n",p->size); PRINTF(" size = %u \n",p->size);
if(p->size == 3) print_OK_with_msg_endl(" FF yeah GOOD test size passed "); if(p->size == 3) print_OK_with_msg_endl(" FF yeah GOOD test size passed ");
else print_KO_with_msg_endl("NOT GOOD test size not passed "); else print_KO_with_msg_endl("NOT GOOD test size not passed ");
*/ */
} }
TEST(float_equal){ TEST(float_equal){
printf("another size_permutation2 float\n"); PRINTF("another size_permutation2 float\n");
ASSERT_TRUE(true); ASSERT_TRUE(true);
float a = 1.00001f; float a = 1.00001f;
float b = 1.00001f; float b = 1.00001f;
@@ -57,7 +55,7 @@ TEST(float_equal){
ASSERT_EQ_TYPE_FLOAT(1.0000102f,b); ASSERT_EQ_TYPE_FLOAT(1.0000102f,b);
} }
TEST(double_equal){ TEST(double_equal){
printf("another size_permutation2 double\n"); PRINTF("another size_permutation2 double\n");
ASSERT_TRUE(true); ASSERT_TRUE(true);
double a = 1.00000001; double a = 1.00000001;
double b = 1.00000001; double b = 1.00000001;
@@ -100,20 +98,32 @@ TEST(expect){
} }
TEST(){ TEST(){
printf("no test, only print\n"); PRINTF("no test, only print\n");
} }
TEST(){ TEST(){
printf("no test, only print\n"); PRINTF("no test, only print\n");
} }
TEST(){ TEST(){
printf("no test, only print\n"); PRINTF("no test, only print\n");
} }
TEST(){ TEST(){
printf("no test, only print\n");
PERMUTATION_TYPE_CHAR *p_char = CREATE_PERMUTATION_TYPE_CHAR(6);
p_char->perm[0]='B';
p_char->perm[1]='A';
p_char->perm[2]='Y';
p_char->perm[3]='C';
p_char->perm[4]='D';
p_char->perm[5]='Z';
PERMUTATION_TYPE_SIZE_T *tr_p_char = TRANSLATE_TO_SET_THEORIC_SIZE_T_TYPE_CHAR(p_char);
for(int i = 0; i < tr_p_char->size; ++i) PRINTF(" [%d ]%ld ,",i,tr_p_char->perm[i]);
PRINTF("p_char == %s\n",p_char->perm);
} }
TEST(lessThan){ TEST(lessThan){
+37 -5
View File
@@ -27,6 +27,8 @@
#endif #endif
#if 0 #if 0
#ifndef PARALLEL #ifndef PARALLEL
#define PARALLEL 1 #define PARALLEL 1
@@ -70,6 +72,8 @@ struct failed_lists{
*/ */
bool is_parallel = 0; bool is_parallel = 0;
FILE **f_ou_th;
size_t count_tests = 0; size_t count_tests = 0;
size_t count_pass_global = 0; size_t count_pass_global = 0;
@@ -174,7 +178,7 @@ void append_failed_list(struct failed_lists **fn_failed_list ,const char *name_f
*/ */
long int id_of_thread_executed(void){ long int id_of_thread_executed(void){
size_t id_from_self = pthread_self(); size_t id_from_self = pthread_self();
for(size_t i=0; i<parallel_nb; ++i){ for(size_t i=0; i<parallel_nb + 1; ++i){
if(id_thread_self[i] == id_from_self) if(id_thread_self[i] == id_from_self)
return i; return i;
} }
@@ -621,6 +625,9 @@ void head_all_parallel_run(struct timespec *start_t){
* print on the top of test in parallel * print on the top of test in parallel
*/ */
void head_parallel_run(struct timespec *start_t, size_t id_thrd){ 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+");
clock_gettime(CLOCK_REALTIME, start_t); 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()); PRINT_HK_C(GREEN_K, HK_EQ," Running tests on thread[%ld] ========== ==threadID== %ld \n", id_thrd,pthread_self());
} }
@@ -739,6 +746,16 @@ void
init_parallel_test_() init_parallel_test_()
{ {
is_parallel = 1; is_parallel = 1;
f_ou_th = malloc((parallel_nb + 1) *sizeof(FILE*));
/*
* on thread principale
*/
char name_file_output[256];
sprintf(name_file_output,"log_principal_thread_%ld_id_%ld",parallel_nb,pthread_self());
f_ou_th[parallel_nb] = fopen(name_file_output, "w+");
count_pass_test = malloc(count_tests * sizeof(size_t)); count_pass_test = malloc(count_tests * sizeof(size_t));
count_fail_test = malloc(count_tests * sizeof(size_t)); count_fail_test = malloc(count_tests * sizeof(size_t));
for(size_t i=0; i<count_tests; ++i){ for(size_t i=0; i<count_tests; ++i){
@@ -749,8 +766,10 @@ init_parallel_test_()
thread_test_failed_l = malloc(parallel_nb * sizeof(struct failed_lists*)); thread_test_failed_l = malloc(parallel_nb * sizeof(struct failed_lists*));
count_pass_thread = malloc(parallel_nb * sizeof(size_t)); count_pass_thread = malloc(parallel_nb * sizeof(size_t));
count_fail_thread = malloc(parallel_nb * sizeof(size_t)); count_fail_thread = malloc(parallel_nb * sizeof(size_t));
id_thread_self = malloc(parallel_nb * sizeof(size_t)); id_thread_self = malloc((parallel_nb + 1) * sizeof(size_t));
id_thread_self[parallel_nb]= pthread_self();// main thread
for(size_t i=0; i<parallel_nb; ++i){ for(size_t i=0; i<parallel_nb; ++i){
thread_test_failed_l[i] = NULL; thread_test_failed_l[i] = NULL;
count_pass_thread[i] = 0; count_pass_thread[i] = 0;
@@ -786,16 +805,29 @@ final_parallel_test_()
pthread_mutex_destroy(&mut_count_fail_global); pthread_mutex_destroy(&mut_count_fail_global);
pthread_mutex_destroy(&mut_count_pass_local); pthread_mutex_destroy(&mut_count_pass_local);
pthread_mutex_destroy(&mut_count_fail_local); pthread_mutex_destroy(&mut_count_fail_local);
char reader[256];
for(size_t id_thrd =0 ; id_thrd <= parallel_nb; ++id_thrd){
rewind(f_ou_th[id_thrd]); // put the file pointer to the begin of file;
while(fgets(reader, 255,f_ou_th[id_thrd] )){
fprintf(F_OUT,"%s",reader);
}
fclose(f_ou_th[id_thrd]);
}
//fclose(f_ou_th[parallel_nb]);
} }
void run_all_tests_parallel(size_t parallel) void run_all_tests_parallel(size_t parallel)
{ {
parallel_nb = parallel; parallel_nb = parallel; /* need to be here to initialise parallel_nb for init_parallel_test_ */
init_parallel_test_();
struct timespec start_t; struct timespec start_t;
head_all_parallel_run(&start_t); head_all_parallel_run(&start_t);
init_parallel_test_();
pthread_t *thrd = malloc(parallel_nb * sizeof(pthread_t)); pthread_t *thrd = malloc(parallel_nb * sizeof(pthread_t));
size_t *id_th = malloc( parallel_nb * sizeof(size_t)); size_t *id_th = malloc( parallel_nb * sizeof(size_t));
+97 -13
View File
@@ -34,7 +34,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 #endif /* HK */
/* /*
* compare symbol * compare symbol
@@ -53,16 +53,10 @@
#define DESCRIPTION_GE "greate than or equality" #define DESCRIPTION_GE "greate than or equality"
#define DESCRIPTION_NE "inequality" #define DESCRIPTION_NE "inequality"
/*
// F_OUT file (stream) to log
#ifndef F_OUT
#define F_OUT stdout
#endif
*/
#ifndef NOT_COLORED #ifndef NOT_COLORED
#define NOT_COLORED 0 #define NOT_COLORED 0
#endif #endif /* NOT_COLORED */
#if 0 #if 0
#ifndef PARALLEL #ifndef PARALLEL
@@ -74,9 +68,94 @@
#define UNLOCK(mutex_var) pthread_mutex_unlock(&mutex_var); #define UNLOCK(mutex_var) pthread_mutex_unlock(&mutex_var);
#define is_parallel 1 #define is_parallel 1
#endif #endif
#endif #endif /* 0 */
extern FILE **f_ou_th;
// ===================== rec not in file
#ifndef REC_IN_FILE
#define PRINT_LOC(fmt, ...) \
fprintf(F_OUT, "%s:%d:%s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__)
#define PRINTF( ...) \
fprintf(F_OUT, __VA_ARGS__)
/*
* print [ HK_NAME ] with color
*/
#define PRINT_HK_C(color,hk,...)\
do{ if(!NOT_COLORED) fprintf(F_OUT, color hk DEFAULT_K __VA_ARGS__); \
else fprintf(F_OUT, hk __VA_ARGS__); } while(0)
/* =================================== end no file */
#else /* REC_IN_FILE */
/* ====================== rec in file */
#define PRINT_LOC(fmt, ...) \
do{ \
if(is_parallel){\
size_t id_thread=id_of_thread_executed();\
if(id_thread < 0){\
fprintf(F_OUT, "%s:%d:%s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__);\
}\
else{\
fprintf(f_ou_th[id_thread], "%s:%d:%s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__);\
}\
} \
else{\
fprintf(F_OUT, "%s:%d:%s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__);\
}\
}while(0)
#define PRINTF( ...) \
do{ \
if(is_parallel){\
size_t id_thread=id_of_thread_executed();\
if(id_thread < 0){\
fprintf(F_OUT,__VA_ARGS__);\
}\
else{\
fprintf(f_ou_th[id_thread], __VA_ARGS__);\
}\
} \
else{\
fprintf(F_OUT, __VA_ARGS__);\
}\
}while(0)
#define PRINT_HK_C(color,hk,...)\
do{ \
if(is_parallel){\
size_t id_thread=id_of_thread_executed();\
if(id_thread < 0){\
if(!NOT_COLORED) fprintf(F_OUT, color hk DEFAULT_K __VA_ARGS__); \
else fprintf(F_OUT, hk __VA_ARGS__); \
}\
else{\
if(!NOT_COLORED) fprintf(f_ou_th[id_thread], color hk DEFAULT_K __VA_ARGS__); \
else fprintf(f_ou_th[id_thread], hk __VA_ARGS__); \
}\
} \
else{\
if(!NOT_COLORED) fprintf(F_OUT, color hk DEFAULT_K __VA_ARGS__); \
else fprintf(F_OUT, hk __VA_ARGS__); \
}\
}while(0)
#endif /* REC_IN_FILE */
// ====================== = end rec log in file
#if 0
/* /*
* print [ HK_NAME ] with color * print [ HK_NAME ] with color
@@ -84,22 +163,29 @@
#define PRINT_HK_C(color,hk,format,...)\ #define PRINT_HK_C(color,hk,format,...)\
do{ if(!NOT_COLORED) fprintf(F_OUT, color hk DEFAULT_K format, __VA_ARGS__); \ do{ if(!NOT_COLORED) fprintf(F_OUT, color hk DEFAULT_K format, __VA_ARGS__); \
else fprintf(F_OUT, hk format, __VA_ARGS__); } while(0) \ else fprintf(F_OUT, hk format, __VA_ARGS__); } while(0) \
#endif /* 0 */
/* /*
* to skip the bloc test function * to skip the bloc test function
*/ */
#define SKIP(msg)\ #define SKIP(...)\
PRINT_HK_C(GREEN_K, HK_SK," %s\n",#msg);\ PRINT_HK_C(GREEN_K, HK_SK __VA_ARGS__);\
PRINT_LOC("%s\n\n"," Skiped"); return; PRINT_LOC("%s\n\n"," Skiped"); return;
struct func { struct func {
char *name; char *name;
void (*run)(void); void (*run)(void);
struct func *next; struct func *next;
}; };
extern bool is_parallel; extern bool is_parallel;
long int id_of_thread_executed(void);
void run_all_tests(); void run_all_tests();
void execute_all(struct func *fun); void execute_all(struct func *fun);
void append_func(void (*run)(void), char *name); void append_func(void (*run)(void), char *name);
@@ -569,6 +655,4 @@ do{
if(expected_false_f(val,#val,__func__) == false) {error_print("%s\n\n","Failure"); return;} if(expected_false_f(val,#val,__func__) == false) {error_print("%s\n\n","Failure"); return;}
*/ */
#endif /* __TEST_C_H__ */ #endif /* __TEST_C_H__ */
+4
View File
@@ -1,5 +1,9 @@
#include "src/tools_t/tools_t.h" #include "src/tools_t/tools_t.h"
/* /*
double diff_timespec_seconds(struct timespec time_stop, struct timespec time_start){ double diff_timespec_seconds(struct timespec time_stop, struct timespec time_start){
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);
+6 -1
View File
@@ -12,6 +12,7 @@
#define DEBUG 0 #define DEBUG 0
#endif #endif
// F_OUT file (stream) to log // F_OUT file (stream) to log
#ifndef F_OUT #ifndef F_OUT
#define F_OUT stdout #define F_OUT stdout
@@ -21,6 +22,10 @@
#define F_ERR stderr #define F_ERR stderr
#endif #endif
/* /*
#ifndef SECOND #ifndef SECOND
#define SECOND 0 #define SECOND 0
@@ -51,7 +56,7 @@ long diff_timespec_nanoseconds(struct timespec time_stop, struct timespec time_s
fprintf(F_ERR, "%s:%d:%s(): " fmt, __FILE__, \ fprintf(F_ERR, "%s:%d:%s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__); __LINE__, __func__, __VA_ARGS__);
#define PRINT_LOC(fmt, ...) \ #define PRINT_LOC_T(fmt, ...) \
fprintf(F_OUT, "%s:%d:%s(): " fmt, __FILE__, \ fprintf(F_OUT, "%s:%d:%s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__); __LINE__, __func__, __VA_ARGS__);