+static void Tensure_fuzzrawfile(void) {
+ static int done;
+
+ if (done) return;
+ done++;
+
+ const char *fdstr= getenv("ADNS_TEST_FUZZRAW_DUMP_FD");
+ if (!fdstr) return;
+
+ int fd= atoi(fdstr);
+ Tfuzzrawfile= fdopen(fd,"ab");
+ if (!Tfuzzrawfile) Tfailed("fdopen ADNS_TEST_FUZZRAW_DUMP_FD");
+}
+
+static void FR_write(const void *p, size_t sz) {
+ if (!Tfuzzrawfile) return;
+ ssize_t got = fwrite(p,1,sz,Tfuzzrawfile);
+ if (ferror(Tfuzzrawfile)) Tfailed("write fuzzraw output file");
+ assert(got==sz);
+}
+
+#define FR_WRITE(x) (FR_write(&(x), sizeof((x))))
+
+extern void Tshutdown(void) {
+ adns__vbuf_free(&vb2);
+ if (Tfuzzrawfile) {
+ if (fclose(Tfuzzrawfile)) Tfailed("close fuzzraw output file");
+ }
+}
+