chiark / gitweb /
regression tests: Properly handle adnshost et al exit status
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 19 Feb 2015 00:55:53 +0000 (00:55 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 21 Feb 2015 11:48:38 +0000 (11:48 +0000)
Only adnstest has an exit status which is compatible with the test
harness's ideas.  adnshost, in particular, uses `5' (skipped test) for
something else (worst failure was misconfig).

So we need to have two exit statuses, that of the program and that of
the test harness machinery.  To this end:

* Enhance the syscall emulation of exit to record the exit status as a
  normal syscall argument.  This has to be done slightly ad hoc
  because the hm_hsyscall macro cannot sanely generate nonreturning
  calls.  After this has been recorded, we do the shutdown activities
  as before and exit the test harness with status 0.

* The previous shutdown function (now the core of the exit emulation)
  is made available as Texit.

* adnstest (only) has a special test-harness-specific override to use
  the core, so a call to exit is not recorded and instead adnstest's
  exit status is that of the harness.

* Update all adnshost-based test cases to match.  This was done with
  this shell script (run once for each test, as needed):

    #!/bin/sh
    f=$1
    o=${f%.sys}.out
    rc=`sed -n '$s/^rc=//p' $o`
    sed -e '$s/^rc=.*/rc=0/' $o >$o.new
    mv $o.new $o
    echo " exit $rc" >>$f

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
24 files changed:
client/adnstest.c
regress/case-adh-cancel.sys
regress/case-adh-cancel2.sys
regress/case-adh-cancel3.sys
regress/case-adh-norm.sys
regress/case-adh-pipe.sys
regress/case-arf-norm.sys
regress/case-arf-text.sys
regress/case-dh-ptr-aaaa.sys
regress/case-srvbaddom.out
regress/case-srvbaddom.sys
regress/case-srvha.sys
regress/case-srvok.sys
regress/case-srvqudom.out
regress/case-srvqudom.sys
regress/case-srvsort.sys
regress/case-unknown2.sys
regress/case-unknown33.sys
regress/case-unknown5.sys
regress/harness.h
regress/harness.h.m4
regress/hcommon.c
regress/hcommon.c.m4
regress/sys-rc-convert [new file with mode: 0755]

index 59a3bbc810d335be0faa1634fdf62a8cf65d8743..f217deadaa568b2fa8acc63bbfdabaca3490929d 100644 (file)
@@ -38,6 +38,8 @@
 
 #ifdef ADNS_REGRESS_TEST
 # include "hredirect.h"
+# undef exit
+# define exit Texit
 #endif
 
 struct myctx {
index a7889c9a7ac6fd43b906ff3189a575a856c2eaf0..47f20074290b8d7038ebfc463202daacdca071fa 100644 (file)
@@ -71,3 +71,4 @@
  close fd=6
  close=OK
  +0.000961
+ exit 0
index 90f114f6c5aa9b2060ada2e6d2852eae9bffcb95..1a6f4fe008553ff9650167893ecd23ebdaac2a47 100644 (file)
@@ -57,3 +57,4 @@
  close fd=6
  close=OK
  +0.000149
+ exit 0
index 3e99426abda877f4647c476af8fc89295d60b81b..99797d1a471a7bc6da0aad72d22be2c1d3fb8978 100644 (file)
@@ -88,3 +88,4 @@
  close fd=6
  close=OK
  +0.000686
+ exit 0
index fa6cd4be216cc25acf9c5fb60bd951a08ec20ab2..928375408686b93fb1d10375648cfb5dec99027c 100644 (file)
@@ -32,3 +32,4 @@ chiark.greenend.org.uk
  close fd=4
  close=OK
  +0.000290
+ exit 0
index 6e9ec3c976d1e8fe956db047b84396ff9100c702..39af36d4749f03973ba6120056e97e673fdcfaf9 100644 (file)
@@ -46,3 +46,4 @@
  close fd=6
  close=OK
  +0.000134
+ exit 0
index a9beaf32c2483b1f79a77e9c18ec848922dc4f3c..83602eb17689f3c3814a7d20f38389e39b72325a 100644 (file)
  close fd=6
  close=OK
  +0.000090
+ exit 0
index 4a2ca5749ee8861bcea502b1d0ce601c1d3e21d6..d6cb1f7d79795118cb9839ec9d0a034195ac5d07 100644 (file)
@@ -61,3 +61,4 @@
  close fd=6
  close=OK
  +0.000117
+ exit 0
index dcd7136e1a12811aa6e204ab7adf09f0715926c9..8b63bec9458855f7f7dcb2613b4bf08be011a99d 100644 (file)
@@ -66,3 +66,4 @@
  close fd=6
  close=OK
  +0.000134
+ exit 0
index ef5105e001f772c0d71b31155a3aec0bf163efff..ab3f8d1909b1cebec53d57df7ddbd7a7eb0220ef 100644 (file)
@@ -1 +1 @@
-rc=6
+rc=0
index 5e03602fa51d4a65d8c259e6d5884f46e17f9343..a21bb0aff4738c7395d60c47b59cd4b9c54bc176 100644 (file)
@@ -48,3 +48,4 @@
  close fd=6
  close=OK
  +0.000091
+ exit 6
index 231c29b79f6f35d35c132273e4e8794ca08b3244..7407b15391b9dd5580d106c9500fb1632ec206a7 100644 (file)
  close fd=6
  close=OK
  +0.006908
+ exit 0
index b7b4120e11b8f648d56b9c1f0d46d3c55d77fead..234f5efa9b7fff6f3661a2e7c2d2b062fa23b074 100644 (file)
@@ -83,3 +83,4 @@
  close fd=6
  close=OK
  +0.004680
+ exit 0
index ef5105e001f772c0d71b31155a3aec0bf163efff..ab3f8d1909b1cebec53d57df7ddbd7a7eb0220ef 100644 (file)
@@ -1 +1 @@
-rc=6
+rc=0
index a54c484539f0a39de1ac2063351a001c6dc995be..763dbae6cad28d56db4da9d698968e438ff71753 100644 (file)
  close fd=6
  close=OK
  +0.000078
+ exit 6
index d44fba5ffe7d3b80d290f2d47e7a58b171b90858..2d343dd6900a5900d36bb6d8931b0d175820cdfb 100644 (file)
  close fd=6
  close=OK
  +0.014060
+ exit 0
index 0a1f5934c4479c56b79d6e6abe6dcdd26f538aa2..88ff57012fa96ce651470aa636a2cbd75b207fe3 100644 (file)
@@ -64,3 +64,4 @@
  close fd=6
  close=OK
  +0.000187
+ exit 0
index 7a6c122fcbf65bb6df0d860f8d2114af7fc1960c..fc567e54f08a7ee19d5c33444963107d9bccebd7 100644 (file)
@@ -35,3 +35,4 @@
  close fd=6
  close=OK
  +0.002395
+ exit 0
index 4a436c49393f6ff6029519f24eeaa9abf8aa7b01..5b019f9f5907c13ca5936f2486471059a70043da 100644 (file)
@@ -43,3 +43,4 @@
  close fd=6
  close=OK
  +0.000144
+ exit 0
index eae42068f4a477dfa97b1ef18f2762b732c04a8d..85a936b684dd22ad163677631471d8294f4cbbc6 100644 (file)
@@ -41,4 +41,6 @@ void Tvba(const char *str);
 extern vbuf vb;
 extern struct timeval currenttime;
 extern const struct Terrno { const char *n; int v; } Terrnos[];
+/* Special cases */
+void Texit(int rv) NONRETURNING;
 #endif
index bf4f308ef3b982aca8fe81a1d3f968c028dd34ee..f3d04d8c1a07f6fe83a0233311eaebe62281e4ce 100644 (file)
@@ -67,5 +67,9 @@ void Tvba(const char *str);
 extern vbuf vb;
 extern struct timeval currenttime;
 extern const struct Terrno { const char *n; int v; } Terrnos[];
+
+/* Special cases */
   
+void Texit(int rv) NONRETURNING;
+
 #endif
index 301fb2f53446fd2596c42b2e14b6b03ad8e8e258..0aa3ffb05e58550310f050f708ed06ebc1b95602 100644 (file)
@@ -289,7 +289,7 @@ void *Hrealloc(void *op, size_t nsz) {
   Hfree(op);
   return np;
 }
-void Hexit(int rv) {
+void Texit(int rv) {
   struct malloced *loopnode;
   Tshutdown();
   adns__vbuf_free(&vb);
@@ -303,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 */
 }
index 760ca0c0bbd4fdd84704b643ab329baa0912b2f8..62b2d03a0f81cc64b53795b7e77fd79d925d230c 100644 (file)
@@ -311,7 +311,7 @@ void *Hrealloc(void *op, size_t nsz) {
   return np;
 }
 
-void Hexit(int rv) {
+void Texit(int rv) {
   struct malloced *loopnode;
 
   Tshutdown();
@@ -327,6 +327,13 @@ 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 */
 }
diff --git a/regress/sys-rc-convert b/regress/sys-rc-convert
new file mode 100755 (executable)
index 0000000..37e60e0
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+f=$1
+o=${f%.sys}.out
+rc=`sed -n '$s/^rc=//p' $o`
+sed -e '$s/^rc=.*/rc=0/' $o >$o.new
+mv $o.new $o
+echo " exit $rc" >>$f