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 59a3bbc..f217dea 100644 (file)
@@ -38,6 +38,8 @@
 
 #ifdef ADNS_REGRESS_TEST
 # include "hredirect.h"
+# undef exit
+# define exit Texit
 #endif
 
 struct myctx {
index a7889c9..47f2007 100644 (file)
@@ -71,3 +71,4 @@
  close fd=6
  close=OK
  +0.000961
+ exit 0
index 90f114f..1a6f4fe 100644 (file)
@@ -57,3 +57,4 @@
  close fd=6
  close=OK
  +0.000149
+ exit 0
index 3e99426..99797d1 100644 (file)
@@ -88,3 +88,4 @@
  close fd=6
  close=OK
  +0.000686
+ exit 0
index fa6cd4b..9283754 100644 (file)
@@ -32,3 +32,4 @@ chiark.greenend.org.uk
  close fd=4
  close=OK
  +0.000290
+ exit 0
index 6e9ec3c..39af36d 100644 (file)
@@ -46,3 +46,4 @@
  close fd=6
  close=OK
  +0.000134
+ exit 0
index a9beaf3..83602eb 100644 (file)
  close fd=6
  close=OK
  +0.000090
+ exit 0
index 4a2ca57..d6cb1f7 100644 (file)
@@ -61,3 +61,4 @@
  close fd=6
  close=OK
  +0.000117
+ exit 0
index dcd7136..8b63bec 100644 (file)
@@ -66,3 +66,4 @@
  close fd=6
  close=OK
  +0.000134
+ exit 0
index 5e03602..a21bb0a 100644 (file)
@@ -48,3 +48,4 @@
  close fd=6
  close=OK
  +0.000091
+ exit 6
index 231c29b..7407b15 100644 (file)
  close fd=6
  close=OK
  +0.006908
+ exit 0
index b7b4120..234f5ef 100644 (file)
@@ -83,3 +83,4 @@
  close fd=6
  close=OK
  +0.004680
+ exit 0
index a54c484..763dbae 100644 (file)
  close fd=6
  close=OK
  +0.000078
+ exit 6
index d44fba5..2d343dd 100644 (file)
  close fd=6
  close=OK
  +0.014060
+ exit 0
index 0a1f593..88ff570 100644 (file)
@@ -64,3 +64,4 @@
  close fd=6
  close=OK
  +0.000187
+ exit 0
index 7a6c122..fc567e5 100644 (file)
@@ -35,3 +35,4 @@
  close fd=6
  close=OK
  +0.002395
+ exit 0
index 4a436c4..5b019f9 100644 (file)
@@ -43,3 +43,4 @@
  close fd=6
  close=OK
  +0.000144
+ exit 0
index eae4206..85a936b 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 bf4f308..f3d04d8 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 301fb2f..0aa3ffb 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 760ca0c..62b2d03 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