2
m4_dnl (part of complex test harness, not of the library)
3
m4_dnl - recording routines
6
m4_dnl Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
8
m4_dnl It is part of adns, which is
9
m4_dnl Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
10
m4_dnl Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
12
m4_dnl This program is free software; you can redistribute it and/or modify
13
m4_dnl it under the terms of the GNU General Public License as published by
14
m4_dnl the Free Software Foundation; either version 2, or (at your option)
15
m4_dnl any later version.
17
m4_dnl This program is distributed in the hope that it will be useful,
18
m4_dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
19
m4_dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
m4_dnl GNU General Public License for more details.
22
m4_dnl You should have received a copy of the GNU General Public License
23
m4_dnl along with this program; if not, write to the Free Software Foundation,
24
m4_dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
m4_include(hmacros.i4)
33
#include <sys/types.h>
39
static FILE *Toutputfile;
41
void Tshutdown(void) {
44
static void R_recordtime(void) {
46
struct timeval tv, tvrel;
49
r= gettimeofday(&tv,0); if (r) Tfailed("gettimeofday syscallbegin");
50
tvrel.tv_sec= tv.tv_sec - currenttime.tv_sec;
51
tvrel.tv_usec= tv.tv_usec - currenttime.tv_usec;
52
if (tv.tv_usec < 0) { tvrel.tv_usec += 1000000; tvrel.tv_sec--; }
53
Tvbf("\n +%ld.%06ld",(long)tvrel.tv_sec,(long)tvrel.tv_usec);
57
void Tensureoutputfile(void) {
61
if (Toutputfile) return;
64
fdstr= getenv("ADNS_TEST_OUT_FD");
67
Toutputfile= fdopen(fd,"a"); if (!Toutputfile) Tfailed("fdopen ADNS_TEST_OUT_FD");
70
r= gettimeofday(¤ttime,0); if (r) Tfailed("gettimeofday syscallbegin");
71
if (fprintf(Toutputfile," start %ld.%06ld\n",
72
(long)currenttime.tv_sec,(long)currenttime.tv_usec) == EOF) Toutputerr();
76
if (!adns__vbuf_append(&vb,"",1)) Tnomem();
78
if (fprintf(Toutputfile," %s\n",vb.buf) == EOF) Toutputerr();
79
if (fflush(Toutputfile)) Toutputerr();
82
static void R_vb(void) {
86
m4_define(`hm_syscall', `
88
int H$1(hm_args_massage($3,void)) {
94
hm_create_hqcall_init($1)
98
Q$1(hm_args_massage($3));
100
hm_create_realcall_args
101
r= $1(hm_args_massage($3));
106
m4_define(`hm_rv_any',`
107
if (r==-1) { Tvberrno(e); goto x_error; }
109
m4_define(`hm_rv_fd',`hm_rv_any($'`1)')
110
m4_define(`hm_rv_succfail',`
111
if (r) { Tvberrno(e); goto x_error; }
113
m4_define(`hm_rv_must',`Tmust("$1","return",!r); Tvba("OK");')
114
m4_define(`hm_rv_len',`
115
if (r==-1) { Tvberrno(e); goto x_error; }
116
Tmust("$1","return",r<=$'`1);
118
m4_define(`hm_rv_fcntl',`
119
if (r==-1) { Tvberrno(e); goto x_error; }
120
if (cmd == F_GETFL) {
121
Tvbf(r & O_NONBLOCK ? "O_NONBLOCK|..." : "~O_NONBLOCK&...");
123
if (cmd == F_SETFL) {
124
Tmust("$1","return",!r);
126
Tmust("cmd","F_GETFL/F_SETFL",0);
133
m4_define(`hm_arg_fdset_io',`Tvba(" $'`1="); Tvbfdset($'`2,$'`1);')
134
m4_define(`hm_arg_pollfds_io',`Tvba(" $'`1="); Tvbpollfds($'`1,$'`2);')
135
m4_define(`hm_arg_addr_out',`Tvba(" $'`1="); Tvbaddr($'`1,*$'`2);')
139
m4_define(`hm_arg_bytes_out',`Tvbbytes($'`2,r);')
142
m4_define(`hm_rv_any',`x_error:')
143
m4_define(`hm_rv_fd',`x_error:')
144
m4_define(`hm_rv_succfail',`x_error:')
145
m4_define(`hm_rv_len',`x_error:')
146
m4_define(`hm_rv_fcntl',`x_error:')
147
m4_define(`hm_rv_must',`')
157
m4_define(`hm_specsyscall', `')
159
m4_include(`hsyscalls.i4')