tests: factor 350 fail=0 initializations into test-lib.sh

Run this command to remove the factored-out "fail=0" lines.
perl -ni -e '/^fail=0$/ or print' $(g grep -l '^fail=0$')
* tests/test-lib.sh: Initialize fail=0 here, not in 300+ scripts.
* tests/...: nearly all bourne shell scripts
Suggested by Eric Blake.
This commit is contained in:
Jim Meyering
2009-10-30 10:50:21 +01:00
parent 12a0a583f6
commit 3c88587b2e
345 changed files with 3 additions and 347 deletions

View File

@@ -24,7 +24,6 @@ fi
. $srcdir/test-lib.sh
require_membership_in_two_groups_
fail=0
set _ $groups; shift
g1=$1

View File

@@ -29,7 +29,6 @@ g2=$2
mkdir d && touch f && ln -s ../f d/s || framework_failure
fail=0
g_init=`stat --printf=%g f`
chgrp -R $g2 d || fail=1

View File

@@ -38,7 +38,6 @@ test "$g" = $g2 ||
skip_test_ "your system doesn't support changing the owner or group" \
"of a symbolic link."
fail=0
chgrp $g1 f
set _ `ls -ln f`; g=$5; test "$g" = $g1 || fail=1

View File

@@ -33,7 +33,6 @@ g2=$2
mkdir -p d/no-x/y || framework_failure
chmod u=rw d/no-x || framework_failure
fail=0
# This must exit nonzero.
chgrp -R $g2 d >/dev/null 2>out && fail=1

View File

@@ -34,7 +34,6 @@ ln -s 1 1s || framework_failure
ln -s ../3 2/2s || framework_failure
chgrp -R $g1 1 2 3 || framework_failure
fail=0
chgrp --preserve-root -H -R $g2 1s 2 || fail=1

View File

@@ -28,7 +28,6 @@ set _ $groups; shift
g1=$1
g2=$2
fail=0
# chgrp -R should not traverse a symlink to a directory.
mkdir d e

View File

@@ -30,7 +30,6 @@ chmod 444 $file || framework_failure
skip_if_setgid_
fail=0
chmod u=rwx $file || fail=1
chmod -c g=rwx $file > out || fail=1

View File

@@ -26,7 +26,6 @@ fi
file=f
touch $file || framework_failure
fail=0
umask 005
for mode in =x =xX =Xx =x,=X =X,=x; do
chmod a=r,$mode $file || fail=1

View File

@@ -27,7 +27,6 @@ fi
touch f || framework_failure
fail=0
expected_u=-rwx------
expected_g=----rwx---

View File

@@ -26,7 +26,6 @@ fi
mkdir -p d/e || framework_failure
chmod 0 d/e d || framework_failure
fail=0
chmod u+rwx d d/e || fail=1

View File

@@ -28,7 +28,6 @@ skip_if_root_
mkdir -p d/no-x/y a/b || framework_failure
chmod u=rw d/no-x || framework_failure
fail=0
# This must exit nonzero.
chmod -R o=r d >/dev/null 2>out && fail=1

View File

@@ -23,7 +23,6 @@ fi
. $srcdir/test-lib.sh
fail=0
# Before coreutils-5.92, this would mistakenly succeed,
# and act like `chmod 0 .'.

View File

@@ -44,7 +44,6 @@ chmod g+s d 2> /dev/null && env -- test -g d ||
env -- test -g d ||
skip_test_ 'cannot create setgid directories'
fail=0
chmod 755 d

View File

@@ -25,7 +25,6 @@ fi
. $srcdir/test-lib.sh
fail=0
chmod -f 0 no-such 2> out && fail=1
chgrp -f 0 no-such 2>> out && fail=1
chown -f 0:0 no-such 2>> out && fail=1

View File

@@ -25,7 +25,6 @@ fi
ln -s non-existent dangle || framework_failure
fail=0
# This operation cannot succeed since the symbolic link dangles.
chmod 644 dangle 2> out && fail=1

View File

