test-xalloc-die.sh: make the code agree with the commit log
[gnulib.git] / tests / test-xalloc-die.sh
1 #!/bin/sh
2
3 tmpfiles=""
4 trap '__st=$?; rm -fr $tmpfiles; exit $__st' 0
5 trap '__st=$?; (exit $__st); exit $__st' 1 2 3 15
6
7 if ( diff --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
8   compare() { diff -u "$@"; }
9 elif ( cmp --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
10   compare() { cmp -s "$@"; }
11 else
12   compare() { cmp "$@"; }
13 fi
14
15 tmpfiles="t-xalloc-die.tmp"
16 PATH=".:$PATH"
17 export PATH
18 test-xalloc-die${EXEEXT} 2> t-xalloc-die.tmp
19 case $? in
20   1) ;;
21   *) (exit 1); exit 1 ;;
22 esac
23
24 compare - t-xalloc-die.tmp <<\EOF || { (exit 1); exit 1; }
25 test-xalloc-die: memory exhausted
26 EOF
27
28 rm -fr $tmpfiles
29
30 exit 0