build: don't use recursive make for tests/ subdirectory
[platform/upstream/coreutils.git] / tests / du / deref.sh
1 #!/bin/sh
2 # prior to coreutils-4.5.3, du -D didn't work in some cases
3 # Based on an example from Andreas Schwab and/or Michal Svec.
4 # Also, up to coreutils-8.5, du -L sometimes incorrectly
5 # counted the space of the followed symlinks.
6
7 # Copyright (C) 2002-2012 Free Software Foundation, Inc.
8
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
22 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
23 print_ver_ du
24
25 mkdir -p a/sub || framework_failure_
26 ln -s a/sub slink || framework_failure_
27 touch b || framework_failure_
28 ln -s .. a/sub/dotdot || framework_failure_
29 ln -s nowhere dangle || framework_failure_
30
31
32 # This used to fail with the following diagnostic:
33 # du: 'b': No such file or directory
34 du -sD slink b > /dev/null 2>&1 || fail=1
35
36 # This used to fail to report the dangling symlink.
37 du -L dangle > /dev/null 2>&1 && fail=1
38
39 # du -L used to mess up, either by counting the symlink's disk space itself
40 # (-L should follow symlinks, not count their space)
41 # or (briefly in July 2010) by omitting the entry for "a".
42 du_L_output=$(du -L a) || fail=1
43 du_lL_output=$(du -lL a) || fail=1
44 du_x_output=$(du --exclude=dotdot a) || fail=1
45 test "X$du_L_output" = "X$du_x_output" || fail=1
46 test "X$du_lL_output" = "X$du_x_output" || fail=1
47
48 Exit $fail