2 m4_dnl (part of complex test harness, not of the library)
3 m4_dnl - recording routines
5 m4_dnl This file is part of adns, which is Copyright (C) 1997, 1998 Ian Jackson
7 m4_dnl This program is free software; you can redistribute it and/or modify
8 m4_dnl it under the terms of the GNU General Public License as published by
9 m4_dnl the Free Software Foundation; either version 2, or (at your option)
10 m4_dnl any later version.
12 m4_dnl This program is distributed in the hope that it will be useful,
13 m4_dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 m4_dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 m4_dnl GNU General Public License for more details.
17 m4_dnl You should have received a copy of the GNU General Public License
18 m4_dnl along with this program; if not, write to the Free Software Foundation,
19 m4_dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 m4_include(hmacros.i4)
32 static struct timeval begin;
33 static FILE *Toutputfile;
35 void Tensureoutputfile(void) {
40 fdstr= getenv("ADNS_TEST_OUT_FD"); if (!fdstr) return;
42 Toutputfile= fdopen(fd,"a"); if (!Toutputfile) Tfailed("fdopen ADNS_TEST_OUT_FD");
46 if (!adns__vbuf_append(&vb,"",1)) Tnomem();
48 if (fprintf(Toutputfile," %s\n",vb.buf) == EOF) Toutputerr();
49 if (fflush(Toutputfile)) Toutputerr();
52 static void R_vb(void) {
56 m4_define(`hm_syscall', `
58 int H$1(hm_args_massage($3,void)) {
64 hm_create_hqcall_init($1)
68 Q$1(hm_args_massage($3));
70 hm_create_realcall_args
71 r= $1(hm_args_massage($3));
76 m4_define(`hm_rv_any',`
77 if (r==-1) { Tvberrno(e); goto x_error; }
79 m4_define(`hm_rv_fd',`hm_rv_any($'`1)')
80 m4_define(`hm_rv_succfail',`
81 if (r) { Tvberrno(e); goto x_error; }
83 m4_define(`hm_rv_must',`Tmust("$1","return",!r); Tvba("OK");')
84 m4_define(`hm_rv_len',`
85 if (r==-1) { Tvberrno(e); goto x_error; }
86 Tmust("$1","return",r<=$'`1);
91 m4_define(`hm_arg_fdset_io',`Tvba(" $'`1="); Tvbfdset($'`2,$'`1);')
92 m4_define(`hm_arg_addr_out',`Tvba(" $'`1="); Tvbaddr($'`1,*$'`2);')
93 m4_define(`hm_arg_timeval_out_abs',`
95 Tvbf(" $'`1=%ld.%06ld",$'`1->tv_sec,$'`1->tv_usec);
100 diff.tv_sec= $'`1->tv_sec - begin.tv_sec;
101 diff.tv_usec= $'`1->tv_usec - begin.tv_usec;
102 if (diff.tv_usec < 0) {
104 diff.tv_usec += 1000000;
106 assert(diff.tv_sec >= 0);
107 assert(diff.tv_usec >= 0);
108 Tvbf(" $'`1=+%ld.%06ld",diff.tv_sec,diff.tv_usec);
113 m4_define(`hm_arg_bytes_out',`Tvbbytes($'`2,r);')
116 m4_define(`hm_rv_any',`x_error:')
117 m4_define(`hm_rv_fd',`x_error:')
118 m4_define(`hm_rv_succfail',`x_error:')
119 m4_define(`hm_rv_len',`x_error:')
120 m4_define(`hm_rv_must',`')
129 m4_include(`hsyscalls.i4')