2 # make sure mkdir's -p options works properly
4 # Copyright (C) 2000, 2004, 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
28 trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
29 trap '(exit $?); exit' 1 2 13 15
33 # Record absolute path of srcdir.
34 cd $srcdir || framework_failure=1
37 cd "$pwd" || framework_failure=1
38 mkdir $tmp || framework_failure=1
39 cd $tmp || framework_failure=1
40 mkdir -m 700 e-dir || framework_failure=1
42 if test $framework_failure = 1; then
43 echo 'failure in testing framework'
47 . "$abs_srcdir/../setgid-check"
51 # Make sure `mkdir -p existing-dir' succeeds
52 # and that `mkdir existing-dir' fails.
53 mkdir -p e-dir || fail=1
54 mkdir e-dir > /dev/null 2>&1 && fail=1
56 # Create an existing directory.
59 mode_arg=`"$abs_srcdir/../rwx-to-mode" $mode_str`
60 mkdir -m $mode_arg a || fail=1
62 # this `mkdir -p ...' shouldn't change perms of existing dir `a'.
64 d_mode_arg=`"$abs_srcdir/../rwx-to-mode" $d_mode_str`
65 mkdir -p -m $d_mode_arg a/b/c/d
67 # Make sure the permissions of `a' haven't been changed.
68 p=`ls -ld a|sed 's/ .*//'`; case $p in $mode_str);; *) fail=1;; esac
69 # `b's and `c's should reflect the umask
70 p=`ls -ld a/b|sed 's/ .*//'`; case $p in drwx------);; *) fail=1;; esac
71 p=`ls -ld a/b/c|sed 's/ .*//'`; case $p in drwx------);; *) fail=1;; esac
73 # `d's perms are determined by the -m argument.
74 p=`ls -ld a/b/c/d|sed 's/ .*//'`; case $p in $d_mode_str);; *) fail=1;; esac
76 (exit $fail); exit $fail