From 893ac5d220d699a1681e12617eaeb0781f356bba Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 18 Jan 2022 22:54:05 +0100 Subject: test: print symbol names to exit codes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- test | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test b/test index 4f0d22e..9bf58c8 100755 --- a/test +++ b/test @@ -6,6 +6,14 @@ set -e exec >&2 +exit2str () { + if test $1 = 0; then + printf '%s\n' 'all good' + else + sed -n 's/^ *#define *EXIT_\([^ ]*\) *'"$1"' *$/ (\1)/p' < common.h | tr '[A-Z]' '[a-z]' + fi +} + nfails=0 for f in tests/*.mk; do @@ -18,11 +26,14 @@ for f in tests/*.mk; do got=$? set -e + expstr="$(exit2str $expected)" + gotstr="$(exit2str $got)" + if test $got -lt $expected; then - printf '%s: %s\n' "$f" "defect was not detected (expected ${expected}, got ${got})" + printf '%s: %s\n' "$f" "defect was not detected (expected ${expected}${expstr}, got ${got}${gotstr})" : $(( nfails++ )) elif test $got -gt $expected; then - printf '%s: %s\n' "$f" "found more serious defects than expected (expected ${expected}, got ${got})" + printf '%s: %s\n' "$f" "found more serious defects than expected (expected ${expected}${expstr}, got ${got}${gotstr})" : $(( nfails++ )) fi done -- cgit v1.2.3-70-g09d2