X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9189fe94c14ef9e31142d1603a1979ea7e731a0a..fca9cf4b67db62878728b687d0f25fb4492c3932:/testsuite/gras/datadesc_usage.c diff --git a/testsuite/gras/datadesc_usage.c b/testsuite/gras/datadesc_usage.c index 4ef95f85bd..cd20ffcfae 100644 --- a/testsuite/gras/datadesc_usage.c +++ b/testsuite/gras/datadesc_usage.c @@ -6,6 +6,10 @@ /* 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 #include "gras.h" @@ -15,7 +19,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test"); #define READ 0 #define WRITE 1 -#define RW 2 +#define COPY 2 +#define RW 3 int r_arch; const char *filename = "datadesc_usage.out"; @@ -33,7 +38,6 @@ write_read(gras_datadesc_type_t type,void *src, void *dst, 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); @@ -46,6 +50,9 @@ write_read(gras_datadesc_type_t type,void *src, void *dst, if (direction == RW) gras_socket_close(sock); + + if (direction == COPY) + gras_datadesc_memcpy(type, src, dst); } void test_int(gras_socket_t sock, int direction); @@ -76,7 +83,7 @@ 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) { @@ -84,7 +91,7 @@ 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) { @@ -92,7 +99,7 @@ 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); } @@ -112,7 +119,7 @@ void test_array(gras_socket_t sock, int direction) { SIZE); write_read(my_type, &i,&j, sock,direction); - if (direction == READ || direction == RW) { + if (direction == READ || direction == RW || direction == COPY) { for (cpt=0; cptc = -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); @@ -265,7 +272,7 @@ void test_hetestruct(gras_socket_t sock, int direction) { 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); @@ -305,7 +312,7 @@ void test_nestedstruct(gras_socket_t sock, int direction) { 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); @@ -374,7 +381,7 @@ void test_chain_list(gras_socket_t sock, int direction) { 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); } @@ -387,7 +394,7 @@ void test_chain_list(gras_socket_t sock, int direction) { 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; @@ -396,7 +403,7 @@ void test_graph(gras_socket_t sock, int direction) { 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); @@ -444,7 +451,7 @@ void test_dynar_ref(gras_socket_t sock, int direction){ } 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); @@ -518,7 +525,7 @@ void test_pbio(gras_socket_t sock, int direction) { } 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++) @@ -583,7 +590,7 @@ void test_clause(gras_socket_t sock, int direction) { 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; cptnum_lits; cpt++) xbt_assert(i->literals[cpt] == j->literals[cpt]); @@ -595,8 +602,12 @@ void test_clause(gras_socket_t sock, int direction) { 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(); @@ -608,6 +619,8 @@ int main(int argc,char *argv[]) { direction = READ; } else if (!strcmp(argv[cpt], "--write")) { direction = WRITE; + } else if (!strcmp(argv[cpt], "--copy")) { + direction = COPY; } else { filename=argv[cpt]; } @@ -632,10 +645,10 @@ int main(int argc,char *argv[]) { 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); @@ -652,7 +665,7 @@ int main(int argc,char *argv[]) { test_clause(sock,direction); - if (direction != RW) + if (direction != RW && direction != COPY) gras_socket_close(sock); gras_exit(); return 0;