chiark / gitweb /
regress: fuzz: Fix check1fuzz and Makefile
[adns.git] / regress / hfuzzraw.c.m4
index 1f76f0ee2de7c7292cd18d61275cbc2e1cb80701..5ce1b3efc92567cb8e01de6288667652ee12714b 100644 (file)
@@ -46,9 +46,8 @@ static vbuf fdtab;
 #define FDF_OPEN     001u
 #define FDF_NONBLOCK 002u
 
-static FILE *Tinputfile;
+static FILE *Tinputfile, *traceout;
 static int traceprint;
-#define traceout stdout
 
 static void Tflushtrace( void) {
   if (fflush(traceout)) Toutputerr();
@@ -73,7 +72,13 @@ void Tensuresetup(void) {
   }
 
   const char *traceprintstr= getenv("ADNS_TEST_FUZZRAW_TRACEPRINT");
-  if (traceprintstr) traceprint= atoi(traceprintstr);
+  if (traceprintstr) {
+    traceprint= atoi(traceprintstr);
+    int tracefd= dup(2);
+    if (tracefd<0) Tfailed("dup for tracefd");
+    traceout= fdopen(tracefd,"w");
+    if (!traceout) Tfailed("fdopen for traceout");
+  }
 }
 
 void Q_vb(void) {
@@ -89,6 +94,7 @@ static void Pformat(const char *what) {
 }
 
 extern void Tshutdown(void) {
+  if (!Tinputfile) return;
   int c= fgetc(Tinputfile);
   if (c!=EOF) Pformat("unwanted additional syscall reply data");
   if (ferror(Tinputfile)) Tfailed("read test log input (at end)");
@@ -201,7 +207,7 @@ m4_define(`syscall_sync',`
 #ifdef FUZZRAW_SYNC
   hm_fr_syscall_ident($'`1)
   static char sync_got[sizeof(sync_expect)];
-  Psync(sync_expect, sync_got, sizeof(sync_got), "sync lost: exp=$1");
+  Psync(sync_expect, sync_got, sizeof(sync_got), "sync lost: program did $1");
 #endif
 ')