Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change completely the test to use messages instead of mucking directly with the trans...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 10 Oct 2007 22:41:46 +0000 (22:41 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 10 Oct 2007 22:41:46 +0000 (22:41 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4799 48e7efb5-ca39-0410-a469-dd3cf9ba447f

teshsuite/gras/datadesc/datadesc.little32_4
teshsuite/gras/datadesc/datadesc_mem.tesh
teshsuite/gras/datadesc/datadesc_r_big32_2.tesh
teshsuite/gras/datadesc/datadesc_r_big32_8.tesh
teshsuite/gras/datadesc/datadesc_r_big32_8_4.tesh
teshsuite/gras/datadesc/datadesc_r_little32_4.tesh
teshsuite/gras/datadesc/datadesc_r_little64.tesh
teshsuite/gras/datadesc/datadesc_rw.tesh
teshsuite/gras/datadesc/datadesc_structs.c
teshsuite/gras/datadesc/datadesc_usage.c
teshsuite/gras/datadesc/mk_datadesc_structs.pl

index 4f7ed64..5648314 100644 (file)
Binary files a/teshsuite/gras/datadesc/datadesc.little32_4 and b/teshsuite/gras/datadesc/datadesc.little32_4 differ
index ea33932..089a5f7 100644 (file)
@@ -1,6 +1,7 @@
 
 p Check the marshaling facilities (trying to to do a in-memory copy)
 $ gras/datadesc/datadesc_usage --copy --log=root.fmt:%m%n
+> Memory copy
 > ---- Test on integer ----
 > ---- Test on float ----
 > ---- Test on double ----
index 7c2674f..dc9978b 100644 (file)
@@ -1,7 +1,7 @@
 
 p Check the marshaling facilities (trying to read the result of linux/mips?)
 $ gras/datadesc/datadesc_usage --read ${srcdir:=.}/gras/datadesc/datadesc.big32_2 --log=root.fmt:%m%n
-> This datafile was generated on big32_2 (8).
+> Read from file ./gras/datadesc/datadesc.big32_2
 > ---- Test on integer ----
 > ---- Test on float ----
 > ---- Test on double ----
index 523f687..0fc4068 100644 (file)
@@ -1,7 +1,7 @@
 
 p Check the marshaling facilities (trying to read the result of ppc or sparc)
 $ gras/datadesc/datadesc_usage --read ${srcdir:=.}/gras/datadesc/datadesc.big32_8 --log=root.fmt:%m%n
-> This datafile was generated on big32_8 (5).
+> Read from file ./gras/datadesc/datadesc.big32_8
 > ---- Test on integer ----
 > ---- Test on float ----
 > ---- Test on double ----
index d9773f2..2c7277e 100644 (file)
@@ -1,7 +1,7 @@
 
 p Check the marshaling facilities (trying to read the result of AIX)
 $ gras/datadesc/datadesc_usage --read ${srcdir:=.}/gras/datadesc/datadesc.big32_8_4 --log=root.fmt:%m%n
-> This datafile was generated on big32_8_4 (6).
+> Read from file ./gras/datadesc/datadesc.big32_8_4
 > ---- Test on integer ----
 > ---- Test on float ----
 > ---- Test on double ----
index fc98c48..2cb01ea 100644 (file)
@@ -1,7 +1,7 @@
 
 p Check the marshaling facilities (trying to read the result of linux/x86)
 $ gras/datadesc/datadesc_usage --read ${srcdir:=.}/gras/datadesc/datadesc.little32_4 --log=root.fmt:%m%n
-> This datafile was generated on little32_4 (2).
+> Read from file ./gras/datadesc/datadesc.little32_4
 > ---- Test on integer ----
 > ---- Test on float ----
 > ---- Test on double ----
index 05eac3c..0f8f0bd 100644 (file)
@@ -1,7 +1,7 @@
 
 p Check the marshaling facilities (trying to read the result of linux/amd64)
 $ $SG_TEST_EXENV gras/datadesc/datadesc_usage --read ${srcdir:=.}/gras/datadesc/datadesc.little64 --log=root.fmt:%m%n $ARGS
-> This datafile was generated on little64 (4).
+> Read from file ./gras/datadesc/datadesc.little64
 > ---- Test on integer ----
 > ---- Test on float ----
 > ---- Test on double ----
index 317a85a..2f73d9c 100644 (file)
@@ -1,6 +1,29 @@
 
 p Check the marshaling facilities (trying to read what we write)
-$ gras/datadesc/datadesc_usage --log=root.fmt:%m%n
+$ rm -f datadesc_usage.out
+
+$ gras/datadesc/datadesc_usage --write --log=root.fmt:%m%n
+> Write to file datadesc_usage.out
+> ---- Test on integer ----
+> ---- Test on float ----
+> ---- Test on double ----
+> ---- Test on fixed array ----
+> ---- Test on a reference to an integer ----
+> ---- Test on string (ref to dynamic array) ----
+> ---- Test on dynar containing integers ----
+> ---- Test on all possible struct having 3 fields (49 structs) ----
+> ---- Test on homogeneous structure ----
+> ---- Test on heterogeneous structure ----
+> ---- Test on nested structures ----
+> ---- Test on chained list ----
+> ---- Test on graph (cyclique chained list of 3 items) ----
+> ---- Test on dynar containing integers ----
+> ---- Test on the PBIO IEEE struct (also tests GRAS DEFINE TYPE) ----
+> ---- Test on struct containing dynamic array and its size (cbps test) ----
+> Exiting GRAS
+
+$ gras/datadesc/datadesc_usage --read --log=root.fmt:%m%n
+> Read from file datadesc_usage.out
 > ---- Test on integer ----
 > ---- Test on float ----
 > ---- Test on double ----
index 0a593c1..155ebbf 100644 (file)
@@ -8,7 +8,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(structs,test,"Logs about the gigantic struct tes
 #define WRITE 1
 #define RW    2
 
-void write_read(gras_datadesc_type_t type,void *src, void *dst, gras_socket_t *sock, int direction);
+void write_read(const char *type,void *src, void *dst, gras_socket_t *sock, int direction);
 
 GRAS_DEFINE_TYPE(cccc,struct cccc { char a; char b; char c;char d;};)
 GRAS_DEFINE_TYPE(ccsc,struct ccsc { char a; char b; short int c;char d;};)
@@ -61,6 +61,58 @@ GRAS_DEFINE_TYPE(dcfc,struct dcfc { double a; char b; float c;char d;};)
 GRAS_DEFINE_TYPE(dcdc,struct dcdc { double a; char b; double c;char d;};)
 
 #define test(a) xbt_assert(a)
+void register_structures(void);
+void register_structures(void) {
+  gras_msgtype_declare("cccc", gras_datadesc_by_symbol(cccc));
+  gras_msgtype_declare("ccsc", gras_datadesc_by_symbol(ccsc));
+  gras_msgtype_declare("ccic", gras_datadesc_by_symbol(ccic));
+  gras_msgtype_declare("cclc", gras_datadesc_by_symbol(cclc));
+  gras_msgtype_declare("ccLc", gras_datadesc_by_symbol(ccLc));
+  gras_msgtype_declare("ccfc", gras_datadesc_by_symbol(ccfc));
+  gras_msgtype_declare("ccdc", gras_datadesc_by_symbol(ccdc));
+  gras_msgtype_declare("sccc", gras_datadesc_by_symbol(sccc));
+  gras_msgtype_declare("scsc", gras_datadesc_by_symbol(scsc));
+  gras_msgtype_declare("scic", gras_datadesc_by_symbol(scic));
+  gras_msgtype_declare("sclc", gras_datadesc_by_symbol(sclc));
+  gras_msgtype_declare("scLc", gras_datadesc_by_symbol(scLc));
+  gras_msgtype_declare("scfc", gras_datadesc_by_symbol(scfc));
+  gras_msgtype_declare("scdc", gras_datadesc_by_symbol(scdc));
+  gras_msgtype_declare("iccc", gras_datadesc_by_symbol(iccc));
+  gras_msgtype_declare("icsc", gras_datadesc_by_symbol(icsc));
+  gras_msgtype_declare("icic", gras_datadesc_by_symbol(icic));
+  gras_msgtype_declare("iclc", gras_datadesc_by_symbol(iclc));
+  gras_msgtype_declare("icLc", gras_datadesc_by_symbol(icLc));
+  gras_msgtype_declare("icfc", gras_datadesc_by_symbol(icfc));
+  gras_msgtype_declare("icdc", gras_datadesc_by_symbol(icdc));
+  gras_msgtype_declare("lccc", gras_datadesc_by_symbol(lccc));
+  gras_msgtype_declare("lcsc", gras_datadesc_by_symbol(lcsc));
+  gras_msgtype_declare("lcic", gras_datadesc_by_symbol(lcic));
+  gras_msgtype_declare("lclc", gras_datadesc_by_symbol(lclc));
+  gras_msgtype_declare("lcLc", gras_datadesc_by_symbol(lcLc));
+  gras_msgtype_declare("lcfc", gras_datadesc_by_symbol(lcfc));
+  gras_msgtype_declare("lcdc", gras_datadesc_by_symbol(lcdc));
+  gras_msgtype_declare("Lccc", gras_datadesc_by_symbol(Lccc));
+  gras_msgtype_declare("Lcsc", gras_datadesc_by_symbol(Lcsc));
+  gras_msgtype_declare("Lcic", gras_datadesc_by_symbol(Lcic));
+  gras_msgtype_declare("Lclc", gras_datadesc_by_symbol(Lclc));
+  gras_msgtype_declare("LcLc", gras_datadesc_by_symbol(LcLc));
+  gras_msgtype_declare("Lcfc", gras_datadesc_by_symbol(Lcfc));
+  gras_msgtype_declare("Lcdc", gras_datadesc_by_symbol(Lcdc));
+  gras_msgtype_declare("fccc", gras_datadesc_by_symbol(fccc));
+  gras_msgtype_declare("fcsc", gras_datadesc_by_symbol(fcsc));
+  gras_msgtype_declare("fcic", gras_datadesc_by_symbol(fcic));
+  gras_msgtype_declare("fclc", gras_datadesc_by_symbol(fclc));
+  gras_msgtype_declare("fcLc", gras_datadesc_by_symbol(fcLc));
+  gras_msgtype_declare("fcfc", gras_datadesc_by_symbol(fcfc));
+  gras_msgtype_declare("fcdc", gras_datadesc_by_symbol(fcdc));
+  gras_msgtype_declare("dccc", gras_datadesc_by_symbol(dccc));
+  gras_msgtype_declare("dcsc", gras_datadesc_by_symbol(dcsc));
+  gras_msgtype_declare("dcic", gras_datadesc_by_symbol(dcic));
+  gras_msgtype_declare("dclc", gras_datadesc_by_symbol(dclc));
+  gras_msgtype_declare("dcLc", gras_datadesc_by_symbol(dcLc));
+  gras_msgtype_declare("dcfc", gras_datadesc_by_symbol(dcfc));
+  gras_msgtype_declare("dcdc", gras_datadesc_by_symbol(dcdc));
+}
 void test_structures(gras_socket_t *sock, int direction);
 void test_structures(gras_socket_t *sock, int direction) {
   struct cccc my_cccc = {'w'+(char)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_cccc2;
@@ -113,7 +165,7 @@ void test_structures(gras_socket_t *sock, int direction) {
   struct dcfc my_dcfc = {1424420.11331+(double)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_dcfc2;
   struct dcdc my_dcdc = {1424420.11331+(double)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_dcdc2;
   INFO0("---- Test on all possible struct having 3 fields (49 structs) ----");
-  write_read(gras_datadesc_by_symbol(cccc), &my_cccc, &my_cccc2, sock,direction);
+  write_read("cccc", &my_cccc, &my_cccc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_cccc.a == my_cccc2.a);
@@ -122,7 +174,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_cccc.d == my_cccc2.d);
      if (!failed) VERB0("Passed cccc");
   }
-  write_read(gras_datadesc_by_symbol(ccsc), &my_ccsc, &my_ccsc2, sock,direction);
+  write_read("ccsc", &my_ccsc, &my_ccsc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_ccsc.a == my_ccsc2.a);
@@ -131,7 +183,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_ccsc.d == my_ccsc2.d);
      if (!failed) VERB0("Passed ccsc");
   }
-  write_read(gras_datadesc_by_symbol(ccic), &my_ccic, &my_ccic2, sock,direction);
+  write_read("ccic", &my_ccic, &my_ccic2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_ccic.a == my_ccic2.a);
@@ -140,7 +192,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_ccic.d == my_ccic2.d);
      if (!failed) VERB0("Passed ccic");
   }
-  write_read(gras_datadesc_by_symbol(cclc), &my_cclc, &my_cclc2, sock,direction);
+  write_read("cclc", &my_cclc, &my_cclc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_cclc.a == my_cclc2.a);
@@ -149,7 +201,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_cclc.d == my_cclc2.d);
      if (!failed) VERB0("Passed cclc");
   }
