coreutils/coreutils-7.0-dftotal.patch
Ondrej Vasik 5a43cb54ac fixed regression in expr command(#474434), enable total-awk test again (and
skip it only when df not working properly at all)
2008-12-03 22:49:50 +00:00

116 lines
2.8 KiB
Diff

diff -urNp coreutils-7.0-orig/tests/df/total-awk coreutils-7.0/tests/df/total-awk
--- coreutils-7.0-orig/tests/df/total-awk 2008-09-27 19:28:54.000000000 +0200
+++ coreutils-7.0/tests/df/total-awk 2008-11-11 16:54:49.000000000 +0100
@@ -18,7 +18,7 @@
if test "$VERBOSE" = yes; then
set -x
- ls --version
+ df --version
fi
. $srcdir/test-lib.sh
@@ -24,6 +24,8 @@
. $srcdir/test-lib.sh
+ df || skip_test_ "df fails"
+
fail=0
# Don't let a different umask perturb the results.
@@ -23,58 +25,44 @@ fi
. $srcdir/test-lib.sh
-fail=0
-
-# Don't let a different umask perturb the results.
-umask 22
-
-echo '
-BEGIN {
- total = 0
- used = 0
- available = 0
-}
-{
- if (NR==1 || $0==$1 || $0~/^total +(-?[0-9]+|-) +(-?[0-9]+|-) +(-?[0-9]+|-) +-?[0-9]+%$/)
- next
- if ($1~/^[0-9]/)
- {
- total += $1
- used += $2
- available += $3
- }
- else
- {
- total += $2
- used += $3
- available += $4
- }
-}
-END {
- print total
- print used
- print available
-}
-' > compute_sum.awk || fail=1
-
-echo '
-/^total +(-?[0-9]+|-) +(-?[0-9]+|-) +(-?[0-9]+|-) +-?[0-9]+%$/ {
- print $2;
- print $3;
- print $4
-}
-' > parse_total.awk || fail=1
+cat <<\EOF > check-df || framework_failure
+my ($total, $used, $avail) = (0, 0, 0);
+while (<>)
+ {
+ $. == 1
+ and next; # skip first (header) line
+ # Recognize df output lines like these:
+ # /dev/sdc1 0 0 0 - /c
+ # tmpfs 1536000 12965 1523035 1% /tmp
+ # total 5285932 787409 4498523 15%
+ /^(.*?) +(-?\d+|-) +(-?\d+|-) +(-?\d+|-) +(?:- |[0-9]+%)(.*)$/
+ or die "$0: invalid input line\n: $_";
+ if ($1 eq 'total' && $5 eq '')
+ {
+ $total == $2 or die "$total != $2";
+ $used == $3 or die "$used != $3";
+ $avail == $4 or die "$avail != $4";
+ my $line = <>;
+ defined $line
+ and die "$0: extra line(s) after totals\n";
+ exit 0;
+ }
+ $total += $2 unless $2 eq '-';
+ $used += $3 unless $3 eq '-';
+ $avail += $4 unless $4 eq '-';
+ }
+die "$0: missing line of totals\n";
+EOF
# Use --block-size=512 to keep df from printing rounded-to-kilobyte
# numbers which wouldn't necessarily add up to the displayed total.
-df --block-size=512 --total |tee tmp || fail=1
-$AWK -f compute_sum.awk tmp > out1 || fail=1
-$AWK -f parse_total.awk tmp > out2 || fail=1
-compare out1 out2 || fail=1
+fail=0
+df --total -P --block-size=512 >space || fail=1
+cat space # this helps when debugging any test failure
+df --total -i -P >inode || fail=1
+cat inode
-df -i --block-size=512 --total |tee tmp || fail=1
-$AWK -f compute_sum.awk tmp > out1 || fail=1
-$AWK -f parse_total.awk tmp > out2 || fail=1
-compare out1 out2 || fail=1
+$PERL -f check-df space || fail=1
+$PERL -f check-df inode || fail=1
Exit $fail