@@ -23,7 +23,6 @@ fi
. $srcdir/test-lib.sh
fail=0
touch file
chmod 755 file
(umask 77 && chmod -x file) 2>/dev/null && fail=1

View File

@@ -23,7 +23,6 @@ fi
. $srcdir/test-lib.sh
fail=0
# Each line in this list is a set of arguments, followed by :,
# followed by the set of files it will attempt to chmod,

View File

@@ -26,7 +26,6 @@ require_root_
touch f || framework_failure
fail=0
chown -R --preserve-root 0:1 f
# Make sure the owner and group are 0 and 1 respectively.

View File

@@ -26,7 +26,6 @@ fi
ln -s no-such dangle || framework_failure
fail=0
set _ `ls -ldo dangle`; shift; user=$3

View File

@@ -26,7 +26,6 @@ skip_if_root_
mkdir d && ln -s / d/slink-to-root
fail=0
# Even if --preserve-root were to malfunction, allowing the chown or
# chgrp to traverse through "/", since we're running as non-root,

View File

@@ -46,7 +46,6 @@ case $host_triplet in
*) ;;
esac
fail=0
chown '' . || fail=1

View File

@@ -32,7 +32,6 @@ echo "cp: will not copy \`b/1' through just-created symlink \`c/1'" \
# Check both cases: a dangling symlink, and one pointing to a writable file.
fail=0
for i in dangling-dest existing-dest; do
test $i = existing-dest && echo i > t
test $i = dangling-dest && rm -f t

View File

@@ -45,7 +45,6 @@ acl1=`cd a && getfacl file | grep -v ':bin:' | grep -v 'mask::'` \
test $skip = yes &&
skip_test_ "'.' is not on a suitable file system for this test"
fail=0
# copy a file without preserving permissions
cp a/file b/ || fail=1

View File

@@ -29,7 +29,6 @@ file_backup="$file$suffix"
temp_files="$file $file_backup"
rm -f $temp_files
fail=0
echo test > $file || fail=1
# Specify both version control and suffix so the environment variables

View File

@@ -25,7 +25,6 @@ fi
mkdir x y || framework_failure
fail=0
cp -a x y || fail=1

View File

@@ -26,7 +26,6 @@ fi
echo a > a || framework_failure
echo a-tilde > a~ || framework_failure
fail=0
# This cp command should exit nonzero.
cp --b=simple a~ a > out 2>&1 && fail=1

View File

@@ -28,7 +28,6 @@ echo f > f || framework_failure
ln -s f slink || framework_failure
ln -s no-such-file src-dir/slink || framework_failure
fail=0
cp -H -R slink src-dir dest-dir || fail=1
test -d src-dir || fail=1

View File

@@ -59,7 +59,6 @@ cd mnt || framework_failure
echo > f || framework_failure
echo > g || framework_failure
fail=0
# /bin/cp from coreutils-6.7-3.fc7 would fail this test by letting cp
# succeed (giving no diagnostics), yet leaving the destination file empty.

View File

@@ -28,7 +28,6 @@ mkdir a b c d || framework_failure
ln -s ../c a || framework_failure
ln -s ../c b || framework_failure
fail=0
# Before coreutils-5.94, the following would fail with this message:
# cp: will not create hard link `d/b/c' to directory `d/a/c'

View File

@@ -26,7 +26,6 @@ fi
mkdir -p a b/a/c || framework_failure
touch a/c || framework_failure
fail=0
# coreutils 6.2 cp would neglect to prompt in this case.
echo n | cp -iR a b 2>/dev/null || fail=1

View File

@@ -36,7 +36,6 @@ expected=expected
exec 1> $actual
fail=0
for prog in cp mv; do
for initial_files in 'x' 'x y' 'x y y~' 'x y y.~1~' 'x y y~ y.~1~'; do
for opt in none off numbered t existing nil simple never; do

View File

@@ -59,7 +59,6 @@ getfattr -d a >out_a || skip_test_ "failed to get xattr of file"
grep -F "$xattr_pair" out_a >/dev/null \
|| skip_test_ "failed to set xattr of file"
fail=0
# This should pass without diagnostics
cp -a a mnt/ 2>err || fail=1