-  write_read(gras_datadesc_by_symbol(ccLc), &my_ccLc, &my_ccLc2, sock,direction);
+  write_read("ccLc", &my_ccLc, &my_ccLc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_ccLc.a == my_ccLc2.a);
@@ -158,7 +210,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_ccLc.d == my_ccLc2.d);
      if (!failed) VERB0("Passed ccLc");
   }
-  write_read(gras_datadesc_by_symbol(ccfc), &my_ccfc, &my_ccfc2, sock,direction);
+  write_read("ccfc", &my_ccfc, &my_ccfc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_ccfc.a == my_ccfc2.a);
@@ -167,7 +219,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_ccfc.d == my_ccfc2.d);
      if (!failed) VERB0("Passed ccfc");
   }
-  write_read(gras_datadesc_by_symbol(ccdc), &my_ccdc, &my_ccdc2, sock,direction);
+  write_read("ccdc", &my_ccdc, &my_ccdc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_ccdc.a == my_ccdc2.a);
@@ -176,7 +228,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_ccdc.d == my_ccdc2.d);
      if (!failed) VERB0("Passed ccdc");
   }
-  write_read(gras_datadesc_by_symbol(sccc), &my_sccc, &my_sccc2, sock,direction);
+  write_read("sccc", &my_sccc, &my_sccc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_sccc.a == my_sccc2.a);
@@ -185,7 +237,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_sccc.d == my_sccc2.d);
      if (!failed) VERB0("Passed sccc");
   }
