Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move big structures out of the stack to try to help the poor powerpc owner, but it...
[simgrid.git] / testsuite / gras / datadesc_usage.c
index f715163..5ff53f0 100644 (file)
@@ -2,14 +2,13 @@
 
 /* datadesc: test of data description (using file transport).               */
 
 
 /* datadesc: test of data description (using file transport).               */
 
-/* Authors: Martin Quinson                                                  */
-/* Copyright (C) 2004 the OURAGAN project.                                  */
+/* Copyright (c) 2004 Martin Quinson. All rights reserved.                  */
 
 /* This program is free software; you can redistribute it and/or modify it
 
 /* This program is free software; you can redistribute it and/or modify it
  under the terms of the license (GNU LGPL) which comes with this package. */
* under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <stdio.h>
 
 #include <stdio.h>
-#include <gras.h>
+#include "gras.h"
 
 #include "gras/DataDesc/datadesc_interface.h"
 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
 #include "gras/DataDesc/datadesc_interface.h"
 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
@@ -35,6 +34,7 @@ write_read(gras_datadesc_type_t type,void *src, void *dst,
     TRY(gras_socket_client_from_file(filename,&sock));
   if (direction == WRITE || direction == RW)
     TRY(gras_datadesc_send(sock, type, src));
     TRY(gras_socket_client_from_file(filename,&sock));
   if (direction == WRITE || direction == RW)
     TRY(gras_datadesc_send(sock, type, src));
+/*  TRY(gras_datadesc_gen_send(sock, type, src));*/
   if (direction == RW) 
     gras_socket_close(sock);
    
   if (direction == RW) 
     gras_socket_close(sock);
    
@@ -441,10 +441,10 @@ struct s_pbio{ /* structure presented in the IEEE article */
 };
                 )
 typedef struct s_pbio pbio_t;
 };
                 )
 typedef struct s_pbio pbio_t;
