chiark / gitweb /
regress: Introduce FUZZRAW_SYNC
[adns.git] / regress / hplayback.c.m4
index f6034cb9fd9c5cec04fb88537637a3cbd10e174f..96da8dfb37fa77e07af48b03a773002233d8de5f 100644 (file)
@@ -70,7 +70,7 @@ static void Tensurefuzzrawfile(void) {
   if (!Tfuzzrawfile) Tfailed("fdopen ADNS_TEST_FUZZRAW_DUMP_FD");
 }
 
-static void FR_write(void *p, size_t sz) {
+static void FR_write(const void *p, size_t sz) {
   if (!Tfuzzrawfile) return;
   ssize_t got = fwrite(p,1,sz,Tfuzzrawfile);
   if (ferror(Tfuzzrawfile)) Tfailed("write fuzzraw output file");
@@ -101,6 +101,7 @@ void T_gettimeofday_hook(void) {
   struct timeval delta;
   memset(&delta,0,sizeof(delta));
   timersub(&currenttime, &previously, &delta);
+  previously = currenttime;
   FR_WRITE(delta);
 }
 
@@ -205,6 +206,20 @@ static void Pfdset(fd_set *set, int max) {
     if (c == hm_squote]hm_squote) break;
     if (c != hm_squote,hm_squote) Psyntax("fd set separator not ,");
   }
+
+  uint16_t accum;
+  int inaccum=0, fd;
+  for (fd=0; ; fd++) {
+    if (fd>=max || inaccum==16) {
+      FR_WRITE(accum);
+      inaccum= 0;
+    }
+    if (fd>=max)
+      break;
+    accum <<= 1;
+    accum |= !!FD_ISSET(fd,set);
+    inaccum++;
+  }
 }
 
 #ifdef HAVE_POLL
@@ -366,6 +381,10 @@ int H$1(hm_args_massage($3,void)) {
  vb2.buf[amtread]= 0;
  if (memcmp(vb2.buf," $1=",hm_r_offset)) Psyntax("syscall reply mismatch");
 
+#ifdef FUZZRAW_SYNC
+ FR_WRITE("$1");
+#endif
+
  m4_define(`hm_rv_check_errno',`
  if (vb2.buf[hm_r_offset] == hm_squoteEhm_squote) {
   int e;
@@ -423,7 +442,7 @@ int H$1(hm_args_massage($3,void)) {
       Psyntax("fcntl flags not O_NONBLOCK|... or ~O_NONBLOCK&...");
     }
   } else if (cmd == F_SETFL) {
-    hm_rv_succfail
+    hm_rv_check_success
   } else {
     Psyntax("fcntl not F_GETFL or F_SETFL");
   }