-  write_read(gras_datadesc_by_symbol(scsc), &my_scsc, &my_scsc2, sock,direction);
+  write_read("scsc", &my_scsc, &my_scsc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_scsc.a == my_scsc2.a);
@@ -194,7 +246,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_scsc.d == my_scsc2.d);
      if (!failed) VERB0("Passed scsc");
   }
-  write_read(gras_datadesc_by_symbol(scic), &my_scic, &my_scic2, sock,direction);
+  write_read("scic", &my_scic, &my_scic2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_scic.a == my_scic2.a);
@@ -203,7 +255,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_scic.d == my_scic2.d);
      if (!failed) VERB0("Passed scic");
   }
-  write_read(gras_datadesc_by_symbol(sclc), &my_sclc, &my_sclc2, sock,direction);
+  write_read("sclc", &my_sclc, &my_sclc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_sclc.a == my_sclc2.a);
@@ -212,7 +264,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_sclc.d == my_sclc2.d);
      if (!failed) VERB0("Passed sclc");
   }
-  write_read(gras_datadesc_by_symbol(scLc), &my_scLc, &my_scLc2, sock,direction);
+  write_read("scLc", &my_scLc, &my_scLc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_scLc.a == my_scLc2.a);
@@ -221,7 +273,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_scLc.d == my_scLc2.d);
      if (!failed) VERB0("Passed scLc");
   }
-  write_read(gras_datadesc_by_symbol(scfc), &my_scfc, &my_scfc2, sock,direction);
+  write_read("scfc", &my_scfc, &my_scfc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_scfc.a == my_scfc2.a);
@@ -230,7 +282,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_scfc.d == my_scfc2.d);
      if (!failed) VERB0("Passed scfc");
   }
-  write_read(gras_datadesc_by_symbol(scdc), &my_scdc, &my_scdc2, sock,direction);
+  write_read("scdc", &my_scdc, &my_scdc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_scdc.a == my_scdc2.a);
@@ -239,7 +291,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_scdc.d == my_scdc2.d);
      if (!failed) VERB0("Passed scdc");
   }
-  write_read(gras_datadesc_by_symbol(iccc), &my_iccc, &my_iccc2, sock,direction);
+  write_read("iccc", &my_iccc, &my_iccc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_iccc.a == my_iccc2.a);
@@ -248,7 +300,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_iccc.d == my_iccc2.d);
      if (!failed) VERB0("Passed iccc");
   }
-  write_read(gras_datadesc_by_symbol(icsc), &my_icsc, &my_icsc2, sock,direction);
+  write_read("icsc", &my_icsc, &my_icsc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_icsc.a == my_icsc2.a);
@@ -257,7 +309,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_icsc.d == my_icsc2.d);
      if (!failed) VERB0("Passed icsc");
   }
-  write_read(gras_datadesc_by_symbol(icic), &my_icic, &my_icic2, sock,direction);
+  write_read("icic", &my_icic, &my_icic2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_icic.a == my_icic2.a);
@@ -266,7 +318,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_icic.d == my_icic2.d);
      if (!failed) VERB0("Passed icic");
   }
-  write_read(gras_datadesc_by_symbol(iclc), &my_iclc, &my_iclc2, sock,direction);
+  write_read("iclc", &my_iclc, &my_iclc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_iclc.a == my_iclc2.a);
@@ -275,7 +327,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_iclc.d == my_iclc2.d);
      if (!failed) VERB0("Passed iclc");
   }
-  write_read(gras_datadesc_by_symbol(icLc), &my_icLc, &my_icLc2, sock,direction);
+  write_read("icLc", &my_icLc, &my_icLc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_icLc.a == my_icLc2.a);
@@ -284,7 +336,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_icLc.d == my_icLc2.d);
      if (!failed) VERB0("Passed icLc");
   }
-  write_read(gras_datadesc_by_symbol(icfc), &my_icfc, &my_icfc2, sock,direction);
+  write_read("icfc", &my_icfc, &my_icfc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_icfc.a == my_icfc2.a);
@@ -293,7 +345,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_icfc.d == my_icfc2.d);
      if (!failed) VERB0("Passed icfc");
   }
-  write_read(gras_datadesc_by_symbol(icdc), &my_icdc, &my_icdc2, sock,direction);
+  write_read("icdc", &my_icdc, &my_icdc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_icdc.a == my_icdc2.a);
@@ -302,7 +354,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_icdc.d == my_icdc2.d);
      if (!failed) VERB0("Passed icdc");
   }
-  write_read(gras_datadesc_by_symbol(lccc), &my_lccc, &my_lccc2, sock,direction);
+  write_read("lccc", &my_lccc, &my_lccc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_lccc.a == my_lccc2.a);
@@ -311,7 +363,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_lccc.d == my_lccc2.d);
      if (!failed) VERB0("Passed lccc");
   }
-  write_read(gras_datadesc_by_symbol(lcsc), &my_lcsc, &my_lcsc2, sock,direction);
+  write_read("lcsc", &my_lcsc, &my_lcsc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_lcsc.a == my_lcsc2.a);
@@ -320,7 +372,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_lcsc.d == my_lcsc2.d);
      if (!failed) VERB0("Passed lcsc");
   }
-  write_read(gras_datadesc_by_symbol(lcic), &my_lcic, &my_lcic2, sock,direction);
+  write_read("lcic", &my_lcic, &my_lcic2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_lcic.a == my_lcic2.a);
@@ -329,7 +381,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_lcic.d == my_lcic2.d);
      if (!failed) VERB0("Passed lcic");
   }
-  write_read(gras_datadesc_by_symbol(lclc), &my_lclc, &my_lclc2, sock,direction);
+  write_read("lclc", &my_lclc, &my_lclc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_lclc.a == my_lclc2.a);
@@ -338,7 +390,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_lclc.d == my_lclc2.d);
      if (!failed) VERB0("Passed lclc");
   }
-  write_read(gras_datadesc_by_symbol(lcLc), &my_lcLc, &my_lcLc2, sock,direction);
+  write_read("lcLc", &my_lcLc, &my_lcLc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_lcLc.a == my_lcLc2.a);
@@ -347,7 +399,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_lcLc.d == my_lcLc2.d);
      if (!failed) VERB0("Passed lcLc");
   }
-  write_read(gras_datadesc_by_symbol(lcfc), &my_lcfc, &my_lcfc2, sock,direction);
+  write_read("lcfc", &my_lcfc, &my_lcfc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_lcfc.a == my_lcfc2.a);
@@ -356,7 +408,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_lcfc.d == my_lcfc2.d);
      if (!failed) VERB0("Passed lcfc");
   }
-  write_read(gras_datadesc_by_symbol(lcdc), &my_lcdc, &my_lcdc2, sock,direction);
+  write_read("lcdc", &my_lcdc, &my_lcdc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_lcdc.a == my_lcdc2.a);
@@ -365,7 +417,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_lcdc.d == my_lcdc2.d);
      if (!failed) VERB0("Passed lcdc");
   }
