chiark / gitweb /
regression tests: Properly handle adnshost et al exit status
[adns.git] / regress / hcommon.c
index ebbef9400e4d361dc96c24cbabe2dcec6d54fd33..0aa3ffb05e58550310f050f708ed06ebc1b95602 100644 (file)
@@ -167,6 +167,10 @@ void Tvbbytes(const void *buf, int len) {
 void Tvbfdset(int max, const fd_set *fds) {
   int i;
   const char *comma= "";
+  if (!fds) {
+    Tvba("null");
+    return;
+  }
   Tvba("[");
   for (i=0; i<max; i++) {
     if (!FD_ISSET(i,fds)) continue;
@@ -281,11 +285,11 @@ void *Hrealloc(void *op, size_t nsz) {
   size_t osz;
   if (op) { oldnode= (void*)((char*)op - MALLOCHSZ); osz= oldnode->sz; } else { osz= 0; }
   np= Hmalloc(nsz);
-  memcpy(np,op, osz>nsz ? nsz : osz);
+  if (osz) memcpy(np,op, osz>nsz ? nsz : osz);
   Hfree(op);
   return np;
 }
-void Hexit(int rv) {
+void Texit(int rv) {
   struct malloced *loopnode;
   Tshutdown();
   adns__vbuf_free(&vb);
@@ -299,6 +303,12 @@ void Hexit(int rv) {
   }
   exit(rv);
 }
+void Hexit(int rv) {
+  vb.used= 0;
+  Tvbf("exit %d", rv);
+  Q_vb();
+  Texit(0);
+}
 pid_t Hgetpid(void) {
   return 2264; /* just some number */
 }