X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=regress%2Fhcommon.c.m4;h=19c7ba421c52fa721afb1122b1fa8b88eb98db9d;hb=04e7fb4d97434b04dfc25c79fd0ceec8d76c38ac;hp=4c1af7c1141539f0d33df5e2a86ea3b4a37e2247;hpb=bb7ba6773439e5bf3dfcc2779783a09906176550;p=adns.git diff --git a/regress/hcommon.c.m4 b/regress/hcommon.c.m4 index 4c1af7c..19c7ba4 100644 --- a/regress/hcommon.c.m4 +++ b/regress/hcommon.c.m4 @@ -2,7 +2,7 @@ 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, 1998 Ian Jackson +m4_dnl This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson 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 @@ -33,6 +33,7 @@ m4_include(hmacros.i4) vbuf vb; FILE *Toutputfile= 0; +struct timeval currenttime; const struct Terrno Terrnos[]= { { "EAGAIN", EAGAIN }, @@ -48,8 +49,23 @@ const struct Terrno Terrnos[]= { { 0, 0 } }; +static vbuf vbw; +int Hgettimeofday(struct timeval *tv, struct timezone *tz) { + Tmust("gettimeofday","tz",!tz); + *tv= currenttime; + return 0; +} +int Hwritev(int fd, const struct iovec *vector, size_t count) { + size_t i; + + vbw.used= 0; + for (i=0; iiov_base,vector->iov_len)) Tnomem(); + } + return Hwrite(fd,vbw.buf,vbw.used); +} m4_define(`hm_syscall', ` hm_create_proto_q @@ -61,6 +77,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");') @@ -71,16 +88,22 @@ void Q$1(hm_args_massage($3,void)) { m4_define(`hm_arg_fd', `Tvbf(" $'`1=%d",$'`1);') m4_define(`hm_arg_fcntl_cmd_arg', ` if ($'`1 == F_SETFL) { - Tvbf(" $'`1=F_SETFL %ld",arg); - } else { + Tvbf(" $'`1=F_SETFL %s",arg & O_NONBLOCK ? "O_NONBLOCK|..." : "~O_NONBLOCK&..."); + } else if ($'`1 == F_GETFL) { Tvba(" $'`1=F_GETFL"); + } else { + Tmust("$'`1","F_GETFL/F_SETFL",0); }') - m4_define(`hm_arg_addr_in', `Tvbaddr($'`1,$'`2);') - m4_define(`hm_arg_bytes_in', `Tvbbytes($'`2,$'`4);') + m4_define(`hm_arg_addr_in', `Tvba(" $'`1="); Tvbaddr($'`1,$'`2);') + m4_define(`hm_arg_bytes_in', `') m4_define(`hm_arg_bytes_out', `Tvbf(" $'`4=%lu",(unsigned long)$'`4);') m4_define(`hm_arg_addr_out', `Tvbf(" *$'`2=%d",$'`2);') $3 + hm_create_nothing + m4_define(`hm_arg_bytes_in', `Tvbbytes($'`2,$'`4);') + $3 + Q_vb(); } ') @@ -106,6 +129,7 @@ void Tvbbytes(const void *buf, int len) { else if (!(i&3)) Tvba(" "); Tvbf("%02x",*bp); } + Tvba("."); } void Tvbfdset(int max, const fd_set *fds) { @@ -122,6 +146,33 @@ 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; @@ -169,8 +220,3 @@ void Tnomem(void) { void Toutputerr(void) { Tfailed("write error on test harness output"); } - -void Tensureoutputfile(void) { - /* fixme: allow sending it elsewhere */ - Toutputfile= stdout; -}