Logo AND Algorithmique Numérique Distribuée

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