View File

@@ -34,7 +34,6 @@ mkdir -p a/b/c d e g || framework_failure
ln -s d/a sym || framework_failure
touch f || framework_failure
fail=0
# With 4.0.37 and earlier (back to when?), this would fail
# with the failed assertion from dirname.c.

View File

@@ -27,7 +27,6 @@ fi
touch f slink-target || framework_failure
ln -s slink-target slink || framework_failure
fail=0
cp -d f slink || fail=1
Exit $fail

View File

@@ -25,7 +25,6 @@ fi
mkdir d e || framework_failure
fail=0
# Do it once with no destination...
cp -R --remove-destination d e || fail=1

View File

@@ -27,7 +27,6 @@ fi
mkdir dir1 dir2 || framework_failure
touch dir1/file || framework_failure
fail=0
cp -R dir1/ dir2 || fail=1
# This file should not exist, but it did with fileutils-4.0w.

View File

@@ -26,7 +26,6 @@ fi
mkdir dir || framework_failure
touch file || framework_failure
fail=0
# In 4.0.35, this cp invocation silently succeeded.
cp -R dir file 2>/dev/null && fail=1

View File

@@ -28,7 +28,6 @@ set _ $groups; shift
g1=$1
g2=$2
fail=0
umask 077
mkfifo fifo ||

View File

@@ -29,7 +29,6 @@ touch D/a || framework_failure
chmod 0 D/a || framework_failure
chmod u=rx,go=,-st D || framework_failure
fail=0
# This is expected to exit non-zero, because it can't read D/a.
cp -pR D DD > /dev/null 2>&1 && fail=1

View File

@@ -30,7 +30,6 @@ fi
mkdir a dir || framework_failure
fail=0
# This command should exit nonzero.
cp -R dir dir 2> out && fail=1

View File

@@ -28,7 +28,6 @@ touch src || framework_failure
touch dest || framework_failure
touch dest2 || framework_failure
fail=0
cp -f --link src dest || fail=1
cp -f --symbolic-link src dest2 || fail=1

View File

@@ -35,7 +35,6 @@ cp -al $a $b || framework_failure
mkdir e || framework_failure
mv $a $b e || framework_failure
fail=0
(ulimit -v 20000; cp -al e f) || fail=1
Exit $fail

View File

@@ -25,7 +25,6 @@ fi
ln -s no-such-file dangling-slink || framework_failure
fail=0
# Prior to coreutils-6.0, this would fail on non-Linux kernels,
# with link being applied to the dangling symlink.

View File

@@ -31,7 +31,6 @@ cp -d a b c || framework_failure
test -f c/a || framework_failure
test -f c/b || framework_failure
fail=0
a_inode=`ls -i c/a|sed 's,c/.*,,'`
b_inode=`ls -i c/b|sed 's,c/.*,,'`

View File

@@ -30,7 +30,6 @@ cd b
ln -s ../a/foo .
cd ..
fail=0
# It should fail with a message something like this:
# ./cp: `a/foo' and `b/foo' are the same file

View File

@@ -30,7 +30,6 @@ cd b
ln -s ../a .
cd ..
fail=0
# It should fail with a message something like this:
# cp: `a' and `b/foo' are the same file

View File

@@ -27,7 +27,6 @@ msg=bar
echo $msg > a
ln -s a b
fail=0
# It should fail with a message something like this:
# cp: `a' and `b' are the same file

View File

@@ -34,7 +34,6 @@ cp -p --parent a/b/c/foo e || framework_failure
# to a destination directory that it doesn't create.
chmod g-rx e/a e/a/b || framework_failure
fail=0
cp -p --parent a/b/d/foo e || fail=1
# Ensure that permissions on just-created directory, e/a/,

View File

@@ -27,7 +27,6 @@ umask 002
mkdir mode ownership d || framework_failure
chmod g+s d 2>/dev/null # The cp test is valid either way.
fail=0
for attr in mode ownership
do

View File

