chiark / gitweb /
regress: fuzzraw: Provide a dictionary
[adns.git] / regress / hfuzzraw.c.m4
index 1f76f0ee2de7c7292cd18d61275cbc2e1cb80701..b2e82fd01663c3fd6f700b9242461204fa96d731 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
 ')
 
@@ -302,6 +308,10 @@ int H$1(hm_args_massage($3,void)) {
     r= newfd;
  }
  ')
+ m4_define(`hm_rv_wlen',`
+  hm_rv_any
+  if (r>$'`1) Pformat("write return value too large");
+ ')
  $2
 
  hm_create_nothing