Logo AND Algorithmique Numérique Distribuée

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