chiark / gitweb /
Regression for poll(2).
authorian <ian>
Sun, 11 Jul 1999 19:11:05 +0000 (19:11 +0000)
committerian <ian>
Sun, 11 Jul 1999 19:11:05 +0000 (19:11 +0000)
16 files changed:
regress/Makefile.in
regress/case-poll.err [new file with mode: 0644]
regress/case-poll.out [new file with mode: 0644]
regress/case-poll.sys [new file with mode: 0644]
regress/case-polltimeout.err [new file with mode: 0644]
regress/case-polltimeout.out [new file with mode: 0644]
regress/case-polltimeout.sys [new file with mode: 0644]
regress/harness.h.m4
regress/hcommon.c.m4
regress/hmacros.i4
regress/hplayback.c.m4
regress/hrecord.c.m4
regress/hsyscalls.i4
regress/m1test
regress/r1test
src/event.c

index c67c68280238bcde04b883cfd2a0b1f21ad44eac..606359ace9973e5c2ef6b1ae0222d1c1f567eedc 100644 (file)
@@ -27,7 +27,7 @@ include               $(srcdir)/../src/adns.make
 DIRCFLAGS=     -I$(srcdir)/../src
 
 HCPPFLAGS:= $(foreach F,                       \
-       gettimeofday select                     \
+       gettimeofday select poll                \
        socket fcntl connect close              \
        sendto recvfrom read write writev       \
 , -D$F=H$F)
diff --git a/regress/case-poll.err b/regress/case-poll.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/regress/case-poll.out b/regress/case-poll.out
new file mode 100644 (file)
index 0000000..6953cea
--- /dev/null
@@ -0,0 +1,5 @@
+adns debug: using nameserver 172.18.45.6
+chiark.greenend.org.uk flags 0 type 1 A(-) submitted
+chiark.greenend.org.uk flags 0 type A(-): OK; nrrs=1; cname=$; owner=$; ttl=86400
+ 195.224.76.132
+rc=0
diff --git a/regress/case-poll.sys b/regress/case-poll.sys
new file mode 100644 (file)
index 0000000..ba05521
--- /dev/null
@@ -0,0 +1,34 @@
+default -,p
+:1 chiark.greenend.org.uk
+ start 931719947.391142
+ socket type=SOCK_DGRAM
+ socket=4
+ +0.000208
+ fcntl fd=4 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000087
+ fcntl fd=4 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000066
+ sendto fd=4 addr=172.18.45.6:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000592
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=1 fds=[{fd=4, events=POLLIN, revents=POLLIN}]
+ +0.006530
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     311f8580 00010001 00020002 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001 c00c0001 00010001 51800004 c3e04c84 08677265 656e656e
+     64036f72 6702756b 00000200 01000151 80001103 6e73300a 72656c61 74697669
+     7479c038 c0380002 00010001 51800006 036e7331 c057c053 00010001 00015180
+     0004ac12 2d06c070 00010001 00015180 0004ac12 2d41.
+ +0.001044
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000211
+ close fd=4
+ close=OK
+ +0.000248
diff --git a/regress/case-polltimeout.err b/regress/case-polltimeout.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/regress/case-polltimeout.out b/regress/case-polltimeout.out
new file mode 100644 (file)
index 0000000..a3f7495
--- /dev/null
@@ -0,0 +1,4 @@
+adns debug: using nameserver 172.18.45.36
+chiark.greenend.org.uk flags 0 type 1 A(-) submitted
+chiark.greenend.org.uk flags 0 type A(-): DNS query timed out; nrrs=0; cname=$; owner=$; ttl=604770
+rc=0
diff --git a/regress/case-polltimeout.sys b/regress/case-polltimeout.sys
new file mode 100644 (file)
index 0000000..4e207f0
--- /dev/null
@@ -0,0 +1,135 @@
+noserver -,p
+:1 chiark.greenend.org.uk
+ start 931719968.733439
+ socket type=SOCK_DGRAM
+ socket=4
+ +0.000199
+ fcntl fd=4 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000087
+ fcntl fd=4 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000067
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000790
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009031
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000436
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009093
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000519
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.008993
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000500
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009010
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000486
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009050
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000485
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009014
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000485
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009045
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000451
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009050
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000483
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009042
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000433
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009083
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000521
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009017
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000442
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009058
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000510
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009012
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000436
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.009085
+ sendto fd=4 addr=172.18.45.36:53
+     311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.000514
+ poll fds=[{fd=4, events=POLLIN, revents=0}] timeout=2000
+ poll=0 fds=[{fd=4, events=POLLIN, revents=0}]
+ +2.008998
+ close fd=4
+ close=OK
+ +0.000302
index b9fddb37421518b23f19c438ed5d4e01b9e45441..de29194aa0bbc5b5c8704b2a156cd111e7e32158 100644 (file)
@@ -27,6 +27,7 @@ m4_include(hmacros.i4)
 #include <sys/socket.h>
 #include <sys/uio.h>
 #include <unistd.h>
