Logo AND Algorithmique Numérique Distribuée

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