+pbio_t pbio_i, pbio_j;
 
 xbt_error_t test_pbio(gras_socket_t sock, int direction) {
   xbt_error_t errcode;
 
 xbt_error_t test_pbio(gras_socket_t sock, int direction) {
   xbt_error_t errcode;
-  pbio_t i,j;
   int cpt;
   int cpt2;
   gras_datadesc_type_t pbio_type;
   int cpt;
   int cpt2;
   gras_datadesc_type_t pbio_type;
@@ -453,62 +453,64 @@ xbt_error_t test_pbio(gras_socket_t sock, int direction) {
   pbio_type = gras_datadesc_by_symbol(s_pbio);
 
   /* Fill in that damn struct */
   pbio_type = gras_datadesc_by_symbol(s_pbio);
 
   /* Fill in that damn struct */
-  i.Cnstatv = 325115;
+  pbio_i.Cnstatv = 325115;
   for (cpt=0; cpt<12; cpt++) 
   for (cpt=0; cpt<12; cpt++) 
-    i.Cstatev[cpt] = ((double) cpt) * -2361.11;
-  i.Cnprops = -37373;
+    pbio_i.Cstatev[cpt] = ((double) cpt) * -2361.11;
+  pbio_i.Cnprops = -37373;
   for (cpt=0; cpt<110; cpt++)
   for (cpt=0; cpt<110; cpt++)
-    i.Cprops[cpt] = cpt * 100.0;
+    pbio_i.Cprops[cpt] = cpt * 100.0;
   for (cpt=0; cpt<4; cpt++)
   for (cpt=0; cpt<4; cpt++)
-    i.Cndi[cpt] = cpt * 23262;
-  i.Cnshr = -4634;
-  i.Cnpt = 114142;
-  i.Cdtime = -11515.662;
-  i.Ctime[0] = 332523.226;
-  i.Ctime[1] = -26216.113;
-  i.Cntens = 235211411;
+    pbio_i.Cndi[cpt] = cpt * 23262;
+  pbio_i.Cnshr = -4634;
+  pbio_i.Cnpt = 114142;
+  pbio_i.Cdtime = -11515.662;
+  pbio_i.Ctime[0] = 332523.226;
+  pbio_i.Ctime[1] = -26216.113;
+  pbio_i.Cntens = 235211411;
   
   for (cpt=0; cpt<3; cpt++) {
     for (cpt2=0; cpt2<373; cpt2++)
   
   for (cpt=0; cpt<3; cpt++) {
     for (cpt2=0; cpt2<373; cpt2++)
-      i.Cdfgrd0[cpt2][cpt] = ((double)cpt) * ((double)cpt2);
+      pbio_i.Cdfgrd0[cpt2][cpt] = ((double)cpt) * ((double)cpt2);
     for (cpt2=0; cpt2<3; cpt2++)
     for (cpt2=0; cpt2<3; cpt2++)
-      i.Cdfgrd1[cpt][cpt2] = -((double)cpt) * ((double)cpt2);
+      pbio_i.Cdfgrd1[cpt][cpt2] = -((double)cpt) * ((double)cpt2);
   }
   for (cpt=0; cpt<106; cpt++) {
   }
   for (cpt=0; cpt<106; cpt++) {
-    i.Cstress[cpt]=(double)cpt * 22.113;
+    pbio_i.Cstress[cpt]=(double)cpt * 22.113;
     for (cpt2=0; cpt2<106; cpt2++) 
     for (cpt2=0; cpt2<106; cpt2++) 
-      i.Cddsdde[cpt][cpt2] = ((double)cpt) * ((double)cpt2);
+      pbio_i.Cddsdde[cpt][cpt2] = ((double)cpt) * ((double)cpt2);
   }
   TRY(write_read(gras_datadesc_by_symbol(s_pbio),
   }
   TRY(write_read(gras_datadesc_by_symbol(s_pbio),
-                &i,&j, sock,direction));
+                &pbio_i,&pbio_j, sock,direction));
   if (direction == READ || direction == RW) {
     /* Check that the data match */
   if (direction == READ || direction == RW) {
     /* Check that the data match */
-    xbt_assert(i.Cnstatv == j.Cnstatv);
+    xbt_assert(pbio_i.Cnstatv == pbio_j.Cnstatv);
     for (cpt=0; cpt<12; cpt++)
     for (cpt=0; cpt<12; cpt++)
-      xbt_assert(i.Cstatev[cpt] == j.Cstatev[cpt]);
-    xbt_assert(i.Cnprops == j.Cnprops);
+      xbt_assert4(pbio_i.Cstatev[cpt] == pbio_j.Cstatev[cpt],
+                 "i.Cstatev[%d] (=%f) != j.Cstatev[%d] (=%f)",
+                 cpt,pbio_i.Cstatev[cpt],cpt,pbio_j.Cstatev[cpt]);
+    xbt_assert(pbio_i.Cnprops == pbio_j.Cnprops);
     for (cpt=0; cpt<110; cpt++)
     for (cpt=0; cpt<110; cpt++)
-      xbt_assert(i.Cprops[cpt] == j.Cprops[cpt]);
+      xbt_assert(pbio_i.Cprops[cpt] == pbio_j.Cprops[cpt]);
     for (cpt=0; cpt<4; cpt++) 
     for (cpt=0; cpt<4; cpt++) 
-      xbt_assert(i.Cndi[cpt] == j.Cndi[cpt]);
-    xbt_assert(i.Cnshr == j.Cnshr);
-    xbt_assert(i.Cnpt == j.Cnpt);
-    xbt_assert(i.Cdtime == j.Cdtime);
-    xbt_assert(i.Ctime[0] == j.Ctime[0]);
-    xbt_assert(i.Ctime[1] == j.Ctime[1]);
-    xbt_assert(i.Cntens == j.Cntens);
+      xbt_assert(pbio_i.Cndi[cpt] == pbio_j.Cndi[cpt]);
+    xbt_assert(pbio_i.Cnshr == pbio_j.Cnshr);
+    xbt_assert(pbio_i.Cnpt == pbio_j.Cnpt);
+    xbt_assert(pbio_i.Cdtime == pbio_j.Cdtime);
+    xbt_assert(pbio_i.Ctime[0] == pbio_j.Ctime[0]);
+    xbt_assert(pbio_i.Ctime[1] == pbio_j.Ctime[1]);
+    xbt_assert(pbio_i.Cntens == pbio_j.Cntens);
     for (cpt=0; cpt<3; cpt++) {
       for (cpt2=0; cpt2<373; cpt2++)
     for (cpt=0; cpt<3; cpt++) {
       for (cpt2=0; cpt2<373; cpt2++)
-       xbt_assert(i.Cdfgrd0[cpt2][cpt] == j.Cdfgrd0[cpt2][cpt]);
+       xbt_assert(pbio_i.Cdfgrd0[cpt2][cpt] == pbio_j.Cdfgrd0[cpt2][cpt]);
       for (cpt2=0; cpt2<3; cpt2++)
       for (cpt2=0; cpt2<3; cpt2++)
-       xbt_assert(i.Cdfgrd1[cpt][cpt2] == j.Cdfgrd1[cpt][cpt2]);
+       xbt_assert(pbio_i.Cdfgrd1[cpt][cpt2] == pbio_j.Cdfgrd1[cpt][cpt2]);
     }
     for (cpt=0; cpt<106; cpt++) {
     }
     for (cpt=0; cpt<106; cpt++) {
-      xbt_assert(i.Cstress[cpt] == j.Cstress[cpt]);
+      xbt_assert(pbio_i.Cstress[cpt] == pbio_j.Cstress[cpt]);
       for (cpt2=0; cpt2<106; cpt2++) 
       for (cpt2=0; cpt2<106; cpt2++) 
-       xbt_assert4(i.Cddsdde[cpt][cpt2] == j.Cddsdde[cpt][cpt2],
+       xbt_assert4(pbio_i.Cddsdde[cpt][cpt2] == pbio_j.Cddsdde[cpt][cpt2],
                     "%f=i.Cddsdde[%d][%d] != j.Cddsdde[cpt][cpt2]=%f",
                     "%f=i.Cddsdde[%d][%d] != j.Cddsdde[cpt][cpt2]=%f",
-                    i.Cddsdde[cpt][cpt2],cpt,cpt2,j.Cddsdde[cpt][cpt2]);
+                    pbio_i.Cddsdde[cpt][cpt2],cpt,cpt2,pbio_j.Cddsdde[cpt][cpt2]);
     }
   }
 
     }
   }
 
@@ -567,7 +569,7 @@ int main(int argc,char *argv[]) {
   int cpt;
   char r_arch_char = gras_arch_selfid();
 
   int cpt;
   char r_arch_char = gras_arch_selfid();
 
-  xbt_init_defaultlog(&argc,argv,NULL);
+  gras_init(&argc,argv,NULL);
 
   for (cpt=1; cpt<argc; cpt++) {
     if (!strcmp(argv[cpt], "--read")) {
 
   for (cpt=1; cpt<argc; cpt++) {
     if (!strcmp(argv[cpt], "--read")) {
@@ -618,7 +620,7 @@ int main(int argc,char *argv[]) {
 
   if (direction != RW) 
     gras_socket_close(sock);
 
   if (direction != RW) 
     gras_socket_close(sock);
-  xbt_exit();
+  gras_exit();
   return 0;
 }
 
   return 0;
 }