+#include <sys/poll.h>
 
 #include "internal.h"
 
@@ -62,6 +63,7 @@ void Tmust(const char *call, const char *arg, int cond);
 void Tvbf(const char *fmt, ...) PRINTFFORMAT(1,2);
 void Tvbvf(const char *fmt, va_list al);
 void Tvbfdset(int max, const fd_set *set);
+void Tvbpollfds(const struct pollfd *fds, int nfds);
 void Tvbaddr(const struct sockaddr *addr, int addrlen);
 void Tvbbytes(const void *buf, int len);
 void Tvberrno(int e);
index d1f72b793b8382fe8f8e65cb9dd715a7d059027d..19c7ba421c52fa721afb1122b1fa8b88eb98db9d 100644 (file)
@@ -77,6 +77,7 @@ void Q$1(hm_args_massage($3,void)) {
  m4_define(`hm_arg_nullptr',`')
  m4_define(`hm_arg_int', `Tvbf(" $'`1=%d",$'`1);')
  m4_define(`hm_arg_fdset_io', `Tvbf(" $'`1="); Tvbfdset($'`2,$'`1);')
+ m4_define(`hm_arg_pollfds_io', `Tvbf(" $'`1="); Tvbpollfds($'`1,$'`2);')
  m4_define(`hm_arg_timeval_in_rel_null', `
   if ($'`1) Tvbf(" $'`1=%ld.%06ld",(long)$'`1->tv_sec,(long)$'`1->tv_usec);
   else Tvba(" $'`1=null");')
@@ -145,6 +146,33 @@ void Tvbfdset(int max, const fd_set *fds) {
   Tvba("]");
 }
 
+static void Tvbpollevents(int events) {
+  const char *delim= "";
+
+  events &= (POLLIN|POLLOUT|POLLPRI);
+  if (!events) { Tvba("0"); return; }
+  if (events & POLLIN) { Tvba("POLLIN"); delim= "|"; }
+  if (events & POLLOUT) { Tvba(delim); Tvba("POLLOUT"); delim= "|"; }
+  if (events & POLLPRI) { Tvba(delim); Tvba("POLLPRI"); }
+}
+
+void Tvbpollfds(const struct pollfd *fds, int nfds) {
+  const char *comma= "";
+  
+  Tvba("[");
+  while (nfds>0) {
+    Tvba(comma);
+    Tvbf("{fd=%d, events=",fds->fd);
+    Tvbpollevents(fds->events);
+    Tvba(", revents=");
+    Tvbpollevents(fds->revents);
+    Tvba("}");
+    comma= ", ";
+    nfds--; fds++;
+  }
+  Tvba("]");
+}
+
 void Tvberrno(int e) {
   const struct Terrno *te;
 
index 3194e03fc90970677229345f5decebd158465934..9433b18fb218563f1cb0f5586cfdadba6a11bfc8 100644 (file)
@@ -38,6 +38,7 @@ m4_define(`hm_create_nothing', `
  m4_define(`hm_arg_nullptr', `')
  m4_define(`hm_arg_int', `')
  m4_define(`hm_arg_fdset_io', `')
+ m4_define(`hm_arg_pollfds_io', `')
  m4_define(`hm_arg_timeval_in_rel_null',`')
  m4_define(`hm_arg_must', `')
  m4_define(`hm_arg_socktype',`')
@@ -55,6 +56,7 @@ m4_define(`hm_create_proto_h',`
  m4_define(`hm_arg_nullptr', `$'`1 $'`2')
  m4_define(`hm_arg_int', `int $'`1')
  m4_define(`hm_arg_fdset_io', `fd_set *$'`1')
+ m4_define(`hm_arg_pollfds_io', `struct pollfd *$'`1 hm_comma int $'`2')
  m4_define(`hm_arg_timeval_in_rel_null', `struct timeval *$'`1')
  m4_define(`hm_arg_must', `$'`1 $'`2')
  m4_define(`hm_arg_socktype', `int $'`1')
@@ -71,6 +73,7 @@ m4_define(`hm_create_proto_q',`
  hm_create_proto_h
  m4_define(`hm_arg_nullptr', `')
  m4_define(`hm_arg_fdset_io', `const fd_set *$'`1')
+ m4_define(`hm_arg_pollfds_io', `const struct pollfd *$'`1 hm_comma int $'`2')
  m4_define(`hm_arg_must', `')
  m4_define(`hm_arg_ign', `')
  m4_define(`hm_arg_fcntl_cmd_arg', `int $'`1 hm_comma long $'`2')
@@ -104,6 +107,7 @@ m4_define(`hm_create_realcall_args',`
  m4_define(`hm_arg_nullptr', `0')
  m4_define(`hm_arg_int', `$'`1')
  m4_define(`hm_arg_fdset_io', `$'`1')
+ m4_define(`hm_arg_pollfds_io', `$'`1 hm_comma $'`2')
  m4_define(`hm_arg_timeval_in_rel_null', `$'`1')
  m4_define(`hm_arg_must', `$'`2')
  m4_define(`hm_arg_socktype', `$'`1')
index 5f8b45627d51e104ae44993d9e8b9d954cbbd447..ce295d0b10703eac098f37f40b5b2ccb23308648 100644 (file)
@@ -89,6 +89,20 @@ static void Parg(const char *argname) {
   if (vb2.buf[vb2.used++] != hm_squote=hm_squote) Psyntax("not = after argument name");
 }
 
+static int Pstring_maybe(const char *string) {
+  int l;
+
+  l= strlen(string);
+  if (memcmp(vb2.buf+vb2.used,string,l)) return 0;
+  vb2.used+= l;
+  return 1;
+}
+
+static void Pstring(const char *string, const char *emsg) {
+  if (Pstring_maybe(string)) return;
+  Psyntax(emsg);
+}
+
 static int Perrno(const char *stuff) {
   const struct Terrno *te;
   int r;
@@ -136,6 +150,47 @@ static void Pfdset(fd_set *set, int max) {
   }
 }
 
+static int Ppollfdevents(void) {
+  int events;
+
+  if (Pstring_maybe("0")) return 0;
+  events= 0;
+
+  if (Pstring_maybe("POLLIN")) {
+    events |= POLLIN;
+    if (!Pstring_maybe("|")) return events;
+  }
+
+  if (Pstring_maybe("POLLOUT")) {
+    events |= POLLOUT;
+    if (!Pstring_maybe("|")) return events;
+  }
+
+  Pstring("POLLPRI","pollfdevents PRI?");
+  return events;
+}
+
+static void Ppollfds(struct pollfd *fds, int nfds) {
+  int i;
+  char *ep;
+  const char *comma= "";
+  
+  if (vb2.buf[vb2.used++] != hm_squote[hm_squote) Psyntax("pollfds start not [");
+  for (i=0; i<nfds; i++) {
+    Pstring("{fd=","{fd= in pollfds");
+    fds->fd= strtoul(vb2.buf+vb2.used,&ep,10);
+    vb2.used= ep - (char*)vb2.buf;    
+    Pstring(", events=",", events= in pollfds");
+    fds->events= Ppollfdevents();
+    Pstring(", revents=",", revents= in pollfds");
+    fds->revents= Ppollfdevents();
+    Pstring("}","} in pollfds");
+    Pstring(comma,"separator in pollfds");
+    comma= ", ";
+  }
+  if (vb2.buf[vb2.used++] != hm_squote]hm_squote) Psyntax("pollfds end not ]");
+}
+
 static void Paddr(struct sockaddr *addr, int *lenr) {
   struct sockaddr_in *sa= (struct sockaddr_in*)addr;
   char *p, *ep;
@@ -281,6 +336,7 @@ int H$1(hm_args_massage($3,void)) {
 
  hm_create_nothing
  m4_define(`hm_arg_fdset_io',`Parg("$'`1"); Pfdset($'`1,$'`2);')
+ m4_define(`hm_arg_pollfds_io',`Parg("$'`1"); Ppollfds($'`1,$'`2);')
  m4_define(`hm_arg_addr_out',`Parg("$'`1"); Paddr($'`1,$'`2);')
  $3
  if (vb2.used != vb2.avail) Psyntax("junk at end of line");
index 98a24b7795993876ace3036dfe8c64ff6203f8bb..4344146080dd66bce63db60cdb0f07fce57872e4 100644 (file)
@@ -120,6 +120,7 @@ int H$1(hm_args_massage($3,void)) {
 
  hm_create_nothing
  m4_define(`hm_arg_fdset_io',`Tvba(" $'`1="); Tvbfdset($'`2,$'`1);')
+ m4_define(`hm_arg_pollfds_io',`Tvba(" $'`1="); Tvbpollfds($'`1,$'`2);')
  m4_define(`hm_arg_addr_out',`Tvba(" $'`1="); Tvbaddr($'`1,*$'`2);')
  $3
 
index e81072ad91ef2263bd0e0cf39fff7a2dc23a59c6..ec4b630f39bcfeb6fa0bbc9bcd0e0cd905317306 100644 (file)
@@ -56,6 +56,12 @@ hm_syscall(
        hm_arg_timeval_in_rel_null(to) hm_na
 ')
 
+hm_syscall(
+       poll, `hm_rv_any', `
+        hm_arg_pollfds_io(fds,nfds) hm_na
+       hm_arg_int(timeout) hm_na
+')
+
 hm_syscall(
        socket, `hm_rv_fd', `
        hm_arg_must(int,domain,AF_INET) hm_na
index 81cd024fe6b6bc7e6fd2af7d95615b66aaa7af91..82e94caba6cc2d0929084ad118c90395962f1a13 100755 (executable)
@@ -4,23 +4,28 @@ set -e
 
 if [ $# -lt 3 ]
 then
-       echo >&2 'usage: m1test <name> <initfile> <queryargs>'
+       echo >&2 'usage: m1test <name> <initfile> [<initflags>] <queryargs>'
        exit 1
 fi
 
 case="case-$1"; shift
 initfile="$1"; shift
+
+case "$1" in
+-*)    initflags="$1"; shift
+esac
+
 queryargs="$*"
 
 initstring="`cat init-$initfile.text`"
 
-echo "$initfile" >"$case.sys"
+echo $initfile $initflags >"$case.sys"
 echo "$queryargs" >>"$case.sys"
 
-echo running "hrecord /... $queryargs"
+echo running hrecord $initflags "/... $queryargs"
 set +e
 ADNS_TEST_OUT_FD=3 3>>"$case.sys" >"$case.out" 2>"$case.err" </dev/null \
- ./hrecord "/$initstring" $queryargs
+ ./hrecord $initflags "/$initstring" $queryargs
 rc=$?
 set -e
 
index 3b2bfdf15125a7d8f649228f22d582cd283da481..4d10101bed755283158c74da2f6bf0e5b473fd2a 100755 (executable)
@@ -7,7 +7,7 @@ case="case-$casename"
 ocase="output-$casename"
 
 exec <"$case.sys"
-read initfile
+read initfile initflags
 read queryargs
 
 initstring="`cat init-$initfile.text`"
@@ -16,7 +16,7 @@ rm -f $ocase.*
 
 set +e
 ADNS_TEST_REPORT_FD=3 3>>"$ocase.report" >"$ocase.out" 2>"$ocase.err" \
- ./hplayback "/$initstring" $queryargs
+ ./hplayback $initflags "/$initstring" $queryargs
 rc=$?
 set -e
 
index 1b527a2fff26a414aa5cc4a5cdc2bc04a23572b8..0115e070b287d4d8b3fd7d11c02ee0455ce9f948 100644 (file)
@@ -228,7 +228,6 @@ int adns__pollfds(adns_state ads, struct pollfd pollfds_buf[MAX_POLLFDS]) {
     abort();
   }
   pollfds_buf[1].fd= ads->tcpsocket;
-  pollfds_buf[1].revents= 0;
   return 2;
 }