2 # Compare actual numbers from du, assuming block size matches mine.
4 # Copyright (C) 2003, 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
26 # DU_BLOCK_SIZE could cause problems
27 . $srcdir/../envvar-check
28 . $srcdir/../lang-default
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
36 mkdir -p $tmp || framework_failure=1
37 cd $tmp || framework_failure=1
38 mkdir -p a/b d d/sub || framework_failure=1
40 # Ensure that these files contain more than 64 bytes, so that we don't
41 # immediately disqualify file systems (e.g., NetApp) on which smaller
42 # files take up zero disk blocks.
43 printf '%*s' 257 make-sure-the-file-is-non-empty > a/b/F || framework_failure=1
44 seq --format=%100g 1 90 | head --bytes=4k > d/1
47 if test $framework_failure = 1; then
48 echo "$0: failure in testing framework" 1>&2
54 B=`stat --format=%B a/b/F`
56 du --block-size=$B -a a > out || fail=1
58 du --block-size=$B -a -S a >> out || fail=1
60 du --block-size=$B -s a >> out || fail=1
62 f=`stat --format=%b a/b/F`
63 b=`stat --format=%b a/b`
64 a=`stat --format=%b a`
68 cat <<EOF | sed 's/ *#.*//' > exp
73 $f a/b/F # size of file, a/b/F
74 $bf a/b # size of dir entry, a/b, + size of file, a/b/F
75 $a a # size of dir entry, a
81 test $fail = 1 && diff -u out exp 2> /dev/null
84 du --block-size=$B -a d | sort -r -k2,2 > out || fail=1
86 du --block-size=$B -S d | sort -r -k2,2 >> out || fail=1
88 t2=`stat --format=%b d/sub/2`
89 ts=`stat --format=%b d/sub`
90 t1=`stat --format=%b d/1`
91 td=`stat --format=%b d`
92 tot=`expr $t1 + $t2 + $ts + $td`
96 cat <<EOF | sed 's/ *#.*//' > exp
103 $d1 d # d + d/1; don't count the dir. entry for d/sub
106 cmp out exp || fail=1
107 test $fail = 1 && diff out exp 2> /dev/null
109 (exit $fail); exit $fail