Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Removes the gras_config.h inclusion, adds the portable.h inclusion for win32 portability.
[simgrid.git] / testsuite / gras / datadesc_usage.c
1 /* $Id$ */
2
3 /* datadesc: test of data description (using file transport).               */
4
5 /* Copyright (c) 2004 Martin Quinson. All rights reserved.                  */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 #include <stdio.h>
11 #include "gras.h"
12
13 #include "gras/DataDesc/datadesc_interface.h"
14 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
15
16 #define READ  0
17 #define WRITE 1
18 #define COPY  2
19 #define RW    3
20
21 int r_arch;
22 const char *filename = "datadesc_usage.out";  
23
24 void
25 write_read(gras_datadesc_type_t type,void *src, void *dst, 
26            gras_socket_t sock, int direction);
27
28 void
29 write_read(gras_datadesc_type_t type,void *src, void *dst, 
30            gras_socket_t sock, int direction) {
31    
32   /* write */
33   if (direction == RW) 
34     sock = gras_socket_client_from_file(filename);
35   if (direction == WRITE || direction == RW)
36     gras_datadesc_send(sock, type, src);
37   if (direction == RW) 
38     gras_socket_close(sock);
39    
40   /* read */
41   if (direction == RW) 
42     sock = gras_socket_server_from_file(filename);
43
44   if (direction == READ || direction == RW)
45     gras_datadesc_recv(sock, type, r_arch, dst);
46
47   if (direction == RW) 
48     gras_socket_close(sock);
49
50   if (direction == COPY)
51     gras_datadesc_copy(type, src, dst);
52 }
53
54 void test_int(gras_socket_t sock, int direction);
55 void test_float(gras_socket_t sock, int direction);
56 void test_double(gras_socket_t sock, int direction);
57 void test_array(gras_socket_t sock, int direction);
58 void test_dynar_scal(gras_socket_t sock, int direction);
59 void test_intref(gras_socket_t sock, int direction);
60 void test_string(gras_socket_t sock, int direction);
61
62 void test_homostruct(gras_socket_t sock, int direction);
63 void test_hetestruct(gras_socket_t sock, int direction);
64 void test_nestedstruct(gras_socket_t sock, int direction);
65 void test_chain_list(gras_socket_t sock, int direction);
66 void test_graph(gras_socket_t sock, int direction);
67 void test_dynar_ref(gras_socket_t sock, int direction);
68
69 void test_pbio(gras_socket_t sock, int direction);
70 void test_clause(gras_socket_t sock, int direction);
71
72 /* defined in datadesc_structures.c, which in perl generated */
73 void test_structures(gras_socket_t sock, int direction); 
74
75
76
77 void test_int(gras_socket_t sock, int direction) {
78   int i=5,j;
79   
80   INFO0("---- Test on integer ----");
81   write_read(gras_datadesc_by_name("int"), &i,&j, sock,direction);
82   if (direction == READ || direction == RW || direction == COPY) 
83     xbt_assert(i == j);
84 }
85 void test_float(gras_socket_t sock, int direction) {
86   float i=5.0,j;
87   
88   INFO0("---- Test on float ----");
89   write_read(gras_datadesc_by_name("float"), &i,&j, sock,direction);
90   if (direction == READ || direction == RW || direction == COPY)
91     xbt_assert2(i == j,"%f != %f",i,j);
92 }
93 void test_double(gras_socket_t sock, int direction) {
94   double i=-3252355.1234,j;
95   
96   INFO0("---- Test on double ----");
97   write_read(gras_datadesc_by_name("double"), &i,&j, sock,direction);
98   if (direction == READ || direction == RW || direction == COPY)
99     xbt_assert2(i == j,"%f != %f",i,j);
100 }
101
102 #define SIZE 5
103 typedef int array[SIZE];
104 void test_array(gras_socket_t sock, int direction) {
105   gras_datadesc_type_t my_type;
106   
107   array i = { 35212,-6226,74337,11414,7733};
108   array j;
109   int cpt;
110
111   INFO0("---- Test on fixed array ----");
112
113   my_type=gras_datadesc_array_fixed("fixed int array", 
114                                     gras_datadesc_by_name("int"),
115                                     SIZE);
116
117   write_read(my_type, &i,&j, sock,direction);
118   if (direction == READ || direction == RW || direction == COPY) {
119     for (cpt=0; cpt<SIZE; cpt++) {
120       DEBUG1("Test spot %d",cpt);
121       xbt_assert4(i[cpt] == j[cpt],"i[%d]=%d  !=  j[%d]=%d",
122                    cpt,i[cpt],cpt,j[cpt]);
123     }
124   }
125 }
126 /*** Dynar of scalar ***/
127
128 void test_dynar_scal(gras_socket_t sock, int direction){
129   gras_datadesc_type_t my_type;
130   xbt_dynar_t i,j;
131   int cpt;
132    
133   INFO0("---- Test on dynar containing integers ----");
134   my_type = gras_datadesc_dynar(gras_datadesc_by_name("int"),NULL);
135   i = xbt_dynar_new(sizeof(int),NULL);
136   for (cpt=0; cpt<64; cpt++) {
137     xbt_dynar_push_as(i,int,cpt); 
138     DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(i));
139   }
140 /*  xbt_dynar_dump(i);*/
141   write_read(my_type, &i,&j, sock, direction);
142 /*  xbt_dynar_dump(j);*/
143   if (direction == READ || direction == RW || direction == COPY) {
144      for (cpt=0; cpt<64; cpt++){
145         int ret=xbt_dynar_get_as(j,cpt,int);
146         if (cpt != ret) {
147            CRITICAL3("The retrieved value for cpt=%d is not the same than the injected one (%d!=%d)",
148                      cpt,ret,cpt);
149            xbt_abort();
150         }
151      }
152      xbt_dynar_free(&j);
153   }
154   xbt_dynar_free(&i);
155 }
156 void test_intref(gras_socket_t sock, int direction) {
157   gras_datadesc_type_t my_type;
158   int *i,*j;
159   
160   i=xbt_new(int,1);
161   *i=12345;
162
163   INFO1("---- Test on a reference to an integer (%p) ----",i);
164
165   my_type = gras_datadesc_ref("int*",gras_datadesc_by_name("int"));
166
167   write_read(my_type, &i,&j, sock,direction);
168   if (direction == READ || direction == RW || direction == COPY) {
169     xbt_assert2(*i == *j,"*i != *j (%d != %d)",*i,*j);
170     free(j);
171   }
172   free(i);
173 }
174
175 /***
176  *** string (dynamic array)
177  ***/ 
178 void test_string(gras_socket_t sock, int direction) {
179   char *i=xbt_strdup("Some data"), *j=NULL;
180   int cpt;
181   
182   INFO0("---- Test on string (ref to dynamic array) ----");
183   write_read(gras_datadesc_by_name("string"), &i,&j,
184              sock,direction);
185   if (direction == READ || direction == RW || direction == COPY) {
186     for (cpt=0; cpt<strlen(i); cpt++) {
187       xbt_assert4(i[cpt] == j[cpt],"i[%d]=%c  !=  j[%d]=%c",
188                    cpt,i[cpt],cpt,j[cpt]);
189     } 
190     free(j);
191   }
192   free(i);
193 }
194
195
196 /***
197  *** homogeneous struct
198  ***/ 
199 typedef struct {
200   int a,b,c,d;
201 } homostruct;
202 void test_homostruct(gras_socket_t sock, int direction) {
203   gras_datadesc_type_t my_type;
204   homostruct *i, *j; 
205
206   INFO0("---- Test on homogeneous structure ----");
207   /* create descriptor */
208   my_type=gras_datadesc_struct("homostruct");
209   gras_datadesc_struct_append(my_type,"a",
210                               gras_datadesc_by_name("signed int"));
211   gras_datadesc_struct_append(my_type,"b",
212                               gras_datadesc_by_name("int"));
213   gras_datadesc_struct_append(my_type,"c",
214                               gras_datadesc_by_name("int"));
215   gras_datadesc_struct_append(my_type,"d",
216                               gras_datadesc_by_name("int"));
217   gras_datadesc_struct_close(my_type);
218   my_type=gras_datadesc_ref("homostruct*",
219                             gras_datadesc_by_name("homostruct"));
220
221   /* init a value, exchange it and check its validity*/
222   i=xbt_new(homostruct,1);
223   i->a = 2235;    i->b = 433425;
224   i->c = -23423;  i->d = -235235;
225
226   write_read(my_type, &i,&j, sock,direction);
227   if (direction == READ || direction == RW || direction == COPY) {
228     xbt_assert2(i->a == j->a,"i->a=%d != j->a=%d",i->a,j->a);
229     xbt_assert(i->b == j->b);
230     xbt_assert(i->c == j->c);
231     xbt_assert(i->d == j->d);
232     free(j);
233   }
234   free(i);
235 }
236
237 /***
238  *** heterogeneous struct
239  ***/ 
240 typedef struct {
241   unsigned char c1;
242   unsigned long int l1;
243   unsigned char c2;
244   unsigned long int l2;
245 } hetestruct;
246 void test_hetestruct(gras_socket_t sock, int direction) {
247   gras_datadesc_type_t my_type;
248   hetestruct *i, *j; 
249
250   INFO0("---- Test on heterogeneous structure ----");
251   /* create descriptor */
252   my_type=gras_datadesc_struct("hetestruct");
253   gras_datadesc_struct_append(my_type,"c1",
254                               gras_datadesc_by_name("unsigned char"));
255   gras_datadesc_struct_append(my_type,"l1",
256                               gras_datadesc_by_name("unsigned long int"));
257   gras_datadesc_struct_append(my_type,"c2",
258                               gras_datadesc_by_name("unsigned char"));
259   gras_datadesc_struct_append(my_type,"l2",
260                               gras_datadesc_by_name("unsigned long int"));
261   gras_datadesc_struct_close(my_type);
262   my_type=gras_datadesc_ref("hetestruct*", gras_datadesc_by_name("hetestruct"));
263
264
265   /* init a value, exchange it and check its validity*/
266   i=xbt_new(hetestruct,1);
267   i->c1 = 's'; i->l1 = 123455;
268   i->c2 = 'e'; i->l2 = 774531;
269
270   write_read(my_type, &i,&j, sock,direction);
271   if (direction == READ || direction == RW || direction == COPY) {
272     xbt_assert(i->c1 == j->c1);
273     xbt_assert(i->c2 == j->c2);
274     xbt_assert2(i->l1 == j->l1,"i->l1(=%ld)  !=  j->l1(=%ld)",i->l1,j->l1);
275     xbt_assert(i->l2 == j->l2);
276     free(j);
277   }
278   free(i);
279 }
280
281 /***
282  *** nested struct
283  ***/ 
284 typedef struct {
285   hetestruct hete;
286   homostruct homo;
287 } nestedstruct;
288 void test_nestedstruct(gras_socket_t sock, int direction) {
289   gras_datadesc_type_t my_type;
290   nestedstruct *i, *j; 
291
292   INFO0("---- Test on nested structures ----");
293   /* create descriptor */
294   my_type=gras_datadesc_struct("nestedstruct");
295
296   gras_datadesc_struct_append(my_type,"hete",
297                               gras_datadesc_by_name("hetestruct"));
298   gras_datadesc_struct_append(my_type,"homo",
299                               gras_datadesc_by_name("homostruct"));
300   gras_datadesc_struct_close(my_type);
301   my_type=gras_datadesc_ref("nestedstruct*", gras_datadesc_by_name("nestedstruct"));
302
303   /* init a value, exchange it and check its validity*/
304   i=xbt_new(nestedstruct,1);
305   i->homo.a = 235231;  i->homo.b = -124151;
306   i->homo.c = 211551;  i->homo.d = -664222;
307   i->hete.c1 = 's'; i->hete.l1 = 123455;
308   i->hete.c2 = 'e'; i->hete.l2 = 774531;
309
310   write_read(my_type, &i,&j, sock,direction);
311   if (direction == READ || direction == RW || direction == COPY) {
312     xbt_assert(i->homo.a == j->homo.a);
313     xbt_assert(i->homo.b == j->homo.b);
314     xbt_assert(i->homo.c == j->homo.c);
315     xbt_assert(i->homo.d == j->homo.d);
316     xbt_assert(i->hete.c1 == j->hete.c1);
317     xbt_assert(i->hete.c2 == j->hete.c2);
318     xbt_assert(i->hete.l1 == j->hete.l1);
319     xbt_assert(i->hete.l2 == j->hete.l2);
320     free(j);
321   }
322   free(i);
323 }
324
325 /***
326  *** chained list
327  ***/ 
328 typedef struct s_chained_list chained_list_t;
329 struct s_chained_list {
330   int          v;
331   chained_list_t *l;
332 };
333 void declare_chained_list_type(void);
334 chained_list_t *cons(int v, chained_list_t *l);
335 void list_free(chained_list_t *l);
336 int list_eq(chained_list_t*i,chained_list_t*j);
337
338 void declare_chained_list_type(void) {
339   gras_datadesc_type_t my_type,ref_my_type;
340
341   my_type=gras_datadesc_struct("chained_list_t");
342   ref_my_type=gras_datadesc_ref("chained_list_t*",my_type);
343
344   gras_datadesc_struct_append(my_type,"v", gras_datadesc_by_name("int"));
345   gras_datadesc_struct_append(my_type,"l", ref_my_type);
346   gras_datadesc_struct_close(my_type);
347 }
348
349 chained_list_t * cons(int v, chained_list_t *l) {
350   chained_list_t *nl = xbt_new(chained_list_t,1);
351   
352   nl->v = v;
353   nl->l = l;
354   
355   return nl;
356 }
357 void list_free(chained_list_t*l) {
358   if (l) {
359     list_free(l->l);
360     free(l);
361   }
362 }
363 int list_eq(chained_list_t*i,chained_list_t*j) {
364   if (!i || !j) return i == j;
365   if (i->v != j->v)
366     return 0;
367   return list_eq(i->l, j->l); 
368 }
369 void test_chain_list(gras_socket_t sock, int direction) {
370   chained_list_t *i, *j; 
371
372   INFO0("---- Test on chained list ----");
373
374   /* init a value, exchange it and check its validity*/
375   i = cons( 12355, cons( 246264 , cons( 23263, NULL)));
376   j = NULL;
377
378   write_read(gras_datadesc_by_name("chained_list_t*"),
379              &i,&j,  sock,direction);
380   if (direction == READ || direction == RW || direction == COPY) {
381     xbt_assert(list_eq(i,j));    
382     list_free(j);
383   }
384
385   list_free(i);
386 }
387 /***
388  *** graph
389  ***/
390 void test_graph(gras_socket_t sock, int direction) {
391   chained_list_t *i, *j; 
392
393   INFO0("---- Test on graph (cyclique chained list of 3 items) ----");
394   /* init a value, exchange it and check its validity*/
395   i = cons( 1151515, cons( -232362 , cons( 222552, NULL)));
396   i->l->l->l = i;
397   j = NULL;
398
399   gras_datadesc_cycle_set(gras_datadesc_by_name("chained_list_t*"));
400   write_read(gras_datadesc_by_name("chained_list_t*"),
401              &i,&j, sock,direction);
402   if (direction == READ || direction == RW || direction == COPY) {
403     
404     DEBUG1("i=%p"         ,i);
405     DEBUG1("i->l=%p"      ,i->l);
406     DEBUG1("i->l->l=%p"   ,i->l->l);
407     DEBUG1("i->l->l->l=%p",i->l->l->l);
408     DEBUG1("j=%p"         ,j);
409     DEBUG1("j->l=%p"      ,j->l);
410     DEBUG1("j->l->l=%p"   ,j->l->l);
411     DEBUG1("j->l->l->l=%p",j->l->l->l);
412     xbt_assert4(j->l->l->l == j,
413                  "Received list is not cyclic. j=%p != j->l->l->l=%p\n"
414                  "j=%p; &j=%p",
415                  j,j->l->l->l, 
416                  j ,&j);
417     j->l->l->l = NULL;
418     i->l->l->l = NULL;
419     xbt_assert(list_eq(i,j));
420
421     list_free(j);
422   }
423   i->l->l->l = NULL; /* do this even in WRITE mode */
424   list_free(i);
425 }
426
427
428 /*** Dynar of references ***/
429 static void free_string(void *d){ /* used to free the data in dynar */
430      free(*(void**)d);
431 }
432 void test_dynar_ref(gras_socket_t sock, int direction){
433   gras_datadesc_type_t my_type;
434   xbt_dynar_t i,j;
435   char buf[1024];
436   char *s1,*s2;
437   int cpt;
438    
439   INFO0("---- Test on dynar containing integers ----");
440   my_type = gras_datadesc_dynar(gras_datadesc_by_name("string"),&free_string);
441
442   i=xbt_dynar_new(sizeof(char*),&free_string);   
443   for (cpt=0; cpt< 64; cpt++) {
444     sprintf(buf,"%d",cpt);
445     s1=strdup(buf);
446     xbt_dynar_push(i,&s1);
447   }
448
449   write_read(my_type, &i,&j, sock, direction);
450   if (direction == READ || direction == RW || direction == COPY) {
451      for (cpt=0; cpt< 64; cpt++) {
452         sprintf(buf,"%d",cpt);
453         xbt_dynar_shift(j,&s2);
454         xbt_assert2 (!strcmp(buf,s2),
455                      "The retrieved value is not the same than the injected one (%s!=%s)",
456                      buf,s2);
457         free(s2);
458      }
459      xbt_dynar_free(&j);
460   }
461   xbt_dynar_free(&i);
462 }
463
464
465 /**** PBIO *****/
466 GRAS_DEFINE_TYPE(s_pbio,
467 struct s_pbio{ /* structure presented in the IEEE article */
468   int Cnstatv;
469   double Cstatev[12];
470   int Cnprops;
471   double Cprops[110];
472   int Cndi[4];
473   int Cnshr;
474   int Cnpt;
475   double Cdtime;
476   double Ctime[2];
477   int Cntens;
478   double Cdfgrd0[373][3];
479   double Cdfgrd1[3][3];
480   double Cstress[106];
481   double Cddsdde[106][106];
482 };
483                  )
484 typedef struct s_pbio pbio_t;
485
486 void test_pbio(gras_socket_t sock, int direction) {
487   int cpt;
488   int cpt2;
489   gras_datadesc_type_t pbio_type;
490   pbio_t i, j;
491
492   INFO0("---- Test on the PBIO IEEE struct (also tests GRAS DEFINE TYPE) ----");
493   pbio_type = gras_datadesc_by_symbol(s_pbio);
494
495   /* Fill in that damn struct */
496   i.Cnstatv = 325115;
497   for (cpt=0; cpt<12; cpt++) 
498     i.Cstatev[cpt] = ((double) cpt) * -2361.11;
499   i.Cnprops = -37373;
500   for (cpt=0; cpt<110; cpt++)
501     i.Cprops[cpt] = cpt * 100.0;
502   for (cpt=0; cpt<4; cpt++)
503     i.Cndi[cpt] = cpt * 23262;
504   i.Cnshr = -4634;
505   i.Cnpt = 114142;
506   i.Cdtime = -11515.662;
507   i.Ctime[0] = 332523.226;
508   i.Ctime[1] = -26216.113;
509   i.Cntens = 235211411;
510   
511   for (cpt=0; cpt<3; cpt++) {
512     for (cpt2=0; cpt2<373; cpt2++)
513       i.Cdfgrd0[cpt2][cpt] = ((double)cpt) * ((double)cpt2);
514     for (cpt2=0; cpt2<3; cpt2++)
515       i.Cdfgrd1[cpt][cpt2] = -((double)cpt) * ((double)cpt2);
516   }
517   for (cpt=0; cpt<106; cpt++) {
518     i.Cstress[cpt]=(double)cpt * 22.113;
519     for (cpt2=0; cpt2<106; cpt2++) 
520       i.Cddsdde[cpt][cpt2] = ((double)cpt) * ((double)cpt2);
521   }
522   write_read(gras_datadesc_by_symbol(s_pbio),
523              &i,&j, sock,direction);
524   if (direction == READ || direction == RW || direction == COPY) {
525     /* Check that the data match */
526     xbt_assert(i.Cnstatv == j.Cnstatv);
527     for (cpt=0; cpt<12; cpt++)
528       xbt_assert4(i.Cstatev[cpt] == j.Cstatev[cpt],
529                   "i.Cstatev[%d] (=%f) != j.Cstatev[%d] (=%f)",
530                   cpt,i.Cstatev[cpt],cpt,j.Cstatev[cpt]);
531     xbt_assert(i.Cnprops == j.Cnprops);
532     for (cpt=0; cpt<110; cpt++)
533       xbt_assert(i.Cprops[cpt] == j.Cprops[cpt]);
534     for (cpt=0; cpt<4; cpt++) 
535       xbt_assert(i.Cndi[cpt] == j.Cndi[cpt]);
536     xbt_assert(i.Cnshr == j.Cnshr);
537     xbt_assert(i.Cnpt == j.Cnpt);
538     xbt_assert(i.Cdtime == j.Cdtime);
539     xbt_assert(i.Ctime[0] == j.Ctime[0]);
540     xbt_assert(i.Ctime[1] == j.Ctime[1]);
541     xbt_assert(i.Cntens == j.Cntens);
542     for (cpt=0; cpt<3; cpt++) {
543       for (cpt2=0; cpt2<373; cpt2++)
544         xbt_assert(i.Cdfgrd0[cpt2][cpt] == j.Cdfgrd0[cpt2][cpt]);
545       for (cpt2=0; cpt2<3; cpt2++)
546         xbt_assert(i.Cdfgrd1[cpt][cpt2] == j.Cdfgrd1[cpt][cpt2]);
547     }
548     for (cpt=0; cpt<106; cpt++) {
549       xbt_assert(i.Cstress[cpt] == j.Cstress[cpt]);
550       for (cpt2=0; cpt2<106; cpt2++) 
551         xbt_assert4(i.Cddsdde[cpt][cpt2] == j.Cddsdde[cpt][cpt2],
552                      "%f=i.Cddsdde[%d][%d] != j.Cddsdde[cpt][cpt2]=%f",
553                      i.Cddsdde[cpt][cpt2],cpt,cpt2,j.Cddsdde[cpt][cpt2]);
554     }
555   }
556 }
557
558 GRAS_DEFINE_TYPE(s_clause,
559 struct s_clause {
560    int num_lits;
561    int *literals GRAS_ANNOTE(size,num_lits); /* Tells GRAS where to find the size */
562 };)
563 typedef struct s_clause Clause;
564
565 void test_clause(gras_socket_t sock, int direction) {
566   gras_datadesc_type_t ddt;
567   Clause *i,*j;
568   int cpt;
569   
570   INFO0("---- Test on struct containing dynamic array and its size (cbps test) ----");
571
572   /* create and fill the struct */
573   i=xbt_new(Clause,1);
574
575   i->num_lits = 5432;
576   i->literals = xbt_new(int, i->num_lits);
577   for (cpt=0; cpt<i->num_lits; cpt++)
578     i->literals[cpt] = cpt * cpt - ((cpt * cpt) / 2);
579   DEBUG3("created data=%p (within %p @%p)",&(i->num_lits),i,&i);
580   DEBUG1("created count=%d",i->num_lits);
581
582   /* create the damn type descriptor */
583   ddt = gras_datadesc_by_symbol(s_clause);
584 /*  gras_datadesc_type_dump(ddt); */
585
586   ddt=gras_datadesc_ref("Clause*",ddt);
587
588   write_read(ddt, &i,&j, sock,direction);
589   if (direction == READ || direction == RW || direction == COPY) {
590     xbt_assert(i->num_lits == j->num_lits);
591     for (cpt=0; cpt<i->num_lits; cpt++)
592       xbt_assert(i->literals[cpt] == j->literals[cpt]);
593     
594     free(j->literals);
595     free(j);
596   }
597   free(i->literals);
598   free(i);
599 }
600
601 int main(int argc,char *argv[]) {
602   gras_socket_t sock=NULL;
603   int direction = RW;
604   int cpt;
605   char r_arch_char = gras_arch_selfid();
606
607   gras_init(&argc,argv);
608
609   for (cpt=1; cpt<argc; cpt++) {
610     if (!strcmp(argv[cpt], "--read")) {
611       direction = READ;
612     } else if (!strcmp(argv[cpt], "--write")) {
613       direction = WRITE;
614     } else if (!strcmp(argv[cpt], "--copy")) {
615       direction = COPY;
616     } else {
617        filename=argv[cpt];
618     }
619   }
620     
621   if (direction == WRITE) {
622     sock = gras_socket_client_from_file(filename);
623     gras_datadesc_send(sock, gras_datadesc_by_name("char"),
624                        &r_arch_char);
625   }
626   if (direction == READ) {
627     sock = gras_socket_server_from_file(filename);
628     gras_datadesc_recv(sock, gras_datadesc_by_name("char"),
629                        gras_arch_selfid(), &r_arch_char);
630     INFO3("This datafile was generated on %s (%d), I'm %s.",
631           gras_datadesc_arch_name(r_arch_char),(int)r_arch_char,
632           gras_datadesc_arch_name(gras_arch_selfid()));
633   }
634   r_arch = (int)r_arch_char;
635
636   test_int(sock,direction);    
637   test_float(sock,direction);  
638   test_double(sock,direction);  
639   test_array(sock,direction);
640   test_intref(sock,direction); 
641
642   test_string(sock,direction); 
643   test_dynar_scal(sock,direction);  
644
645   test_structures(sock,direction);
646
647   test_homostruct(sock,direction);
648   test_hetestruct(sock,direction);
649   test_nestedstruct(sock,direction);
650
651   declare_chained_list_type();
652   test_chain_list(sock,direction);
653   test_graph(sock,direction); 
654   test_dynar_ref(sock,direction);  
655
656   test_pbio(sock,direction);
657
658   test_clause(sock,direction);
659
660   if (direction != RW && direction != COPY) 
661     gras_socket_close(sock);
662   gras_exit();
663   return 0;
664 }
665