+ double Cdfgrd0[373][3];
+ double Cdfgrd1[3][3];
+ double Cstress[106];
+ double Cddsdde[106][106];
+};
+ )
+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;
+ int cpt;
+ int cpt2;
+ gras_datadesc_type_t pbio_type;
+
+ 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 */
+ pbio_i.Cnstatv = 325115;
+ for (cpt=0; cpt<12; cpt++)
+ pbio_i.Cstatev[cpt] = ((double) cpt) * -2361.11;
+ pbio_i.Cnprops = -37373;
+ for (cpt=0; cpt<110; cpt++)
+ pbio_i.Cprops[cpt] = cpt * 100.0;
+ for (cpt=0; cpt<4; cpt++)
+ 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++)
+ pbio_i.Cdfgrd0[cpt2][cpt] = ((double)cpt) * ((double)cpt2);
+ for (cpt2=0; cpt2<3; cpt2++)
+ pbio_i.Cdfgrd1[cpt][cpt2] = -((double)cpt) * ((double)cpt2);
+ }
+ for (cpt=0; cpt<106; cpt++) {
+ pbio_i.Cstress[cpt]=(double)cpt * 22.113;
+ for (cpt2=0; cpt2<106; cpt2++)
+ pbio_i.Cddsdde[cpt][cpt2] = ((double)cpt) * ((double)cpt2);
+ }
+ TRY(write_read(gras_datadesc_by_symbol(s_pbio),
+ &pbio_i,&pbio_j, sock,direction));
+ if (direction == READ || direction == RW) {
+ /* Check that the data match */
+ xbt_assert(pbio_i.Cnstatv == pbio_j.Cnstatv);
+ for (cpt=0; cpt<12; cpt++)
+ 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++)
+ xbt_assert(pbio_i.Cprops[cpt] == pbio_j.Cprops[cpt]);
+ for (cpt=0; cpt<4; cpt++)
+ 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++)
+ xbt_assert(pbio_i.Cdfgrd0[cpt2][cpt] == pbio_j.Cdfgrd0[cpt2][cpt]);
+ for (cpt2=0; cpt2<3; cpt2++)
+ xbt_assert(pbio_i.Cdfgrd1[cpt][cpt2] == pbio_j.Cdfgrd1[cpt][cpt2]);
+ }
+ for (cpt=0; cpt<106; cpt++) {
+ xbt_assert(pbio_i.Cstress[cpt] == pbio_j.Cstress[cpt]);
+ for (cpt2=0; cpt2<106; cpt2++)
+ xbt_assert4(pbio_i.Cddsdde[cpt][cpt2] == pbio_j.Cddsdde[cpt][cpt2],
+ "%f=i.Cddsdde[%d][%d] != j.Cddsdde[cpt][cpt2]=%f",
+ pbio_i.Cddsdde[cpt][cpt2],cpt,cpt2,pbio_j.Cddsdde[cpt][cpt2]);
+ }
+ }
+
+ return no_error;
+}
+
+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;
+
+xbt_error_t test_clause(gras_socket_t sock, int direction) {
+ xbt_error_t errcode;
+ gras_datadesc_type_t ddt,array_t;
+ 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);
+
+ TRY(write_read(ddt, &i,&j, sock,direction));
+ if (direction == READ || direction == RW) {
+ 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);
+ return no_error;
+}