chiark / gitweb /
+ * Call Tensurerecordfile in Hgettimeofday (Tensurerecordfile was
authorian <ian>
Sat, 15 Oct 2005 16:29:58 +0000 (16:29 +0000)
committerian <ian>
Sat, 15 Oct 2005 16:29:58 +0000 (16:29 +0000)
@@ -11,6 +11,11 @@
     updated).
+  * Call Tensurerecordfile in Hgettimeofday (Tensurerecordfile was
+    Tensureinputfile/Tensureoutputfile).
+  * Add bind(2) and listen(2) to test harness (for epithet's benefit, but
+    harmless in adns).
+  * Add missing ENOTSOCK to hcommon.c.m4 (was already in hcommon.c!)

12 files changed:
changelog
regress/harness.h
regress/harness.h.m4
regress/hcommon.c
regress/hcommon.c.m4
regress/hplayback.c
regress/hplayback.c.m4
regress/hrecord.c
regress/hrecord.c.m4
regress/hredirect.h
regress/hsyscalls.h
regress/hsyscalls.i4

index 04f2bce075e0d9fc620ddb0c471bb8c38745e524..058436de13707701688f6a9d71d61489c3a0bd81 100644 (file)
--- a/changelog
+++ b/changelog
@@ -11,6 +11,11 @@ adns (1.2); urgency=medium
     updated).
   * Add documentation comment by definition of adns_r_ptr_raw type enum.
   * Add -Wno-pointer-sign if GCC has that option.
+  * Call Tensurerecordfile in Hgettimeofday (Tensurerecordfile was
+    Tensureinputfile/Tensureoutputfile).
+  * Add bind(2) and listen(2) to test harness (for epithet's benefit, but
+    harmless in adns).
+  * Add missing ENOTSOCK to hcommon.c.m4 (was already in hcommon.c!)
 
  --
 
index 2708e66688efccd7bdace2fcc4bfe05f054eb10f..3bcccf9b30af366b3507524ae1015bf375e8d708 100644 (file)
@@ -13,6 +13,8 @@ void Qpoll(   const struct pollfd *fds , int nfds , int timeout       );
 void Qsocket(   int type       );
 void Qfcntl(   int fd , int cmd , long arg     );
 void Qconnect( int fd , const struct sockaddr *addr , int addrlen      );
+void Qbind(    int fd , const struct sockaddr *addr , int addrlen      );
+void Qlisten(  int fd , int backlog    );
 void Qclose(   int fd  );
 void Qsendto(  int fd , const void *msg , int msglen , const struct sockaddr *addr , int addrlen       );
 void Qrecvfrom(        int fd , int buflen , int addrlen       );
@@ -25,7 +27,7 @@ void Tfailed(const char *why);
 void Toutputerr(void);
 void Tnomem(void);
 void Tfsyscallr(const char *fmt, ...) PRINTFFORMAT(1,2);
-void Tensureoutputfile(void);
+void Tensurerecordfile(void);
 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);
index a25bd37ee79dbff73f99c45d9d4c28d276dcf4cc..fca588d263a8e8ba63e8601c9e1560a00f67b320 100644 (file)
@@ -51,7 +51,7 @@ void Tfailed(const char *why);
 void Toutputerr(void);
 void Tnomem(void);
 void Tfsyscallr(const char *fmt, ...) PRINTFFORMAT(1,2);
-void Tensureoutputfile(void);
+void Tensurerecordfile(void);
 void Tmust(const char *call, const char *arg, int cond);
 
 void Tvbf(const char *fmt, ...) PRINTFFORMAT(1,2);