@@ -27,7 +27,6 @@ very_expensive_
umask 037
fail=0
# Now, try it with `mv', with combinations of --force, no-f and
# existing-destination and not.

View File

@@ -25,7 +25,6 @@ fi
touch f || framework_failure
fail=0
cp --preserve=mode,links f g || fail=1

View File

@@ -102,5 +102,4 @@ t1 b1 "$nameless_uid" "$nameless_gid2" cp -p
t1 c0 "$nameless_uid" "$nameless_gid1" cp -p
t1 c1 "$nameless_uid" "$nameless_gid2" cp -p
fail=0
Exit $fail

View File

@@ -40,7 +40,6 @@ cp -Pp dangle d2 || framework_failure
stat --format=%y dangle > t1 || framework_failure
stat --format=%y d2 > t2 || framework_failure
fail=0
compare t1 t2 || fail=1
Exit $fail

View File

@@ -23,7 +23,6 @@ fi
. $srcdir/test-lib.sh
fail=0
kall=/proc/kallsyms
test -r $kall || skip_test_ "your system lacks $kall"

View File

@@ -28,7 +28,6 @@ touch empty || framework_failure
f=/proc/cpuinfo
test -r $f || f=empty
fail=0
cat $f > out || fail=1
# With coreutils-6.9, this would create a zero-length "exp" file.

View File

@@ -31,7 +31,6 @@ echo abc > foo || framework_failure
ln -s foo slink || framework_failure
ln -s no-such-file no-file || framework_failure
fail=0
# This would fail in 4.1.5, not in 4.1.6.
cp -r no-file junk 2>/dev/null || fail=1

View File

@@ -30,7 +30,6 @@ rm -f "$a_other" || framework_failure
echo non_zero_size > "$a_other" || framework_failure
fail=0
# we shouldn't be able to reflink() files on separate partitions
cp --reflink "$a_other" b && fail=1

View File

@@ -23,7 +23,6 @@ fi
. $srcdir/test-lib.sh
fail=0
: > time_check
: > file

View File

@@ -220,7 +220,6 @@ cat <<\EOF | sed "$remove_these_sed" > $expected
EOF
fail=0
compare $expected $actual 1>&2 || fail=1

View File

@@ -30,7 +30,6 @@ ln -s file b || framework_failure
ln -s no-such-file c || framework_failure
ln -s no-such-file d || framework_failure
fail=0
cp --update --no-dereference a b || fail=1
cp --update --no-dereference c d || fail=1

View File

@@ -31,7 +31,6 @@ require_sparse_support_
size=`expr 128 \* 1024 + 1`
dd bs=1 seek=$size of=sparse < /dev/null 2> /dev/null || framework_failure
fail=0
cp --sparse=always sparse copy || fail=1

View File

@@ -35,7 +35,6 @@ chmod a=r,ug+sx c || framework_failure
chown $NON_ROOT_USERNAME . || framework_failure
chmod u=rwx,g=rx,o=rx . || framework_failure
fail=0
cp -p a a2 || fail=1
set _ `ls -l a`; shift; p1=$1

View File

@@ -28,7 +28,6 @@ mkfifo fifo ||
skip_test_ "fifos not supported"
touch e || framework-failure
fail=0
# Without -f, expect it to fail.
cp -R fifo e || fail=1

View File

@@ -25,7 +25,6 @@ fi
mkdir x y || framework_failure
fail=0
cd y
cp --verbose -ab ../x/. . > out 2>&1 || fail=1

View File

@@ -27,7 +27,6 @@ fi
mkdir dir || framework_failure
ln -s dir symlink || framework_failure
fail=0
cp -dR symlink/ s || fail=1
set `ls -l s`

View File

@@ -29,7 +29,6 @@ echo hi > exp || framework_failure
echo "cp: not writing through dangling symlink \`dangle'" \
> exp-err || framework_failure
fail=0
# Starting with 6.9.90, this usage fails, by default:
cp f dangle > err 2>&1 && fail=1

View File

