tests: update init.sh from gnulib
[coreutils.git] / tests / mkdir / p-3
blob6aa422ae49124b86bd5849f45f836e82ea1bf469
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.
6 # Copyright (C) 2005-2010 Free Software Foundation, Inc.
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 3 of the License, or
11 # (at your option) any later version.
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.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 if test "$VERBOSE" = yes; then
22 set -x
23 mkdir --version
26 . $srcdir/test-lib.sh
27 skip_if_root_
29 mkdir no-access || framework_failure
30 mkdir no-acce2s || framework_failure
31 mkdir -p no-acce3s/d || framework_failure
33 p=`pwd`
34 (cd no-access && chmod 0 . && mkdir -p "$p/a/b" u/v) 2> /dev/null && fail=1
35 test -d "$p/a/b" || fail=1
37 # Same as above, but with a following *absolute* name, it should succeed
38 (cd no-acce2s && chmod 0 . && mkdir -p "$p/b/b" "$p/z") || fail=1
39 test -d "$p/b/b" && test -d "$p/z" || fail=1
41 # Same as above, but a trailing relative name in an unreadable directory
42 # whose parent is inaccessible. coreutils 5.97 fails this test.
43 # Perform this test only if "." is on a local file system.
44 # Otherwise, it would fail e.g., on an NFS-mounted file system.
45 if df --local . >/dev/null 2>&1; then
46 (cd no-acce3s/d && chmod a-r . && chmod a-rx .. &&
47 mkdir -p a/b "$p/b/c" d/e && test -d a/b && test -d d/e) || fail=1
48 test -d "$p/b/c" || fail=1
51 b=`ls "$p/a" | tr -d '\n'`
52 # With coreutils-5.3.0, this would fail with $b=bu.
53 test "x$b" = xb || fail=1
55 Exit $fail