-  write_read(gras_datadesc_by_symbol(Lccc), &my_Lccc, &my_Lccc2, sock,direction);
+  write_read("Lccc", &my_Lccc, &my_Lccc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_Lccc.a == my_Lccc2.a);
@@ -374,7 +426,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_Lccc.d == my_Lccc2.d);
      if (!failed) VERB0("Passed Lccc");
   }
-  write_read(gras_datadesc_by_symbol(Lcsc), &my_Lcsc, &my_Lcsc2, sock,direction);
+  write_read("Lcsc", &my_Lcsc, &my_Lcsc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_Lcsc.a == my_Lcsc2.a);
@@ -383,7 +435,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_Lcsc.d == my_Lcsc2.d);
      if (!failed) VERB0("Passed Lcsc");
   }
-  write_read(gras_datadesc_by_symbol(Lcic), &my_Lcic, &my_Lcic2, sock,direction);
+  write_read("Lcic", &my_Lcic, &my_Lcic2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_Lcic.a == my_Lcic2.a);
@@ -392,7 +444,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_Lcic.d == my_Lcic2.d);
      if (!failed) VERB0("Passed Lcic");
   }
-  write_read(gras_datadesc_by_symbol(Lclc), &my_Lclc, &my_Lclc2, sock,direction);
+  write_read("Lclc", &my_Lclc, &my_Lclc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_Lclc.a == my_Lclc2.a);
@@ -401,7 +453,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_Lclc.d == my_Lclc2.d);
      if (!failed) VERB0("Passed Lclc");
   }
-  write_read(gras_datadesc_by_symbol(LcLc), &my_LcLc, &my_LcLc2, sock,direction);
+  write_read("LcLc", &my_LcLc, &my_LcLc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_LcLc.a == my_LcLc2.a);
@@ -410,7 +462,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_LcLc.d == my_LcLc2.d);
      if (!failed) VERB0("Passed LcLc");
   }
-  write_read(gras_datadesc_by_symbol(Lcfc), &my_Lcfc, &my_Lcfc2, sock,direction);
+  write_read("Lcfc", &my_Lcfc, &my_Lcfc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_Lcfc.a == my_Lcfc2.a);
@@ -419,7 +471,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_Lcfc.d == my_Lcfc2.d);
      if (!failed) VERB0("Passed Lcfc");
   }
-  write_read(gras_datadesc_by_symbol(Lcdc), &my_Lcdc, &my_Lcdc2, sock,direction);
+  write_read("Lcdc", &my_Lcdc, &my_Lcdc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_Lcdc.a == my_Lcdc2.a);
@@ -428,7 +480,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_Lcdc.d == my_Lcdc2.d);
      if (!failed) VERB0("Passed Lcdc");
   }
-  write_read(gras_datadesc_by_symbol(fccc), &my_fccc, &my_fccc2, sock,direction);
+  write_read("fccc", &my_fccc, &my_fccc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_fccc.a == my_fccc2.a);
@@ -437,7 +489,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_fccc.d == my_fccc2.d);
      if (!failed) VERB0("Passed fccc");
   }
-  write_read(gras_datadesc_by_symbol(fcsc), &my_fcsc, &my_fcsc2, sock,direction);
+  write_read("fcsc", &my_fcsc, &my_fcsc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_fcsc.a == my_fcsc2.a);
@@ -446,7 +498,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_fcsc.d == my_fcsc2.d);
      if (!failed) VERB0("Passed fcsc");
   }
-  write_read(gras_datadesc_by_symbol(fcic), &my_fcic, &my_fcic2, sock,direction);
+  write_read("fcic", &my_fcic, &my_fcic2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_fcic.a == my_fcic2.a);
@@ -455,7 +507,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_fcic.d == my_fcic2.d);
      if (!failed) VERB0("Passed fcic");
   }
-  write_read(gras_datadesc_by_symbol(fclc), &my_fclc, &my_fclc2, sock,direction);
+  write_read("fclc", &my_fclc, &my_fclc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_fclc.a == my_fclc2.a);
@@ -464,7 +516,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_fclc.d == my_fclc2.d);
      if (!failed) VERB0("Passed fclc");
   }
-  write_read(gras_datadesc_by_symbol(fcLc), &my_fcLc, &my_fcLc2, sock,direction);
+  write_read("fcLc", &my_fcLc, &my_fcLc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_fcLc.a == my_fcLc2.a);
@@ -473,7 +525,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_fcLc.d == my_fcLc2.d);
      if (!failed) VERB0("Passed fcLc");
   }
-  write_read(gras_datadesc_by_symbol(fcfc), &my_fcfc, &my_fcfc2, sock,direction);
+  write_read("fcfc", &my_fcfc, &my_fcfc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_fcfc.a == my_fcfc2.a);
@@ -482,7 +534,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_fcfc.d == my_fcfc2.d);
      if (!failed) VERB0("Passed fcfc");
   }
-  write_read(gras_datadesc_by_symbol(fcdc), &my_fcdc, &my_fcdc2, sock,direction);
+  write_read("fcdc", &my_fcdc, &my_fcdc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_fcdc.a == my_fcdc2.a);
@@ -491,7 +543,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_fcdc.d == my_fcdc2.d);
      if (!failed) VERB0("Passed fcdc");
   }
-  write_read(gras_datadesc_by_symbol(dccc), &my_dccc, &my_dccc2, sock,direction);
+  write_read("dccc", &my_dccc, &my_dccc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_dccc.a == my_dccc2.a);
@@ -500,7 +552,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_dccc.d == my_dccc2.d);
      if (!failed) VERB0("Passed dccc");
   }
-  write_read(gras_datadesc_by_symbol(dcsc), &my_dcsc, &my_dcsc2, sock,direction);
+  write_read("dcsc", &my_dcsc, &my_dcsc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_dcsc.a == my_dcsc2.a);
@@ -509,7 +561,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_dcsc.d == my_dcsc2.d);
      if (!failed) VERB0("Passed dcsc");
   }
-  write_read(gras_datadesc_by_symbol(dcic), &my_dcic, &my_dcic2, sock,direction);
+  write_read("dcic", &my_dcic, &my_dcic2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_dcic.a == my_dcic2.a);
@@ -518,7 +570,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_dcic.d == my_dcic2.d);
      if (!failed) VERB0("Passed dcic");
   }
-  write_read(gras_datadesc_by_symbol(dclc), &my_dclc, &my_dclc2, sock,direction);
+  write_read("dclc", &my_dclc, &my_dclc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_dclc.a == my_dclc2.a);
@@ -527,7 +579,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_dclc.d == my_dclc2.d);
      if (!failed) VERB0("Passed dclc");
   }
-  write_read(gras_datadesc_by_symbol(dcLc), &my_dcLc, &my_dcLc2, sock,direction);
+  write_read("dcLc", &my_dcLc, &my_dcLc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_dcLc.a == my_dcLc2.a);
@@ -536,7 +588,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_dcLc.d == my_dcLc2.d);
      if (!failed) VERB0("Passed dcLc");
   }
-  write_read(gras_datadesc_by_symbol(dcfc), &my_dcfc, &my_dcfc2, sock,direction);
+  write_read("dcfc", &my_dcfc, &my_dcfc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_dcfc.a == my_dcfc2.a);
@@ -545,7 +597,7 @@ void test_structures(gras_socket_t *sock, int direction) {
      test(my_dcfc.d == my_dcfc2.d);
      if (!failed) VERB0("Passed dcfc");
   }
