/* 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. */
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
#include <stdio.h>
#include "gras.h"
#define READ 0
#define WRITE 1
-#define RW 2
+#define COPY 2
+#define RW 3
int r_arch;
const char *filename = "datadesc_usage.out";
sock = gras_socket_client_from_file(filename);
if (direction == WRITE || direction == RW)
gras_datadesc_send(sock, type, src);
-/* gras_datadesc_gen_send(sock, type, src);*/
if (direction == RW)
gras_socket_close(sock);
if (direction == RW)
gras_socket_close(sock);
+
+ if (direction == COPY)
+ gras_datadesc_copy(type, src, dst);
}
void test_int(gras_socket_t sock, int direction);
INFO0("---- Test on integer ----");
write_read(gras_datadesc_by_name("int"), &i,&j, sock,direction);
- if (direction == READ || direction == RW)
+ if (direction == READ || direction == RW || direction == COPY)
xbt_assert(i == j);
}
void test_float(gras_socket_t sock, int direction) {
INFO0("---- Test on float ----");
write_read(gras_datadesc_by_name("float"), &i,&j, sock,direction);
- if (direction == READ || direction == RW)
+ if (direction == READ || direction == RW || direction == COPY)
xbt_assert2(i == j,"%f != %f",i,j);
}
void test_double(gras_socket_t sock, int direction) {
INFO0("---- Test on double ----");
write_read(gras_datadesc_by_name("double"), &i,&j, sock,direction);
- if (direction == READ || direction == RW)
+ if (direction == READ || direction == RW || direction == COPY)
xbt_assert2(i == j,"%f != %f",i,j);
}
SIZE);
write_read(my_type, &i,&j, sock,direction);
- if (direction == READ || direction == RW) {
+ if (direction == READ || direction == RW || direction == COPY) {
for (cpt=0; cpt<SIZE; cpt++) {
DEBUG1("Test spot %d",cpt);
xbt_assert4(i[cpt] == j[cpt],"i[%d]=%d != j[%d]=%d",
/* xbt_dynar_dump(i);*/
write_read(my_type, &i,&j, sock, direction);
/* xbt_dynar_dump(j);*/
- if (direction == READ || direction == RW) {
+ if (direction == READ || direction == RW || direction == COPY) {
for (cpt=0; cpt<64; cpt++){
int ret=xbt_dynar_get_as(j,cpt,int);
if (cpt != ret) {
my_type = gras_datadesc_ref("int*",gras_datadesc_by_name("int"));
write_read(my_type, &i,&j, sock,direction);
- if (direction == READ || direction == RW) {
- xbt_assert(*i == *j);
+ if (direction == READ || direction == RW || direction == COPY) {
+ xbt_assert2(*i == *j,"*i != *j (%d != %d)",*i,*j);
free(j);
}
free(i);
INFO0("---- Test on string (ref to dynamic array) ----");
write_read(gras_datadesc_by_name("string"), &i,&j,
sock,direction);
- if (direction == READ || direction == RW) {
+ if (direction == READ || direction == RW || direction == COPY) {
for (cpt=0; cpt<strlen(i); cpt++) {
xbt_assert4(i[cpt] == j[cpt],"i[%d]=%c != j[%d]=%c",
cpt,i[cpt],cpt,j[cpt]);
i->c = -23423; i->d = -235235;
write_read(my_type, &i,&j, sock,direction);
- if (direction == READ || direction == RW) {
+ if (direction == READ || direction == RW || direction == COPY) {
xbt_assert2(i->a == j->a,"i->a=%d != j->a=%d",i->a,j->a);
xbt_assert(i->b == j->b);
xbt_assert(i->c == j->c);
i->c2 = 'e'; i->l2 = 774531;
write_read(my_type, &i,&j, sock,direction);
- if (direction == READ || direction == RW) {
+ if (direction == READ || direction == RW || direction == COPY) {
xbt_assert(i->c1 == j->c1);
xbt_assert(i->c2 == j->c2);
xbt_assert2(i->l1 == j->l1,"i->l1(=%ld) != j->l1(=%ld)",i->l1,j->l1);
i->hete.c2 = 'e'; i->hete.l2 = 774531;
write_read(my_type, &i,&j, sock,direction);
- if (direction == READ || direction == RW) {
+ if (direction == READ || direction == RW || direction == COPY) {
xbt_assert(i->homo.a == j->homo.a);
xbt_assert(i->homo.b == j->homo.b);
xbt_assert(i->homo.c == j->homo.c);
write_read(gras_datadesc_by_name("chained_list_t*"),
&i,&j, sock,direction);
- if (direction == READ || direction == RW) {
+ if (direction == READ || direction == RW || direction == COPY) {
xbt_assert(list_eq(i,j));
list_free(j);
}
void test_graph(gras_socket_t sock, int direction) {
chained_list_t *i, *j;
- INFO0("---- Test on graph (cyclique chained list) ----");
+ INFO0("---- Test on graph (cyclique chained list of 3 items) ----");
/* init a value, exchange it and check its validity*/
i = cons( 1151515, cons( -232362 , cons( 222552, NULL)));
i->l->l->l = i;
gras_datadesc_cycle_set(gras_datadesc_by_name("chained_list_t*"));
write_read(gras_datadesc_by_name("chained_list_t*"),
&i,&j, sock,direction);
- if (direction == READ || direction == RW) {
+ if (direction == READ || direction == RW || direction == COPY) {
DEBUG1("i=%p" ,i);
DEBUG1("i->l=%p" ,i->l);
}
write_read(my_type, &i,&j, sock, direction);
- if (direction == READ || direction == RW) {
+ if (direction == READ || direction == RW || direction == COPY) {
for (cpt=0; cpt< 64; cpt++) {
sprintf(buf,"%d",cpt);
xbt_dynar_shift(j,&s2);
}
write_read(gras_datadesc_by_symbol(s_pbio),
&i,&j, sock,direction);
- if (direction == READ || direction == RW) {
+ if (direction == READ || direction == RW || direction == COPY) {
/* Check that the data match */
xbt_assert(i.Cnstatv == j.Cnstatv);
for (cpt=0; cpt<12; cpt++)
ddt=gras_datadesc_ref("Clause*",ddt);
write_read(ddt, &i,&j, sock,direction);
- if (direction == READ || direction == RW) {
+ 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(i);
}
+#ifdef __BORLANDC__
+#pragma argsused
+#endif
+
int main(int argc,char *argv[]) {
- gras_socket_t sock;
+ gras_socket_t sock=NULL;
int direction = RW;
int cpt;
char r_arch_char = gras_arch_selfid();
direction = READ;
} else if (!strcmp(argv[cpt], "--write")) {
direction = WRITE;
+ } else if (!strcmp(argv[cpt], "--copy")) {
+ direction = COPY;
} else {
filename=argv[cpt];
}
test_float(sock,direction);
test_double(sock,direction);
test_array(sock,direction);
- test_dynar_scal(sock,direction);
test_intref(sock,direction);
-
+
test_string(sock,direction);
+ test_dynar_scal(sock,direction);
test_structures(sock,direction);
test_clause(sock,direction);
- if (direction != RW)
+ if (direction != RW && direction != COPY)
gras_socket_close(sock);
gras_exit();
return 0;