Blame gnulib-tests/test-perror.sh

Packit 33f14e
#!/bin/sh
Packit 33f14e
: ${srcdir=.}
Packit 33f14e
. "$srcdir/init.sh"; path_prepend_ .
Packit 33f14e
Packit 33f14e
# Test NULL prefix. Result should not contain a number, except in lines that
Packit 33f14e
# start with 'EDC' (IBM z/OS libc produces an error identifier before the
Packit 33f14e
# error message).
Packit 33f14e
test-perror 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror.tmp
Packit 33f14e
grep -v '^EDC' t-perror.tmp | grep '[0-9]' > /dev/null \
Packit 33f14e
  && fail_ "result should not contain a number"
Packit 33f14e
Packit 33f14e
# Test empty prefix. Result should be the same.
Packit 33f14e
test-perror '' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror1.tmp
Packit 33f14e
diff t-perror.tmp t-perror1.tmp \
Packit 33f14e
  || fail_ "empty prefix should behave like NULL argument"
Packit 33f14e
Packit 33f14e
# Test non-empty prefix.
Packit 33f14e
test-perror foo 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror3.tmp
Packit 33f14e
sed -e 's/^/foo: /' < t-perror.tmp > t-perror2.tmp
Packit 33f14e
diff t-perror2.tmp t-perror3.tmp || fail_ "prefix applied incorrectly"
Packit 33f14e
Packit 33f14e
# Test exit status.
Packit 33f14e
test-perror >out 2>/dev/null || fail_ "unexpected exit status"
Packit 33f14e
test -s out && fail_ "unexpected output"
Packit 33f14e
Packit 33f14e
Exit 0