chiark / gitweb /
regress: fuzzraw: Provide for ADNS_TEST_FUZZRAW_STDOUT_ENABLE
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Nov 2016 16:32:04 +0000 (16:32 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 11 Jun 2020 15:13:02 +0000 (16:13 +0100)
This generates sort-of-.sys-file output, which is useful for
debugging.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
regress/hfuzzraw.c.m4

index f4892799d6a5971dcff23b3f4ef8ab3b6eca21c5..6ed62da77a87144dda9615b11c75d00501c6efb2 100644 (file)
@@ -47,8 +47,13 @@ static vbuf fdtab;
 #define FDF_NONBLOCK 002u
 
 static FILE *Tinputfile;
+static int stdout_enable;
 
-void Q_vb(void) { abort(); /* we neve called Q_anythig */ }
+void Q_vb(void) {
+  if (!adns__vbuf_append(&vb,"",1)) Tnomem();
+  if (fprintf(stdout," %s\n",vb.buf) == EOF) Toutputerr();
+  if (fflush(stdout)) Toutputerr();
+}
 
 static void Pformat(const char *what) {
   fprintf(stderr,"adns test harness: format error in raw log input file: %s\n",what);
@@ -56,6 +61,9 @@ static void Pformat(const char *what) {
 }
 
 extern void Tshutdown(void) {
+  int c= fgetc(Tinputfile);
+  if (c!=EOF) Pformat("unwanted additional syscall reply data");
+  if (ferror(Tinputfile)) Tfailed("read test log input (at end)");
 }
 
 static void Pcheckinput(void) {
@@ -80,6 +88,9 @@ void Tensurerecordfile(void) {
     const char fdfstd = FDF_OPEN;
     if (!adns__vbuf_append(&fdtab,&fdfstd,1)) Tnomem();
   }
+
+  const char *proutstr= getenv("ADNS_TEST_FUZZRAW_STDOUT_ENABLE");
+  if (proutstr) stdout_enable= atoi(proutstr);
 }
 
 static void P_read(void *p, size_t sz) {
@@ -176,6 +187,11 @@ int H$1(hm_args_massage($3,void)) {
 
  Tensurerecordfile();
 
+ if (stdout_enable) {
+   hm_create_hqcall_args
+   Q$1(hm_args_massage($3));
+ }
+
  m4_define(`hm_rv_succfail',`
   P_READ(r);
   if (r<0 && -r<Tnerrnos) {