4 # Copyright (C) 2003, 2006 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 if test "$VERBOSE" = yes; then
26 . $srcdir/../envvar-check
27 . $srcdir/../lang-default
30 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
31 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
32 trap '(exit $?); exit $?' 1 2 13 15
35 mkdir -p $tmp || framework_failure=1
36 cd $tmp || framework_failure=1
38 if test $framework_failure = 1; then
39 echo "$0: failure in testing framework" 1>&2
45 nohup sh -c 'echo stdout; echo stderr 1>&2' 2>err || fail=1
47 # Be careful. The results of the above nohup command
48 # change depending on whether stdin and stdout are redirected.
50 test "`cat nohup.out`" = stdout || fail=1
52 echo 'nohup: ignoring input and appending output to `nohup.out'\'
54 echo 'nohup: appending output to `nohup.out'\'
57 # Here it should not even exist.
58 test -f nohup.out && fail=1
60 echo 'nohup: ignoring input' >exp
65 echo 'stderr' >> exp || fail=1
68 test $fail = 1 && diff exp err 2> /dev/null
69 rm -f nohup.out err exp
70 # ----------------------
72 # Be careful. The results of the following nohup command
73 # change depending on whether stderr is redirected.
74 nohup sh -c 'echo stdout; echo stderr 1>&2' >out || fail=1
76 test "`cat out|tr '\n' -`" = stdout-stderr- || fail=1
78 test "`cat out|tr '\n' -`" = stdout- || fail=1
80 # It must *not* exist.
81 test -f nohup.out && fail=1
83 # ----------------------
85 nohup no-such-command 2> err
88 test $errno = 127 || fail=1
90 test -f nohup.out || fail=1
92 test -s nohup.out && fail=1
95 cat <<\EOF > exp || fail=1
96 nohup: appending output to `nohup.out'
97 nohup: cannot run command `no-such-command': No such file or directory
99 # Disable these comparisons. Too much variation in 2nd line.
100 # cmp exp err || fail=1
101 # test $fail = 1 && diff exp err 2> /dev/null
102 rm -f nohup.out err exp
103 # ----------------------
108 test $errno = 126 || fail=1
111 test -f nohup.out || fail=1
113 test -s nohup.out && fail=1
116 cat <<\EOF > exp || fail=1
117 nohup: appending output to `nohup.out'
118 nohup: cannot run command `./k': Permission denied
120 # Disable these comparisons. Too much variation in 2nd line.
121 # cmp exp err || fail=1
122 # test $fail = 1 && diff exp err 2> /dev/null
124 # Make sure it fails with exit status of 127 when given too few arguments.
125 nohup >/dev/null 2>&1
126 test $? = 127 || fail=1
128 (exit $fail); exit $fail