lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1401 - in nss-pam-ldapd: . common compat nslcd nss pam tests

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd commit: r1401 - in nss-pam-ldapd: . common compat nslcd nss pam tests



Author: arthur
Date: Sat Mar 19 16:14:50 2011
New Revision: 1401
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1401

Log:
more tests and general test improvements

Modified:
   nss-pam-ldapd/Makefile.am
   nss-pam-ldapd/common/   (props changed)
   nss-pam-ldapd/compat/   (props changed)
   nss-pam-ldapd/nslcd/   (props changed)
   nss-pam-ldapd/nss/   (props changed)
   nss-pam-ldapd/pam/   (props changed)
   nss-pam-ldapd/tests/   (props changed)
   nss-pam-ldapd/tests/test_expr.c
   nss-pam-ldapd/tests/test_pamcmds.expect   (props changed)
   nss-pam-ldapd/tests/test_tio.c

Modified: nss-pam-ldapd/Makefile.am
==============================================================================
--- nss-pam-ldapd/Makefile.am   Sat Mar 19 16:14:24 2011        (r1400)
+++ nss-pam-ldapd/Makefile.am   Sat Mar 19 16:14:50 2011        (r1401)
@@ -114,7 +114,7 @@
 splint.txt:
        -env LARCH_PATH=/usr/share/splint/lib/ \
            LCLIMPORTDIR=/usr/share/splint/imports/ \
-           splint -checks \
+           splint -checks -mustfreefresh \
                   -warnposix +showsummary +showalluses +hints -namechecks \
                   -globstate -predboolint -mustfreeonly -temptrans -kepttrans \
                   -I. -I$(srcdir) -I$(top_builddir) $(DEFS) -D_REENTRANT 
-DDEBUG \

Modified: nss-pam-ldapd/tests/test_expr.c
==============================================================================
--- nss-pam-ldapd/tests/test_expr.c     Sat Mar 19 16:14:24 2011        (r1400)
+++ nss-pam-ldapd/tests/test_expr.c     Sat Mar 19 16:14:50 2011        (r1401)
@@ -59,8 +59,12 @@
   char buffer[1024];
   assert(expr_parse("$test1",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
   assertstreq(buffer,"foobar");
+  assert(expr_parse("\\$test1",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
+  assertstreq(buffer,"$test1");
   assert(expr_parse("$empty",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
   assertstreq(buffer,"");
+  
assert(expr_parse("$foo1$empty-$foo2",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
+  assertstreq(buffer,"foobar-foobar");
   
assert(expr_parse("${test1}\\$",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
   assertstreq(buffer,"foobar$");
   
assert(expr_parse("${test1:-default}",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
@@ -83,6 +87,9 @@
   assertstreq(buffer,"afoobarbfoobarec");
   
assert(expr_parse("a${test1}b${test2:+${empty:-d$test4}e}c",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
   assertstreq(buffer,"afoobarbdfoobarec");
+  /* these are errors */
+  assert(expr_parse("$&",buffer,sizeof(buffer),expanderfn,NULL)==NULL);
+  assert(expr_parse("${a",buffer,sizeof(buffer),expanderfn,NULL)==NULL);
 }
 
 static void test_buffer_overflow(void)

Modified: nss-pam-ldapd/tests/test_tio.c
==============================================================================
--- nss-pam-ldapd/tests/test_tio.c      Sat Mar 19 16:14:24 2011        (r1400)
+++ nss-pam-ldapd/tests/test_tio.c      Sat Mar 19 16:14:50 2011        (r1401)
@@ -275,6 +275,67 @@
   assertok(pthread_join(wthread,NULL)==0);
 }
 
+/* this test starts a reader and writer and does not write for a while */
+static void test_timeout_reader(void)
+{
+  int sp[2];
+  TFILE *rfp;
+  FILE *wfp;
+  struct timeval timeout;
+  uint8_t buf[20];
+  time_t start,end;
+  /* set up the socket pair */
+  assertok(socketpair(AF_UNIX,SOCK_STREAM,0,sp)==0);
+  /* open the writer */
+  assertok((wfp=fdopen(sp[0],"wb"))!=NULL);
+  /* open the reader */
+  timeout.tv_sec=1;
+  timeout.tv_usec=100000;
+  
assertok((rfp=tio_fdopen(sp[1],&timeout,&timeout,2*1024,4*1024,2*1024,4*1024))!=NULL);
+  /* perform a read */
+  start=time(NULL);
+  assertok(tio_read(rfp,buf,sizeof(buf))!=0);
+  end=time(NULL);
+  assert(end>start);
+  /* close the files */
+  assertok(tio_close(rfp)==0);
+  assertok(fclose(wfp)==0);
+}
+
+/* this test starts a writer and an idle reader */
+static void test_timeout_writer(void)
+{
+  int sp[2];
+  FILE *rfp;
+  TFILE *wfp;
+  int i;
+  struct timeval timeout;
+  uint8_t buf[20];
+  time_t start,end;
+  /* set up the socket pair */
+  assertok(socketpair(AF_UNIX,SOCK_STREAM,0,sp)==0);
+  /* open the reader */
+  assertok((rfp=fdopen(sp[0],"rb"))!=NULL);
+  /* open the writer */
+  timeout.tv_sec=1;
+  timeout.tv_usec=100000;
+  
assertok((wfp=tio_fdopen(sp[1],&timeout,&timeout,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 */
+  start=time(NULL);
+  for (i=0;(i<10000)&&(tio_write(wfp,buf,sizeof(buf))==0);i++);
+  assert(i<10000);
+  end=time(NULL);
+  assert(end>start);
+  /* close the files */
+  assertok(tio_close(wfp)!=0); /* fails because of bufferred data */
+  assertok(fclose(rfp)==0);
+}
+
 /* the main program... */
 int main(int UNUSED(argc),char UNUSED(*argv[]))
 {
@@ -290,5 +351,8 @@
 /*  test_blocks(10,9,10,10); */
   /* set tio_mark() and tio_reset() functions */
   test_reset();
+  /* test timeout functionality */
+  test_timeout_reader();
+  test_timeout_writer();
   return 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