@@ -31,7 +31,6 @@ truncate -s 511 short || framework_failure
truncate -s 8191 m1 || framework_failure
truncate -s 8193 p1 || framework_failure
fail=0
for i in short m1 p1; do
rm -f out
dd if=$i oflag=direct of=out || fail=1

View File

@@ -29,7 +29,6 @@ tmp_in2=dd-in2.$$
tmp_sym=dd-sym.$$
tmp_out=dd-out.$$
fail=0
warn=0
echo data > $tmp_in || framework_failure
ln $tmp_in $tmp_in2 || framework_failure

View File

@@ -24,7 +24,6 @@ fi
. $srcdir/test-lib.sh
fail=0
echo abcde > in
(dd skip=1 count=1 bs=1; dd skip=1 bs=1) < in > out 2> /dev/null || fail=1

View File

@@ -37,7 +37,6 @@ cat <<\EOF > exp-no-reblock || framework_failure
4 bytes (4 B) copied
EOF
fail=0
# Use a fifo rather than a pipe in the tests below
# so that the producer (printf subshell) will wait

View File

@@ -33,7 +33,6 @@ get_device_size() {
$BLOCKDEV --getsize64 "$1"
}
fail=0
# Get path to device the current dir is on.
# Note df can only get fs size, not device size.

View File

@@ -25,7 +25,6 @@ fi
require_sparse_support_ # for `truncate --size=$OFF_T_MAX`
eval $(getlimits) # for OFF_T limits
fail=0
printf "1234" > file || framework_failure

View File

@@ -24,7 +24,6 @@ fi
. $srcdir/test-lib.sh
fail=0
echo LA:3456789abcdef > in || fail=1
(dd bs=1 skip=3 count=0 && dd bs=5) < in > out 2> /dev/null || fail=1

View File

@@ -25,7 +25,6 @@ fi
p=$abs_top_builddir
fail=0
# Ensure this exits successfully, even though stderr is closed,
# because it generates no stderr output.

View File

@@ -25,7 +25,6 @@ fi
printf 000100020003xx > in || framework_failure
fail=0
dd cbs=4 ibs=4 conv=unblock,sync < in > out 2> /dev/null || fail=1
cat <<\EOF > exp || fail=1

View File

@@ -61,7 +61,6 @@ cat space # this helps when debugging any test failure
df --total -i -P > inode || framework_failure
cat inode
fail=0
$PERL check-df space || fail=1
$PERL check-df inode || fail=1

View File

@@ -24,7 +24,6 @@ fi
. $srcdir/test-lib.sh
skip_if_root_
fail=0
touch unreadable || fail=1
chmod a-r unreadable || fail=1
df unreadable || fail=1

View File

@@ -28,7 +28,6 @@ fi
# Creating a 2GB file counts as `very expensive'.
very_expensive_
fail=0
# Get number of free kilobytes on current partition, so we can
# skip this test if there is insufficient free space.

View File

@@ -44,7 +44,6 @@ possibly because this system's NFS support is buggy
Consider rerunning this test on a different file system."
fi
fail=0
# This would print `0 big' with coreutils-4.5.8.
du -ab big > out || fail=1

View File

@@ -32,7 +32,6 @@ 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
fail=0
B=`stat --format=%B a/b/F`

View File

@@ -28,7 +28,6 @@ mkdir -p a/sub || framework_failure
ln -s a/sub slink || framework_failure
touch b || framework_failure
fail=0
# This used to fail with the following diagnostic:
# du: `b': No such file or directory

View File

@@ -29,7 +29,6 @@ ln -s dir slink || framework_failure
printf %65536s x > 64k || framework_failure
ln -s 64k slink-to-64k || framework_failure
fail=0
du -D slink | sed 's/^[0-9][0-9]* //' > out
# Ensure that the trailing slash is preserved and handled properly.

View File

@@ -25,7 +25,6 @@ fi
mkdir -p a/b/c a/x/y a/u/v || framework_failure
fail=0
du --exclude=x a | sed 's/^[0-9][0-9]* //' | sort > out || fail=1
printf '===\n' >> out

View File

