Add/fix copyright notices and adjust to latest GNU FDL.
[platform/upstream/coreutils.git] / tests / mkdir / p-3
1 #!/bin/sh
2 # Ensure that mkdir-p.c's fail-to-return-to-initial-working-directory
3 # causes immediate failure.  Also, ensure that we don't create
4 # subsequent, relative command-line arguments in the wrong place.
5
6 # Copyright (C) 2005, 2006 Free Software Foundation, Inc.
7
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 # 02110-1301, USA.
22
23 if test "$VERBOSE" = yes; then
24   set -x
25   mkdir --version
26 fi
27
28 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
29
30 pwd=`pwd`
31 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
32 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
33 trap '(exit $?); exit $?' 1 2 13 15
34
35 framework_failure=0
36 mkdir -p $tmp || framework_failure=1
37 cd $tmp || framework_failure=1
38 mkdir no-access || framework_failure=1
39 mkdir no-acce2s || framework_failure=1
40 mkdir no-acce3s || framework_failure=1
41
42 if test $framework_failure = 1; then
43   echo "$0: failure in testing framework" 1>&2
44   (exit 1); exit 1
45 fi
46
47 p=$pwd/$tmp
48 (cd no-access; chmod 0 . && mkdir -p $p/a/b u/v) 2> /dev/null && fail=1
49 test -d $p/a/b || fail=1
50
51 # Same as above, but with a following *absolute* name, it should succeed
52 (cd no-acce2s; chmod 0 . && mkdir -p $p/b/b $p/z) || fail=1
53
54 test -d $p/z || fail=1
55
56 b=`ls $p/a|tr -d '\n'`
57 # With coreutils-5.3.0, this would fail with $b=bu.
58 test "x$b" = xb || fail=1
59
60 exit $fail