Mercurial > hg > octave-lojdl > gnulib-hg
changeset 14776:a3bd209aea02
test-perror: rewrite to use init script
Make the test simpler, and also check for correct exit status.
* modules/perror-tests (Files): Add init.sh.
* tests/test-perror.sh: Use temporary directory.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Fri, 20 May 2011 08:57:54 -0600 |
parents | a152da4489c4 |
children | d614bf2c2613 |
files | ChangeLog modules/perror-tests tests/test-perror.sh |
diffstat | 3 files changed, 21 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-05-20 Eric Blake <eblake@redhat.com> + + test-perror: rewrite to use init script + * modules/perror-tests (Files): Add init.sh. + * tests/test-perror.sh: Use temporary directory. + 2011-05-20 Jim Meyering <meyering@redhat.com> maint: replace misused "a" with "an"
--- a/modules/perror-tests +++ b/modules/perror-tests @@ -1,4 +1,5 @@ Files: +tests/init.sh tests/signature.h tests/test-perror.c tests/test-perror.sh
--- a/tests/test-perror.sh +++ b/tests/test-perror.sh @@ -1,27 +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" -rm -fr $tmpfiles +# Test exit status. +test-perror >out 2>/dev/null || fail_ "unexpected exit status" +test -s out && fail_ "unexpected output" + exit 0