RSS

(root)/fsp/fsplib : /test.c (revision 61)

Line Revision Contents
1 6 #include <stdio.h>
2 #include <assert.h>
3 10 #include <dirent.h>
4 #include <unistd.h>
5 21 #include <stdlib.h>
6 17 #include <sys/stat.h>
7 6 #include "fsplib.h"
8
9 int main (int argc, char *argv[])
10 {
11     int i;
12     FSP_SESSION* s;
13     FSP_PKT p;
14 10     FSP_PKT r;
15     FSP_FILE *f;
16     struct dirent *d;
17     FSP_DIR *dir;
18 21     int port=2000;
19 15     
20     printf("Checking for fsp/udp service\n");
21 10     s=fsp_open_session("localhost",0,NULL);
22     assert(s);
23 13     fsp_close_session(s);
24 21     
25     if(argc>1)
26         port=atoi(argv[1]);
27     printf("Running tests against fspd on localhost %d\n",port);
28     s=fsp_open_session("localhost",port,NULL);
29 6     assert(s);
30 16     s->timeout=9000;
31 12
32 6     p.cmd=FSP_CC_VERSION;
33 7     for(i=0;i<100;i++)
34 6     {
35 10        assert (fsp_transaction(s,&p,&r)==0 );
36 6     }
37 10
38     /* dir list test */
39     dir=fsp_opendir(s,"/");
40     assert(dir);
41
42     while ( (d=fsp_readdir(dir)) != NULL )
43         printf("%s\n",d->d_name);
44
45     fsp_closedir(dir);  
46
47     /* get a file */
48     f=fsp_fopen(s,"system.log","rb");
49     assert(f);
50     while( ( i=fsp_fread(p.buf,1,1000,f) ) )
51         write(1,p.buf,i);
52     fsp_fclose(f);
53
54 13     printf("resends %d, dupes %d, cum. rtt %ld, last rtt %d\n",s->resends,s->dupes,s->rtts/s->trips,s->last_rtt);
55 10     /* bye! */ 
56 13     fsp_close_session(s);
57 6     return 0;
58 }

Loggerhead is a web-based interface for Bazaar branches