File: test-perror.sh

package info (click to toggle)
libprelude 1.0.0-11.9
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 24,456 kB
  • ctags: 17,851
  • sloc: ansic: 190,841; cpp: 38,769; xml: 30,141; sh: 11,668; makefile: 692; python: 481; awk: 341; yacc: 238; lex: 186; perl: 5
file content (27 lines) | stat: -rwxr-xr-x 853 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15

# 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 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 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
sed -e 's/^/foo: /' < t-perror.tmp > t-perror2.tmp
diff t-perror2.tmp t-perror3.tmp
test $? = 0 || { rm -fr $tmpfiles; exit 1; }

rm -fr $tmpfiles
exit 0