@@ -40,7 +40,6 @@ done
# This may fail due to command line limitations.
touch $f || framework_failure
fail=0
# With coreutils-5.0, this would fail due to a file descriptor leak.
du $f > out || fail=1

View File

@@ -28,7 +28,6 @@ fi
mkdir -p dir/sub
( cd dir && { echo non-empty > f1; ln f1 f2; echo non-empty > sub/F; } )
fail=0
# Note that for this first test, we transform f1 or f2
# (whichever name we find first) to f_. That is necessary because,

View File

@@ -28,7 +28,6 @@ skip_if_root_
mkdir f && cd f && mkdir a b c d e && touch c/j && chmod a-x c \
|| framework_failure
fail=0
du > ../t 2>&1 && fail=1
# Accept either of the following outputs.

View File

@@ -25,7 +25,6 @@ skip_if_root_
mkdir -p a/sub || framework_failure
fail=0
du -s a > exp || fail=1
chmod 0 a/sub || fail=1

View File

@@ -33,7 +33,6 @@ mkdir -p no-x a/b || framework_failure
cd no-x || framework_failure
chmod 0 . || framework_failure
fail=0
du "$cwd/a" > /dev/null || fail=1

View File

@@ -65,7 +65,6 @@ mkdir inaccessible || framework_failure
cd inaccessible || framework_failure
chmod 0 . || framework_failure
fail=0
du -s "$cwd/$dir" > /dev/null || fail=1
Exit $fail

View File

@@ -62,7 +62,6 @@ cat $file > /dev/null 2> err &&
in file name resolution'
too_many=`sed 's/.*: //' err`
fail=0
# With coreutils-5.93 there was no failure.
# With coreutils-5.94 we get the desired diagnostic:

View File

@@ -26,7 +26,6 @@ fi
mkdir -p dir/a/b || framework_failure
ln -s dir slink || framework_failure
fail=0
du slink | sed 's/^[0-9][0-9]* //' > out
cat <<\EOF > exp

View File

@@ -28,7 +28,6 @@ skip_if_root_
mkdir -p d/no-x/y || framework_failure
chmod u=rw d/no-x || framework_failure
fail=0
# This must exit nonzero.
du d >/dev/null 2>out && fail=1

View File

@@ -26,7 +26,6 @@ fi
mkdir -p b/c y/z || framework_failure
fail=0
# Due to a used-uninitialized variable, the "du -x" from coreutils-6.6
# would not traverse into second and subsequent directories listed

View File

@@ -26,7 +26,6 @@ fi
mkdir a b || framework_failure
fail=0
# With du from coreutils-4.5.5 and 4.5.6, this would fail with
# du: `b': No such file or directory

View File

@@ -24,7 +24,6 @@ fi
. $srcdir/test-lib.sh
require_readable_root_
fail=0
du --exclude='[^/]*' -x / > out-t || fail=1
sed 's/^[0-9][0-9]* //' out-t > out

View File

@@ -45,7 +45,6 @@ if df --type=nfsv3 . >/dev/null 2>&1; then
skip_test_ "\`.' is on an NFS file system"
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
name=`seq 1 $len|tr -c x y |head -c$len`

View File

@@ -29,7 +29,6 @@ fi
mkdir -p dir/1/2 || framework_failure
ln -s dir slink || framework_failure
fail=0
du slink/ | sed 's/^[0-9][0-9]* //' > out
echo === >> out

View File

@@ -33,7 +33,6 @@ cd sub || framework_failure
t=t
mkdir -p $t/1 $t/2 || framework_failure
fail=0
test -d $t || fail=1
du $t/1 $t/2 > /dev/null || fail=1

View File

@@ -27,7 +27,6 @@ fi
# but this is as good a witness as any, in general.
require_selinux_
fail=0
# Require the context=... part by default.
id > out || fail=1

View File

@@ -31,7 +31,6 @@ rm -rf $dir $file || framework_failure
mkdir -p $dir || framework_failure
echo foo > $file || framework_failure
fail=0
ginstall $file $dir || fail=1
# Make sure the source file still exists.
test -f $file || fail=1

Some files were not shown because too many files have changed in this diff Show More