diff options
author | Jim Meyering <jim@meyering.net> | 2007-09-07 15:25:23 +0200 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-09-15 08:40:38 +0200 |
commit | ec2064acc84d9cc6e0bfae04c591974efc449d8a (patch) | |
tree | fc20b7c780175d6f428c392ce333199c9b24e79f /tests | |
parent | 18b3231bbfdb1fe36c08511bda930588cc836c71 (diff) | |
download | coreutils-ec2064acc84d9cc6e0bfae04c591974efc449d8a.tar.xz |
Convert tests/du/*, too.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/du/2g | 21 | ||||
-rwxr-xr-x | tests/du/8gb | 21 | ||||
-rwxr-xr-x | tests/du/basic | 25 | ||||
-rwxr-xr-x | tests/du/deref | 23 | ||||
-rwxr-xr-x | tests/du/deref-args | 28 | ||||
-rwxr-xr-x | tests/du/exclude | 22 | ||||
-rwxr-xr-x | tests/du/fd-leak | 18 | ||||
-rwxr-xr-x | tests/du/files0-from | 1 | ||||
-rwxr-xr-x | tests/du/hard-link | 21 | ||||
-rwxr-xr-x | tests/du/inacc-dest | 40 | ||||
-rwxr-xr-x | tests/du/inacc-dir | 23 | ||||
-rwxr-xr-x | tests/du/inaccessible-cwd | 25 | ||||
-rwxr-xr-x | tests/du/long-from-unreadable | 36 | ||||
-rwxr-xr-x | tests/du/long-sloop | 24 | ||||
-rwxr-xr-x | tests/du/no-deref | 24 | ||||
-rwxr-xr-x | tests/du/no-x | 21 | ||||
-rwxr-xr-x | tests/du/one-file-system | 22 | ||||
-rwxr-xr-x | tests/du/restore-wd | 17 | ||||
-rwxr-xr-x | tests/du/slash | 21 | ||||
-rwxr-xr-x | tests/du/slink | 14 | ||||
-rwxr-xr-x | tests/du/trailing-slash | 24 | ||||
-rwxr-xr-x | tests/du/two-args | 30 |
22 files changed, 108 insertions, 393 deletions
diff --git a/tests/du/2g b/tests/du/2g index 2ab923732..ea2d6c784 100755 --- a/tests/du/2g +++ b/tests/du/2g @@ -3,7 +3,7 @@ # Before coreutils-5.93, on systems with a signed, 32-bit stat.st_blocks # one of du's computations would overflow. -# Copyright (C) 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2005-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,24 +23,10 @@ if test "$VERBOSE" = yes; then du --version fi -. $srcdir/../envvar-check - # Creating a 2GB file counts as `very expensive'. . $srcdir/../very-expensive -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 @@ -85,7 +71,6 @@ cat <<\EOF > exp || fail=1 ~2M EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/8gb b/tests/du/8gb index d585f70b5..29d48c2e0 100755 --- a/tests/du/8gb +++ b/tests/du/8gb @@ -2,7 +2,7 @@ # Ensure that du does not rely on narrow types like size_t for # file sizes or sums. -# Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,22 +22,8 @@ if test "$VERBOSE" = yes; then du --version fi -. $srcdir/../envvar-check . $srcdir/../sparse-file - -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh dd bs=1 seek=8G of=big < /dev/null 2> /dev/null if test $? != 0; then @@ -69,7 +55,6 @@ cat <<\EOF > exp 8589934592 big EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/basic b/tests/du/basic index d8d8486a6..b7bfa3a58 100755 --- a/tests/du/basic +++ b/tests/du/basic @@ -22,31 +22,18 @@ if test "$VERBOSE" = yes; then fi # DU_BLOCK_SIZE could cause problems -. $srcdir/../envvar-check . $srcdir/../lang-default +. $srcdir/../test-lib.sh -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir -p a/b d d/sub || framework_failure=1 +mkdir -p a/b d d/sub || framework_failure # Ensure that these files contain more than 64 bytes, so that we don't # immediately disqualify file systems (e.g., NetApp) on which smaller # files take up zero disk blocks. -printf '%*s' 257 make-sure-the-file-is-non-empty > a/b/F || framework_failure=1 +printf '%*s' 257 make-sure-the-file-is-non-empty > a/b/F || framework_failure printf %4096s x > d/1 cp d/1 d/sub/2 -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi - fail=0 B=`stat --format=%B a/b/F` @@ -75,8 +62,7 @@ $a a # size of dir entry, a $tot a EOF -cmp out exp || fail=1 -test $fail = 1 && diff -u out exp 2> /dev/null +compare out exp || fail=1 # Perform this test only if "." is on a local file system. # Otherwise, it would fail e.g., on an NFS-mounted Solaris ZFS file system. @@ -104,8 +90,7 @@ $s2 d/sub $d1 d # d + d/1; don't count the dir. entry for d/sub EOF - cmp out exp || fail=1 - test $fail = 1 && diff out exp 2> /dev/null + compare out exp || fail=1 fi (exit $fail); exit $fail diff --git a/tests/du/deref b/tests/du/deref index f5adcd756..63cd606b2 100755 --- a/tests/du/deref +++ b/tests/du/deref @@ -2,7 +2,7 @@ # prior to coreutils-4.5.3, du -D didn't work in some cases # Based on an example from Andreas Schwab and/or Michal Svec. -# Copyright (C) 2002, 2006 Free Software Foundation, Inc. +# Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,22 +22,11 @@ if test "$VERBOSE" = yes; then du --version fi -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir -p a/sub || framework_failure=1 -ln -s a/sub slink || framework_failure=1 -touch b || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh + +mkdir -p a/sub || framework_failure +ln -s a/sub slink || framework_failure +touch b || framework_failure fail=0 diff --git a/tests/du/deref-args b/tests/du/deref-args index 01b7b83e7..441b21dd7 100755 --- a/tests/du/deref-args +++ b/tests/du/deref-args @@ -2,7 +2,7 @@ # Ensure that --dereference-args (-D) gives reasonable names. # This test would fail for coreutils-5.0.91. -# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,25 +22,12 @@ if test "$VERBOSE" = yes; then du --version fi -. $srcdir/../envvar-check +. $srcdir/../test-lib.sh -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir -p dir/a -ln -s dir slink -printf %65536s x > 64k -ln -s 64k slink-to-64k - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +mkdir -p dir/a || framework_failure +ln -s dir slink || framework_failure +printf %65536s x > 64k || framework_failure +ln -s 64k slink-to-64k || framework_failure fail=0 @@ -61,7 +48,6 @@ slink/ 64 slink-to-64k EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/exclude b/tests/du/exclude index d426400ed..7e4805157 100755 --- a/tests/du/exclude +++ b/tests/du/exclude @@ -1,7 +1,7 @@ #!/bin/sh # make sure du's --exclude option works -# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,22 +21,9 @@ if test "$VERBOSE" = yes; then du --version fi -. $srcdir/../envvar-check +. $srcdir/../test-lib.sh -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir -p a/b/c a/x/y a/u/v - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +mkdir -p a/b/c a/x/y a/u/v || framework_failure fail=0 @@ -71,7 +58,6 @@ a/x a/x/y EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/fd-leak b/tests/du/fd-leak index 6b25b8608..bc2ea81bf 100755 --- a/tests/du/fd-leak +++ b/tests/du/fd-leak @@ -1,7 +1,7 @@ #!/bin/sh # check for file descriptor leak -# Copyright (C) 2003, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,15 +24,8 @@ fi # Call this an expensive test. It's not that expensive, but command line # limitations might induce failure on some losing systems. . $srcdir/../expensive +. $srcdir/../test-lib.sh -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 # Create 1296 (36^2) files. # Their names and separating spaces take up 3887 bytes. x='a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9' @@ -44,12 +37,7 @@ for i in $x; do done # This may fail due to command line limitations. -touch $f || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +touch $f || framework_failure fail=0 diff --git a/tests/du/files0-from b/tests/du/files0-from index 7f32f318f..cb82daea2 100755 --- a/tests/du/files0-from +++ b/tests/du/files0-from @@ -20,7 +20,6 @@ : ${PERL=perl} : ${srcdir=.} -. $srcdir/../envvar-check $PERL -e 1 > /dev/null 2>&1 || { echo 1>&2 "$0: configure didn't find a usable version of Perl," \ diff --git a/tests/du/hard-link b/tests/du/hard-link index e1c8a11d3..139bae2ec 100755 --- a/tests/du/hard-link +++ b/tests/du/hard-link @@ -3,7 +3,7 @@ # Likewise for excluded directories. # Ensure that hard links _are_ listed twice when using --count-links. -# Copyright (C) 2003, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,26 +23,12 @@ if test "$VERBOSE" = yes; then du --version fi -. $srcdir/../envvar-check . $srcdir/../lang-default - -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 +. $srcdir/../test-lib.sh mkdir -p dir/sub ( cd dir && { echo non-empty > f1; ln f1 f2; echo non-empty > sub/F; } ) -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi - fail=0 # Note that for this first test, we transform f1 or f2 @@ -63,7 +49,6 @@ dir/f1 dir EOF -cmp out exp || fail=1 -test $fail = 1 && diff -u out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/inacc-dest b/tests/du/inacc-dest index af28fcc04..cd2e1e828 100755 --- a/tests/du/inacc-dest +++ b/tests/du/inacc-dest @@ -22,29 +22,14 @@ if test "$VERBOSE" = yes; then du --version fi -. $srcdir/../envvar-check . $srcdir/../lang-default PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check - -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 +. $srcdir/../test-lib.sh mkdir f && cd f && mkdir a b c d e && touch c/j && chmod a-x c \ - || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi + || framework_failure fail=0 - du > ../t 2>&1 && fail=1 # Accept either of the following outputs. @@ -64,19 +49,14 @@ cat <<\EOF > exp || fail=1 du: cannot read directory `./c': Permission denied EOF -cat <<\EOF > exp2 || fail=1 -. -./a -./b -./c -./d -./e -du: cannot access `./c/j': Permission denied -EOF +# Map a diagnostic like this +# du: cannot access `./c/j': Permission denied +# to this: +# du: cannot access `./c': Permission denied +# And accept "cannot read directory" in place of "cannot access" +sed "s,/c/j': ,/c': ," out > t && mv t out +sed 's,cannot access,cannot read directory,' out > t && mv t out -cmp out exp > /dev/null 2>&1 || { - cmp out exp2 || fail=1 - } -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/inacc-dir b/tests/du/inacc-dir index add929347..1ee5943b4 100755 --- a/tests/du/inacc-dir +++ b/tests/du/inacc-dir @@ -20,20 +20,9 @@ if test "$VERBOSE" = yes; then du --version fi -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir -p a/sub || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh + +mkdir -p a/sub || framework_failure fail=0 @@ -42,8 +31,7 @@ chmod 0 a/sub || fail=1 # Expect failure, ignore diagnostics. du -s a > out 2> /dev/null && fail=1 -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 # Same as above, but don't use -s, so we print # an entry for the unreadable "sub", too. @@ -53,7 +41,6 @@ chmod 0 a/sub || fail=1 # Expect failure, ignore diagnostics. du -k a > out 2> /dev/null && fail=1 -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/inaccessible-cwd b/tests/du/inaccessible-cwd index c5aaabe40..6706c19aa 100755 --- a/tests/du/inaccessible-cwd +++ b/tests/du/inaccessible-cwd @@ -2,7 +2,7 @@ # Ensure that even when run from an inaccessible directory, du can still # operate on accessible directories elsewhere. -# Copyright (C) 2003, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,26 +26,15 @@ if test "$VERBOSE" = yes; then fi PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check +. $srcdir/../test-lib.sh -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir -p no-x a/b || framework_failure=1 -cd no-x || framework_failure=1 -chmod 0 . || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +cwd=`pwd` +mkdir -p no-x a/b || framework_failure +cd no-x || framework_failure +chmod 0 . || framework_failure fail=0 -du "$pwd/$tmp/a" > /dev/null || fail=1 +du "$cwd/a" > /dev/null || fail=1 (exit $fail); exit $fail diff --git a/tests/du/long-from-unreadable b/tests/du/long-from-unreadable index 9718b2bd2..64c35b9a5 100755 --- a/tests/du/long-from-unreadable +++ b/tests/du/long-from-unreadable @@ -1,7 +1,7 @@ #!/bin/sh # Show fts fails on old-fashioned systems. -# Copyright (C) 2006 Free Software Foundation, Inc. +# Copyright (C) 2006-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ if test "$VERBOSE" = yes; then du --version fi -. $srcdir/../envvar-check +. $srcdir/../test-lib.sh proc_file=/proc/self/fd if test ! -d $proc_file; then @@ -44,44 +44,32 @@ EOF (exit 77); exit 77 fi -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - dir=`printf '%200s\n' ' '|tr ' ' x` # Construct a hierarchy containing a relative file with a name # longer than PATH_MAX. # for i in `seq 52`; do -# mkdir $dir || framework_failure=1 -# cd $dir || framework_failure=1 +# mkdir $dir || framework_failure +# cd $dir || framework_failure # done -# cd $tmp || framework_failure=1 +# cd $tmp || framework_failure # Sheesh. Bash 3.1.5 can't create this hierarchy. I get # cd: error retrieving current directory: getcwd: cannot access parent directories: + +cwd=`pwd` # Use perl instead: : ${PERL=perl} $PERL \ -e 'my $d = '$dir'; foreach my $i (1..52)' \ -e ' { mkdir ($d, 0700) && chdir $d or die "$!" }' \ - || framework_failure=1 + || framework_failure -mkdir inaccessible || framework_failure=1 -cd inaccessible || framework_failure=1 -chmod 0 . || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +mkdir inaccessible || framework_failure +cd inaccessible || framework_failure +chmod 0 . || framework_failure fail=0 -du -s "$pwd/$tmp/$dir" > /dev/null || fail=1 +du -s "$cwd/$dir" > /dev/null || fail=1 (exit $fail); exit $fail diff --git a/tests/du/long-sloop b/tests/du/long-sloop index 4f538d067..f6adf7238 100755 --- a/tests/du/long-sloop +++ b/tests/du/long-sloop @@ -3,7 +3,7 @@ # Show that du fails with ELOOP (Too many levels of symbolic links) # when it encounters that condition. -# Copyright (C) 2006 Free Software Foundation, Inc. +# Copyright (C) 2006-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,15 +24,7 @@ if test "$VERBOSE" = yes; then fi . $srcdir/../lang-default - -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 +. $srcdir/../test-lib.sh # Create lots of directories, each containing a single symlink # pointing at the next directory in the list. @@ -43,25 +35,20 @@ cd $tmp || framework_failure=1 n=400 dir_list=`seq $n` -mkdir $dir_list || framework_failure=1 +mkdir $dir_list || framework_failure file=1 i_minus_1=0 for i in $dir_list `expr $n + 1`; do case $i_minus_1 in 0) ;; *) - ln -s ../$i $i_minus_1/s || framework_failure=1 + ln -s ../$i $i_minus_1/s || framework_failure file=$file/s;; esac i_minus_1=$i done echo foo > $i -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi - # If a system can handle this many symlinks in a file name, # just skip this test. @@ -91,7 +78,6 @@ sed "s, .1/s/s/s/[/s]*',," out1 > out || fail=1 echo "du: cannot access: $too_many" > exp || fail=1 -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/no-deref b/tests/du/no-deref index ec3c6e1f9..cd76b557f 100755 --- a/tests/du/no-deref +++ b/tests/du/no-deref @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that by default, du doesn't dereference command-line symlinks. -# Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2006-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,23 +21,10 @@ if test "$VERBOSE" = yes; then du --version fi -. $srcdir/../envvar-check +. $srcdir/../test-lib.sh -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir -p dir/a/b -ln -s dir slink - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +mkdir -p dir/a/b || framework_failure +ln -s dir slink || framework_failure fail=0 @@ -46,7 +33,6 @@ cat <<\EOF > exp slink EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/no-x b/tests/du/no-x index 45cdb0d12..630ca17a3 100755 --- a/tests/du/no-x +++ b/tests/du/no-x @@ -24,22 +24,10 @@ fi . $srcdir/../lang-default PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check +. $srcdir/../test-lib.sh -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir -p d/no-x/y || framework_failure=1 -chmod u=rw d/no-x || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +mkdir -p d/no-x/y || framework_failure +chmod u=rw d/no-x || framework_failure fail=0 @@ -62,7 +50,6 @@ cat <<EOF > exp $prog: \`d/no-x': Permission denied EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/one-file-system b/tests/du/one-file-system index 07e6e9577..244887152 100755 --- a/tests/du/one-file-system +++ b/tests/du/one-file-system @@ -2,7 +2,7 @@ # Test for a bug in fts's handling of FTS_XDEV, the flag behind # du's --one-file-system (-x) option. -# Copyright (C) 2006 Free Software Foundation, Inc. +# Copyright (C) 2006-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,22 +22,9 @@ if test "$VERBOSE" = yes; then du --version fi -. $srcdir/../envvar-check +. $srcdir/../test-lib.sh -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir -p b/c y/z || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +mkdir -p b/c y/z || framework_failure fail=0 @@ -53,7 +40,6 @@ y/z y EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/restore-wd b/tests/du/restore-wd index e9fcfa197..e868bf85c 100755 --- a/tests/du/restore-wd +++ b/tests/du/restore-wd @@ -2,7 +2,7 @@ # due to a bug in glibc's ftw.c, in some cases, nftw w/FTW_CHDIR # would not restore the working directory. -# Copyright (C) 2003, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,20 +22,9 @@ if test "$VERBOSE" = yes; then du --version fi -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 +. $srcdir/../test-lib.sh -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir a b || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +mkdir a b || framework_failure fail=0 diff --git a/tests/du/slash b/tests/du/slash index c0c66672b..dd9175112 100755 --- a/tests/du/slash +++ b/tests/du/slash @@ -1,7 +1,7 @@ #!/bin/sh # `du /' would omit the `/' on the last line. -# Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2006-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,21 +21,7 @@ if test "$VERBOSE" = yes; then du --version fi -. $srcdir/../envvar-check - -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 @@ -46,7 +32,6 @@ cat <<\EOF > exp / EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/slink b/tests/du/slink index 5913d8371..e9f7bbd7d 100755 --- a/tests/du/slink +++ b/tests/du/slink @@ -21,14 +21,7 @@ if test "$VERBOSE" = yes; then du --version fi -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 +. $srcdir/../test-lib.sh # Determine if `.' is on a local (would non-NFS be sufficient?) file system. # On at least some NFS implementations, symlinks never take up space, @@ -55,11 +48,6 @@ if df --type=nfsv3 . >/dev/null 2>&1; then (exit 77); exit 77 fi -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi - fail=0 symlink_name_lengths='1 15 16 31 32 59 60 63 64 127 128 255 256 511 512 1024' for len in $symlink_name_lengths; do diff --git a/tests/du/trailing-slash b/tests/du/trailing-slash index 6918f255a..80ce5ba8d 100755 --- a/tests/du/trailing-slash +++ b/tests/du/trailing-slash @@ -2,7 +2,7 @@ # Ensure that du works properly for an argument that refers to a # symbolic link, and that is specified with a trailing slash. -# Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 2002-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,23 +24,10 @@ if test "$VERBOSE" = yes; then du --version fi -. $srcdir/../envvar-check +. $srcdir/../test-lib.sh -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -mkdir -p dir/1/2 || framework_failure=1 -ln -s dir slink || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +mkdir -p dir/1/2 || framework_failure +ln -s dir slink || framework_failure fail=0 @@ -60,7 +47,6 @@ slink/1 slink EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/du/two-args b/tests/du/two-args index aa3975e10..a9a3e75b0 100755 --- a/tests/du/two-args +++ b/tests/du/two-args @@ -2,7 +2,7 @@ # Make sure `du d/1 d/2' works. # That command failed with du from fileutils-4.0q. -# Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 2000, 2004-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,28 +22,18 @@ if test "$VERBOSE" = yes; then du --version fi -pwd=`pwd` -tmp=du2-$$ -trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0 -trap '(exit $?); exit' 1 2 13 15 +. $srcdir/../test-lib.sh -framework_failure=0 -mkdir $tmp || framework_failure=1 -cd $tmp || framework_failure=1 +t=t +mkdir -p $t/1 $t/2 || framework_failure -if test $framework_failure = 1; then - echo 'failure in testing framework' - (exit 1); exit 1 -fi - -mkdir -p $tmp/1 $tmp/2 - -test -d $tmp || fail=1 -du $tmp/1 $tmp/2 > /dev/null || fail=1 +fail=0 +test -d $t || fail=1 +du $t/1 $t/2 > /dev/null || fail=1 -# Make sure `du . $tmp' and `du .. $tmp' work. +# Make sure `du . $t' and `du .. $t' work. # These would fail prior to fileutils-4.0y. -du . $tmp > /dev/null || fail=1 -du .. $tmp > /dev/null || fail=1 +du . $t > /dev/null || fail=1 +du .. $t > /dev/null || fail=1 (exit $fail); exit $fail |