-  write_read(gras_datadesc_by_symbol(dcdc), &my_dcdc, &my_dcdc2, sock,direction);
+  write_read("dcdc", &my_dcdc, &my_dcdc2, sock,direction);
   if (direction == READ || direction == RW) {
      int failed = 0;
      test(my_dcdc.a == my_dcdc2.a);
index 2b4b217..a95d4cb 100644 (file)
@@ -2,7 +2,7 @@
 
 /* datadesc: test of data description (using file transport).               */
 
-/* Copyright (c) 2004 Martin Quinson. All rights reserved.                  */
+/* Copyright (c) 2004-2007 Martin Quinson. All rights reserved.             */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,107 +20,78 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 #define READ  0
 #define WRITE 1
 #define COPY  2
-#define RW    3
 
-int r_arch;
 const char *filename = "datadesc_usage.out";  
 
 void
-write_read(gras_datadesc_type_t type,void *src, void *dst, 
+write_read(const char* msgtype,void *src, void *dst, 
           gras_socket_t sock, int direction);
 
 void
-write_read(gras_datadesc_type_t type,void *src, void *dst, 
+write_read(const char* msgtype,void *src, void *dst, 
           gras_socket_t sock, int direction) {
    
-  /* write */
-  if (direction == RW) 
-    sock = gras_socket_client_from_file(filename);
-  if (direction == WRITE || direction == RW)
-    gras_datadesc_send(sock, type, src);
-  if (direction == RW) 
-    gras_socket_close(sock);
-   
-  /* read */
-  if (direction == RW) 
-    sock = gras_socket_server_from_file(filename);
-
-  if (direction == READ || direction == RW)
-    gras_datadesc_recv(sock, type, r_arch, dst);
-
-  if (direction == RW) 
-    gras_socket_close(sock);
-
-  if (direction == COPY)
-    gras_datadesc_memcpy(type, src, dst);
+  switch (direction) {
+   case READ:
+     gras_msg_wait(15, msgtype, NULL, dst);
+     break;
+     
+   case WRITE:
+     gras_msg_send(sock, msgtype, src);
+     break;
+     
+   case COPY:
+     gras_datadesc_memcpy(gras_datadesc_by_name(msgtype), src, dst);
+     break;
+  }
 }
 
-void test_int(gras_socket_t sock, int direction);
-void test_float(gras_socket_t sock, int direction);
-void test_double(gras_socket_t sock, int direction);
-void test_array(gras_socket_t sock, int direction);
-void test_dynar_scal(gras_socket_t sock, int direction);
-void test_intref(gras_socket_t sock, int direction);
-void test_string(gras_socket_t sock, int direction);
-
-void test_homostruct(gras_socket_t sock, int direction);
-void test_hetestruct(gras_socket_t sock, int direction);
-void test_nestedstruct(gras_socket_t sock, int direction);
-void test_chain_list(gras_socket_t sock, int direction);
-void test_graph(gras_socket_t sock, int direction);
-void test_dynar_ref(gras_socket_t sock, int direction);
-
-void test_pbio(gras_socket_t sock, int direction);
-void test_clause(gras_socket_t sock, int direction);
 
 /* defined in datadesc_structures.c, which in perl generated */
+void register_structures(void);
 void test_structures(gras_socket_t sock, int direction); 
 
+/************************
+ * Each and every tests *
+ ************************/
 
-
-void test_int(gras_socket_t sock, int direction) {
+static void test_int(gras_socket_t sock, int direction) {
   int i=5,j;
   
   INFO0("---- Test on integer ----");
-  write_read(gras_datadesc_by_name("int"), &i,&j, sock,direction);
-  if (direction == READ || direction == RW || direction == COPY) 
+  write_read("int", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY) 
     xbt_assert(i == j);
 }
-void test_float(gras_socket_t sock, int direction) {
+static void test_float(gras_socket_t sock, int direction) {
   float i=5.0,j;
   
   INFO0("---- Test on float ----");
-  write_read(gras_datadesc_by_name("float"), &i,&j, sock,direction);
-  if (direction == READ || direction == RW || direction == COPY)
+  write_read("float", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY)
     xbt_assert2(i == j,"%f != %f",i,j);
 }
-void test_double(gras_socket_t sock, int direction) {
+static void test_double(gras_socket_t sock, int direction) {
   double i=-3252355.1234,j;
   
   INFO0("---- Test on double ----");
-  write_read(gras_datadesc_by_name("double"), &i,&j, sock,direction);
-  if (direction == READ || direction == RW || direction == COPY)
+  write_read("double", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY)
     xbt_assert2(i == j,"%f != %f",i,j);
 }
 
-#define SIZE 5
-typedef int array[SIZE];
-void test_array(gras_socket_t sock, int direction) {
-  gras_datadesc_type_t my_type;
-  
+#define FIXED_ARRAY_SIZE 5
+typedef int array[FIXED_ARRAY_SIZE];
+static void test_array(gras_socket_t sock, int direction) {
   array i = { 35212,-6226,74337,11414,7733};
   array j;
   int cpt;
 
   INFO0("---- Test on fixed array ----");
 
-  my_type=gras_datadesc_array_fixed("fixed int array", 
-                                   gras_datadesc_by_name("int"),
-                                   SIZE);
-
-  write_read(my_type, &i,&j, sock,direction);
-  if (direction == READ || direction == RW || direction == COPY) {
-    for (cpt=0; cpt<SIZE; cpt++) {
+  write_read("fixed int array", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY) {
+    for (cpt=0; cpt<FIXED_ARRAY_SIZE; cpt++) {
       DEBUG1("Test spot %d",cpt);
       xbt_assert4(i[cpt] == j[cpt],"i[%d]=%d  !=  j[%d]=%d",
                   cpt,i[cpt],cpt,j[cpt]);
@@ -129,22 +100,20 @@ void test_array(gras_socket_t sock, int direction) {
 }
 /*** Dynar of scalar ***/
 
-void test_dynar_scal(gras_socket_t sock, int direction){
-  gras_datadesc_type_t my_type;
+static void test_dynar_scal(gras_socket_t sock, int direction){
   xbt_dynar_t i,j;
   int cpt;
    
   INFO0("---- Test on dynar containing integers ----");
-  my_type = gras_datadesc_dynar(gras_datadesc_by_name("int"),NULL);
   i = xbt_dynar_new(sizeof(int),NULL);
   for (cpt=0; cpt<64; cpt++) {
     xbt_dynar_push_as(i,int,cpt); 
     DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(i));
   }
 /*  xbt_dynar_dump(i);*/
-  write_read(my_type, &i,&j, sock, direction);
+  write_read("xbt_dynar_of_int", &i,&j, sock, direction);
 /*  xbt_dynar_dump(j);*/
-  if (direction == READ || direction == RW || direction == COPY) {
+  if (direction == READ || direction == COPY) {
      for (cpt=0; cpt<64; cpt++){
        int ret=xbt_dynar_get_as(j,cpt,int);
        if (cpt != ret) {
@@ -157,8 +126,7 @@ void test_dynar_scal(gras_socket_t sock, int direction){
   }
   xbt_dynar_free(&i);
 }
-void test_intref(gras_socket_t sock, int direction) {
-  gras_datadesc_type_t my_type;
+static void test_intref(gras_socket_t sock, int direction) {
   int *i,*j;
   
   i=xbt_new(int,1);
@@ -166,10 +134,8 @@ void test_intref(gras_socket_t sock, int direction) {
 
   INFO0("---- Test on a reference to an integer ----");
 
-  my_type = gras_datadesc_ref("int*",gras_datadesc_by_name("int"));
-
-  write_read(my_type, &i,&j, sock,direction);
-  if (direction == READ || direction == RW || direction == COPY) {
+  write_read("int*", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY) {
     xbt_assert2(*i == *j,"*i != *j (%d != %d)",*i,*j);
     free(j);
   }
@@ -179,14 +145,13 @@ void test_intref(gras_socket_t sock, int direction) {
 /***
  *** string (dynamic array)
  ***/ 
-void test_string(gras_socket_t sock, int direction) {
+static void test_string(gras_socket_t sock, int direction) {
   char *i=xbt_strdup("Some data"), *j=NULL;
   int cpt;
   
   INFO0("---- Test on string (ref to dynamic array) ----");
-  write_read(gras_datadesc_by_name("string"), &i,&j,
-            sock,direction);
-  if (direction == READ || direction == RW || direction == COPY) {
+  write_read("string", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY) {
     for (cpt=0; cpt<strlen(i); cpt++) {
       xbt_assert4(i[cpt] == j[cpt],"i[%d]=%c  !=  j[%d]=%c",
                   cpt,i[cpt],cpt,j[cpt]);
@@ -203,32 +168,17 @@ void test_string(gras_socket_t sock, int direction) {
 typedef struct {
   int a,b,c,d;
 } homostruct;
-void test_homostruct(gras_socket_t sock, int direction) {
-  gras_datadesc_type_t my_type;
+static void test_homostruct(gras_socket_t sock, int direction) {
   homostruct *i, *j; 
 
   INFO0("---- Test on homogeneous structure ----");
-  /* create descriptor */
-  my_type=gras_datadesc_struct("homostruct");
-  gras_datadesc_struct_append(my_type,"a",
-                             gras_datadesc_by_name("signed int"));
-  gras_datadesc_struct_append(my_type,"b",
-                             gras_datadesc_by_name("int"));
-  gras_datadesc_struct_append(my_type,"c",
-                             gras_datadesc_by_name("int"));
-  gras_datadesc_struct_append(my_type,"d",
-                             gras_datadesc_by_name("int"));
-  gras_datadesc_struct_close(my_type);
-  my_type=gras_datadesc_ref("homostruct*",
-                           gras_datadesc_by_name("homostruct"));
-
   /* init a value, exchange it and check its validity*/
   i=xbt_new(homostruct,1);
   i->a = 2235;    i->b = 433425;
   i->c = -23423;  i->d = -235235;
 
-  write_read(my_type, &i,&j, sock,direction);
-  if (direction == READ || direction == RW || direction == COPY) {
+  write_read("homostruct*", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY) {
     xbt_assert2(i->a == j->a,"i->a=%d != j->a=%d",i->a,j->a);
     xbt_assert(i->b == j->b);
     xbt_assert(i->c == j->c);
@@ -247,32 +197,17 @@ typedef struct {
   unsigned char c2;
   unsigned long int l2;
 } hetestruct;
-void test_hetestruct(gras_socket_t sock, int direction) {
-  gras_datadesc_type_t my_type;
+static void test_hetestruct(gras_socket_t sock, int direction) {
   hetestruct *i, *j; 
 
   INFO0("---- Test on heterogeneous structure ----");
-  /* create descriptor */
-  my_type=gras_datadesc_struct("hetestruct");
-  gras_datadesc_struct_append(my_type,"c1",
-                             gras_datadesc_by_name("unsigned char"));
-  gras_datadesc_struct_append(my_type,"l1",
-                             gras_datadesc_by_name("unsigned long int"));
-  gras_datadesc_struct_append(my_type,"c2",
-                             gras_datadesc_by_name("unsigned char"));
-  gras_datadesc_struct_append(my_type,"l2",
-                             gras_datadesc_by_name("unsigned long int"));
-  gras_datadesc_struct_close(my_type);
-  my_type=gras_datadesc_ref("hetestruct*", gras_datadesc_by_name("hetestruct"));
-
-
   /* init a value, exchange it and check its validity*/
   i=xbt_new(hetestruct,1);
   i->c1 = 's'; i->l1 = 123455;
   i->c2 = 'e'; i->l2 = 774531;
 
-  write_read(my_type, &i,&j, sock,direction);
-  if (direction == READ || direction == RW || direction == COPY) {
+  write_read("hetestruct*", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY) {
     xbt_assert(i->c1 == j->c1);
     xbt_assert(i->c2 == j->c2);
     xbt_assert2(i->l1 == j->l1,"i->l1(=%ld)  !=  j->l1(=%ld)",i->l1,j->l1);
@@ -289,21 +224,10 @@ typedef struct {
   hetestruct hete;
   homostruct homo;
 } nestedstruct;
-void test_nestedstruct(gras_socket_t sock, int direction) {
-  gras_datadesc_type_t my_type;
+static void test_nestedstruct(gras_socket_t sock, int direction) {
   nestedstruct *i, *j; 
 
   INFO0("---- Test on nested structures ----");
-  /* create descriptor */
-  my_type=gras_datadesc_struct("nestedstruct");
-
-  gras_datadesc_struct_append(my_type,"hete",
-                             gras_datadesc_by_name("hetestruct"));
-  gras_datadesc_struct_append(my_type,"homo",
-                             gras_datadesc_by_name("homostruct"));
-  gras_datadesc_struct_close(my_type);
-  my_type=gras_datadesc_ref("nestedstruct*", gras_datadesc_by_name("nestedstruct"));
-
   /* init a value, exchange it and check its validity*/
   i=xbt_new(nestedstruct,1);
   i->homo.a = 235231;  i->homo.b = -124151;
@@ -311,8 +235,8 @@ void test_nestedstruct(gras_socket_t sock, int direction) {
   i->hete.c1 = 's'; i->hete.l1 = 123455;
   i->hete.c2 = 'e'; i->hete.l2 = 774531;
 
-  write_read(my_type, &i,&j, sock,direction);
-  if (direction == READ || direction == RW || direction == COPY) {
+  write_read("nestedstruct*", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY) {
     xbt_assert(i->homo.a == j->homo.a);
     xbt_assert(i->homo.b == j->homo.b);
     xbt_assert(i->homo.c == j->homo.c);
@@ -334,22 +258,10 @@ struct s_chained_list {
   int          v;
   chained_list_t *l;
 };
-void declare_chained_list_type(void);
 chained_list_t *cons(int v, chained_list_t *l);
 void list_free(chained_list_t *l);
 int list_eq(chained_list_t*i,chained_list_t*j);
 
-void declare_chained_list_type(void) {
-  gras_datadesc_type_t my_type,ref_my_type;
-
-  my_type=gras_datadesc_struct("chained_list_t");
-  ref_my_type=gras_datadesc_ref("chained_list_t*",my_type);
-
-  gras_datadesc_struct_append(my_type,"v", gras_datadesc_by_name("int"));
-  gras_datadesc_struct_append(my_type,"l", ref_my_type);
-  gras_datadesc_struct_close(my_type);
-}
-
 chained_list_t * cons(int v, chained_list_t *l) {
   chained_list_t *nl = xbt_new(chained_list_t,1);
   
@@ -370,7 +282,7 @@ int list_eq(chained_list_t*i,chained_list_t*j) {
     return 0;
   return list_eq(i->l, j->l); 
 }
-void test_chain_list(gras_socket_t sock, int direction) {
+static void test_chain_list(gras_socket_t sock, int direction) {
   chained_list_t *i, *j; 
 
   INFO0("---- Test on chained list ----");
@@ -379,9 +291,8 @@ void test_chain_list(gras_socket_t sock, int direction) {
   i = cons( 12355, cons( 246264 , cons( 23263, NULL)));
   j = NULL;
 
-  write_read(gras_datadesc_by_name("chained_list_t*"),
-            &i,&j,  sock,direction);
-  if (direction == READ || direction == RW || direction == COPY) {
+  write_read("chained_list_t*", &i,&j,  sock,direction);
+  if (direction == READ || direction == COPY) {
     xbt_assert(list_eq(i,j));    
     list_free(j);
   }
@@ -391,7 +302,7 @@ void test_chain_list(gras_socket_t sock, int direction) {
 /***
  *** graph
  ***/
-void test_graph(gras_socket_t sock, int direction) {
+static void test_graph(gras_socket_t sock, int direction) {
   chained_list_t *i, *j; 
 
   INFO0("---- Test on graph (cyclique chained list of 3 items) ----");
@@ -400,10 +311,8 @@ void test_graph(gras_socket_t sock, int direction) {
   i->l->l->l = i;
   j = NULL;
 
-  gras_datadesc_cycle_set(gras_datadesc_by_name("chained_list_t*"));
-  write_read(gras_datadesc_by_name("chained_list_t*"),
-            &i,&j, sock,direction);
-  if (direction == READ || direction == RW || direction == COPY) {
+  write_read("chained_list_t*", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY) {
     
     DEBUG1("i=%p"         ,i);
     DEBUG1("i->l=%p"      ,i->l);
@@ -433,15 +342,13 @@ void test_graph(gras_socket_t sock, int direction) {
 static void free_string(void *d){ /* used to free the data in dynar */
      free(*(void**)d);
 }
-void test_dynar_ref(gras_socket_t sock, int direction){
-  gras_datadesc_type_t my_type;
+static void test_dynar_ref(gras_socket_t sock, int direction){
   xbt_dynar_t i,j;
   char buf[1024];
   char *s1,*s2;
   int cpt;
    
   INFO0("---- Test on dynar containing integers ----");
-  my_type = gras_datadesc_dynar(gras_datadesc_by_name("string"),&free_string);
 
   i=xbt_dynar_new(sizeof(char*),&free_string);   
   for (cpt=0; cpt< 64; cpt++) {
@@ -450,8 +357,8 @@ void test_dynar_ref(gras_socket_t sock, int direction){
     xbt_dynar_push(i,&s1);
   }
 
-  write_read(my_type, &i,&j, sock, direction);
-  if (direction == READ || direction == RW || direction == COPY) {
+  write_read("xbt_dynar_of_string", &i,&j, sock, direction);
+  if (direction == READ || direction == COPY) {
      for (cpt=0; cpt< 64; cpt++) {
        sprintf(buf,"%d",cpt);
        xbt_dynar_shift(j,&s2);
@@ -487,7 +394,7 @@ struct s_pbio{ /* structure presented in the IEEE article */
                 )
 typedef struct s_pbio pbio_t;
 
-void test_pbio(gras_socket_t sock, int direction) {
+static void test_pbio(gras_socket_t sock, int direction) {
   int cpt;
   int cpt2;
   gras_datadesc_type_t pbio_type;
@@ -523,9 +430,8 @@ void test_pbio(gras_socket_t sock, int direction) {
     for (cpt2=0; cpt2<106; cpt2++) 
       i.Cddsdde[cpt][cpt2] = ((double)cpt) * ((double)cpt2);
   }
-  write_read(gras_datadesc_by_symbol(s_pbio),
-            &i,&j, sock,direction);
-  if (direction == READ || direction == RW || direction == COPY) {
+  write_read("s_pbio", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY) {
     /* Check that the data match */
     xbt_assert(i.Cnstatv == j.Cnstatv);
     for (cpt=0; cpt<12; cpt++)
@@ -566,8 +472,7 @@ struct s_clause {
 };)
 typedef struct s_clause Clause;
 
-void test_clause(gras_socket_t sock, int direction) {
-  gras_datadesc_type_t ddt;
+static void test_clause(gras_socket_t sock, int direction) {
   Clause *i,*j;
   int cpt;
   
@@ -583,14 +488,8 @@ void test_clause(gras_socket_t sock, int direction) {
   DEBUG3("created data=%p (within %p @%p)",&(i->num_lits),i,&i);
   DEBUG1("created count=%d",i->num_lits);
 
-  /* create the damn type descriptor */
-  ddt = gras_datadesc_by_symbol(s_clause);
-/*  gras_datadesc_type_dump(ddt); */
-
-  ddt=gras_datadesc_ref("Clause*",ddt);
-
-  write_read(ddt, &i,&j, sock,direction);
-  if (direction == READ || direction == RW || direction == COPY) {
+  write_read("Clause*", &i,&j, sock,direction);
+  if (direction == READ || direction == COPY) {
     xbt_assert(i->num_lits == j->num_lits);
     for (cpt=0; cpt<i->num_lits; cpt++)
       xbt_assert(i->literals[cpt] == j->literals[cpt]);
@@ -602,18 +501,87 @@ void test_clause(gras_socket_t sock, int direction) {
   free(i);
 }
 
+static void register_types(void) {
+  gras_datadesc_type_t my_type,ref_my_type;
+
+  gras_msgtype_declare("char",gras_datadesc_by_name("char"));
+  gras_msgtype_declare("int",gras_datadesc_by_name("int"));
+  gras_msgtype_declare("float",gras_datadesc_by_name("float"));
+  gras_msgtype_declare("double",gras_datadesc_by_name("double"));
+   
+  my_type=gras_datadesc_array_fixed("fixed int array", 
+                                   gras_datadesc_by_name("int"),
+                                   FIXED_ARRAY_SIZE);
+  gras_msgtype_declare("fixed int array",my_type);
+
+  my_type = gras_datadesc_dynar(gras_datadesc_by_name("int"),NULL);
+  gras_msgtype_declare("xbt_dynar_of_int",my_type);
+
+  my_type = gras_datadesc_ref("int*",gras_datadesc_by_name("int"));
+  gras_msgtype_declare("int*",my_type);
+
+  gras_msgtype_declare("string",gras_datadesc_by_name("string"));
+   
+  my_type=gras_datadesc_struct("homostruct");
+  gras_datadesc_struct_append(my_type,"a",gras_datadesc_by_name("signed int"));
+  gras_datadesc_struct_append(my_type,"b",gras_datadesc_by_name("int"));
+  gras_datadesc_struct_append(my_type,"c",gras_datadesc_by_name("int"));
+  gras_datadesc_struct_append(my_type,"d",gras_datadesc_by_name("int"));
+  gras_datadesc_struct_close(my_type);
+  my_type=gras_datadesc_ref("homostruct*",gras_datadesc_by_name("homostruct"));
+  gras_msgtype_declare("homostruct*",my_type);
+   
+  my_type=gras_datadesc_struct("hetestruct");
+  gras_datadesc_struct_append(my_type,"c1", gras_datadesc_by_name("unsigned char"));
+  gras_datadesc_struct_append(my_type,"l1", gras_datadesc_by_name("unsigned long int"));
+  gras_datadesc_struct_append(my_type,"c2", gras_datadesc_by_name("unsigned char"));
+  gras_datadesc_struct_append(my_type,"l2", gras_datadesc_by_name("unsigned long int"));
+  gras_datadesc_struct_close(my_type);
+  my_type=gras_datadesc_ref("hetestruct*", gras_datadesc_by_name("hetestruct"));
+  gras_msgtype_declare("hetestruct*",my_type);
+
+  my_type=gras_datadesc_struct("nestedstruct");
+  gras_datadesc_struct_append(my_type,"hete",gras_datadesc_by_name("hetestruct"));
+  gras_datadesc_struct_append(my_type,"homo",gras_datadesc_by_name("homostruct"));
+  gras_datadesc_struct_close(my_type);
+  my_type=gras_datadesc_ref("nestedstruct*", gras_datadesc_by_name("nestedstruct"));
+  gras_msgtype_declare("nestedstruct*",my_type);
+   
+  my_type=gras_datadesc_struct("chained_list_t");
+  ref_my_type=gras_datadesc_ref("chained_list_t*",my_type);
+  gras_datadesc_struct_append(my_type,"v", gras_datadesc_by_name("int"));
+  gras_datadesc_struct_append(my_type,"l", ref_my_type);
+  gras_datadesc_struct_close(my_type);
+  gras_datadesc_cycle_set(gras_datadesc_by_name("chained_list_t*"));
+  gras_msgtype_declare("chained_list_t",my_type);
+  gras_msgtype_declare("chained_list_t*",ref_my_type);   
+
+  my_type = gras_datadesc_dynar(gras_datadesc_by_name("string"),&free_string);
+  gras_msgtype_declare("xbt_dynar_of_string",my_type);   
+
+  my_type = gras_datadesc_by_symbol(s_pbio);
+  gras_msgtype_declare("s_pbio",my_type);
+
+  my_type = gras_datadesc_by_symbol(s_clause);
+  my_type = gras_datadesc_ref("Clause*",my_type);
+  gras_msgtype_declare("Clause*",my_type);
+
+}
+
 #ifdef __BORLANDC__
 #pragma argsused
 #endif
 
 int main(int argc,char *argv[]) {
   gras_socket_t sock=NULL;
-  int direction = RW;
+  int direction = WRITE;
   int cpt;
-  char r_arch_char = gras_arch_selfid();
+  char local_arch, remote_arch;
 
   gras_init(&argc,argv);
-
+  register_types();
+  register_structures();
+   
   for (cpt=1; cpt<argc; cpt++) {
     if (!strcmp(argv[cpt], "--read")) {
       direction = READ;
@@ -627,21 +595,23 @@ int main(int argc,char *argv[]) {
   }
     
   if (direction == WRITE) {
+    INFO1("Write to file %s",filename);
     sock = gras_socket_client_from_file(filename);
-    gras_datadesc_send(sock, gras_datadesc_by_name("char"),
-                      &r_arch_char);
   }
   if (direction == READ) {
+    INFO1("Read from file %s",filename);
     sock = gras_socket_server_from_file(filename);
-    gras_datadesc_recv(sock, gras_datadesc_by_name("char"),
-                      gras_arch_selfid(), &r_arch_char);
-    INFO2("This datafile was generated on %s (%d).",
-         gras_datadesc_arch_name(r_arch_char),(int)r_arch_char);
-    VERB1("I'm %s.",
-         gras_datadesc_arch_name(gras_arch_selfid()));
-
   }
-  r_arch = (int)r_arch_char;
+  if (direction == COPY) {
+    INFO0("Memory copy");
+  }
+
+  local_arch = gras_arch_selfid();
+  write_read("char", &local_arch,&remote_arch, sock,direction);
+  if (direction == READ)
+     VERB2("This file was generated on %s (%d)",
+          gras_datadesc_arch_name(remote_arch),(int)remote_arch);
+
 
   test_int(sock,direction);    
   test_float(sock,direction);  
@@ -658,7 +628,6 @@ int main(int argc,char *argv[]) {
   test_hetestruct(sock,direction);
   test_nestedstruct(sock,direction);
 
-  declare_chained_list_type();
   test_chain_list(sock,direction);
   test_graph(sock,direction); 
   test_dynar_ref(sock,direction);  
@@ -667,8 +636,9 @@ int main(int argc,char *argv[]) {
 
   test_clause(sock,direction);
 
-  if (direction != RW && direction != COPY) 
+  if (direction != COPY) 
     gras_socket_close(sock);
+  
   gras_exit();
   return 0;
 }
index 8e62de0..07c8fde 100755 (executable)
@@ -25,8 +25,7 @@ print "XBT_LOG_NEW_DEFAULT_SUBCATEGORY(structs,test,\"Logs about the gigantic st
 
 print "#define READ  0\n#define WRITE 1\n#define RW    2\n\n";
   
-
-print "void write_read(gras_datadesc_type_t type,void *src, void *dst, gras_socket_t *sock, int direction);\n\n";
+print "void write_read(const char *type,void *src, void *dst, gras_socket_t *sock, int direction);\n\n";
 
 my ($i,$j,$k,$l);
 my $max=scalar @types;
@@ -49,6 +48,14 @@ for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l
 # print "\n#define test(a) do {if (!(a)) { failed = 1; ERROR1(\"%s failed\",#a);}} while (0)\n";
  print "\n#define test(a) xbt_assert(a)\n";
 
+print "void register_structures(void);\n";
+print "void register_structures(void) {\n";
+for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l) {
+    my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
+    print "  gras_msgtype_declare(\"$struct\", gras_datadesc_by_symbol($struct));\n";
+}}}}
+print "}\n";
+
 print "void test_structures(gras_socket_t *sock, int direction);\n";
 print "void test_structures(gras_socket_t *sock, int direction) {\n";
 for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l) {
@@ -62,7 +69,7 @@ for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l
 print "  INFO0(\"---- Test on all possible struct having 3 fields (".(($max_i+1)*($max_j+1)*($max_k+1)*($max_l+1))." structs) ----\");\n";
 for $i (0..$max_i) { for $j (0..$max_j) { for $k (0..$max_k) { for $l (0..$max_l) {
     my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
-    print "  write_read(gras_datadesc_by_symbol($struct), &my_$struct, &my_${struct}2, sock,direction);\n";
+    print "  write_read(\"$struct\", &my_$struct, &my_${struct}2, sock,direction);\n";
     print "  if (direction == READ || direction == RW) {\n";
     print "     int failed = 0;\n";
     print "     test(my_$struct.a == my_${struct}2.a);\n";