10 push @types,"char"; push @abrev, "c"; push @val, "'w'";
11 push @types,"short int"; push @abrev, "s"; push @val, '134';
12 push @types,"int"; push @abrev, "i"; push @val, '-11249';
13 push @types,"long int"; push @abrev, "l"; push @val, '31319919';
14 push @types,"long long int"; push @abrev, "L"; push @val, '-232130010';
15 push @types,"float"; push @abrev, "f"; push @val, '-11313.1135';
16 push @types,"double"; push @abrev, "d"; push @val, '1424420.11331';
18 die 'scalar @types != scalar @abrev' unless (scalar @types == scalar @abrev);
20 print "/* This file is perl-generated, of course */\n\n";
22 print "#include \"gras.h\"\n\n";
24 print "XBT_LOG_NEW_DEFAULT_SUBCATEGORY(structs,test,\"Logs about the gigantic struct test\");\n\n";
26 print "#define READ 0\n#define WRITE 1\n#define RW 2\n\n";
29 print "void write_read(gras_datadesc_type_t type,void *src, void *dst, gras_socket_t *sock, int direction);\n\n";
32 my $max=scalar @types;
33 # Those max variables can be used to tune how much test you are ready to do.
34 # But WARNING! changing them naturally invalidate any existing data file.
39 for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l) {
40 print "GRAS_DEFINE_TYPE(".$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l].",".
41 "struct ".$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l]." { ".
49 # print "\n#define test(a) do {if (!(a)) { failed = 1; ERROR1(\"%s failed\",#a);}} while (0)\n";
50 print "\n#define test(a) xbt_assert(a)\n";
52 print "void test_structures(gras_socket_t *sock, int direction);\n";
53 print "void test_structures(gras_socket_t *sock, int direction) {\n";
54 for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l) {
55 my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
56 print " struct $struct my_$struct = {".$val[$i]."+(".$types[$i].")1,"
57 .$val[$j]."+(".$types[$j].")2,"
58 .$val[$k]."+(".$types[$k].")3,"
59 .$val[$l]."+(".$types[$l].")4}, my_${struct}2;\n";
62 print " INFO0(\"---- Test on all possible struct having 3 fields (".(($max_i+1)*($max_j+1)*($max_k+1)*($max_l+1))." structs) ----\");\n";
63 for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l) {
64 my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
65 print " write_read(gras_datadesc_by_symbol($struct), &my_$struct, &my_${struct}2, sock,direction);\n";
66 print " if (direction == READ || direction == RW) {\n";
67 print " int failed = 0;\n";
68 print " test(my_$struct.a == my_${struct}2.a);\n";
69 print " test(my_$struct.b == my_${struct}2.b);\n";
70 print " test(my_$struct.c == my_${struct}2.c);\n";
71 print " test(my_$struct.d == my_${struct}2.d);\n";
72 print " if (!failed) VERB0(\"Passed $struct\");\n";