~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/du/long-sloop

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# Use du to exercise a corner of fts's FTS_LOGICAL code.
3
 
# Show that du fails with ELOOP (Too many levels of symbolic links)
4
 
# when it encounters that condition.
5
 
 
6
 
# Copyright (C) 2006-2011 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 3 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, see <http://www.gnu.org/licenses/>.
20
 
 
21
 
. "${srcdir=.}/init.sh"; path_prepend_ ../src
22
 
print_ver_ du
23
 
 
24
 
# Create lots of directories, each containing a single symlink
25
 
# pointing at the next directory in the list.
26
 
 
27
 
# This number should be larger than the number of symlinks allowed in
28
 
# file name resolution, but not too large as a number of entries
29
 
# in a single directory.
30
 
n=400
31
 
 
32
 
dir_list=`seq $n`
33
 
mkdir $dir_list || framework_failure_
34
 
file=1
35
 
i_minus_1=0
36
 
for i in $dir_list `expr $n + 1`; do
37
 
  case $i_minus_1 in
38
 
  0) ;;
39
 
  *)
40
 
    ln -s ../$i $i_minus_1/s || framework_failure_
41
 
    file=$file/s;;
42
 
  esac
43
 
  i_minus_1=$i
44
 
done
45
 
echo foo > $i
46
 
 
47
 
# If a system can handle this many symlinks in a file name,
48
 
# just skip this test.
49
 
 
50
 
# The following also serves to record in `err' the string
51
 
# corresponding to strerror (ELOOP).  This is necessary because while
52
 
# Linux/libc gives `Too many levels of symbolic links', Solaris
53
 
# renders it as `Number of symbolic links encountered during path
54
 
# name traversal exceeds MAXSYMLINKS'.
55
 
 
56
 
cat $file > /dev/null 2> err &&
57
 
    skip_ 'Your system appears to be able to handle more than $n symlinks
58
 
in file name resolution'
59
 
too_many=`sed 's/.*: //' err`
60
 
 
61
 
 
62
 
# With coreutils-5.93 there was no failure.
63
 
# With coreutils-5.94 we get the desired diagnostic:
64
 
# du: cannot access `1/s/s/s/.../s': Too many levels of symbolic links
65
 
du -L 1 > /dev/null 2> out1 && fail=1
66
 
sed "s, .1/s/s/s/[/s]*',," out1 > out || fail=1
67
 
 
68
 
echo "du: cannot access: $too_many" > exp || fail=1
69
 
 
70
 
compare out exp || fail=1
71
 
 
72
 
Exit $fail