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-1999 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)
31 static FILE *Toutputfile;
33 static void R_recordtime(void) {
35 struct timeval tv, tvrel;
38 r= gettimeofday(&tv,0); if (r) Tfailed("gettimeofday syscallbegin");
39 tvrel.tv_sec= tv.tv_sec - currenttime.tv_sec;
40 tvrel.tv_usec= tv.tv_usec - currenttime.tv_usec;
41 if (tv.tv_usec < 0) { tvrel.tv_usec += 1000000; tvrel.tv_sec--; }
42 Tvbf("\n +%ld.%06ld",(long)tvrel.tv_sec,(long)tvrel.tv_usec);
46 void Tensureoutputfile(void) {
50 if (Toutputfile) return;
53 fdstr= getenv("ADNS_TEST_OUT_FD");
56 Toutputfile= fdopen(fd,"a"); if (!Toutputfile) Tfailed("fdopen ADNS_TEST_OUT_FD");
59 r= gettimeofday(¤ttime,0); if (r) Tfailed("gettimeofday syscallbegin");
60 if (fprintf(Toutputfile," start %ld.%06ld\n",
61 (long)currenttime.tv_sec,(long)currenttime.tv_usec) == EOF) Toutputerr();
65 if (!adns__vbuf_append(&vb,"",1)) Tnomem();
67 if (fprintf(Toutputfile," %s\n",vb.buf) == EOF) Toutputerr();
68 if (fflush(Toutputfile)) Toutputerr();
71 static void R_vb(void) {
75 m4_define(`hm_syscall', `
77 int H$1(hm_args_massage($3,void)) {
83 hm_create_hqcall_init($1)
87 Q$1(hm_args_massage($3));
89 hm_create_realcall_args
90 r= $1(hm_args_massage($3));
95 m4_define(`hm_rv_any',`
96 if (r==-1) { Tvberrno(e); goto x_error; }
98 m4_define(`hm_rv_fd',`hm_rv_any($'`1)')
99 m4_define(`hm_rv_succfail',`
100 if (r) { Tvberrno(e); goto x_error; }
102 m4_define(`hm_rv_must',`Tmust("$1","return",!r); Tvba("OK");')
103 m4_define(`hm_rv_len',`
104 if (r==-1) { Tvberrno(e); goto x_error; }
105 Tmust("$1","return",r<=$'`1);
107 m4_define(`hm_rv_fcntl',`
108 if (r==-1) { Tvberrno(e); goto x_error; }
109 if (cmd == F_GETFL) {
110 Tvbf(r & O_NONBLOCK ? "O_NONBLOCK|..." : "~O_NONBLOCK&...");
112 if (cmd == F_SETFL) {
113 Tmust("$1","return",!r);
115 Tmust("cmd","F_GETFL/F_SETFL",0);
122 m4_define(`hm_arg_fdset_io',`Tvba(" $'`1="); Tvbfdset($'`2,$'`1);')
123 m4_define(`hm_arg_pollfds_io',`Tvba(" $'`1="); Tvbpollfds($'`1,$'`2);')
124 m4_define(`hm_arg_addr_out',`Tvba(" $'`1="); Tvbaddr($'`1,*$'`2);')
128 m4_define(`hm_arg_bytes_out',`Tvbbytes($'`2,r);')
131 m4_define(`hm_rv_any',`x_error:')
132 m4_define(`hm_rv_fd',`x_error:')
133 m4_define(`hm_rv_succfail',`x_error:')
134 m4_define(`hm_rv_len',`x_error:')
135 m4_define(`hm_rv_fcntl',`x_error:')
136 m4_define(`hm_rv_must',`')
146 m4_include(`hsyscalls.i4')