index 4a6293ae4fad5a14ba639375bf82e2728c28c740..3466ec98025648f29faff2be6bace386885734a7 100644 (file)
@@ -34,6 +34,7 @@ const struct Terrno Terrnos[]= {
 };
 static vbuf vbw;
 int Hgettimeofday(struct timeval *tv, struct timezone *tz) {
+  Tensurerecordfile();
   Tmust("gettimeofday","tz",!tz);
   *tv= currenttime;
   return 0;
@@ -92,6 +93,20 @@ void Qconnect(       int fd , const struct sockaddr *addr , int addrlen      ) {
        Tvba(" addr="); Tvbaddr(addr,addrlen); 
   Q_vb();
 }
+void Qbind(    int fd , const struct sockaddr *addr , int addrlen      ) {
+ vb.used= 0;
+ Tvba("bind");
+       Tvbf(" fd=%d",fd); 
+       Tvba(" addr="); Tvbaddr(addr,addrlen); 
+  Q_vb();
+}
+void Qlisten(  int fd , int backlog    ) {
+ vb.used= 0;
+ Tvba("listen");
+       Tvbf(" fd=%d",fd); 
+       Tvbf(" backlog=%d",backlog); 
+  Q_vb();
+}
 void Qclose(   int fd  ) {
  vb.used= 0;
  Tvba("close");
index 68127bea0ba3099ca0374990c9117e2119991fa7..17f6955a84cc122c3593799a733dc2b1c3907284 100644 (file)
@@ -61,12 +61,14 @@ const struct Terrno Terrnos[]= {
   { "ECONNRESET",                ECONNRESET                   },
   { "ECONNREFUSED",              ECONNREFUSED                 },
   { "EPIPE",                     EPIPE                        },
+  { "ENOTSOCK",                  ENOTSOCK                     },
   {  0,                          0                            }
 };
 
 static vbuf vbw;
 
 int Hgettimeofday(struct timeval *tv, struct timezone *tz) {
+  Tensurerecordfile();
   Tmust("gettimeofday","tz",!tz);
   *tv= currenttime;
   return 0;
index fdb3a7d307e17eecf699d30fa8ceec9e9b174e29..594f7e60decc9f68c6a302bf59e77d9edf0bdeb7 100644 (file)
@@ -32,7 +32,7 @@ static void Pcheckinput(void) {
   if (ferror(Tinputfile)) Tfailed("read test log input file");
   if (feof(Tinputfile)) Psyntax("eof at syscall reply");
 }
-static void Tensureinputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd;
   int chars;
@@ -196,7 +196,7 @@ static int Pbytes(byte *buf, int maxlen) {
 void Q_vb(void) {
   int r;
   const char *nl;
-  Tensureinputfile();
+  Tensurerecordfile();
   if (!adns__vbuf_ensure(&vb2,vb.used+2)) Tnomem();
   r= fread(vb2.buf,1,vb.used+2,Tinputfile);
   if (feof(Tinputfile)) {
@@ -385,6 +385,60 @@ int Hconnect(      int fd , const struct sockaddr *addr , int addrlen      ) {
  P_updatetime();
  return r;
 }
+int Hbind(     int fd , const struct sockaddr *addr , int addrlen      ) {
+ int r, amtread;
+ Qbind(        fd , addr , addrlen     );
+ if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
+ fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
+ Tensurereportfile();
+ fprintf(Treportfile,"%s",vb2.buf);
+ amtread= strlen(vb2.buf);
+ if (amtread<=0 || vb2.buf[--amtread]!='\n')
+  Psyntax("badly formed line");
+ vb2.buf[amtread]= 0;
+ if (memcmp(vb2.buf," bind=",6)) Psyntax("syscall reply mismatch");
+ if (vb2.buf[6] == 'E') {
+  int e;
+  e= Perrno(vb2.buf+6);
+  P_updatetime();
+  errno= e;
+  return -1;
+ }
+  if (memcmp(vb2.buf+6,"OK",2)) Psyntax("success/fail not E* or OK");
+  vb2.used= 6+2;
+  r= 0;
+ assert(vb2.used <= amtread);
+ if (vb2.used != amtread) Psyntax("junk at end of line");
+ P_updatetime();
+ return r;
+}
+int Hlisten(   int fd , int backlog    ) {
+ int r, amtread;
+ Qlisten(      fd , backlog    );
+ if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
+ fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
+ Tensurereportfile();
+ fprintf(Treportfile,"%s",vb2.buf);
+ amtread= strlen(vb2.buf);
+ if (amtread<=0 || vb2.buf[--amtread]!='\n')
+  Psyntax("badly formed line");
+ vb2.buf[amtread]= 0;
+ if (memcmp(vb2.buf," listen=",8)) Psyntax("syscall reply mismatch");
+ if (vb2.buf[8] == 'E') {
+  int e;
+  e= Perrno(vb2.buf+8);
+  P_updatetime();
+  errno= e;
+  return -1;
+ }
+  if (memcmp(vb2.buf+8,"OK",2)) Psyntax("success/fail not E* or OK");
+  vb2.used= 8+2;
+  r= 0;
+ assert(vb2.used <= amtread);
+ if (vb2.used != amtread) Psyntax("junk at end of line");
+ P_updatetime();
+ return r;
+}
 int Hclose(    int fd  ) {
  int r, amtread;
  Qclose(       fd      );
index 3437293d9a71fa651101386e65c3b55c0ad62c33..9fd0780071b7057c7a28064189e8917eb44fefd9 100644 (file)
@@ -69,7 +69,7 @@ static void Pcheckinput(void) {
   if (feof(Tinputfile)) Psyntax("eof at syscall reply");
 }
 
-static void Tensureinputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd;
   int chars;
@@ -261,7 +261,7 @@ void Q_vb(void) {
   int r;
   const char *nl;
 
-  Tensureinputfile();
+  Tensurerecordfile();
   if (!adns__vbuf_ensure(&vb2,vb.used+2)) Tnomem();
   r= fread(vb2.buf,1,vb.used+2,Tinputfile);
   if (feof(Tinputfile)) {
index c60f93c2286c93782a8f1c915e1dcac6187d69e5..88e24a41f48925918a5601747e178098fd2df027 100644 (file)
@@ -12,7 +12,7 @@ void Tshutdown(void) {
 static void R_recordtime(void) {
   int r;
   struct timeval tv, tvrel;
-  Tensureoutputfile();
+  Tensurerecordfile();
   r= gettimeofday(&tv,0); if (r) Tfailed("gettimeofday syscallbegin");
   tvrel.tv_sec= tv.tv_sec - currenttime.tv_sec;
   tvrel.tv_usec= tv.tv_usec - currenttime.tv_usec;
@@ -20,7 +20,7 @@ static void R_recordtime(void) {
   Tvbf("\n +%ld.%06ld",(long)tvrel.tv_sec,(long)tvrel.tv_usec);
   currenttime= tv;
 }
-void Tensureoutputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd, r;
   if (Toutputfile) return;
@@ -36,7 +36,7 @@ void Tensureoutputfile(void) {
 }
 void Q_vb(void) {
   if (!adns__vbuf_append(&vb,"",1)) Tnomem();
-  Tensureoutputfile();
+  Tensurerecordfile();
   if (fprintf(Toutputfile," %s\n",vb.buf) == EOF) Toutputerr();
   if (fflush(Toutputfile)) Toutputerr();
 }
@@ -142,6 +142,36 @@ int Hconnect(      int fd , const struct sockaddr *addr , int addrlen      ) {
  errno= e;
  return r;
 }
+int Hbind(     int fd , const struct sockaddr *addr , int addrlen      ) {
+ int r, e;
+ Qbind(        fd , addr , addrlen     );
+ r= bind(      fd , addr , addrlen     );
+ e= errno;
+ vb.used= 0;
+ Tvba("bind=");
+  if (r) { Tvberrno(e); goto x_error; }
+  Tvba("OK");
+ x_error:
+ R_recordtime();
+ R_vb();
+ errno= e;
+ return r;
+}
+int Hlisten(   int fd , int backlog    ) {
+ int r, e;
+ Qlisten(      fd , backlog    );
+ r= listen(    fd , backlog    );
+ e= errno;
+ vb.used= 0;
+ Tvba("listen=");
+  if (r) { Tvberrno(e); goto x_error; }
+  Tvba("OK");
+ x_error:
+ R_recordtime();
+ R_vb();
+ errno= e;
+ return r;
+}
 int Hclose(    int fd  ) {
  int r, e;
  Qclose(       fd      );
index e5287a0d09a383ece9533a1f3b54bd458b5b8f7c..033796c5c638ab7981bd51334c708dd301fdee1b 100644 (file)
@@ -45,7 +45,7 @@ static void R_recordtime(void) {
   int r;
   struct timeval tv, tvrel;
 
-  Tensureoutputfile();
+  Tensurerecordfile();
   r= gettimeofday(&tv,0); if (r) Tfailed("gettimeofday syscallbegin");
   tvrel.tv_sec= tv.tv_sec - currenttime.tv_sec;
   tvrel.tv_usec= tv.tv_usec - currenttime.tv_usec;
@@ -54,7 +54,7 @@ static void R_recordtime(void) {
   currenttime= tv;
 }
 
-void Tensureoutputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd, r;
 
@@ -74,7 +74,7 @@ void Tensureoutputfile(void) {
 
 void Q_vb(void) {
   if (!adns__vbuf_append(&vb,"",1)) Tnomem();
-  Tensureoutputfile();
+  Tensurerecordfile();
   if (fprintf(Toutputfile," %s\n",vb.buf) == EOF) Toutputerr();
   if (fflush(Toutputfile)) Toutputerr();
 }
index 75506877c65ee222c7dbb810ada17556d2e400e9..fd2fa405116a0ed880a63b6e8a4df9ca84328543 100644 (file)
 #define fcntl Hfcntl
 #undef connect
 #define connect Hconnect
+#undef bind
+#define bind Hbind
+#undef listen
+#define listen Hlisten
 #undef close
 #define close Hclose
 #undef sendto
index 5d87442322241805d30456149ccba0cf4e4a015c..3e886be0a1b24a31f27f0ce62a437b0499a315b4 100644 (file)
@@ -15,6 +15,8 @@ int Hpoll(    struct pollfd *fds , int nfds , int timeout     );
 int Hsocket(   int domain , int type , int protocol    );
 int Hfcntl(    int fd , int cmd , ...  );
 int Hconnect(  int fd , const struct sockaddr *addr , int addrlen      );
+int Hbind(     int fd , const struct sockaddr *addr , int addrlen      );
+int Hlisten(   int fd , int backlog    );
 int Hclose(    int fd  );
 int Hsendto(   int fd , const void *msg , int msglen , unsigned int flags , const struct sockaddr *addr , int addrlen  );
 int Hrecvfrom( int fd , void *buf , int buflen , unsigned int flags , struct sockaddr *addr , int *addrlen     );
index d5a57b75e2ebd7085240cce3cb26531c35aa27ee..6be9556ccd473f9eacc85f7e707a0b2b79f76fa9 100644 (file)
@@ -88,6 +88,18 @@ hm_syscall(
        hm_arg_addr_in(addr,addrlen) hm_na
 ')
 
+hm_syscall(
+       bind, `hm_rv_succfail', `
+       hm_arg_fd(fd) hm_na
+       hm_arg_addr_in(addr,addrlen) hm_na
+')
+
+hm_syscall(
+       listen, `hm_rv_succfail', `
+       hm_arg_fd(fd) hm_na
+       hm_arg_int(backlog) hm_na
+')
+
 hm_syscall(
        close, `hm_rv_succfail', `
        hm_arg_fd(fd) hm_na