Logo AND Algorithmique Numérique Distribuée

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