Logo AND Algorithmique Numérique Distribuée

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