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.
. $srcdir/test-lib.sh
require_membership_in_two_groups_
-fail=0
set _ $groups; shift
g1=$1
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
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
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
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
g1=$1
g2=$2
-fail=0
# chgrp -R should not traverse a symlink to a directory.
mkdir d e
skip_if_setgid_
-fail=0
chmod u=rwx $file || fail=1
chmod -c g=rwx $file > out || fail=1
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
touch f || framework_failure
-fail=0
expected_u=-rwx------
expected_g=----rwx---
mkdir -p d/e || framework_failure
chmod 0 d/e d || framework_failure
-fail=0
chmod u+rwx d d/e || fail=1
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
. $srcdir/test-lib.sh
-fail=0
# Before coreutils-5.92, this would mistakenly succeed,
# and act like `chmod 0 .'.
env -- test -g d ||
skip_test_ 'cannot create setgid directories'
-fail=0
chmod 755 d
. $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
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
. $srcdir/test-lib.sh
-fail=0
touch file
chmod 755 file
(umask 77 && chmod -x file) 2>/dev/null && fail=1
. $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,
touch f || framework_failure
-fail=0
chown -R --preserve-root 0:1 f
# Make sure the owner and group are 0 and 1 respectively.
ln -s no-such dangle || framework_failure
-fail=0
set _ `ls -ldo dangle`; shift; user=$3
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,
*) ;;
esac
-fail=0
chown '' . || fail=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
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
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
mkdir x y || framework_failure
-fail=0
cp -a x y || fail=1
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
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
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.
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'
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
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
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
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.
touch f slink-target || framework_failure
ln -s slink-target slink || framework_failure
-fail=0
cp -d f slink || fail=1
Exit $fail
mkdir d e || framework_failure
-fail=0
# Do it once with no destination...
cp -R --remove-destination d e || fail=1
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.
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
g1=$1
g2=$2
-fail=0
umask 077
mkfifo fifo ||
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
mkdir a dir || framework_failure
-fail=0
# This command should exit nonzero.
cp -R dir dir 2> out && fail=1
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
mkdir e || framework_failure
mv $a $b e || framework_failure
-fail=0
(ulimit -v 20000; cp -al e f) || fail=1
Exit $fail
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.
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/.*,,'`
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
ln -s ../a .
cd ..
-fail=0
# It should fail with a message something like this:
# cp: `a' and `b/foo' are the same file
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
# 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/,
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
umask 037
-fail=0
# Now, try it with `mv', with combinations of --force, no-f and
# existing-destination and not.
touch f || framework_failure
-fail=0
cp --preserve=mode,links f g || fail=1
t1 c0 "$nameless_uid" "$nameless_gid1" cp -p
t1 c1 "$nameless_uid" "$nameless_gid2" cp -p
-fail=0
Exit $fail
stat --format=%y dangle > t1 || framework_failure
stat --format=%y d2 > t2 || framework_failure
-fail=0
compare t1 t2 || fail=1
Exit $fail
. $srcdir/test-lib.sh
-fail=0
kall=/proc/kallsyms
test -r $kall || skip_test_ "your system lacks $kall"
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.
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
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
. $srcdir/test-lib.sh
-fail=0
: > time_check
: > file
EOF
-fail=0
compare $expected $actual 1>&2 || fail=1
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
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
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
skip_test_ "fifos not supported"
touch e || framework-failure
-fail=0
# Without -f, expect it to fail.
cp -R fifo e || fail=1
mkdir x y || framework_failure
-fail=0
cd y
cp --verbose -ab ../x/. . > out 2>&1 || fail=1
mkdir dir || framework_failure
ln -s dir symlink || framework_failure
-fail=0
cp -dR symlink/ s || fail=1
set `ls -l s`
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
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
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
. $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
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
$BLOCKDEV --getsize64 "$1"
}
-fail=0
# Get path to device the current dir is on.
# Note df can only get fs size, not device size.
require_sparse_support_ # for `truncate --size=$OFF_T_MAX`
eval $(getlimits) # for OFF_T limits
-fail=0
printf "1234" > file || framework_failure
. $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
p=$abs_top_builddir
-fail=0
# Ensure this exits successfully, even though stderr is closed,
# because it generates no stderr output.
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
df --total -i -P > inode || framework_failure
cat inode
-fail=0
$PERL check-df space || fail=1
$PERL check-df inode || fail=1
. $srcdir/test-lib.sh
skip_if_root_
-fail=0
touch unreadable || fail=1
chmod a-r unreadable || fail=1
df unreadable || fail=1
# 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.
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
printf %4096s x > d/1
cp d/1 d/sub/2
-fail=0
B=`stat --format=%B a/b/F`
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
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.
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
# 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
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,
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.
mkdir -p a/sub || framework_failure
-fail=0
du -s a > exp || fail=1
chmod 0 a/sub || fail=1
cd no-x || framework_failure
chmod 0 . || framework_failure
-fail=0
du "$cwd/a" > /dev/null || fail=1
cd inaccessible || framework_failure
chmod 0 . || framework_failure
-fail=0
du -s "$cwd/$dir" > /dev/null || fail=1
Exit $fail
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:
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
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
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
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
. $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
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`
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
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
# 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
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
. $srcdir/test-lib.sh
-fail=0
file=file
echo foo > $file
. $srcdir/test-lib.sh
-fail=0
ginstall -d d1/. || fail=1
test -d d1 || fail=1
mode2=0755
mode3=2755
-fail=0
echo test > a || framework_failure
echo "\`a' -> \`b'" > out_installed_first || framework_failure
g1=1
g2=2
-fail=0
echo test > a || framework_failure
echo "\`a' -> \`b'" > out_installed_first
. $srcdir/test-lib.sh
require_selinux_
-fail=0
echo test > a || framework_failure
chcon -u system_u a || skip_test_ "chcon doesn't work"
EOF
chmod a+x b || framework_failure
-fail=0
echo abc > src || fail=1
echo aBc > exp || fail=1
. $srcdir/test-lib.sh
-fail=0
# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
(
touch a b || framework_failure
-fail=0
ln b b~ || fail=1
ln -f --b=simple a b || fail=1
touch f || framework_failure
-fail=0
ln --backup f f 2> out && fail=1
cat <<\EOF > exp || fail=1
. $srcdir/test-lib.sh
-fail=0
# ===================================================
# ensure -s silently overrides -L, -P
d=tln-subdir
ld=tln-symlink-to-subdir
f=tln-file
-fail=0
# Create a simple symlink with both source and destination files
# in current directory.
echo foo > a || framework_failure
ln -s . b || framework_failure
-fail=0
ln -sf a b > err 2>&1 && fail=1
case `cat err` in
*'are the same file') ;;
touch f || framework_failure
-fail=0
# Before coreutils-7.6, this would succeed on Solaris 10
ln -T f no-such-file/ && fail=1
. $srcdir/test-lib.sh
mkdir d || framework_failure
-fail=0
ln -s --target-dir=d ../f || fail=1
Exit $fail
touch -d"+$mon month" $mon.ts || framework_failure
done
-fail=0
# Note some of the following locales may be missing but if so
# we should fail back to the C locale which should be aligned
(setcap --help) 2>&1 |grep 'usage: setcap' > /dev/null \
|| skip_test_ "setcap utility not found"
-fail=0
# Don't let a different umask perturb the results.
umask 22
c_post="$e[0m$e[K\n$e[m"
printf "$c_pre$long_name$c_post\n" > exp || framework_failure
-fail=0
env TERM=xterm COLUMNS=80 LS_COLORS="*.foo=$color_code" TIME_STYLE=+T \
ls -og --color=always $long_name > out || fail=1
chmod o+w other-writable || framework_failure
chmod o+t sticky || framework_failure
-fail=0
ls --color=always > out || fail=1
cat -A out > o1 || fail=1
printf '? dangle\n' > subdir_Li_exp || framework_failure
printf 'total 0\n? dangle\n' > subdir_Ls_exp || framework_failure
-fail=0
# This must exit nonzero.
ls -L dangle > /dev/null 2>&1 && fail=1
mkdir dir || framework_failure
-fail=0
LC_MESSAGES=C ls -lR --dired dir > out || fail=1
cat <<EOF > exp
cd ..
-fail=0
ls -F sub > out || fail=1
cat <<EOF > exp
# systems running some DJGPP-2.03 libc.
ls -F link > /dev/null || framework_failure
-fail=0
# When explicitly listing a broken link, the command must fail.
ls -L link 2> /dev/null && fail=1
ls: loop/sub: not listing already-listed directory
EOF
-fail=0
timeout 1 ls -RL loop 2>err > out
# Ensure that ls exits with status 2 upon detecting a cycle
touch f || framework_failure
ln -s f slink || framework_failure
-fail=0
# When listed explicitly:
seq 2000 > b || framework_failure
touch a || framework_failure
-fail=0
# Before coreutils-5.1.1, the following would output a space after the comma.
ls -w2 -m a b > out || fail=1
c_mh=$(printf '\033[%sm' $code_mh)
c_ex=$(printf '\033[%sm' $code_ex)
c_png=$(printf '\033[%sm' $code_png)
-fail=0
# regular file - not hard linked
LS_COLORS="mh=$code_mh" ls -U1 --color=always file > out || fail=1
touch f || framework_failure
chown $nameless_uid f || framework_failure
-fail=0
set -- `ls -o f` || fail=1
test $3 = $nameless_uid || fail=1
symlink
EOF
-fail=0
ls -1 > out || fail=1
. $srcdir/test-lib.sh
require_strace_ capget
-fail=0
strace -e capget ls --color=always > /dev/null 2> out || fail=1
$EGREP 'capget\(' out || skip_test_ "your ls doesn't call capget"
f=/proc/sys
test -r $f || f=.
-fail=0
ls -l $f > out || fail=1
Exit $fail
. $srcdir/test-lib.sh
-fail=0
mount_points=$(df --local -P 2>&1 | sed -n 's,.*[0-9]% \(/.\),\1,p')
test -z "$mount_points" && skip_test_ "this test requires a non-root mount point"
mkdir x y a b c a/1 a/2 a/3 || framework_failure
touch f a/1/I a/1/II || framework_failure
-fail=0
# This first example is from Andreas Schwab's bug report.
ls -R1 a b c > out || fail=1
touch -d "$date" a || framework_failure
touch -d "$date" b || framework_failure
-fail=0
ls -1t a b c > out || fail=1
cat <<EOF > exp
mkdir -p e/a2345 e/b || framework_failure
chmod 600 e || framework_failure
-fail=0
ls --file-type d > out || fail=1
cat <<\EOF > exp || fail=1
ln -s / d/s || framework_failure
chmod 600 d || framework_failure
-fail=0
ls -Log d > out
test $? = 1 || fail=1
chmod a+x x || framework_failure
ln -s x link-to-x || framework_failure
-fail=0
# ls from coreutils 6.9 would unnecessarily stat a symlink in an unusual case:
# When not coloring orphan and missing entries, and without ln=target,
. $srcdir/test-lib.sh
-fail=0
root_dev_ino=`stat --format=%d-%i /`
t=`pwd`
mkdir dir || framework_failure
ln -s dir symlink || framework_failure
-fail=0
set `ls -l symlink/`
# Prior to fileutils-4.0k, the following would have output `... symlink -> dir'.
touch subdir/b || framework_failure
touch subdir/a || framework_failure
-fail=0
# Coreutils 6.8 and 6.9 would output this in the wrong order.
ls -x subdir > out || fail=1
arch --version
fi
-fail=0
arch > out || fail=1
uname -m > exp || fail=1
# write separately.
mkfifo fifo || framework_failure
-fail=0
echo 1 > exp
test -f $f \
|| skip_test_ "no $f"
-fail=0
# Yes, parts of /proc/cpuinfo might change between cat runs.
# If that happens, consider choosing a file that's less likely to change,
mkdir -p d/sub/s2 || framework_failure
touch f g d/sub/1 d/sub/2 || framework_failure
-fail=0
# Set to a specified context.
# Use root:object_r:tmp_t:s0. It is special in that
. $srcdir/test-lib.sh
-fail=0
# neither context nor file
chcon 2> /dev/null && fail=1
require_root_
-fail=0
# Verify that root credentials are kept.
test $(chroot / whoami) = root || fail=1
. $srcdir/test-lib.sh
-fail=0
# These tests verify exact status of internal failure; since none of
# them actually run a command, we don't need root privileges
p=$abs_top_builddir
-fail=0
# Ensure these exit successfully, even though stdout is closed,
# because they generate no output.
. $srcdir/test-lib.sh
-fail=0
# csplit could get a failed assertion to 2.0.17
(echo a; echo; echo) > in
. $srcdir/test-lib.sh
-fail=0
# It would be easier simply to sleep for two seconds between two runs
# of `date --date="21:04 +0100" +%S` and ensure that both outputs
. $srcdir/test-lib.sh
-fail=0
df -P . > t1 || fail=1
BLOCK_SIZE=1M df -P . > t2 || fail=1
. $srcdir/test-lib.sh
-fail=0
# Verify clearing the environment
a=1
. $srcdir/test-lib.sh
-fail=0
# POSIX is clear that environ may, but need not be, sorted.
# Environment variable values may contain newlines, which cannot be
. $srcdir/test-lib.sh
-fail=0
false --version > /dev/null && fail=1
false --help > /dev/null && fail=1
y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y
EOF
-fail=0
fmt -s in > out || fail=1
# Coreutils 6.9 and earlier failed to display information on first argument
# if later argument was --.
-fail=0
groups none -- > out 2>&1 && fail=1
echo $? >> out
groups -- none -- > exp 2>&1 && fail=1
. $srcdir/test-lib.sh
require_built_ groups
-fail=0
groups --version | sed 's/^groups/id/; /^$/q' > out || fail=1
id --version | sed '/^$/q' > exp || fail=1
echo abc > in || framework_failure
-fail=0
(head -c1; head -c1) < in > out || fail=1
case "`cat out`" in
ab) ;;
(echo a; echo b) > in || framework_failure
-fail=0
(head -n 1 >/dev/null; cat) < in > out || fail=1
cat <<EOF > exp
b
expected_failure_status_ls=2
expected_failure_status_vdir=2
-fail=0
test "$built_programs" \
|| { echo "$this_test: no programs built!?!" 1>&2; Exit $fail; }
# Require selinux - when selinux is disabled, id never prints scontext.
require_selinux_
-fail=0
# Check without specified user, context string should be present.
id | grep context= >/dev/null || fail=1
. $srcdir/test-lib.sh
-fail=0
id -G $(id -nu) || fail=1
Exit $fail
sleep 2
touch -a -d "$u1" a || framework_failure
-fail=0
# A has ctime more recent than C.
set `ls -c a c`
md5sum --version
fi
-fail=0
(mkdir tmp && cd tmp && seq 500 | xargs touch)
. $srcdir/test-lib.sh
-fail=0
umask 777
skip_test_ "this test must be run at nice level 0"
fi
-fail=0
while :; do
test_name=$1
args=$2
. $srcdir/test-lib.sh
-fail=0
# These tests verify exact status of internal failure.
nice -n 1 # missing command
. $srcdir/test-lib.sh
-fail=0
echo a | nl > out || fail=1
echo b | nl -s%n >> out || fail=1
. $srcdir/test-lib.sh
-fail=0
nohup sh -c 'echo stdout; echo stderr 1>&2' 2>err || fail=1
echo abcdefg > in || framework_failure
-fail=0
(od -An -N3 -c; od -An -N3 -c) < in > out
cat <<EOF > exp || fail=1
seq 19 > in || framework_failure
test `wc -c < in` -eq 48 || framework_failure
-fail=0
list='a c dC dS dI dL oC oS oI oL uC uS uI uL xC xS xI xL fF fD fL'
for format1 in $list; do
echo abcdefgh |tr -d '\n' > in || framework_failure
-fail=0
od -An -t x8 in > out-raw || fail=1
sed 's/^ //;s/\(..\)/\1 /g;s/ $//' out-raw \
touch file || framework_failure
-fail=0
# This should exit nonzero. Before 2.0.13, it gave a diagnostic,
# but exited successfully.
. $srcdir/test-lib.sh
-fail=0
# Without arguments, printenv behaves like env. Some shells provide
# printenv as a builtin, so we must test via absolute name.
. $srcdir/test-lib.sh
getlimits_
-fail=0
# Verify the 3 methods of specifying "Escape":
test $("$prog" "\x1b\n\33\n\e\n" | uniq -u) && fail=1
. $srcdir/test-lib.sh
-fail=0
"$prog" '\x7e3\n' > out || fail=1
cat <<\EOF > exp
. $srcdir/test-lib.sh
require_ulimit_
-fail=0
# Up to coreutils-6.9, "printf %.Nf 0" would encounter an ENOMEM internal
# error from glibc's printf(3) function whenever N was large relative to
f=01234567890123456789012345678901234567890123456789
touch $f empty || framework_failure
-fail=0
# Specifying a regular expression ending in a lone backslash
# would cause ptx to write beyond the end of a malloc'd buffer.
cd c || framework_failure
test "x$PWD" = "x$base/c" || skip_test_ "cd does not properly update \$PWD"
-fail=0
env -- pwd -L > out || fail=1
printf %s\\n "$base/c" > exp || fail=1
cd a/b || framework_failure
chmod a=x .. || framework_failure
-fail=0
env -- pwd > exp || fail=1
readlink -ev . > out || fail=1
echo 2 > d/2 || framework_failure
ln -s ../s/2 d/1 || framework_failure
-fail=0
# With coreutils-6.9, this would fail with ELOOP.
readlink -v -e p/1 > out || fail=1
# readlink -e d/2 > exp || fail=1
diag='runcon: runcon may be used only on a SELinux kernel'
echo "$diag" > exp || framework_failure
-fail=0
# This test works even on systems without SELinux.
# On such a system it fails with the above diagnostic, which is fine.
mkdir d s1 s2 || framework_failure
mkfifo p || framework_failure
-fail=0
# special context that works both with and without mcstransd
ctx=root:object_r:tmp_t:s0
a=$INTMAX_MAX
b=$INTMAX_OFLOW
-fail=0
seq $a $b > out || fail=1
printf "$a\n$b\n" > exp || fail=1
compare out exp || fail=1
. $srcdir/test-lib.sh
-fail=0
for opt in --exact --zero; do
echo a > a || fail=1
shred: f: renamed to 0
shred: f: removed" > exp || framework_failure
-fail=0
shred -v -u f 2>out || fail=1
touch $file || framework_failure
chmod u-w $file || framework_failure
-fail=0
# This would take so long that it appears to infloop
# when using version from fileutils-4.0k.
seq 100 > in || framework_failure
-fail=0
shuf in >out || fail=1
# Fail if the input is the same as the output.
# Ensure that $TMPDIR is valid.
TMPDIR=.; export TMPDIR
-fail=0
# This should force the use of temp files
sort -S 1k in > out || fail=1
echo $i | tee -a in > __test.$i || framework_failure
done
-fail=0
(
ulimit -n 6
mkdir in err || framework_failure
-fail=0
for i in `seq 17`; do
echo $i >in/$i
seq 100 > in || framework_failure
-fail=0
sort --random-sort in > out || fail=1
string start 5.90.0 end of str
_EOF_
-fail=0
sort --sort=version -o out in || fail=1
compare exp out || fail=1
Exit $fail
echo split: output file suffixes exhausted \
> exp-too-short || framework_failure
-fail=0
# This should fail.
split -b 1 -a 1 in 2> err && fail=1
touch in || framework_failure
-fail=0
split -a 0 in 2> /dev/null || fail=1
split -b 0 in 2> /dev/null && fail=1
printf '1\n2\n3\n4\n5\n' > in || framework_failure
-fail=0
split --lines=2 in > out || fail=1
cat <<\EOF > exp-1
1
. $srcdir/test-lib.sh
-fail=0
for i in `seq 50`; do
fmt=`printf "%${i}s" %`
printf -- '-\n' > exp || framework_failure
touch f || framework_failure
-fail=0
stat --format=%n - < f > out || fail=1
stat -f - < f && fail=1
directory
EOF
-fail=0
# This failed on Solaris 9 for coreutils 8.0.
stat --format=%n link1 > out || fail=1
stat --format=%n link1/ >> out && fail=1
# write separately.
mkfifo fifo || framework_failure
-fail=0
# Verify input parameter checking
stdbuf -o1 true || fail=1 # verify size syntax
REV_oddp=1 REV_nl=1 REV_cooked=1 REV_raw=1 REV_pass8=1 REV_litout=1
REV_cbreak=1 REV_decctlq=1 REV_tabs=1 REV_lcase=1 REV_LCASE=1
-fail=0
saved_state=.saved-state
stty --save > $saved_state || fail=1
require_controlling_input_terminal_
trap '' TTOU # Ignore SIGTTOU
-fail=0
saved_state=`stty -g` || fail=1
stty $saved_state || fail=1
saved_size=`stty size` && test -n "$saved_size" \
|| skip_test_ "can't get window size"
-fail=0
while :; do
test_name=$1
args=$2
su --version
fi
-fail=0
# Very little that we can test without a root password
su --- / true # unknown option
. $srcdir/test-lib.sh
-fail=0
# FYI, 16843009 is floor (2^32 / 255).
seq 5 > in
-fail=0
# Give tac a fifo command line argument.
# This makes it try to create a temporary file in $TMPDIR.
echo line >sample || framework_failure
nums=`seq 9` || framework_failure
-fail=0
for n in 0 $nums; do
files=`seq $n`
rm -f $files
. $srcdir/test-lib.sh
-fail=0
tee - </dev/null || fail=1
Exit $fail
. $srcdir/test-lib.sh
-fail=0
# no timeout
timeout 1 true || fail=1
. $srcdir/test-lib.sh
getlimits_
-fail=0
# internal errors are 125, distinct from execution failure
. $srcdir/test-lib.sh
ln -s truncate-target t-symlink
-fail=0
truncate -s0 t-symlink || fail=1
. $srcdir/test-lib.sh
skip_if_root_
-fail=0
d1=no
mkfifo_or_skip_ "fifo"
-fail=0
truncate -s0 "fifo" || fail=1
. $srcdir/test-lib.sh
-fail=0
# truncate -c no-such-file should not fail.
truncate -s0 -c no-such-file || fail=1
. $srcdir/test-lib.sh
getlimits_
-fail=0
# -= overflow
truncate -s-1 create-zero-len-file || fail=1
# Ensure that the current directory is searchable by $NON_ROOT_USERNAME.
chmod g+x .
-fail=0
setuidgid $NON_ROOT_USERNAME env PATH="$PATH" truncate -s0 root-owned || fail=1
Exit $fail
. $srcdir/test-lib.sh
-fail=0
# must specify at least 1 file
truncate --size=0 && fail=1
. $srcdir/test-lib.sh
-fail=0
# mixture of relative modifiers not allowed
truncate --size="+>0" file && fail=1
echo 2 words > 2w || framework_failure
printf '2b\n2w\n' |tr '\n' '\0' > names || framework_failure
-fail=0
wc --files0-from=names > out || fail=1
cat <<\EOF > exp || fail=1
grep -F "$xattr_pair" out_a \
|| skip_test_ "failed to set xattr of file"
-fail=0
# cp should not preserve xattr by default
cp a b || fail=1
. $srcdir/test-lib.sh
-fail=0
mkdir --parents "`pwd`/t" || fail=1
test -d t || fail=1
. $srcdir/test-lib.sh
-fail=0
mkdir --parents "`pwd`/t/u" || fail=1
test -d t/u || fail=1
mkdir no-acce2s || framework_failure
mkdir -p no-acce3s/d || framework_failure
-fail=0
p=`pwd`
(cd no-access && chmod 0 . && mkdir -p "$p/a/b" u/v) 2> /dev/null && fail=1
test -d "$p/a/b" || fail=1
. $srcdir/test-lib.sh
-fail=0
mkdir -p d1/. || fail=1
test -d d1 || fail=1
ln -s . slink || framework_failure
-fail=0
mkdir -p slink/x || fail=1
test -d x || fail=1
. $srcdir/test-lib.sh
-fail=0
mkdir -pv foo/a/b/c/d >out || fail=1
diff - out <<\EOF
mkdir -m 700 e-dir || framework_failure
-fail=0
# Make sure `mkdir -p existing-dir' succeeds
# and that `mkdir existing-dir' fails.
working_umask_or_skip_
-fail=0
# parent parent/dir
# umask -m option resulting perm resulting perm
c=invalid-selinux-context
msg="failed to set default file creation context to \`$c':"
-fail=0
# Test each of mkdir, mknod, mkfifo with "-Z invalid-context".
for cmd_w_arg in 'mkdir dir' 'mknod b p' 'mkfifo f'; do
set_mode_string=u=rwx,g=rx,o=w,-s,+t
output_mode_string=drwxr-x-wT
-fail=0
tmp=t
mkdir -m$set_mode_string $tmp || fail=1
. $srcdir/test-lib.sh
-fail=0
mkdir -p dir/ || fail=1
test -d dir || fail=1
# FIXME: define cleanup_ to do the umount
-fail=0
# FIXME: use mktemp
cd /tmp \
&& dd if=/dev/zero of=1 bs=8192 count=50 \
test $skip_partition != none &&
skip_test_ "'$skip' is not on a suitable file system for this test"
-fail=0
# move the access acl of a file
mv file "$other_partition_tmpdir" || fail=1
acl2=`cd "$other_partition_tmpdir" && getfacl file` || framework_failure
ln -s t1 s1 || framework_failure
ln -s t2 s2 || framework_failure
-fail=0
strace -qe unlink mv -T s1 s2 > out 2>&1 || fail=1
$EGREP 'unlink.*"s1"' out && fail=1
touch a b || framework_failure
ln b b2 || framework_failure
-fail=0
strace -qe unlink mv a b > out 2>&1 || fail=1
$EGREP 'unlink.*"b"' out && fail=1
mkdir A B || framework_failure
touch X Y || framework_failure
-fail=0
# Before coreutils-6.2, the " (backup: `B.~1~')" suffix was not printed.
mv --verbose --backup=numbered -T A B > out || fail=1
echo a > "$a" || framework_failure
echo a2 > "$a2" || framework_failure
-fail=0
# This mv command should exit nonzero.
mv --b=simple "$a2" "$a" > out 2>&1 && fail=1
echo a > a/f || framework_failure
echo b > b/f || framework_failure
-fail=0
cp a/f b/f c 2> /dev/null && fail=1
test -f a/f || fail=1
touch f2 || framework_failure
touch d || framework_failure
-fail=0
# These mv commands should all exit nonzero.
# Too few args. This first one did fail, but with an incorrect diagnostic
mkdir -p dir/file || framework_failure
> file || framework_failure
-fail=0
# These should both fail, but until fileutils-4.0q only the second one did.
mv dir file > /dev/null 2>&1 && fail=1
mkdir -p a/t b/t || framework_failure
touch a/t/f || framework_failure
-fail=0
# Expect this to fail with the expected diagnostic.
# For an interrim (pre-6.0) release, it would give an erroneous
. $srcdir/test-lib.sh
skip_if_root_
-fail=0
for i in cp; do
echo force-contents > $ff || framework_failure
ln $ff $ff2 || framework_failure
-fail=0
# This mv command should exit nonzero.
mv $ff $ff > out 2>&1 && fail=1
ln a b || framework_failure
ln a c || framework_failure
-fail=0
# ======================================
cp --preserve=link a b c dst || fail=1
ln a x/b || framework_failure
ln a c || framework_failure
-fail=0
# ======================================
# This must fail -- because x/b cannot be unlinked.
touch a || framework_failure
ln a b || framework_failure
-fail=0
mv a b || fail=1
> $dir/a || framework_failure
ln $dir/a $dir/b || framework_failure
-fail=0
mv $dir "$other_partition_tmpdir" || fail=1
# Display inode numbers, one per line.
touch x || framework_failure
ln x y || framework_failure
-fail=0
mv --verbose x y > out || fail=1
cat <<\EOF > exp || fail=1
chmod 0 b d f h || framework_failure
echo y > y || framework_failure
-fail=0
mv -if a b || fail=1
mv -fi c d < y >/dev/null 2>&1 || fail=1
touch f g h i || framework_failure
chmod 0 g i || framework_failure
-fail=0
ls /dev/stdin >/dev/null 2>&1 \
|| skip_test_ 'there is no /dev/stdin file'
done
echo y > y || framework_failure
-fail=0
mv -i a b < y >/dev/null 2>&1 || fail=1
# Make sure out contains the prompt.
mkdir a || framework_failure
touch b || framework_failure
-fail=0
# coreutils 6.2 mv would neglect to prompt in this case.
echo n | mv -i a b 2>/dev/null || fail=1
chmod a-w b/bar || framework_failure
echo n > no || framework_failure
-fail=0
mv a/bar a/foo b < no > out 2> err || fail=1
touch exp
mkdir -p $dir/a/b || framework_failure
touch $file || framework_failure
-fail=0
# This mv command should fail.
mv $dir $file $dir > out 2>&1 && fail=1
file="$other_partition_tmpdir/file"
symlink=symlink
-fail=0
echo whatever > $file || framework_failure
ln -s $file $symlink || framework_failure
mkdir $dir1 $dir2 || framework_failure
-fail=0
# This mv command should exit nonzero.
mv $dir1 $dir2 $dir2 > out 2>&1 && fail=1
touch file || framework_failure
ln -s file s || framework_failure
-fail=0
# This must fail.
mv s s 2> /dev/null && fail=1
last_file=`tail -n1 .dirs`/f
test -f $last_file || framework_failure
-fail=0
mv * "$other_partition_tmpdir" || fail=1
test -f $last_file/f && fail=1
. $srcdir/test-lib.sh
-fail=0
# test miscellaneous combinations of -f -i -n parameters
touch a b || framework_failure
# from an OpenBSD system, the above mknod fails.
# It's not worth making an exception any more.
-fail=0
mv --verbose $null $dir "$other_partition_tmpdir" > out || fail=1
# Make sure the files are gone.
test -p $null && fail=1
mv a b ||
skip_test_ "your kernel's rename syscall is buggy"
-fail=0
# This should succeed, since both src and dest are directories,
# and the dest dir is empty.
touch k "$other_partition_tmpdir/k" || framework_failure
chmod u-w "$other_partition_tmpdir" || framework_failure
-fail=0
mv -f k "$other_partition_tmpdir" 2> out && fail=1
cat <<EOF > exp
touch a/1 || framework_failure
ln a/1 b/1 || framework_failure
-fail=0
mv f g "$other_partition_tmpdir" || fail=1
mv a b "$other_partition_tmpdir" || fail=1
mkdir foo || framework_failure
-fail=0
mv foo/ "$other_partition_tmpdir/bar" || fail=1
# can make this test fail.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-fail=0
# Four cases:
# local regular file w/symlink on another partition
umask 077
mv file "$other_partition_tmpdir"
-fail=0
test -f file && fail=1
test -f "$other_partition_tmpdir/file" || fail=1
mkdir -p no-write/dir || framework_failure
chmod u-w no-write || framework_failure
-fail=0
mv no-write/dir . > out 2>&1 && fail=1
cat <<\EOF > exp
# We have to allow $NON_ROOT_USERNAME access to ".".
chmod go+x . || framework_failure
-fail=0
# Ensure that $NON_ROOT_USERNAME can access the required version of mv.
version=`setuidgid $NON_ROOT_USERNAME env PATH="$PATH" mv --version|sed -n '1s/.* //p'`
rem_symlink="$other_partition_tmpdir/symlink"
file=to-sym-$$
-fail=0
rm -f $file || framework_failure
echo local > $file || framework_failure
mkdir foo || framework_failure
-fail=0
mv foo/ bar || fail=1
touch -d yesterday old || framework_failure
echo new > new || framework_failure
-fail=0
for interactive in '' -i; do
for cp_or_mv in cp mv; do
my_pwd=$("$abs_top_builddir/src/pwd")
tmp=d
-fail=0
mkdir $tmp || framework_failure
cd $tmp || framework_failure
cd "$pwd/$tmp/removed" || framework_failure
-fail=0
# Skip this test if the system doesn't let you remove the working directory.
if rmdir ../removed 2>/dev/null; then
v=`readlink -e .` && fail=1
my_pwd=$("$abs_top_builddir/src/pwd")
tmp=d
-fail=0
mkdir $tmp || framework_failure
cd $tmp || framework_failure
cd "$pwd/$tmp/removed" || framework_failure
-fail=0
# Skip this test if the system doesn't let you remove the working directory.
if rmdir ../removed 2>/dev/null; then
v=`readlink -e .` && fail=1
my_pwd=$("$abs_top_builddir/src/pwd")
tmp=d
-fail=0
mkdir $tmp || framework_failure
cd $tmp || framework_failure
cd "$pwd/$tmp/removed" || framework_failure
-fail=0
# Skip this test if the system doesn't let you remove the working directory.
if rmdir ../removed 2>/dev/null; then
v=`readlink -e .` && fail=1
ln -s regfile link1 || framework_failure
ln -s missing link2 || framework_failure
-fail=0
v=`readlink link1` || fail=1
test "$v" = regfile || fail=1
touch a/b/file
chmod u-w a/b
-fail=0
rm -rf a a 2>&1 | sed 's/:[^:]*$//' > out || fail=1
cat <<\EOF > exp
ln -s no-file dangle
ln -s / symlink
-fail=0
rm ---presume-input-tty dangle symlink &
pid=$!
umask 022
-fail=0
k20=/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k
k200=$k20$k20$k20$k20$k20$k20$k20$k20$k20$k20
cd .. || framework_failure
echo n > no || framework_failure
-fail=0
rm ---presume-input-tty -r x < no > out || fail=1
# expect empty output
mkdir --mode=0500 unwritable-dir || framework_failure
-fail=0
# For rm from coreutils-5.0.1, this would prompt.
rm ---presume-input-tty unwritable-dir < /dev/null > out-t 2>&1 && fail=1
mkdir d || framework_failure
-fail=0
rm d 2> out && fail=1
cat <<\EOF > exp || fail=1
mkdir a b || framework_failure
touch a/f b/f || framework_failure
-fail=0
rm -r a b || fail=1
# that is empty (hence removable) and unreadable.
mkdir -m a-r -p a/unreadable
-fail=0
# This would fail for e.g., coreutils-5.93.
rm -rf inacc || fail=1
test $threshold_seconds -lt $setup_duration \
&& threshold_seconds=$setup_duration
-fail=0
start=$(date +%s)
timeout ${threshold_seconds}s rm -rf d; err=$?
duration=$(expr $(date +%s) - $start)
mkdir -p d || framework_failure
-fail=0
rm -f d/no-such-file || fail=1
Exit $fail
chmod 1777 a || framework_failure
touch a/b || framework_failure
-fail=0
# Try to ensure that $NON_ROOT_USERNAME can access
# the required version of rm.
ok=1
test $ok = 1 || framework_failure
-fail=0
rm -rf d/f 2> out && fail=1
cat <<\EOF > exp
done
done
-fail=0
rm -r t || fail=1
echo y > $t/$test.Iy
echo n > $t/$test.In
-fail=0
rm -i $t/a < $t/$test.In > /dev/null 2>&1 || fail=1
# The file should not have been removed.
test -f $t/a || fail=1
chmod 0 f || framework_failure
touch exp || framework_failure
-fail=0
rm --interactive=never f > out || fail=1
mkdir dir || framework_failure
echo y > y || framework_failure
-fail=0
# This must fail.
rm -i dir < y > /dev/null 2>&1 && fail=1
touch existing-non-dir || framework_failure
-fail=0
# With coreutils-6.3, this would exit nonzero. It should not.
# Example from Andreas Schwab.
p=`pwd`
mkdir abs1 abs2 no-access || framework_failure
-fail=0
set +x
(cd no-access; chmod 0 . && rm -r "$p/abs1" rel "$p/abs2") 2> out && fail=1
y' > $test.I || framework_failure
rm -f out err || framework_failure
-fail=0
# The prompt has a trailing space, and no newline, so an extra
# 'echo .' is inserted after each rm to make it obvious what was asked.
echo n > $test.In || framework_failure
rm -f out err || framework_failure
-fail=0
# The prompt has a trailing space, and no newline, so an extra
# 'echo .' is inserted after each rm to make it obvious what was asked.
# Remove all but one of a, b, c -- I doubt that this test can portably
# determine which one was removed based on order of dir entries.
# This is a good argument for switching to a dejagnu-style test suite.
-fail=0
rm --verbose -i -r $t < $test.I > /dev/null 2>&1 || fail=1
# $t should not have been removed.
. $srcdir/test-lib.sh
skip_if_root_
-fail=0
# Skip this test if there is no /dev/stdin file.
ls /dev/stdin >/dev/null 2>&1 \
# Ensure that non-root can access files in root-owned ".".
chmod go=x . || framework_failure
-fail=0
# This must fail, since `.' is not writable by $NON_ROOT_USERNAME.
setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm -rf d 2>/dev/null && fail=1
rm: skipping `a/b', since it's on a different device
EOF
-fail=0
rm --one-file-system -rf a 2> out && fail=1
test -d $t/y || fail=1
removed `b'
EOF
-fail=0
rm --verbose -r a b > $test.O || fail=1
for d in $dirs; do
# Note that both the expected output (above) and the actual output lines
# are sorted, because directory entries may be processed in arbitrary order.
-fail=0
rm --verbose -r t/a | sort > t/O || fail=1
if test -d t/a; then
test -f by || framework_failure
cd .. || framework_failure
-fail=0
rm -rf t || fail=1
test -d t && fail=1
mkdir d || framework_failure
touch d/a || framework_failure
-fail=0
rm -fr d/. 2>/dev/null && fail=1
rm -fr d/./ 2>/dev/null && fail=1
rm -fr d/.//// 2>/dev/null && fail=1
done
cd .. || framework_failure
-fail=0
# On a buggy system, this would fail with the diagnostic,
# "cannot remove directory `b': Directory not empty"
mkdir -p b/a/p b/c b/d || framework_failure
chmod u-w b/a || framework_failure
-fail=0
# This should fail.
rm -rf b > out 2>&1 && fail=1
mkdir a/2 a/3 || framework_failure
chmod u-x a/1 b || framework_failure
-fail=0
# Exercise two separate code paths -- though both result
# in the same sort of diagnostic.
chmod u-w fu du empty-u || framework_failure
cd ..
-fail=0
cat <<EOF > in
y
mkdir dir || framework_failure
-fail=0
# This should fail.
rm dir > /dev/null 2>&1 && fail=1
rm: remove directory `d'
EOF
-fail=0
rm -ir d < in > out 2>&1 || fail=1
. $srcdir/test-lib.sh
-fail=0
rm -r '' > /dev/null 2>&1 && fail=1
Exit $fail
mkdir -p a/b || framework_failure
chmod u-r a
-fail=0
# This should fail.
rm -rf a > out 2>&1 && fail=1
mkdir -p a/1 b c d/2 e/3 || framework_failure
-fail=0
t=`pwd`
cd c
mkdir a || framework_failure
touch a/x || framework_failure
-fail=0
rm --verbose -r a/// > out || fail=1
cat <<\EOF > exp || fail=1
mkdir d d/e d/e/f || framework_failure
chmod a-w d || framework_failure
-fail=0
# This rmdir command outputs two diagnostics.
# Before coreutils-5.1.2, it would mistakenly exit successfully.
cwd=`pwd`
mkdir -p "$cwd/a/b/c" "$cwd/a/x" || framework_failure
-fail=0
rmdir -p --ignore-fail-on-non-empty "$cwd/a/b/c" || fail=1
# $cwd/a/x should remain
test -d "$cwd/a/x" || fail=1
mkdir dir || framework_failure
-fail=0
# Prior to coreutils-4.5.2, this would fail with the following:
# rmdir: `dir': No such file or directory
# FIXME: cleanup_() { rm -rf "$other_partition_tmpdir"; }
# FIXME: . "$abs_srcdir/other-fs-tmpdir"
-fail=0
FIXME > out || fail=1
cat <<\EOF > exp || fail=1
FIXME
skip_test_ "chattr +a doesn't work on this file system"
fi
-fail=0
for inotify in ---disable-inotify ''; do
sleep 1 &
Consider rerunning this test on a different file system.'
fi
-fail=0
tail -c1 big > out || fail=1
# Append a newline.
. $srcdir/test-lib.sh
-fail=0
echo line > in || fail=1
# Output should be buffered since we're writing to file
# so we're depending on the flush to write out
echo line > exp || framework_failure
echo line > in || framework_failure
-fail=0
timeout 1 tail -f < in > out 2> err
# tail from coreutils-7.5 would fail
sleep .1
done
-fail=0
kill $tail_pid && fail=1 || :
Exit $fail
. $srcdir/test-lib.sh
-fail=0
touch file || framework_failure
touch tail.out || framework_failure
touch empty here || framework_failure
-fail=0
for inotify in ---disable-inotify ''; do
# Use tail itself to create a background process to monitor,
. $srcdir/test-lib.sh
-fail=0
echo foo | timeout 2 tail -f -c3 > out || fail=1
echo oo > exp || fail=1
echo 1 > fifo &
echo 1 > exp || framework_failure
-fail=0
timeout 1 tail -f fifo > out
test $? = 124 || fail=1
. $srcdir/test-lib.sh
-fail=0
ksyms=/proc/ksyms
if test -r $ksyms; then
(echo 1; echo 2) > k || framework_failure
-fail=0
sh -c 'read x; tail' < k > out || fail=1
cat <<EOF > exp
touch empty || framework_failure
echo anything > nonempty || framework_failure
-fail=0
for inotify in ---disable-inotify ''; do
for file in empty nonempty; do
touch k || framework_failure
{ touch unreadable && chmod a-r unreadable; } || framework_failure
-fail=0
for inotify in ---disable-inotify ''; do
timeout 1 tail -s0.1 -f $inotify not_here
else
compare() { cmp "$@"; }
fi
+
+# Initialize; all bourne shell scripts end with "Exit $fail".
+fail=0
echo 60 > exp || framework_failure
-fail=0
# Before coreutils-7.7, this would fail, complaining of
# an `invalid date format'. Specifying 60 seconds *is* valid.
rm -f touch-target t-symlink
ln -s touch-target t-symlink
-fail=0
# This used to infloop.
touch t-symlink || fail=1
. $srcdir/test-lib.sh
-fail=0
touch . || fail=1
Exit $fail
DEFAULT_SLEEP_SECONDS=2
SLEEP_SECONDS=${SLEEP_SECONDS=$DEFAULT_SLEEP_SECONDS}
-fail=0
# FIXME: find writable directories on other partitions
# and run the test in those directories, too.
# Ensure that $d1 doesn't already exist.
ls -d $d1 2> /dev/null && framework_failure
-fail=0
touch $dir > out 2>&1 && fail=1
cat <<EOF > exp
mkfifo_or_skip_ fifo
-fail=0
touch fifo || fail=1
. $srcdir/test-lib.sh
-fail=0
touch -c no-file > /dev/null 2>&1 || fail=1
touch -cm no-file > /dev/null 2>&1 || fail=1
touch file || framework_failure
ln -s file link || framework_failure
-fail=0
# These first tests should work on every platform.
# -h does not create files, but it warns. Use -c to silence warning.
set x `ls -t t1 t2`
test "$*" = "x t2 t1" || framework_failure
-fail=0
chmod 0 t1
touch -d '2000-01-03 00:00' -c t1 || fail=1
skip_if_root_
-fail=0
# Before fileutils-4.1, we'd get the following misleading
# diagnostic instead of `...: Permission denied'.
# Ensure that the current directory is searchable by $NON_ROOT_USERNAME.
chmod g+x .
-fail=0
setuidgid $NON_ROOT_USERNAME env PATH="$PATH" touch -d now root-owned || fail=1
Exit $fail
_POSIX2_VERSION=199209; export _POSIX2_VERSION
POSIXLY_CORRECT=1; export POSIXLY_CORRECT
-fail=0
yearstart=01010000
: > read-only || framework_failure
chmod 444 read-only || framework_failure
-fail=0
touch read-only || fail=1
TZ=UTC0 touch --date='2004-01-16 12:00 +0000' f || framework_failure
-fail=0
# Set times back by 5 days.
touch --ref f --date='-5 days' f || fail=1
mkdir dir || framework_failure
ln -s dir link2 || framework_failure
-fail=0
# Trailing slash can only appear on directory or symlink-to-directory.
# Up through coreutils 8.0, Solaris 9 failed these tests.