diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2012-11-30 14:43:51 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2012-11-30 14:43:51 +0000 |
commit | 2b09ee086a8a261ca20c1c74757e6e4c68602f89 (patch) | |
tree | 6ec14b11ba34c47fd0b275dcbced46d4323af165 /tests | |
parent | c5597a12b4ba0639620c72aead1b80136252b656 (diff) |
rephrase test to more clearly explain what we're testing and be a little more verbose
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1845 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_tio.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/test_tio.c b/tests/test_tio.c index beb5480..7b1c19b 100644 --- a/tests/test_tio.c +++ b/tests/test_tio.c @@ -302,17 +302,22 @@ static void test_timeout_writer(void) /* open the reader */ assertok((rfp=fdopen(sp[0],"rb"))!=NULL); /* open the writer */ - assertok((wfp=tio_fdopen(sp[1],1100,1100,2*1024,4*1024,2*20,4*20+1))!=NULL); - /* perform a few write (these should be OK because they fill the buffer) */ - assertok(tio_write(wfp,buf,sizeof(buf))==0); - assertok(tio_write(wfp,buf,sizeof(buf))==0); - assertok(tio_write(wfp,buf,sizeof(buf))==0); - assertok(tio_write(wfp,buf,sizeof(buf))==0); - /* one of these should fail but it depends on OS buffers */ + assertok((wfp=tio_fdopen(sp[1],1100,1100, /* fd, readtimeout, writetimeout */ + 2*1024,4*1024, /* read buffer sizes */ + 2*sizeof(buf),4*sizeof(buf)+1 /* write buffer sizes */ + ))!=NULL); + /* we perform a number of writes to the stream to see if they are buffered */ start=time(NULL); - for (i=0;(i<10000)&&(tio_write(wfp,buf,sizeof(buf))==0);i++); - assert(i<10000); + for (i=0;(i<1000)&&(tio_write(wfp,buf,sizeof(buf))==0);i++); end=time(NULL); + printf("test_tio: test_timeout_writer: written %d blocks of %d bytes in %d second(s)\n", + i,(int)sizeof(buf),(int)(end-start)); + /* at the very least 4 writes should be OK because they filled the tio buffer */ + assert(i>=4); + /* but at a certain point the writes should have failed */ + assert(i<1000); + /* since the write timeout is more than a second end time should be bigger + than start time */ assert(end>start); /* close the files */ assertok(tio_close(wfp)!=0); /* fails because of bufferred data */ |