+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"
#!/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"
-rm -fr $tmpfiles
exit 0