From e7308d2612173a14b26f797ae3aca830859ea3bf Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 19 Feb 2015 00:55:53 +0000 Subject: [PATCH] regression tests: Properly handle adnshost et al exit status 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 --- client/adnstest.c | 2 ++ regress/case-adh-cancel.sys | 1 + regress/case-adh-cancel2.sys | 1 + regress/case-adh-cancel3.sys | 1 + regress/case-adh-norm.sys | 1 + regress/case-adh-pipe.sys | 1 + regress/case-arf-norm.sys | 1 + regress/case-arf-text.sys | 1 + regress/case-dh-ptr-aaaa.sys | 1 + regress/case-srvbaddom.out | 2 +- regress/case-srvbaddom.sys | 1 + regress/case-srvha.sys | 1 + regress/case-srvok.sys | 1 + regress/case-srvqudom.out | 2 +- regress/case-srvqudom.sys | 1 + regress/case-srvsort.sys | 1 + regress/case-unknown2.sys | 1 + regress/case-unknown33.sys | 1 + regress/case-unknown5.sys | 1 + regress/harness.h | 2 ++ regress/harness.h.m4 | 4 ++++ regress/hcommon.c | 8 +++++++- regress/hcommon.c.m4 | 9 ++++++++- regress/sys-rc-convert | 7 +++++++ 24 files changed, 48 insertions(+), 4 deletions(-) create mode 100755 regress/sys-rc-convert diff --git a/client/adnstest.c b/client/adnstest.c index 59a3bbc..f217dea 100644 --- a/client/adnstest.c +++ b/client/adnstest.c @@ -38,6 +38,8 @@ #ifdef ADNS_REGRESS_TEST # include "hredirect.h" +# undef exit +# define exit Texit #endif struct myctx { diff --git a/regress/case-adh-cancel.sys b/regress/case-adh-cancel.sys index a7889c9..47f2007 100644 --- a/regress/case-adh-cancel.sys +++ b/regress/case-adh-cancel.sys @@ -71,3 +71,4 @@ close fd=6 close=OK +0.000961 + exit 0 diff --git a/regress/case-adh-cancel2.sys b/regress/case-adh-cancel2.sys index 90f114f..1a6f4fe 100644 --- a/regress/case-adh-cancel2.sys +++ b/regress/case-adh-cancel2.sys @@ -57,3 +57,4 @@ close fd=6 close=OK +0.000149 + exit 0 diff --git a/regress/case-adh-cancel3.sys b/regress/case-adh-cancel3.sys index 3e99426..99797d1 100644 --- a/regress/case-adh-cancel3.sys +++ b/regress/case-adh-cancel3.sys @@ -88,3 +88,4 @@ close fd=6 close=OK +0.000686 + exit 0 diff --git a/regress/case-adh-norm.sys b/regress/case-adh-norm.sys index fa6cd4b..9283754 100644 --- a/regress/case-adh-norm.sys +++ b/regress/case-adh-norm.sys @@ -32,3 +32,4 @@ chiark.greenend.org.uk close fd=4 close=OK +0.000290 + exit 0 diff --git a/regress/case-adh-pipe.sys b/regress/case-adh-pipe.sys index 6e9ec3c..39af36d 100644 --- a/regress/case-adh-pipe.sys +++ b/regress/case-adh-pipe.sys @@ -46,3 +46,4 @@ close fd=6 close=OK +0.000134 + exit 0 diff --git a/regress/case-arf-norm.sys b/regress/case-arf-norm.sys index a9beaf3..83602eb 100644 --- a/regress/case-arf-norm.sys +++ b/regress/case-arf-norm.sys @@ -322,3 +322,4 @@ close fd=6 close=OK +0.000090 + exit 0 diff --git a/regress/case-arf-text.sys b/regress/case-arf-text.sys index 4a2ca57..d6cb1f7 100644 --- a/regress/case-arf-text.sys +++ b/regress/case-arf-text.sys @@ -61,3 +61,4 @@ close fd=6 close=OK +0.000117 + exit 0 diff --git a/regress/case-dh-ptr-aaaa.sys b/regress/case-dh-ptr-aaaa.sys index dcd7136..8b63bec 100644 --- a/regress/case-dh-ptr-aaaa.sys +++ b/regress/case-dh-ptr-aaaa.sys @@ -66,3 +66,4 @@ close fd=6 close=OK +0.000134 + exit 0 diff --git a/regress/case-srvbaddom.out b/regress/case-srvbaddom.out index ef5105e..ab3f8d1 100644 --- a/regress/case-srvbaddom.out +++ b/regress/case-srvbaddom.out @@ -1 +1 @@ -rc=6 +rc=0 diff --git a/regress/case-srvbaddom.sys b/regress/case-srvbaddom.sys index 5e03602..a21bb0a 100644 --- a/regress/case-srvbaddom.sys +++ b/regress/case-srvbaddom.sys @@ -48,3 +48,4 @@ close fd=6 close=OK +0.000091 + exit 6 diff --git a/regress/case-srvha.sys b/regress/case-srvha.sys index 231c29b..7407b15 100644 --- a/regress/case-srvha.sys +++ b/regress/case-srvha.sys @@ -101,3 +101,4 @@ close fd=6 close=OK +0.006908 + exit 0 diff --git a/regress/case-srvok.sys b/regress/case-srvok.sys index b7b4120..234f5ef 100644 --- a/regress/case-srvok.sys +++ b/regress/case-srvok.sys @@ -83,3 +83,4 @@ close fd=6 close=OK +0.004680 + exit 0 diff --git a/regress/case-srvqudom.out b/regress/case-srvqudom.out index ef5105e..ab3f8d1 100644 --- a/regress/case-srvqudom.out +++ b/regress/case-srvqudom.out @@ -1 +1 @@ -rc=6 +rc=0 diff --git a/regress/case-srvqudom.sys b/regress/case-srvqudom.sys index a54c484..763dbae 100644 --- a/regress/case-srvqudom.sys +++ b/regress/case-srvqudom.sys @@ -102,3 +102,4 @@ close fd=6 close=OK +0.000078 + exit 6 diff --git a/regress/case-srvsort.sys b/regress/case-srvsort.sys index d44fba5..2d343dd 100644 --- a/regress/case-srvsort.sys +++ b/regress/case-srvsort.sys @@ -185,3 +185,4 @@ close fd=6 close=OK +0.014060 + exit 0 diff --git a/regress/case-unknown2.sys b/regress/case-unknown2.sys index 0a1f593..88ff570 100644 --- a/regress/case-unknown2.sys +++ b/regress/case-unknown2.sys @@ -64,3 +64,4 @@ close fd=6 close=OK +0.000187 + exit 0 diff --git a/regress/case-unknown33.sys b/regress/case-unknown33.sys index 7a6c122..fc567e5 100644 --- a/regress/case-unknown33.sys +++ b/regress/case-unknown33.sys @@ -35,3 +35,4 @@ close fd=6 close=OK +0.002395 + exit 0 diff --git a/regress/case-unknown5.sys b/regress/case-unknown5.sys index 4a436c4..5b019f9 100644 --- a/regress/case-unknown5.sys +++ b/regress/case-unknown5.sys @@ -43,3 +43,4 @@ close fd=6 close=OK +0.000144 + exit 0 diff --git a/regress/harness.h b/regress/harness.h index eae4206..85a936b 100644 --- a/regress/harness.h +++ b/regress/harness.h @@ -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 diff --git a/regress/harness.h.m4 b/regress/harness.h.m4 index bf4f308..f3d04d8 100644 --- a/regress/harness.h.m4 +++ b/regress/harness.h.m4 @@ -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 diff --git a/regress/hcommon.c b/regress/hcommon.c index 301fb2f..0aa3ffb 100644 --- a/regress/hcommon.c +++ b/regress/hcommon.c @@ -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 */ } diff --git a/regress/hcommon.c.m4 b/regress/hcommon.c.m4 index 760ca0c..62b2d03 100644 --- a/regress/hcommon.c.m4 +++ b/regress/hcommon.c.m4 @@ -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 index 0000000..37e60e0 --- /dev/null +++ b/regress/sys-rc-convert @@ -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 -- 2.11.0