nss-pam-ldapd commit: r1858 - nss-pam-ldapd/tests
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
nss-pam-ldapd commit: r1858 - nss-pam-ldapd/tests
- From: Commits of the nss-pam-ldapd project <nss-pam-ldapd-commits [at] lists.arthurdejong.org>
- To: nss-pam-ldapd-commits [at] lists.arthurdejong.org
- Reply-to: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Subject: nss-pam-ldapd commit: r1858 - nss-pam-ldapd/tests
- Date: Fri, 14 Dec 2012 15:50:48 +0100 (CET)
Author: arthur
Date: Fri Dec 14 15:50:47 2012
New Revision: 1858
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?revision=1858&view=revision
Log:
also test for correct value of errno on timeout and make read and write timeout
tests consistent
Modified:
nss-pam-ldapd/tests/test_tio.c
Modified: nss-pam-ldapd/tests/test_tio.c
==============================================================================
--- nss-pam-ldapd/tests/test_tio.c Fri Dec 14 15:45:17 2012 (r1857)
+++ nss-pam-ldapd/tests/test_tio.c Fri Dec 14 15:50:47 2012 (r1858)
@@ -272,6 +272,7 @@
FILE *wfp;
uint8_t buf[20];
time_t start,end;
+ int saved_errno;
/* set up the socket pair */
assertok(socketpair(AF_UNIX,SOCK_STREAM,0,sp)==0);
/* open the writer */
@@ -282,11 +283,17 @@
(int)sizeof(buf));
/* perform a read */
start=time(NULL);
+ errno=0;
assertok(tio_read(rfp,buf,sizeof(buf))!=0);
+ saved_errno=errno;
end=time(NULL);
printf("test_tio: test_timeout_reader: read 0 blocks of %d bytes in %d
second(s) (%s)\n",
- (int)sizeof(buf),(int)(end-start),strerror(errno));
+ (int)sizeof(buf),(int)(end-start),strerror(saved_errno));
+ /* since the read timeout is more than a second end time should be bigger
+ than start time */
assert(end>start);
+ /* the error should be timeout */
+ assert(saved_errno==ETIME);
/* close the files */
assertok(tio_close(rfp)==0);
assertok(fclose(wfp)==0);
@@ -302,6 +309,7 @@
uint8_t buf[20];
time_t start,end;
int numblocks=10000;
+ int saved_errno;
/* set up the socket pair */
assertok(socketpair(AF_UNIX,SOCK_STREAM,0,sp)==0);
/* open the reader */
@@ -314,12 +322,13 @@
printf("test_tio: test_timeout_writer: trying to write %d blocks of %d
bytes\n",
numblocks,(int)sizeof(buf));
/* we perform a number of writes to the stream to see if they are buffered */
- errno=0;
start=time(NULL);
+ errno=0;
for (i=0;(i<numblocks)&&(tio_write(wfp,buf,sizeof(buf))==0);i++);
+ saved_errno=errno;
end=time(NULL);
printf("test_tio: test_timeout_writer: written %d blocks of %d bytes in %d
second(s) (%s)\n",
- i,(int)sizeof(buf),(int)(end-start),strerror(errno));
+ i,(int)sizeof(buf),(int)(end-start),strerror(saved_errno));
/* 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 */
@@ -327,6 +336,8 @@
/* since the write timeout is more than a second end time should be bigger
than start time */
assert(end>start);
+ /* the error should be timeout */
+ assert(saved_errno==ETIME);
/* close the files */
assertok(tio_close(wfp)!=0); /* fails because of bufferred data */
assertok(fclose(rfp)==0);
--
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/
- nss-pam-ldapd commit: r1858 - nss-pam-ldapd/tests,
Commits of the nss-pam-ldapd project