From 841e6defa7971943e853f131df9625e2a4fc7084 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 27 Nov 2016 19:48:04 +0000 Subject: [PATCH] regress: Introduce FUZZRAW_SYNC Signed-off-by: Ian Jackson --- regress/Makefile.in | 1 + regress/hfuzzraw.c.m4 | 13 +++++++++++++ regress/hplayback.c.m4 | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/regress/Makefile.in b/regress/Makefile.in index 36ff10f..d378d23 100644 --- a/regress/Makefile.in +++ b/regress/Makefile.in @@ -34,6 +34,7 @@ include $(srcdir)/../src/adns.make DIRCFLAGS= -I../src -I$(srcdir) -I$(srcdir)/../src HCPPFLAGS= -DADNS_REGRESS_TEST -I. +#HCPPFLAGS+= -DFUZZRAW_SYNC REDIRLIBOBJS= $(addsuffix _d.o, $(basename $(LIBOBJS))) HARNLOBJS= hcommon.o $(REDIRLIBOBJS) diff --git a/regress/hfuzzraw.c.m4 b/regress/hfuzzraw.c.m4 index c2c44cb..16475bf 100644 --- a/regress/hfuzzraw.c.m4 +++ b/regress/hfuzzraw.c.m4 @@ -188,6 +188,13 @@ static void Pfdset(fd_set *set, int max, int *r_io) { } } +#ifdef FUZZRAW_SYNC +static void Psync(const char *exp, char *got, size_t sz, const char *what) { + P_read(got,sz,"syscall"); + if (memcmp(exp,got,sz)) Pformat(what); +} +#endif + #ifdef HAVE_POLL static void Ppollfds(struct pollfd *fds, int nfds, int *r_io) { int fd; @@ -236,6 +243,12 @@ int H$1(hm_args_massage($3,void)) { Q$1(hm_args_massage($3)); } +#ifdef FUZZRAW_SYNC + static const char sync_expect[]= "$1"; + static char sync_got[sizeof(sync_expect)]; + Psync(sync_expect, sync_got, sizeof(sync_got), "sync lost: exp=$1"); +#endif + m4_define(`hm_rv_succfail',` r= P_succfail(); if (r<0) return r; diff --git a/regress/hplayback.c.m4 b/regress/hplayback.c.m4 index 26660d0..96da8df 100644 --- a/regress/hplayback.c.m4 +++ b/regress/hplayback.c.m4 @@ -381,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; -- 2.30.2