#include #include #include #include "gm.h" #include "rio.h" #define __int64 long long int rio_write( char *name, void *addr, unsigned bytes, __int64 offset ); int rio_read( char *name, void *addr, unsigned bytes, __int64 offset ); void rio_start( unsigned port,FILE *log ); int rio_ping( char *name ); double getmillis_(); /*---------------------------------------------------------------------------- * Test rio: program params are: * pathname nbytes */ int main( int argc, char **argv ) { int ibase; int nint,n,i,err; int *buf, nbad; double t0,t1; char *name; setbuf(stderr,NULL); if ( argc < 2 ) { fprintf(stderr,"Usage: %s pathname [nbytes]\n",argv[0] ); exit(1); } name= argv[1]; if ( argc >= 3 ) nint= atoi(argv[2]); else nint= 102400; fprintf(stderr,"****Test of %d word transfers\n", nint ); rio_start(GMCLIENTPORT,stderr); if ( rio_ping( name ) ) { /* fprintf(stderr,"server pings\n"); */ } else { fprintf(stderr,"server does not reply\n"); exit(1); } n= sizeof(int)*nint; buf= (int*)malloc( n ); /* use random (but repeatable for same size xfer) data */ #if 1 srand( n ); ibase= rand()%10000; /* random offset */ #else ibase= 0; #endif if ( argc ==4 ) goto skipwrite; for(i=0;i 10 ) break; } fprintf(stderr,"looks %s to me!\n", (nbad==0)?"GOOD":"BAD" ); fprintf(stderr," read buffer is: %d %d %d %d %d...\n", buf[0],buf[1],buf[2],buf[3],buf[4] ); n= nint-1; fprintf(stderr," and at the end (%d), %d %d %d %d %d\n",n, buf[n-4],buf[n-3],buf[n-2],buf[n-1],buf[n] ); return 0; }