X-Git-Url: https://git.distorted.org.uk/~mdw/adns/blobdiff_plain/73c4c523c0fc436ed51e7d473e016d36e9a4b6bd..6a578b2c64660a32ac3d5b53d3d27a4cd358e7ae:/regress/hcommon.c.m4 diff --git a/regress/hcommon.c.m4 b/regress/hcommon.c.m4 index d1f72b7..abd01d3 100644 --- a/regress/hcommon.c.m4 +++ b/regress/hcommon.c.m4 @@ -2,7 +2,12 @@ m4_dnl hcommon.c m4_dnl (part of complex test harness, not of the library) m4_dnl - routines used for both record and playback -m4_dnl This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson +m4_dnl This file is +m4_dnl Copyright (C) 1997-1999 Ian Jackson +m4_dnl +m4_dnl It is part of adns, which is +m4_dnl Copyright (C) 1997-1999 Ian Jackson +m4_dnl Copyright (C) 1999 Tony Finch m4_dnl m4_dnl This program is free software; you can redistribute it and/or modify m4_dnl it under the terms of the GNU General Public License as published by @@ -77,6 +82,7 @@ void Q$1(hm_args_massage($3,void)) { m4_define(`hm_arg_nullptr',`') m4_define(`hm_arg_int', `Tvbf(" $'`1=%d",$'`1);') m4_define(`hm_arg_fdset_io', `Tvbf(" $'`1="); Tvbfdset($'`2,$'`1);') + m4_define(`hm_arg_pollfds_io', `Tvbf(" $'`1="); Tvbpollfds($'`1,$'`2);') m4_define(`hm_arg_timeval_in_rel_null', ` if ($'`1) Tvbf(" $'`1=%ld.%06ld",(long)$'`1->tv_sec,(long)$'`1->tv_usec); else Tvba(" $'`1=null");') @@ -145,12 +151,39 @@ void Tvbfdset(int max, const fd_set *fds) { Tvba("]"); } +static void Tvbpollevents(int events) { + const char *delim= ""; + + events &= (POLLIN|POLLOUT|POLLPRI); + if (!events) { Tvba("0"); return; } + if (events & POLLIN) { Tvba("POLLIN"); delim= "|"; } + if (events & POLLOUT) { Tvba(delim); Tvba("POLLOUT"); delim= "|"; } + if (events & POLLPRI) { Tvba(delim); Tvba("POLLPRI"); } +} + +void Tvbpollfds(const struct pollfd *fds, int nfds) { + const char *comma= ""; + + Tvba("["); + while (nfds>0) { + Tvba(comma); + Tvbf("{fd=%d, events=",fds->fd); + Tvbpollevents(fds->events); + Tvba(", revents="); + Tvbpollevents(fds->revents); + Tvba("}"); + comma= ", "; + nfds--; fds++; + } + Tvba("]"); +} + void Tvberrno(int e) { const struct Terrno *te; for (te= Terrnos; te->n && te->v != e; te++); - if (te->n) Tvba(te->n); - else Tvbf("E#%d",e); + assert(te->n); + Tvba(te->n); } void Tvba(const char *str) {