+ double Cdfgrd0[373][3];
+ double Cdfgrd1[3][3];
+ double Cstress[106];
+ double Cddsdde[106][106];
+};
+ )
+typedef struct s_pbio pbio_t;
+
+void test_pbio(gras_socket_t sock, int direction) {
+ int cpt;
+ int cpt2;
+ gras_datadesc_type_t pbio_type;
+ pbio_t i, j;
+
+ INFO0("---- Test on the PBIO IEEE struct (also tests GRAS DEFINE TYPE) ----");
+ pbio_type = gras_datadesc_by_symbol(s_pbio);
+
+ /* Fill in that damn struct */
+ i.Cnstatv = 325115;
+ for (cpt=0; cpt<12; cpt++)
+ i.Cstatev[cpt] = ((double) cpt) * -2361.11;
+ i.Cnprops = -37373;
+ for (cpt=0; cpt<110; cpt++)
+ i.Cprops[cpt] = cpt * 100.0;
+ 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;
+
+ for (cpt=0; cpt<3; cpt++) {
+ for (cpt2=0; cpt2<373; cpt2++)
+ i.Cdfgrd0[cpt2][cpt] = ((double)cpt) * ((double)cpt2);
+ for (cpt2=0; cpt2<3; cpt2++)
+ i.Cdfgrd1[cpt][cpt2] = -((double)cpt) * ((double)cpt2);
+ }
+ for (cpt=0; cpt<106; cpt++) {
+ i.Cstress[cpt]=(double)cpt * 22.113;
+ for (cpt2=0; cpt2<106; cpt2++)
+ i.Cddsdde[cpt][cpt2] = ((double)cpt) * ((double)cpt2);
+ }
+ write_read(gras_datadesc_by_symbol(s_pbio),
+ &i,&j, sock,direction);
+ if (direction == READ || direction == RW || direction == COPY) {
+ /* Check that the data match */
+ xbt_assert(i.Cnstatv == j.Cnstatv);
+ for (cpt=0; cpt<12; cpt++)
+ xbt_assert4(i.Cstatev[cpt] == j.Cstatev[cpt],
+ "i.Cstatev[%d] (=%f) != j.Cstatev[%d] (=%f)",
+ cpt,i.Cstatev[cpt],cpt,j.Cstatev[cpt]);
+ xbt_assert(i.Cnprops == j.Cnprops);
+ for (cpt=0; cpt<110; cpt++)
+ xbt_assert(i.Cprops[cpt] == j.Cprops[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);
+ for (cpt=0; cpt<3; cpt++) {
+ for (cpt2=0; cpt2<373; cpt2++)
+ xbt_assert(i.Cdfgrd0[cpt2][cpt] == j.Cdfgrd0[cpt2][cpt]);
+ for (cpt2=0; cpt2<3; cpt2++)
+ xbt_assert(i.Cdfgrd1[cpt][cpt2] == j.Cdfgrd1[cpt][cpt2]);
+ }
+ for (cpt=0; cpt<106; cpt++) {
+ xbt_assert(i.Cstress[cpt] == j.Cstress[cpt]);
+ for (cpt2=0; cpt2<106; cpt2++)
+ xbt_assert4(i.Cddsdde[cpt][cpt2] == j.Cddsdde[cpt][cpt2],
+ "%f=i.Cddsdde[%d][%d] != j.Cddsdde[cpt][cpt2]=%f",
+ i.Cddsdde[cpt][cpt2],cpt,cpt2,j.Cddsdde[cpt][cpt2]);
+ }
+ }
+}
+
+GRAS_DEFINE_TYPE(s_clause,
+struct s_clause {
+ int num_lits;
+ int *literals GRAS_ANNOTE(size,num_lits); /* Tells GRAS where to find the size */
+};)
+typedef struct s_clause Clause;
+
+void test_clause(gras_socket_t sock, int direction) {
+ gras_datadesc_type_t ddt;
+ Clause *i,*j;
+ int cpt;
+
+ INFO0("---- Test on struct containing dynamic array and its size (cbps test) ----");
+
+ /* create and fill the struct */
+ i=xbt_new(Clause,1);
+
+ i->num_lits = 5432;
+ i->literals = xbt_new(int, i->num_lits);
+ for (cpt=0; cpt<i->num_lits; cpt++)
+ i->literals[cpt] = cpt * cpt - ((cpt * cpt) / 2);
+ DEBUG3("created data=%p (within %p @%p)",&(i->num_lits),i,&i);
+ DEBUG1("created count=%d",i->num_lits);
+
+ /* create the damn type descriptor */
+ ddt = gras_datadesc_by_symbol(s_clause);
+/* gras_datadesc_type_dump(ddt); */
+
+ ddt=gras_datadesc_ref("Clause*",ddt);
+
+ write_read(ddt, &i,&j, sock,direction);
+ if (direction == READ || direction == RW || direction == COPY) {
+ xbt_assert(i->num_lits == j->num_lits);
+ for (cpt=0; cpt<i->num_lits; cpt++)
+ xbt_assert(i->literals[cpt] == j->literals[cpt]);
+
+ free(j->literals);
+ free(j);
+ }
+ free(i->literals);
+ free(i);
+}