X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-perror.sh;h=7274d3223f15e72fa1ee3c6b4d637197a46b91f1;hb=9fc77bc59374e21e1174742df416af186a368e14;hp=3ab20abfc0ee50e135b6a8bd8902d0ca131f42fc;hpb=17017b2d0c6679ca81452ce96dac91f0de9a1646;p=gnulib.git diff --git a/tests/test-perror.sh b/tests/test-perror.sh index 3ab20abfc..7274d3223 100755 --- a/tests/test-perror.sh +++ b/tests/test-perror.sh @@ -1,26 +1,24 @@ #!/bin/sh - -tmpfiles="" -trap 'rm -fr $tmpfiles' 1 2 3 15 +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ . # Test NULL prefix. Result should not contain a number. -tmpfiles="$tmpfiles t-perror.tmp" -./test-perror${EXEEXT} 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror.tmp -if grep '[0-9]' t-perror.tmp > /dev/null; then - rm -fr $tmpfiles; exit 1 -fi +test-perror 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror.tmp +grep '[0-9]' t-perror.tmp > /dev/null \ + && fail_ "result should not contain a number" # Test empty prefix. Result should be the same. -tmpfiles="$tmpfiles t-perror1.tmp" -./test-perror${EXEEXT} '' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror1.tmp -diff t-perror.tmp t-perror1.tmp -test $? = 0 || { rm -fr $tmpfiles; exit 1; } +test-perror '' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror1.tmp +diff t-perror.tmp t-perror1.tmp \ + || fail_ "empty prefix should behave like NULL argument" # Test non-empty prefix. -tmpfiles="$tmpfiles t-perror2.tmp t-perror3.tmp" -./test-perror${EXEEXT} 'foo' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror3.tmp +test-perror foo 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror3.tmp sed -e 's/^/foo: /' < t-perror.tmp > t-perror2.tmp -diff t-perror2.tmp t-perror3.tmp -test $? = 0 || { rm -fr $tmpfiles; exit 1; } +diff t-perror2.tmp t-perror3.tmp || fail_ "prefix applied incorrectly" + +# Test exit status. +test-perror >out 2>/dev/null || fail_ "unexpected exit status" +test -s out && fail_ "unexpected output" -exit 0 +Exit 0