summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/arch.sh2
-rwxr-xr-xtests/misc/base64.pl2
-rwxr-xr-xtests/misc/basename.pl4
-rwxr-xr-xtests/misc/cat-buf.sh8
-rwxr-xr-xtests/misc/cat-proc.sh2
-rwxr-xr-xtests/misc/cat-self.sh33
-rwxr-xr-xtests/misc/chcon-fail.sh10
-rwxr-xr-xtests/misc/chcon.sh8
-rwxr-xr-xtests/misc/chroot-credentials.sh9
-rwxr-xr-xtests/misc/chroot-fail.sh54
-rwxr-xr-xtests/misc/close-stdout.sh18
-rwxr-xr-xtests/misc/comm.pl2
-rwxr-xr-xtests/misc/coreutils.sh2
-rwxr-xr-xtests/misc/csplit-1000.sh2
-rwxr-xr-xtests/misc/csplit-heap.sh2
-rwxr-xr-xtests/misc/csplit-suppress-matched.pl2
-rwxr-xr-xtests/misc/csplit.sh2
-rwxr-xr-xtests/misc/cut-huge-range.sh6
-rwxr-xr-xtests/misc/cut.pl2
-rwxr-xr-xtests/misc/date-next-dow.pl2
-rwxr-xr-xtests/misc/date-sec.sh2
-rwxr-xr-xtests/misc/date.pl2
-rwxr-xr-xtests/misc/dircolors.pl2
-rwxr-xr-xtests/misc/dirname.pl2
-rwxr-xr-xtests/misc/env-null.sh2
-rwxr-xr-xtests/misc/env.sh4
-rwxr-xr-xtests/misc/expand.pl2
-rwxr-xr-xtests/misc/expr.pl2
-rwxr-xr-xtests/misc/factor-parallel.sh34
-rwxr-xr-xtests/misc/factor.pl2
-rwxr-xr-xtests/misc/false-status.sh10
-rwxr-xr-xtests/misc/fold.pl2
-rwxr-xr-xtests/misc/groups-dash.sh2
-rwxr-xr-xtests/misc/groups-version.sh2
-rwxr-xr-xtests/misc/head-c.sh14
-rwxr-xr-xtests/misc/head-elide-tail.pl2
-rwxr-xr-xtests/misc/head-pos.sh2
-rwxr-xr-xtests/misc/head-write-error.sh2
-rwxr-xr-xtests/misc/head.pl2
-rwxr-xr-xtests/misc/help-version.sh15
-rwxr-xr-xtests/misc/invalid-opt.pl2
-rwxr-xr-xtests/misc/join.pl2
-rwxr-xr-xtests/misc/ls-misc.pl4
-rwxr-xr-xtests/misc/ls-time.sh2
-rwxr-xr-xtests/misc/md5sum-bsd.sh10
-rwxr-xr-xtests/misc/md5sum-newline.pl2
-rwxr-xr-xtests/misc/md5sum-parallel.sh8
-rwxr-xr-xtests/misc/md5sum.pl2
-rwxr-xr-xtests/misc/mknod.sh2
-rwxr-xr-xtests/misc/mktemp.pl2
-rwxr-xr-xtests/misc/nice-fail.sh2
-rwxr-xr-xtests/misc/nice.sh4
-rwxr-xr-xtests/misc/nl.sh2
-rwxr-xr-xtests/misc/nohup.sh2
-rwxr-xr-xtests/misc/nproc-avail.sh2
-rwxr-xr-xtests/misc/nproc-positive.sh4
-rwxr-xr-xtests/misc/numfmt.pl438
-rwxr-xr-xtests/misc/od-N.sh2
-rwxr-xr-xtests/misc/od-endian.sh2
-rwxr-xr-xtests/misc/od-float.sh22
-rwxr-xr-xtests/misc/od-j.sh39
-rwxr-xr-xtests/misc/od-multiple-t.sh2
-rwxr-xr-xtests/misc/od-x8.sh2
-rwxr-xr-xtests/misc/od.pl2
-rwxr-xr-xtests/misc/paste.pl2
-rwxr-xr-xtests/misc/pathchk1.sh12
-rwxr-xr-xtests/misc/printenv.sh10
-rwxr-xr-xtests/misc/printf-cov.pl2
-rwxr-xr-xtests/misc/printf-hex.sh2
-rwxr-xr-xtests/misc/printf-surprise.sh9
-rwxr-xr-xtests/misc/printf.sh16
-rwxr-xr-xtests/misc/ptx-overrun.sh2
-rwxr-xr-xtests/misc/ptx.pl2
-rwxr-xr-xtests/misc/pwd-long.sh3
-rwxr-xr-xtests/misc/pwd-option.sh2
-rwxr-xr-xtests/misc/readlink-fp-loop.sh2
-rwxr-xr-xtests/misc/readlink-root.sh2
-rwxr-xr-xtests/misc/realpath.sh14
-rwxr-xr-xtests/misc/runcon-no-reorder.sh2
-rwxr-xr-xtests/misc/selinux.sh4
-rwxr-xr-xtests/misc/seq-long-double.sh2
-rwxr-xr-xtests/misc/seq-precision.sh79
-rwxr-xr-xtests/misc/seq.pl2
-rwxr-xr-xtests/misc/sha1sum-vec.pl2
-rwxr-xr-xtests/misc/sha1sum.pl2
-rwxr-xr-xtests/misc/sha224sum.pl2
-rwxr-xr-xtests/misc/sha256sum.pl2
-rwxr-xr-xtests/misc/sha384sum.pl2
-rwxr-xr-xtests/misc/sha512sum.pl2
-rwxr-xr-xtests/misc/shred-exact.sh4
-rwxr-xr-xtests/misc/shred-passes.sh2
-rwxr-xr-xtests/misc/shred-remove.sh6
-rwxr-xr-xtests/misc/shred-size.sh (renamed from tests/misc/shred-negative.sh)14
-rwxr-xr-xtests/misc/shuf-reservoir.sh2
-rwxr-xr-xtests/misc/shuf.sh23
-rwxr-xr-xtests/misc/sort-NaN-infloop.sh2
-rwxr-xr-xtests/misc/sort-benchmark-random.sh2
-rwxr-xr-xtests/misc/sort-compress-hang.sh6
-rwxr-xr-xtests/misc/sort-compress-proc.sh17
-rwxr-xr-xtests/misc/sort-compress.sh6
-rwxr-xr-xtests/misc/sort-continue.sh2
-rwxr-xr-xtests/misc/sort-debug-keys.sh2
-rwxr-xr-xtests/misc/sort-debug-warn.sh2
-rwxr-xr-xtests/misc/sort-discrim.sh2
-rwxr-xr-xtests/misc/sort-exit-early.sh10
-rwxr-xr-xtests/misc/sort-files0-from.pl2
-rwxr-xr-xtests/misc/sort-float.sh2
-rwxr-xr-xtests/misc/sort-merge-fdlimit.sh2
-rwxr-xr-xtests/misc/sort-merge.pl2
-rwxr-xr-xtests/misc/sort-month.sh2
-rwxr-xr-xtests/misc/sort-rand.sh2
-rwxr-xr-xtests/misc/sort-spinlock-abuse.sh7
-rwxr-xr-xtests/misc/sort-stale-thread-mem.sh2
-rwxr-xr-xtests/misc/sort-u-FMR.sh2
-rwxr-xr-xtests/misc/sort-unique-segv.sh2
-rwxr-xr-xtests/misc/sort-unique.sh2
-rwxr-xr-xtests/misc/sort-version.sh2
-rwxr-xr-xtests/misc/sort.pl10
-rwxr-xr-xtests/misc/stat-birthtime.sh2
-rwxr-xr-xtests/misc/stat-fmt.sh2
-rwxr-xr-xtests/misc/stat-hyphen.sh4
-rwxr-xr-xtests/misc/stat-mount.sh2
-rwxr-xr-xtests/misc/stat-nanoseconds.sh2
-rwxr-xr-xtests/misc/stat-printf.pl2
-rwxr-xr-xtests/misc/stat-slash.sh4
-rwxr-xr-xtests/misc/stdbuf.sh15
-rwxr-xr-xtests/misc/stty-invalid.sh8
-rwxr-xr-xtests/misc/stty-pairs.sh2
-rwxr-xr-xtests/misc/stty-row-col.sh4
-rwxr-xr-xtests/misc/stty.sh12
-rwxr-xr-xtests/misc/sum-sysv.sh2
-rwxr-xr-xtests/misc/sum.pl2
-rwxr-xr-xtests/misc/sync.sh52
-rwxr-xr-xtests/misc/tac-2-nonseekable.sh16
-rwxr-xr-xtests/misc/tac-continue.sh16
-rwxr-xr-xtests/misc/tac.pl2
-rwxr-xr-xtests/misc/tail.pl15
-rwxr-xr-xtests/misc/tee.sh95
-rwxr-xr-xtests/misc/test-diag.pl2
-rwxr-xr-xtests/misc/test.pl2
-rwxr-xr-xtests/misc/timeout-blocked.pl2
-rwxr-xr-xtests/misc/timeout-group.sh19
-rwxr-xr-xtests/misc/timeout-parameters.sh2
-rwxr-xr-xtests/misc/timeout.sh2
-rwxr-xr-xtests/misc/tr-case-class.sh12
-rwxr-xr-xtests/misc/tr.pl2
-rwxr-xr-xtests/misc/truncate-dangling-symlink.sh2
-rwxr-xr-xtests/misc/truncate-dir-fail.sh4
-rwxr-xr-xtests/misc/truncate-fail-diag.sh2
-rwxr-xr-xtests/misc/truncate-fifo.sh2
-rwxr-xr-xtests/misc/truncate-no-create-missing.sh2
-rwxr-xr-xtests/misc/truncate-overflow.sh8
-rwxr-xr-xtests/misc/truncate-owned-by-other.sh4
-rwxr-xr-xtests/misc/truncate-parameters.sh14
-rwxr-xr-xtests/misc/truncate-relative.sh10
-rwxr-xr-xtests/misc/tsort.pl2
-rwxr-xr-xtests/misc/tty-eof.pl2
-rwxr-xr-xtests/misc/unexpand.pl2
-rwxr-xr-xtests/misc/uniq-perf.sh4
-rwxr-xr-xtests/misc/uniq.pl2
-rwxr-xr-xtests/misc/wc-files0-from.pl2
-rwxr-xr-xtests/misc/wc-files0.sh2
-rwxr-xr-xtests/misc/wc-parallel.sh8
-rwxr-xr-xtests/misc/wc-proc.sh (renamed from tests/misc/tee-dash.sh)16
-rwxr-xr-xtests/misc/wc.pl2
-rwxr-xr-xtests/misc/xattr.sh2
-rwxr-xr-xtests/misc/xstrtol.pl2
-rwxr-xr-xtests/misc/yes.sh42
168 files changed, 1071 insertions, 529 deletions
diff --git a/tests/misc/arch.sh b/tests/misc/arch.sh
index 95369067..d5ae5822 100755
--- a/tests/misc/arch.sh
+++ b/tests/misc/arch.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that arch output is equal to uname -m
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
diff --git a/tests/misc/base64.pl b/tests/misc/base64.pl
index 54e2cc21..fd75c624 100755
--- a/tests/misc/base64.pl
+++ b/tests/misc/base64.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Exercise base64.
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
diff --git a/tests/misc/basename.pl b/tests/misc/basename.pl
index 3aace6f8..7b0ea7dd 100755
--- a/tests/misc/basename.pl
+++ b/tests/misc/basename.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# Test basename.
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
@@ -71,7 +71,7 @@ my @Tests =
);
# Append a newline to end of each expected 'OUT' string.
-# Skip -z tests, i.e. those whose 'OUT' string has a trailing '\0'.
+# Skip -z tests, i.e., those whose 'OUT' string has a trailing '\0'.
my $t;
foreach $t (@Tests)
{
diff --git a/tests/misc/cat-buf.sh b/tests/misc/cat-buf.sh
index 592b5a1d..31382481 100755
--- a/tests/misc/cat-buf.sh
+++ b/tests/misc/cat-buf.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that cat outputs processed data immediately.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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,6 +26,8 @@ print_ver_ cat
# write separately.
mkfifo_or_skip_ fifo
+# Terminate any background cp process
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
echo 1 > exp
@@ -33,9 +35,9 @@ cat_buf_1()
{
local delay="$1"
- dd count=1 if=fifo > out &
+ dd count=1 if=fifo > out & pid=$!
(echo 1; sleep $delay; echo 2) | cat -v > fifo
- wait # for dd to complete
+ wait $pid
compare exp out
}
diff --git a/tests/misc/cat-proc.sh b/tests/misc/cat-proc.sh
index 7b826ef3..32e71e10 100755
--- a/tests/misc/cat-proc.sh
+++ b/tests/misc/cat-proc.sh
@@ -2,7 +2,7 @@
# Ensure that cat -E produces same output as cat, module '$'s,
# even when applied to a file in /proc.
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
diff --git a/tests/misc/cat-self.sh b/tests/misc/cat-self.sh
new file mode 100755
index 00000000..57777e53
--- /dev/null
+++ b/tests/misc/cat-self.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# Check that cat operates correctly when the input is the same as the output.
+
+# Copyright 2014-2015 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ cat
+
+echo x >out || framework_failure_
+echo x >out1 || framework_failure_
+returns_ 1 cat out >>out || fail=1
+compare out out1 || fail=1
+
+# This example is taken from the POSIX spec for 'cat'.
+echo x >doc || framework_failure_
+echo y >doc.end || framework_failure_
+cat doc doc.end >doc || fail=1
+compare doc doc.end || fail=1
+
+Exit $fail
diff --git a/tests/misc/chcon-fail.sh b/tests/misc/chcon-fail.sh
index 77b91d3b..5265fa01 100755
--- a/tests/misc/chcon-fail.sh
+++ b/tests/misc/chcon-fail.sh
@@ -2,7 +2,7 @@
# Ensure that chcon fails when it should.
# These tests don't use any actual SE Linux syscalls.
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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,16 +22,16 @@ print_ver_ chcon
# neither context nor file
-chcon 2> /dev/null && fail=1
+returns_ 1 chcon 2> /dev/null || fail=1
# No file
-chcon CON 2> /dev/null && fail=1
+returns_ 1 chcon CON 2> /dev/null || fail=1
# No file
touch f
-chcon --reference=f 2> /dev/null && fail=1
+returns_ 1 chcon --reference=f 2> /dev/null || fail=1
# No file
-chcon -u anyone 2> /dev/null && fail=1
+returns_ 1 chcon -u anyone 2> /dev/null || fail=1
Exit $fail
diff --git a/tests/misc/chcon.sh b/tests/misc/chcon.sh
index ec573967..e3f61e8b 100755
--- a/tests/misc/chcon.sh
+++ b/tests/misc/chcon.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise chcon
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
@@ -44,7 +44,7 @@ stat --printf='g|%C\n' g >> out || fail=1
# Change the individual parts of the context, one by one.
u2=user_u
r2=object_r
-t2=file_t
+t2=unlabeled_t
for i in --user=$u2 --role=$r2 --type=$t2 --range=$range; do
chcon $i f || fail=1
stat --printf="f|$i|"'%C\n' f >> out || fail=1
@@ -63,8 +63,8 @@ f|--user=$u2|$u2:$r1:$t1:$range
f|--role=$r2|$u2:$r2:$t1:$range
f|--type=$t2|$u2:$r2:$t2:$range
f|--range=$range|$u2:$r2:$t2:$range
-f|-uroot|root:object_r:file_t:$range
-f|-robject_r|root:object_r:file_t:$range
+f|-uroot|root:object_r:$t2:$range
+f|-robject_r|root:object_r:$t2:$range
f|-ttmp_t|root:object_r:tmp_t:$range
EOF
diff --git a/tests/misc/chroot-credentials.sh b/tests/misc/chroot-credentials.sh
index b06e8b7f..8b677100 100755
--- a/tests/misc/chroot-credentials.sh
+++ b/tests/misc/chroot-credentials.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify that the credentials are changed correctly.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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,6 +22,8 @@ print_ver_ chroot
require_root_
+EXIT_CANCELED=125
+
grep '^#define HAVE_SETGROUPS 1' "$CONFIG_HEADER" >/dev/null \
&& HAVE_SETGROUPS=1
@@ -36,7 +38,8 @@ chroot --userspec=$NON_ROOT_UID: / true || fail=1
# verify that invalid groups are diagnosed
for g in ' ' ',' '0trail'; do
- test "$(chroot --groups="$g" / id -G)" && fail=1
+ returns_ $EXIT_CANCELED chroot --groups="$g" / id -G >invalid || fail=1
+ compare /dev/null invalid || fail=1
done
# Verify that root credentials are kept.
@@ -111,7 +114,7 @@ if ! id -u +12342; then
test "$(chroot --userspec=+12342:+5678 / id -G)" = '5678' || fail=1
# Ensure we fail when we don't know what groups to set for an unknown ID
- chroot --userspec=+12342 / true && fail=1
+ returns_ $EXIT_CANCELED chroot --userspec=+12342 / true || fail=1
fi
Exit $fail
diff --git a/tests/misc/chroot-fail.sh b/tests/misc/chroot-fail.sh
index a84826fd..14499edd 100755
--- a/tests/misc/chroot-fail.sh
+++ b/tests/misc/chroot-fail.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify that internal failure in chroot gives exact status.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
@@ -29,20 +29,42 @@ test $? = 125 || fail=1
chroot --- / true # unknown option
test $? = 125 || fail=1
-# Note chroot("/") succeeds for non-root users on some systems, but not all,
-# however we avoid the chroot() with "/" to have common behvavior.
-chroot / sh -c 'exit 2' # exit status propagation
-test $? = 2 || fail=1
-chroot / . # invalid command
-test $? = 126 || fail=1
-chroot / no_such # no such command
-test $? = 127 || fail=1
-
-# Ensure we don't chdir("/") when not changing root
-# to allow only changing user ids for a command.
-for dir in '/' '/.' '/../'; do
- curdir=$(chroot "$dir" env pwd) || fail=1
- test "$curdir" = '/' && fail=1
-done
+# chroot("/") succeeds for non-root users on some systems, but not all.
+if chroot / true ; then
+ can_chroot_root=1
+ chroot / sh -c 'exit 2' # exit status propagation
+ test $? = 2 || fail=1
+ chroot / . # invalid command
+ test $? = 126 || fail=1
+ chroot / no_such # no such command
+ test $? = 127 || fail=1
+else
+ test $? = 125 || fail=1
+ can_chroot_root=0
+fi
+
+# Ensure that --skip-chdir fails with a non-"/" argument.
+cat <<\EOF > exp || framework_failure_
+chroot: option --skip-chdir only permitted if NEWROOT is old '/'
+Try 'chroot --help' for more information.
+EOF
+chroot --skip-chdir . env pwd >out 2>err && fail=1
+compare /dev/null out || fail=1
+compare exp err || fail=1
+
+# Ensure we chdir("/") appropriately when NEWROOT is old "/".
+if test $can_chroot_root = 1; then
+ ln -s / isroot || framework_failure_
+ for dir in '/' '/.' '/../' isroot; do
+ # Verify that chroot(1) succeeds and performs chdir("/")
+ # (chroot(1) of coreutils-8.23 failed to run the latter).
+ curdir=$(chroot "$dir" env pwd) || fail=1
+ test "$curdir" = '/' || fail=1
+
+ # Test the "--skip-chdir" option.
+ curdir=$(chroot --skip-chdir "$dir" env pwd) || fail=1
+ test "$curdir" = '/' && fail=1
+ done
+fi
Exit $fail
diff --git a/tests/misc/close-stdout.sh b/tests/misc/close-stdout.sh
index 4da696c4..6714ec0f 100755
--- a/tests/misc/close-stdout.sh
+++ b/tests/misc/close-stdout.sh
@@ -2,7 +2,7 @@
# Ensure that several programs work fine, even with stdout initially closed.
# This is effectively a test of closeout.c's close_stdout function.
-# Copyright (C) 2004-2014 Free Software Foundation, Inc.
+# Copyright (C) 2004-2015 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
@@ -44,21 +44,21 @@ sleep 0 >&- || fail=1
# This test is ineffective unless /dev/stdout also works.
if "$p/src/test" -w /dev/stdout >/dev/null &&
"$p/src/test" ! -w /dev/stdout >&-; then
- "$p/src/printf" 'foo' >&- 2>/dev/null && fail=1
- cp --verbose a b >&- 2>/dev/null && fail=1
+ returns_ 1 "$p/src/printf" 'foo' >&- 2>/dev/null || fail=1
+ returns_ 1 cp --verbose a b >&- 2>/dev/null || fail=1
rm -Rf tmpfile-?????? || fail=1
- mktemp tmpfile-XXXXXX >&- 2>/dev/null && fail=1
- mktemp tmpfile-XXXXXX -q >&- 2>/dev/null && fail=1
+ returns_ 1 mktemp tmpfile-XXXXXX >&- 2>/dev/null || fail=1
+ returns_ 1 mktemp tmpfile-XXXXXX -q >&- 2>/dev/null || fail=1
case $(echo tmpfile-??????) in 'tmpfile-??????') ;; *) fail=1 ;; esac
fi
# Likewise for /dev/full, if /dev/full works.
if test -w /dev/full && test -c /dev/full; then
- "$p/src/printf" 'foo' >/dev/full 2>/dev/null && fail=1
- cp --verbose a b >/dev/full 2>/dev/null && fail=1
+ returns_ 1 "$p/src/printf" 'foo' >/dev/full 2>/dev/null || fail=1
+ returns_ 1 cp --verbose a b >/dev/full 2>/dev/null || fail=1
rm -Rf tmpdir-?????? || fail=1
- mktemp -d tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1
- mktemp -d -q tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1
+ returns_ 1 mktemp -d tmpdir-XXXXXX >/dev/full 2>/dev/null || fail=1
+ returns_ 1 mktemp -d -q tmpdir-XXXXXX >/dev/full 2>/dev/null || fail=1
case $(echo tmpfile-??????) in 'tmpfile-??????') ;; *) fail=1 ;; esac
fi
diff --git a/tests/misc/comm.pl b/tests/misc/comm.pl
index c96939b1..76be936f 100755
--- a/tests/misc/comm.pl
+++ b/tests/misc/comm.pl
@@ -2,7 +2,7 @@
# -*- perl -*-
# Test comm
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/coreutils.sh b/tests/misc/coreutils.sh
index a22bc9f6..c568ac02 100755
--- a/tests/misc/coreutils.sh
+++ b/tests/misc/coreutils.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify behavior of separate coreutils multicall binary
-# Copyright (C) 2014 Free Software Foundation, Inc.
+# Copyright (C) 2014-2015 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
diff --git a/tests/misc/csplit-1000.sh b/tests/misc/csplit-1000.sh
index 6757a464..9baac2fa 100755
--- a/tests/misc/csplit-1000.sh
+++ b/tests/misc/csplit-1000.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# cause a 1-byte heap buffer overrun
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/csplit-heap.sh b/tests/misc/csplit-heap.sh
index 03fc9a36..9e51cb15 100755
--- a/tests/misc/csplit-heap.sh
+++ b/tests/misc/csplit-heap.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure that csplit uses a bounded amount of memory
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/csplit-suppress-matched.pl b/tests/misc/csplit-suppress-matched.pl
index cea64e4f..d4ca3cd0 100755
--- a/tests/misc/csplit-suppress-matched.pl
+++ b/tests/misc/csplit-suppress-matched.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 2013-2014 Free Software Foundation, Inc.
+# Copyright (C) 2013-2015 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
diff --git a/tests/misc/csplit.sh b/tests/misc/csplit.sh
index da09c1f0..1ccf1218 100755
--- a/tests/misc/csplit.sh
+++ b/tests/misc/csplit.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# various csplit tests
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2015 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
diff --git a/tests/misc/cut-huge-range.sh b/tests/misc/cut-huge-range.sh
index e2c4108c..035d8d08 100755
--- a/tests/misc/cut-huge-range.sh
+++ b/tests/misc/cut-huge-range.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that cut does not allocate mem for large ranges
-# Copyright (C) 2012-2014 Free Software Foundation, Inc.
+# Copyright (C) 2012-2015 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
@@ -56,8 +56,8 @@ CUT_MAX=$(echo $SIZE_MAX | sed "$subtract_one")
(ulimit -v 20000; : | cut -b1-$CUT_MAX >> err 2>&1) || fail=1
# Explicitly disallow values above CUT_MAX
-(ulimit -v 20000; : | cut -b$SIZE_MAX 2>/dev/null) && fail=1
-(ulimit -v 20000; : | cut -b$SIZE_OFLOW 2>/dev/null) && fail=1
+(ulimit -v 20000; : | returns_ 1 cut -b$SIZE_MAX 2>/dev/null) || fail=1
+(ulimit -v 20000; : | returns_ 1 cut -b$SIZE_OFLOW 2>/dev/null) || fail=1
compare /dev/null err || fail=1
diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl
index 04188621..23e9ce36 100755
--- a/tests/misc/cut.pl
+++ b/tests/misc/cut.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "cut".
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
diff --git a/tests/misc/date-next-dow.pl b/tests/misc/date-next-dow.pl
index a1c21127..feb076be 100755
--- a/tests/misc/date-next-dow.pl
+++ b/tests/misc/date-next-dow.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "date".
-# Copyright (C) 2005-2014 Free Software Foundation, Inc.
+# Copyright (C) 2005-2015 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
diff --git a/tests/misc/date-sec.sh b/tests/misc/date-sec.sh
index 9c001fdc..d3d5e6c5 100755
--- a/tests/misc/date-sec.sh
+++ b/tests/misc/date-sec.sh
@@ -3,7 +3,7 @@
# date --date="21:04 +0100" +%S' always prints '00'.
# Before coreutils-5.2.1, it would print the seconds from the current time.
-# Copyright (C) 2004-2014 Free Software Foundation, Inc.
+# Copyright (C) 2004-2015 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
diff --git a/tests/misc/date.pl b/tests/misc/date.pl
index 40be4cab..6a7c6f88 100755
--- a/tests/misc/date.pl
+++ b/tests/misc/date.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "date".
-# Copyright (C) 2005-2014 Free Software Foundation, Inc.
+# Copyright (C) 2005-2015 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
diff --git a/tests/misc/dircolors.pl b/tests/misc/dircolors.pl
index a70a8c5d..b9f8a1d2 100755
--- a/tests/misc/dircolors.pl
+++ b/tests/misc/dircolors.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Simple dircolors tests.
-# Copyright (C) 1998-2014 Free Software Foundation, Inc.
+# Copyright (C) 1998-2015 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
diff --git a/tests/misc/dirname.pl b/tests/misc/dirname.pl
index 34c905d4..98416694 100755
--- a/tests/misc/dirname.pl
+++ b/tests/misc/dirname.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "dirname".
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
diff --git a/tests/misc/env-null.sh b/tests/misc/env-null.sh
index 9b9c95e7..de9e016d 100755
--- a/tests/misc/env-null.sh
+++ b/tests/misc/env-null.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify behavior of env -0 and printenv -0.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
diff --git a/tests/misc/env.sh b/tests/misc/env.sh
index d06a1fb0..d7c5a099 100755
--- a/tests/misc/env.sh
+++ b/tests/misc/env.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify behavior of env.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
@@ -102,7 +102,7 @@ cat <<EOF > unlikely_name/also_unlikely || framework_failure_
echo pass
EOF
chmod +x unlikely_name/also_unlikely || framework_failure_
-env also_unlikely && fail=1
+returns_ 127 env also_unlikely || fail=1
test x$(PATH=$PATH:unlikely_name env also_unlikely) = xpass || fail=1
test x$(env PATH="$PATH":unlikely_name also_unlikely) = xpass || fail=1
diff --git a/tests/misc/expand.pl b/tests/misc/expand.pl
index 939e22b8..283b8579 100755
--- a/tests/misc/expand.pl
+++ b/tests/misc/expand.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Exercise expand.
-# Copyright (C) 2004-2014 Free Software Foundation, Inc.
+# Copyright (C) 2004-2015 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
diff --git a/tests/misc/expr.pl b/tests/misc/expr.pl
index c084b118..0fa7111e 100755
--- a/tests/misc/expr.pl
+++ b/tests/misc/expr.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Basic tests for "expr".
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2015 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
diff --git a/tests/misc/factor-parallel.sh b/tests/misc/factor-parallel.sh
new file mode 100755
index 00000000..8cec630e
--- /dev/null
+++ b/tests/misc/factor-parallel.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Test for complete lines on output
+
+# Copyright (C) 2015 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ factor
+
+
+odd() { LC_ALL=C sed '/[24680]$/d'; }
+primes() { LC_ALL=C sed 's/.*: //; / /d'; }
+
+# Before v8.24 the number reported here would vary
+# Note -u not supplied to split, increased batching of quickly processed items.
+# As processing cost increases it becomes advantageous to use -u to keep
+# the factor processes supplied with data.
+nprimes=$(seq 1e6 | odd | split -nr/4 --filter='factor' | primes | wc -l)
+
+test "$nprimes" = '78498' || fail=1
+
+Exit $fail
diff --git a/tests/misc/factor.pl b/tests/misc/factor.pl
index 294b814f..b48eb3c0 100755
--- a/tests/misc/factor.pl
+++ b/tests/misc/factor.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Basic tests for "factor".
-# Copyright (C) 1998-2014 Free Software Foundation, Inc.
+# Copyright (C) 1998-2015 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
diff --git a/tests/misc/false-status.sh b/tests/misc/false-status.sh
index 77bea451..03fe98c2 100755
--- a/tests/misc/false-status.sh
+++ b/tests/misc/false-status.sh
@@ -2,7 +2,7 @@
# ensure that false exits nonzero even with --help or --version
# and ensure that true exits nonzero when it can't write --help or --version
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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
@@ -20,12 +20,12 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ false true
-env false --version > /dev/null && fail=1
-env false --help > /dev/null && fail=1
+returns_ 1 env false --version > /dev/null || fail=1
+returns_ 1 env false --help > /dev/null || fail=1
if test -w /dev/full && test -c /dev/full; then
- env true --version > /dev/full && fail=1
- env true --help > /dev/full && fail=1
+ returns_ 1 env true --version > /dev/full || fail=1
+ returns_ 1 env true --help > /dev/full || fail=1
fi
Exit $fail
diff --git a/tests/misc/fold.pl b/tests/misc/fold.pl
index 69b0c5b5..be13cc14 100755
--- a/tests/misc/fold.pl
+++ b/tests/misc/fold.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Exercise fold.
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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
diff --git a/tests/misc/groups-dash.sh b/tests/misc/groups-dash.sh
index 0aed2229..8f7ec759 100755
--- a/tests/misc/groups-dash.sh
+++ b/tests/misc/groups-dash.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure groups handles -- sanely
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
diff --git a/tests/misc/groups-version.sh b/tests/misc/groups-version.sh
index a867701c..44394435 100755
--- a/tests/misc/groups-version.sh
+++ b/tests/misc/groups-version.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure groups --version output is similar to id --version
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
diff --git a/tests/misc/head-c.sh b/tests/misc/head-c.sh
index d6433d0d..a553a55b 100755
--- a/tests/misc/head-c.sh
+++ b/tests/misc/head-c.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise head -c
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2015 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
@@ -42,4 +42,16 @@ esac
# based on the value passed to -c
(ulimit -v 20000; head --bytes=-$SSIZE_MAX < /dev/null) || fail=1
+# Make sure it works on funny files in /proc and /sys.
+
+for file in /proc/version /sys/kernel/profiling; do
+ if test -r $file; then
+ cp -f $file copy &&
+ head -c -1 copy > exp1 || framework_failure_
+
+ head -c -1 $file > out1 || fail=1
+ compare exp1 out1 || fail=1
+ fi
+done
+
Exit $fail
diff --git a/tests/misc/head-elide-tail.pl b/tests/misc/head-elide-tail.pl
index 3c178d69..bae87174 100755
--- a/tests/misc/head-elide-tail.pl
+++ b/tests/misc/head-elide-tail.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Exercise head's --bytes=-N option.
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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
diff --git a/tests/misc/head-pos.sh b/tests/misc/head-pos.sh
index 1cf9e04b..c195f320 100755
--- a/tests/misc/head-pos.sh
+++ b/tests/misc/head-pos.sh
@@ -2,7 +2,7 @@
# When reading a specified number of lines, ensure that the output
# file pointer is positioned just after those lines.
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 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
diff --git a/tests/misc/head-write-error.sh b/tests/misc/head-write-error.sh
index 22ecf993..53582278 100755
--- a/tests/misc/head-write-error.sh
+++ b/tests/misc/head-write-error.sh
@@ -2,7 +2,7 @@
# Ensure we diagnose and not continue writing to
# the output if we get a write error.
-# Copyright (C) 2014 Free Software Foundation, Inc.
+# Copyright (C) 2014-2015 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
diff --git a/tests/misc/head.pl b/tests/misc/head.pl
index 159d4efc..b8bbd676 100755
--- a/tests/misc/head.pl
+++ b/tests/misc/head.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# test head
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/help-version.sh b/tests/misc/help-version.sh
index 0598557f..78150374 100755
--- a/tests/misc/help-version.sh
+++ b/tests/misc/help-version.sh
@@ -2,7 +2,7 @@
# Make sure all of these programs work properly
# when invoked with --help or --version.
-# Copyright (C) 2000-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000-2015 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
@@ -17,14 +17,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Ensure that $SHELL is set to *some* value and exported.
-# This is required for dircolors, which would fail e.g., when
-# invoked via debuild (which removes SHELL from the environment).
-test "x$SHELL" = x && SHELL=/bin/sh
-export SHELL
-
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+# Terminate any background processes
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+
expected_failure_status_chroot=125
expected_failure_status_env=125
expected_failure_status_nice=125
@@ -216,8 +213,8 @@ id_setup () { args=-u; }
# Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh.
kill_setup () {
- env sleep 31.5 &
- args=$!
+ env sleep 10m & pid=$!
+ args=$pid
}
link_setup () { args="$tmp_in link-target"; }
diff --git a/tests/misc/invalid-opt.pl b/tests/misc/invalid-opt.pl
index bcf6ee71..a319bb14 100755
--- a/tests/misc/invalid-opt.pl
+++ b/tests/misc/invalid-opt.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# exercise the 'invalid option' handling code in each program
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/join.pl b/tests/misc/join.pl
index cf3f4bd4..08f29656 100755
--- a/tests/misc/join.pl
+++ b/tests/misc/join.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test join.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/ls-misc.pl b/tests/misc/ls-misc.pl
index a47e70b7..f88c7a8e 100755
--- a/tests/misc/ls-misc.pl
+++ b/tests/misc/ls-misc.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 1998-2014 Free Software Foundation, Inc.
+# Copyright (C) 1998-2015 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
@@ -266,7 +266,7 @@ my @Tests =
# The patch associated with sl-dangle[678] introduced a regression
# that was fixed after coreutils-8.19. This edge case triggers when
# listing a dir containing dangling symlinks, but with orphans uncolored.
- # I.E. the same as the previous test, but listing the directory
+ # I.e., the same as the previous test, but listing the directory
# rather than the symlink directly.
['sl-dangle9', '--color=always d',
{OUT => "$e\e[1;36ms$e\n"},
diff --git a/tests/misc/ls-time.sh b/tests/misc/ls-time.sh
index 3ce4a91c..676d1850 100755
--- a/tests/misc/ls-time.sh
+++ b/tests/misc/ls-time.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test some of ls's sorting options.
-# Copyright (C) 1998-2014 Free Software Foundation, Inc.
+# Copyright (C) 1998-2015 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
diff --git a/tests/misc/md5sum-bsd.sh b/tests/misc/md5sum-bsd.sh
index f73e0622..c5069f35 100755
--- a/tests/misc/md5sum-bsd.sh
+++ b/tests/misc/md5sum-bsd.sh
@@ -2,7 +2,7 @@
# 'md5sum' tests for generation and checking of
# BSD traditional and alternate formats (md5 [-r])
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2015 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
@@ -25,7 +25,7 @@ print_ver_ md5sum
# Ensure we can --check BSD alternate format.
# Note we start this list with a name
# that's unambiguous in BSD format.
-# I.E. one not starting with ' ' or '*'
+# I.e., one not starting with ' ' or '*'
for i in 'a' ' b' '*c' 'dd' ' '; do
echo "$i" > "$i"
md5sum "$i" >> check.md5sum
@@ -40,20 +40,20 @@ md5sum --strict -c check.md5 || fail=1
# then it'll be detected as standard format and error.
# This unlikely caveat was thought better than mandating
# an option to avoid the ambiguity.
-tail -n+2 check.md5 | md5sum --strict -c && fail=1
+tail -n+2 check.md5 | returns_ 1 md5sum --strict -c || fail=1
## BSD traditional format tests (--tag option) ##
# Ensure --tag and --check are mutually exclusive
-md5sum --tag --check /dev/null && fail=1
+returns_ 1 md5sum --tag --check /dev/null || fail=1
# Ensure --tag and --text are mutually exclusive
# We don't support --text with BSD tradition format,
# as that would complicate the output format,
# while providing little benefit over --text processing
# available with the default md5sum output format.
-md5sum --tag --text /dev/null && fail=1
+returns_ 1 md5sum --tag --text /dev/null || fail=1
# Ensure we can --check BSD traditional format we produce
rm check.md5
diff --git a/tests/misc/md5sum-newline.pl b/tests/misc/md5sum-newline.pl
index b418d5b4..4d2c21e4 100755
--- a/tests/misc/md5sum-newline.pl
+++ b/tests/misc/md5sum-newline.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Newline tests for "md5sum".
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2015 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
diff --git a/tests/misc/md5sum-parallel.sh b/tests/misc/md5sum-parallel.sh
index 92f66296..2a526bdf 100755
--- a/tests/misc/md5sum-parallel.sh
+++ b/tests/misc/md5sum-parallel.sh
@@ -2,7 +2,7 @@
# Ensure that md5sum prints each checksum atomically
# so that concurrent md5sums don't intersperse their output
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
@@ -20,13 +20,17 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ md5sum
+xargs -P2 </dev/null >/dev/null 2>&1 \
+ || skip_ 'xargs -P is required'
+
(mkdir tmp && cd tmp && seq 500 | xargs touch)
# This will output at least 16KiB per process
# and start 3 processes, with 2 running concurrently,
# which triggers often on Fedora 11 at least.
-(find tmp tmp tmp -type f | xargs -n500 -P2 md5sum) |
+(find tmp tmp tmp -type f | xargs -n500 -P2 md5sum 2>err) |
sed -n '/[0-9a-f]\{32\} /!p' |
grep . > /dev/null && fail=1
+compare /dev/null err || fail=1
Exit $fail
diff --git a/tests/misc/md5sum.pl b/tests/misc/md5sum.pl
index 0aa0056f..b3ff4b4f 100755
--- a/tests/misc/md5sum.pl
+++ b/tests/misc/md5sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Basic tests for "md5sum".
-# Copyright (C) 1998-2014 Free Software Foundation, Inc.
+# Copyright (C) 1998-2015 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
diff --git a/tests/misc/mknod.sh b/tests/misc/mknod.sh
index fb907f16..8ca35648 100755
--- a/tests/misc/mknod.sh
+++ b/tests/misc/mknod.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that mknod, mkfifo, mkdir -m MODE work with a restrictive umask
-# Copyright (C) 2004-2014 Free Software Foundation, Inc.
+# Copyright (C) 2004-2015 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
diff --git a/tests/misc/mktemp.pl b/tests/misc/mktemp.pl
index 13ee03f5..ca6a8516 100755
--- a/tests/misc/mktemp.pl
+++ b/tests/misc/mktemp.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "mktemp".
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
diff --git a/tests/misc/nice-fail.sh b/tests/misc/nice-fail.sh
index 3bf823ab..2e957000 100755
--- a/tests/misc/nice-fail.sh
+++ b/tests/misc/nice-fail.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify that internal failure in nice gives exact status.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
diff --git a/tests/misc/nice.sh b/tests/misc/nice.sh
index 26a01ca9..59316ec5 100755
--- a/tests/misc/nice.sh
+++ b/tests/misc/nice.sh
@@ -1,7 +1,7 @@
#! /bin/sh
# Test "nice".
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 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
@@ -73,7 +73,7 @@ done
if test x$(nice -n -1 nice 2> /dev/null) = x0 ; then
# unprivileged user - warn about failure to change
nice -n -1 true 2> err || fail=1
- test -s err || fail=1
+ compare /dev/null err && fail=1
mv err exp || framework_failure_
nice --1 true 2> err || fail=1
compare exp err || fail=1
diff --git a/tests/misc/nl.sh b/tests/misc/nl.sh
index 676c75d7..310d45fe 100755
--- a/tests/misc/nl.sh
+++ b/tests/misc/nl.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise nl functionality
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 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
diff --git a/tests/misc/nohup.sh b/tests/misc/nohup.sh
index b3f4274c..b0621f4d 100755
--- a/tests/misc/nohup.sh
+++ b/tests/misc/nohup.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# test nohup
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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
diff --git a/tests/misc/nproc-avail.sh b/tests/misc/nproc-avail.sh
index 1a7e7219..a045c580 100755
--- a/tests/misc/nproc-avail.sh
+++ b/tests/misc/nproc-avail.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that "nproc" is less than or equal to "nproc --all".
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
diff --git a/tests/misc/nproc-positive.sh b/tests/misc/nproc-positive.sh
index c8fe9bae..fb825fac 100755
--- a/tests/misc/nproc-positive.sh
+++ b/tests/misc/nproc-positive.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that nproc prints a number > 0
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
@@ -35,7 +35,7 @@ for i in 0 ' 1' 1000; do
done
for i in -1 N; do
- nproc --ignore=$i && fail=1
+ returns_ 1 nproc --ignore=$i || fail=1
done
procs=$(OMP_NUM_THREADS=42 nproc --ignore=40)
diff --git a/tests/misc/numfmt.pl b/tests/misc/numfmt.pl
index dfb4b2e0..0e4dc79c 100755
--- a/tests/misc/numfmt.pl
+++ b/tests/misc/numfmt.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Basic tests for "numfmt".
-# Copyright (C) 2012-2014 Free Software Foundation, Inc.
+# Copyright (C) 2012-2015 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,6 +21,8 @@ use strict;
(my $program_name = $0) =~ s|.*/||;
my $prog = 'numfmt';
+my $limits = getlimits ();
+
# TODO: add localization tests with "grouping"
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@@ -92,10 +94,16 @@ my @Tests =
['unit-6', '--from-unit=54W --from=iec --to=iec 4M',
{ERR => "$prog: invalid unit size: '54W'\n"},
{EXIT => '1'}],
- # Not fully documented.. "--{from,to}-unit" can accept IEC suffixes
- ['unit-7', '--from-unit=2K --to=iec 30', {OUT=>"60K"}],
- ['unit-8', '--from-unit=1234567890123456789012345 --to=iec 30',
- {ERR => "$prog: invalid unit size: '1234567890123456789012345'\n"},
+ ['unit-7', '--from-unit=K 30', {OUT=>"30000"}],
+ ['unit-7.1', '--from-unit=Ki 30', {OUT=>"30720"}],
+ ['unit-7.2', '--from-unit=i 0',
+ {ERR => "$prog: invalid unit size: 'i'\n"},
+ {EXIT => '1'}],
+ ['unit-7.3', '--from-unit=1i 0',
+ {ERR => "$prog: invalid unit size: '1i'\n"},
+ {EXIT => '1'}],
+ ['unit-8', '--from-unit='.$limits->{UINTMAX_OFLOW}.' --to=iec 30',
+ {ERR => "$prog: invalid unit size: '$limits->{UINTMAX_OFLOW}'\n"},
{EXIT => '1'}],
['unit-9', '--from-unit=0 1',
{ERR => "$prog: invalid unit size: '0'\n"},
@@ -188,21 +196,16 @@ my @Tests =
['delim-3', '--delimiter=" " --from=auto "40M Foo"',{OUT=>'40000000 Foo'}],
['delim-4', '--delimiter=: --from=auto 40M:60M', {OUT=>'40000000:60M'}],
['delim-5', '-d: --field=2 --from=auto :40M:60M', {OUT=>':40000000:60M'}],
- ['delim-6', '--delimiter=: --field 3 --from=auto 40M:60M',
- {EXIT=>2},
- {ERR=>"$prog: input line is too short, no numbers found " .
- "to convert in field 3\n"}],
+ ['delim-6', '-d: --field 3 --from=auto 40M:60M', {OUT=>"40M:60M"}],
#Fields
['field-1', '--field A',
{ERR => "$prog: invalid field value 'A'\n"},
{EXIT => '1'}],
- ['field-1.1', '--field -5',
- {ERR => "$prog: invalid field value '-5'\n"},
- {EXIT => '1'}],
['field-2', '--field 2 --from=auto "Hello 40M World 90G"',
{OUT=>'Hello 40000000 World 90G'}],
['field-3', '--field 3 --from=auto "Hello 40M World 90G"',
+ {OUT=>"Hello 40M "},
{ERR=>"$prog: invalid number: 'World'\n"},
{EXIT => 2},],
# Last field - no text after number
@@ -217,10 +220,32 @@ my @Tests =
{OUT=>"Hello:40000000:World:90G"}],
# not enough fields
- ['field-8', '--field 3 --to=si "Hello World"',
- {EXIT=>2},
- {ERR=>"$prog: input line is too short, no numbers found " .
- "to convert in field 3\n"}],
+ ['field-8', '--field 3 --to=si "Hello World"', {OUT=>"Hello World"}],
+
+ # Multiple fields
+ ['field-range-1', '--field 2,4 --to=si "1000 2000 3000 4000 5000"',
+ {OUT=>"1000 2.0K 3000 4.0K 5000"}],
+
+ ['field-range-2', '--field 2-4 --to=si "1000 2000 3000 4000 5000"',
+ {OUT=>"1000 2.0K 3.0K 4.0K 5000"}],
+
+ ['field-range-3', '--field 1,2,3-5 --to=si "1000 2000 3000 4000 5000"',
+ {OUT=>"1.0K 2.0K 3.0K 4.0K 5.0K"}],
+
+ ['field-range-4', '--field 1-5 --to=si "1000 2000 3000 4000 5000"',
+ {OUT=>"1.0K 2.0K 3.0K 4.0K 5.0K"}],
+
+ ['field-range-5', '--field 1-3,5 --to=si "1000 2000 3000 4000 5000"',
+ {OUT=>"1.0K 2.0K 3.0K 4000 5.0K"}],
+
+ ['field-range-6', '--field 3- --to=si "1000 2000 3000 4000 5000"',
+ {OUT=>"1000 2000 3.0K 4.0K 5.0K"}],
+
+ ['field-range-7', '--field -3 --to=si "1000 2000 3000 4000 5000"',
+ {OUT=>"1.0K 2.0K 3.0K 4000 5000"}],
+
+ ['all-fields-1', '--field=- --to=si "1000 2000 3000 4000 5000"',
+ {OUT=>"1.0K 2.0K 3.0K 4.0K 5.0K"}],
# Auto-consume white-space, setup auto-padding
['whitespace-1', '--to=si --field 2 "A 500 B"', {OUT=>"A 500 B"}],
@@ -336,15 +361,6 @@ my @Tests =
{ERR=>"$prog: invalid number: ''\n"},
{EXIT=> 2}],
- # INTEGRAL_OVERFLOW
- ['strtod-3', '--from=si "1234567890123456789012345678901234567890'.
- '1234567890123456789012345678901234567890"',
- {ERR=>"$prog: value too large to be converted: '" .
- "1234567890123456789012345678901234567890" .
- "1234567890123456789012345678901234567890'\n",
- },
- {EXIT=> 2}],
-
# FRACTION_NO_DIGITS_FOUND
['strtod-5', '--from=si 12.',
{ERR=>"$prog: invalid number: '12.'\n"},
@@ -358,15 +374,6 @@ my @Tests =
{ERR=>"$prog: invalid number: '12. 2'\n"},
{EXIT=>2}],
- # FRACTION_OVERFLOW
- ['strtod-7', '--from=si "12.1234567890123456789012345678901234567890'.
- '1234567890123456789012345678901234567890"',
- {ERR=>"$prog: value too large to be converted: '" .
- "12.1234567890123456789012345678901234567890" .
- "1234567890123456789012345678901234567890'\n",
- },
- {EXIT=> 2}],
-
# INVALID_SUFFIX
['strtod-9', '--from=si 12.2Q',
{ERR=>"$prog: invalid suffix in input: '12.2Q'\n"},
@@ -502,128 +509,35 @@ my @Tests =
{OUT=>"5.8594\n-5.8594"}],
- # Large Values
- ['large-1','1000000000000000', {OUT=>"1000000000000000"}],
- # 18 digits is OK
- ['large-2','1000000000000000000', {OUT=>"1000000000000000000"}],
- # 19 digits is too much (without output scaling)
- ['large-3','10000000000000000000',
- {ERR => "$prog: value too large to be printed: '1e+19' " .
- "(consider using --to)\n"},
- {EXIT=>2}],
-
- # Test input:
- # Up to 27 digits is OK.
- ['large-3.1', '--to=si 1', {OUT=> "1"}],
- ['large-3.2', '--to=si 10', {OUT=> "10"}],
- ['large-3.3', '--to=si 100', {OUT=> "100"}],
- ['large-3.4', '--to=si 1000', {OUT=>"1.0K"}],
- ['large-3.5', '--to=si 10000', {OUT=> "10K"}],
- ['large-3.6', '--to=si 100000', {OUT=>"100K"}],
- ['large-3.7', '--to=si 1000000', {OUT=>"1.0M"}],
- ['large-3.8', '--to=si 10000000', {OUT=> "10M"}],
- ['large-3.9', '--to=si 100000000', {OUT=>"100M"}],
- ['large-3.10','--to=si 1000000000', {OUT=>"1.0G"}],
- ['large-3.11','--to=si 10000000000', {OUT=> "10G"}],
- ['large-3.12','--to=si 100000000000', {OUT=>"100G"}],
- ['large-3.13','--to=si 1000000000000', {OUT=>"1.0T"}],
- ['large-3.14','--to=si 10000000000000', {OUT=> "10T"}],
- ['large-3.15','--to=si 100000000000000', {OUT=>"100T"}],
- ['large-3.16','--to=si 1000000000000000', {OUT=>"1.0P"}],
- ['large-3.17','--to=si 10000000000000000', {OUT=> "10P"}],
- ['large-3.18','--to=si 100000000000000000', {OUT=>"100P"}],
- ['large-3.19','--to=si 1000000000000000000', {OUT=>"1.0E"}],
- ['large-3.20','--to=si 10000000000000000000', {OUT=> "10E"}],
- ['large-3.21','--to=si 210000000000000000000', {OUT=>"210E"}],
- ['large-3.22','--to=si 3210000000000000000000', {OUT=>"3.3Z"}],
- ['large-3.23','--to=si 43210000000000000000000', {OUT=> "44Z"}],
- ['large-3.24','--to=si 543210000000000000000000', {OUT=>"544Z"}],
- ['large-3.25','--to=si 6543210000000000000000000', {OUT=>"6.6Y"}],
- ['large-3.26','--to=si 76543210000000000000000000', {OUT=> "77Y"}],
- ['large-3.27','--to=si 876543210000000000000000000', {OUT=>"877Y"}],
-
- # More than 27 digits is not OK
- ['large-3.28','--to=si 9876543210000000000000000000',
- {ERR => "$prog: value too large to be converted: " .
- "'9876543210000000000000000000'\n"},
- {EXIT => 2}],
-
- # Test Output
- ['large-4.1', '--from=si 9.7M', {OUT=>"9700000"}],
- ['large-4.2', '--from=si 10M', {OUT =>"10000000"}],
- ['large-4.3', '--from=si 200M', {OUT =>"200000000"}],
- ['large-4.4', '--from=si 3G', {OUT =>"3000000000"}],
- ['large-4.5', '--from=si 40G', {OUT =>"40000000000"}],
- ['large-4.6', '--from=si 500G', {OUT =>"500000000000"}],
- ['large-4.7', '--from=si 6T', {OUT =>"6000000000000"}],
- ['large-4.8', '--from=si 70T', {OUT =>"70000000000000"}],
- ['large-4.9', '--from=si 800T', {OUT =>"800000000000000"}],
- ['large-4.10','--from=si 9P', {OUT =>"9000000000000000"}],
- ['large-4.11','--from=si 10P', {OUT =>"10000000000000000"}],
- ['large-4.12','--from=si 200P', {OUT =>"200000000000000000"}],
- ['large-4.13','--from=si 3E', {OUT =>"3000000000000000000"}],
-
- # More than 18 digits of output without scaling - no good.
- ['large-4.14','--from=si 40E',
- {ERR => "$prog: value too large to be printed: '4e+19' " .
- "(consider using --to)\n"},
- {EXIT => 2}],
- ['large-4.15','--from=si 500E',
- {ERR => "$prog: value too large to be printed: '5e+20' " .
- "(consider using --to)\n"},
- {EXIT => 2}],
- ['large-4.16','--from=si 6Z',
- {ERR => "$prog: value too large to be printed: '6e+21' " .
- "(consider using --to)\n"},
- {EXIT => 2}],
- ['large-4.17','--from=si 70Z',
- {ERR => "$prog: value too large to be printed: '7e+22' " .
- "(consider using --to)\n"},
+ # Leading zeros weren't handled appropriately before 8.24
+ ['leading-1','0000000000000000000000000001', {OUT=>"1"}],
+ ['leading-2','.1', {OUT=>"0.1"}],
+ ['leading-3','bad.1',
+ {ERR => "$prog: invalid number: 'bad.1'\n"},
{EXIT => 2}],
- ['large-4.18','--from=si 800Z',
- {ERR => "$prog: value too large to be printed: '8e+23' " .
- "(consider using --to)\n"},
+ ['leading-4','..1',
+ {ERR => "$prog: invalid suffix in input: '..1'\n"},
{EXIT => 2}],
- ['large-4.19','--from=si 9Y',
- {ERR => "$prog: value too large to be printed: '9e+24' " .
- "(consider using --to)\n"},
- {EXIT => 2}],
- ['large-4.20','--from=si 10Y',
- {ERR => "$prog: value too large to be printed: '1e+25' " .
- "(consider using --to)\n"},
- {EXIT => 2}],
- ['large-4.21','--from=si 200Y',
- {ERR => "$prog: value too large to be printed: '2e+26' " .
- "(consider using --to)\n"},
- {EXIT => 2}],
-
- ['large-5.1','--to=si 1000000000000000000', {OUT=>"1.0E"}],
- ['large-5','--from=si --to=si 2E', {OUT=>"2.0E"}],
- ['large-6','--from=si --to=si 3.4Z', {OUT=>"3.4Z"}],
- ['large-7','--from=si --to=si 80Y', {OUT=>"80Y"}],
- ['large-8','--from=si --to=si 9000Z', {OUT=>"9.0Y"}],
-
- ['large-10','--from=si --to=si 999Y', {OUT=>"999Y"}],
- ['large-11','--from=si --to=iec 999Y', {OUT=>"827Y"}],
- ['large-12','--from=si --round=down --to=iec 999Y', {OUT=>"826Y"}],
-
- # units can also affect the output
- ['large-13','--from=si --from-unit=1000000 9P',
- {ERR => "$prog: value too large to be printed: '9e+21' " .
- "(consider using --to)\n"},
+ ['leading-5','1.',
+ {ERR => "$prog: invalid number: '1.'\n"},
{EXIT => 2}],
- ['large-13.1','--from=si --from-unit=1000000 --to=si 9P', {OUT=>"9.0Z"}],
- # Numbers>999Y are never acceptable, regardless of scaling
- ['large-14','--from=si --to=si 999Y', {OUT=>"999Y"}],
- ['large-14.1','--from=si --to=si 1000Y',
- {ERR => "$prog: value too large to be printed: '1e+27' " .
- "(cannot handle values > 999Y)\n"},
- {EXIT => 2}],
- ['large-14.2','--from=si --to=si --from-unit=10000 1Y',
- {ERR => "$prog: value too large to be printed: '1e+28' " .
- "(cannot handle values > 999Y)\n"},
- {EXIT => 2}],
+ # precision override
+ ['precision-1','--format=%.4f 9991239123 --to=si', {OUT=>"9.9913G"}],
+ ['precision-2','--format=%.1f 9991239123 --to=si', {OUT=>"10.0G"}],
+ ['precision-3','--format=%.1f 1', {OUT=>"1.0"}],
+ ['precision-4','--format=%.1f 1.12', {OUT=>"1.2"}],
+ ['precision-5','--format=%.1f 9991239123 --to-unit=G', {OUT=>"10.0"}],
+ ['precision-6','--format="% .1f" 9991239123 --to-unit=G', {OUT=>"10.0"}],
+ ['precision-7','--format=%.-1f 1.1',
+ {ERR => "$prog: invalid precision in format '%.-1f'\n"},
+ {EXIT => 1}],
+ ['precision-8','--format=%.+1f 1.1',
+ {ERR => "$prog: invalid precision in format '%.+1f'\n"},
+ {EXIT => 1}],
+ ['precision-9','--format="%. 1f" 1.1',
+ {ERR => "$prog: invalid precision in format '%. 1f'\n"},
+ {EXIT => 1}],
# debug warnings
['debug-1', '--debug 4096', {OUT=>"4096"},
@@ -632,14 +546,6 @@ my @Tests =
['debug-1.1', '--debug --padding 10 4096', {OUT=>" 4096"}],
['debug-2', '--debug --grouping --from=si 4.0K', {OUT=>"4000"},
{ERR=>"$prog: grouping has no effect in this locale\n"}],
- ['debug-4', '--to=si --debug 12345678901234567890',
- {OUT=>"13E"},
- {ERR=>"$prog: large input value '12345678901234567890':" .
- " possible precision loss\n"}],
- ['debug-5', '--to=si --from=si --debug 1.12345678901234567890Y',
- {OUT=>"1.2Y"},
- {ERR=>"$prog: large input value '1.12345678901234567890Y':" .
- " possible precision loss\n"}],
# dev-debug messages - the actual messages don't matter
# just ensure the program works, and for code coverage testing.
@@ -673,14 +579,12 @@ my @Tests =
['devdebug-11', '---debug --format "%\'-10f" 10000',{OUT=>"10000 "},
{ERR=>""},
{ERR_SUBST=>"s/.*//msg"}],
- ['devdebug-12', '---debug --field 2 A',{OUT=>""},
- {ERR=>""}, {EXIT=>2},
- {ERR_SUBST=>"s/.*//msg"}],
# Invalid parameters
['help-1', '--foobar',
- {ERR=>"$prog: unrecognized option '--foobar'\n" .
+ {ERR=>"$prog: unrecognized option\n" .
"Try '$prog --help' for more information.\n"},
+ {ERR_SUBST=>"s/option.*/option/; s/unknown/unrecognized/"},
{EXIT=>1}],
## Format string - check error detection
@@ -695,17 +599,17 @@ my @Tests =
{EXIT=>1}],
['fmt-err-4', '--format "%d"',
{ERR=>"$prog: invalid format '%d', " .
- "directive must be %[0]['][-][N]f\n"},
+ "directive must be %[0]['][-][N][.][N]f\n"},
{EXIT=>1}],
['fmt-err-5', '--format "% -43 f"',
{ERR=>"$prog: invalid format '% -43 f', " .
- "directive must be %[0]['][-][N]f\n"},
+ "directive must be %[0]['][-][N][.][N]f\n"},
{EXIT=>1}],
['fmt-err-6', '--format "%f %f"',
{ERR=>"$prog: format '%f %f' has too many % directives\n"},
{EXIT=>1}],
- ['fmt-err-7', '--format "%123456789012345678901234567890f"',
- {ERR=>"$prog: invalid format '%123456789012345678901234567890f'".
+ ['fmt-err-7', '--format "%'.$limits->{LONG_OFLOW}.'f"',
+ {ERR=>"$prog: invalid format '%$limits->{LONG_OFLOW}f'".
" (width overflow)\n"},
{EXIT=>1}],
['fmt-err-9', '--format "%f" --grouping',
@@ -781,11 +685,6 @@ my @Tests =
{ERR => "$prog: invalid number: 'World'\n"},
{OUT => "Hello 40M World 90G\n"},
{EXIT => 2}],
- ['ign-err-6', '--invalid=fail --field 3 --to=si "Hello World"',
- {ERR => "$prog: input line is too short, no numbers found " .
- "to convert in field 3\n"},
- {OUT => "Hello World\n"},
- {EXIT => 2}],
['ign-err-7', '--invalid=fail --from=si "foo"',
{ERR => "$prog: invalid number: 'foo'\n"},
{OUT => "foo\n"},
@@ -800,16 +699,6 @@ my @Tests =
"'12M' (e.g Ki/Mi/Gi)\n"},
{OUT => "12M\n"},
{EXIT=>2}],
- ['ign-err-10','--invalid=fail 10000000000000000000',
- {ERR => "$prog: value too large to be printed: '1e+19' " .
- "(consider using --to)\n"},
- {OUT => "10000000000000000000\n"},
- {EXIT=>2}],
- ['ign-err-11','--invalid=fail --to=si 9876543210000000000000000000',
- {ERR => "$prog: value too large to be converted: " .
- "'9876543210000000000000000000'\n"},
- {OUT => "9876543210000000000000000000\n"},
- {EXIT => 2}],
## Ignore Errors with multiple conversions
['ign-err-m1', '--invalid=ignore --to=si 1000 2000 bad 3000',
@@ -849,15 +738,184 @@ my @Tests =
{OUT => "A 1000 x\nB Foo y\nC 2.8G z\n"},
{ERR => "$prog: invalid number: 'Foo'\n"},
{EXIT => 2}],
- # one of the lines is too short
- ['ign-err-m3.2', '--invalid=fail --field 2 --from=si --to=iec',
- {IN_PIPE => "A 1K x\nB\nC 3G z\n"},
- {OUT => "A 1000 x\nB\nC 2.8G z\n"},
- {ERR => "$prog: input line is too short, no numbers found " .
- "to convert in field 2\n"},
- {EXIT => 2}],
);
+my @Limit_Tests =
+ (
+ # Large Values
+ ['large-1','1000000000000000', {OUT=>"1000000000000000"}],
+ # 18 digits is OK
+ ['large-2','1000000000000000000', {OUT=>"1000000000000000000"}],
+ # 19 digits is too much (without output scaling)
+ ['large-3','10000000000000000000',
+ {ERR => "$prog: value too large to be printed: '1e+19' " .
+ "(consider using --to)\n"},
+ {EXIT=>2}],
+ ['large-4','1000000000000000000.0',
+ {ERR => "$prog: value/precision too large to be printed: " .
+ "'1e+18/1' (consider using --to)\n"},
+ {EXIT=>2}],
+
+
+ # Test input:
+ # Up to 27 digits is OK.
+ ['large-3.1', '--to=si 1', {OUT=> "1"}],
+ ['large-3.2', '--to=si 10', {OUT=> "10"}],
+ ['large-3.3', '--to=si 100', {OUT=> "100"}],
+ ['large-3.4', '--to=si 1000', {OUT=>"1.0K"}],
+ ['large-3.5', '--to=si 10000', {OUT=> "10K"}],
+ ['large-3.6', '--to=si 100000', {OUT=>"100K"}],
+ ['large-3.7', '--to=si 1000000', {OUT=>"1.0M"}],
+ ['large-3.8', '--to=si 10000000', {OUT=> "10M"}],
+ ['large-3.9', '--to=si 100000000', {OUT=>"100M"}],
+ ['large-3.10','--to=si 1000000000', {OUT=>"1.0G"}],
+ ['large-3.11','--to=si 10000000000', {OUT=> "10G"}],
+ ['large-3.12','--to=si 100000000000', {OUT=>"100G"}],
+ ['large-3.13','--to=si 1000000000000', {OUT=>"1.0T"}],
+ ['large-3.14','--to=si 10000000000000', {OUT=> "10T"}],
+ ['large-3.15','--to=si 100000000000000', {OUT=>"100T"}],
+ ['large-3.16','--to=si 1000000000000000', {OUT=>"1.0P"}],
+ ['large-3.17','--to=si 10000000000000000', {OUT=> "10P"}],
+ ['large-3.18','--to=si 100000000000000000', {OUT=>"100P"}],
+ ['large-3.19','--to=si 1000000000000000000', {OUT=>"1.0E"}],
+ ['large-3.20','--to=si 10000000000000000000', {OUT=> "10E"}],
+ ['large-3.21','--to=si 210000000000000000000', {OUT=>"210E"}],
+ ['large-3.22','--to=si 3210000000000000000000', {OUT=>"3.3Z"}],
+ ['large-3.23','--to=si 43210000000000000000000', {OUT=> "44Z"}],
+ ['large-3.24','--to=si 543210000000000000000000', {OUT=>"544Z"}],
+ ['large-3.25','--to=si 6543210000000000000000000', {OUT=>"6.6Y"}],
+ ['large-3.26','--to=si 76543210000000000000000000', {OUT=> "77Y"}],
+ ['large-3.27','--to=si 876543210000000000000000000', {OUT=>"877Y"}],
+
+ # More than 27 digits is not OK
+ ['large-3.28','--to=si 9876543210000000000000000000',
+ {ERR => "$prog: value too large to be converted: " .
+ "'9876543210000000000000000000'\n"},
+ {EXIT => 2}],
+
+ # Test Output
+ ['large-4.1', '--from=si 9.7M', {OUT=>"9700000"}],
+ ['large-4.2', '--from=si 10M', {OUT =>"10000000"}],
+ ['large-4.3', '--from=si 200M', {OUT =>"200000000"}],
+ ['large-4.4', '--from=si 3G', {OUT =>"3000000000"}],
+ ['large-4.5', '--from=si 40G', {OUT =>"40000000000"}],
+ ['large-4.6', '--from=si 500G', {OUT =>"500000000000"}],
+ ['large-4.7', '--from=si 6T', {OUT =>"6000000000000"}],
+ ['large-4.8', '--from=si 70T', {OUT =>"70000000000000"}],
+ ['large-4.9', '--from=si 800T', {OUT =>"800000000000000"}],
+ ['large-4.10','--from=si 9P', {OUT =>"9000000000000000"}],
+ ['large-4.11','--from=si 10P', {OUT =>"10000000000000000"}],
+ ['large-4.12','--from=si 200P', {OUT =>"200000000000000000"}],
+ ['large-4.13','--from=si 3E', {OUT =>"3000000000000000000"}],
+
+ # More than 18 digits of output without scaling - no good.
+ ['large-4.14','--from=si 40E',
+ {ERR => "$prog: value too large to be printed: '4e+19' " .
+ "(consider using --to)\n"},
+ {EXIT => 2}],
+ ['large-4.15','--from=si 500E',
+ {ERR => "$prog: value too large to be printed: '5e+20' " .
+ "(consider using --to)\n"},
+ {EXIT => 2}],
+ ['large-4.16','--from=si 6Z',
+ {ERR => "$prog: value too large to be printed: '6e+21' " .
+ "(consider using --to)\n"},
+ {EXIT => 2}],
+ ['large-4.17','--from=si 70Z',
+ {ERR => "$prog: value too large to be printed: '7e+22' " .
+ "(consider using --to)\n"},
+ {EXIT => 2}],
+ ['large-4.18','--from=si 800Z',
+ {ERR => "$prog: value too large to be printed: '8e+23' " .
+ "(consider using --to)\n"},
+ {EXIT => 2}],
+ ['large-4.19','--from=si 9Y',
+ {ERR => "$prog: value too large to be printed: '9e+24' " .
+ "(consider using --to)\n"},
+ {EXIT => 2}],
+ ['large-4.20','--from=si 10Y',
+ {ERR => "$prog: value too large to be printed: '1e+25' " .
+ "(consider using --to)\n"},
+ {EXIT => 2}],
+ ['large-4.21','--from=si 200Y',
+ {ERR => "$prog: value too large to be printed: '2e+26' " .
+ "(consider using --to)\n"},
+ {EXIT => 2}],
+
+ ['large-5.1','--to=si 1000000000000000000', {OUT=>"1.0E"}],
+ ['large-5','--from=si --to=si 2E', {OUT=>"2.0E"}],
+ ['large-6','--from=si --to=si 3.4Z', {OUT=>"3.4Z"}],
+ ['large-7','--from=si --to=si 80Y', {OUT=>"80Y"}],
+ ['large-8','--from=si --to=si 9000Z', {OUT=>"9.0Y"}],
+
+ ['large-10','--from=si --to=si 999Y', {OUT=>"999Y"}],
+ ['large-11','--from=si --to=iec 999Y', {OUT=>"827Y"}],
+ ['large-12','--from=si --round=down --to=iec 999Y', {OUT=>"826Y"}],
+
+ # units can also affect the output
+ ['large-13','--from=si --from-unit=1000000 9P',
+ {ERR => "$prog: value too large to be printed: '9e+21' " .
+ "(consider using --to)\n"},
+ {EXIT => 2}],
+ ['large-13.1','--from=si --from-unit=1000000 --to=si 9P', {OUT=>"9.0Z"}],
+
+ # Numbers>999Y are never acceptable, regardless of scaling
+ ['large-14','--from=si --to=si 999Y', {OUT=>"999Y"}],
+ ['large-14.1','--from=si --to=si 1000Y',
+ {ERR => "$prog: value too large to be printed: '1e+27' " .
+ "(cannot handle values > 999Y)\n"},
+ {EXIT => 2}],
+ ['large-14.2','--from=si --to=si --from-unit=10000 1Y',
+ {ERR => "$prog: value too large to be printed: '1e+28' " .
+ "(cannot handle values > 999Y)\n"},
+ {EXIT => 2}],
+
+ # intmax_t overflow when rounding caused this to fail before 8.24
+ ['large-15',$limits->{INTMAX_OFLOW}, {OUT=>$limits->{INTMAX_OFLOW}}],
+ ['large-16','9.300000000000000000', {OUT=>'9.300000000000000000'}],
+
+ # INTEGRAL_OVERFLOW
+ ['strtod-3', '--from=si "1234567890123456789012345678901234567890'.
+ '1234567890123456789012345678901234567890"',
+ {ERR=>"$prog: value too large to be converted: '" .
+ "1234567890123456789012345678901234567890" .
+ "1234567890123456789012345678901234567890'\n",
+ },
+ {EXIT=> 2}],
+
+ # FRACTION_OVERFLOW
+ ['strtod-7', '--from=si "12.1234567890123456789012345678901234567890'.
+ '1234567890123456789012345678901234567890"',
+ {ERR=>"$prog: value too large to be converted: '" .
+ "12.1234567890123456789012345678901234567890" .
+ "1234567890123456789012345678901234567890'\n",
+ },
+ {EXIT=> 2}],
+
+ ['debug-4', '--to=si --debug 12345678901234567890',
+ {OUT=>"13E"},
+ {ERR=>"$prog: large input value '12345678901234567890':" .
+ " possible precision loss\n"}],
+ ['debug-5', '--to=si --from=si --debug 1.12345678901234567890Y',
+ {OUT=>"1.2Y"},
+ {ERR=>"$prog: large input value '1.12345678901234567890Y':" .
+ " possible precision loss\n"}],
+
+ ['ign-err-10','--invalid=fail 10000000000000000000',
+ {ERR => "$prog: value too large to be printed: '1e+19' " .
+ "(consider using --to)\n"},
+ {OUT => "10000000000000000000\n"},
+ {EXIT=>2}],
+ ['ign-err-11','--invalid=fail --to=si 9876543210000000000000000000',
+ {ERR => "$prog: value too large to be converted: " .
+ "'9876543210000000000000000000'\n"},
+ {OUT => "9876543210000000000000000000\n"},
+ {EXIT => 2}],
+ );
+# Restrict these tests to systems with LDBL_DIG == 18
+(system "$prog ---debug 1 2>&1|grep 'MAX_UNSCALED_DIGITS: 18' > /dev/null") == 0
+ and push @Tests, @Limit_Tests;
+
my @Locale_Tests =
(
# Locale that supports grouping, but without '--grouping' parameter
diff --git a/tests/misc/od-N.sh b/tests/misc/od-N.sh
index 247ea546..ec417d27 100755
--- a/tests/misc/od-N.sh
+++ b/tests/misc/od-N.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify that 'od -N N' reads no more than N bytes of input.
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2015 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
diff --git a/tests/misc/od-endian.sh b/tests/misc/od-endian.sh
index a01ae0a8..c3acca70 100755
--- a/tests/misc/od-endian.sh
+++ b/tests/misc/od-endian.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# verify that od --endian works properly
-# Copyright (C) 2014 Free Software Foundation, Inc.
+# Copyright (C) 2014-2015 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
diff --git a/tests/misc/od-float.sh b/tests/misc/od-float.sh
index 8a8e29b2..bbfa5704 100755
--- a/tests/misc/od-float.sh
+++ b/tests/misc/od-float.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test od on floating-point values.
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
@@ -29,7 +29,7 @@ export LC_ALL=C
# on x86: sometimes there was no space between the columns.
set x $(echo aaaabaaa | tr ab '\376\377' | od -t fF) ||
- framework_failure_
+ fail=1
case "$*" in
*0-*) fail=1;;
esac
@@ -38,7 +38,7 @@ case $3,$4 in
esac
set x $(echo aaaaaaaabaaaaaaa | tr ab '\376\377' | od -t fD) ||
- framework_failure_
+ fail=1
case "$*" in
*0-*) fail=1;;
esac
@@ -47,7 +47,7 @@ case $3,$4 in
esac
set x $(echo aaaaaaaaaaaaaaaabaaaaaaaaaaaaaaa | tr ab '\376\377' | od -t fL) ||
- framework_failure_
+ fail=1
case "$*" in
*0-*) fail=1;;
esac
@@ -55,4 +55,18 @@ case $3,$4 in
-1.023442870282055988e+4855,-1.023442870282055988e+4855) fail=1;;
esac
+# Ensure od doesn't crash as it did on glibc <= 2.5:
+# https://sourceware.org/bugzilla/show_bug.cgi?id=4586
+set x $(printf 00000000ff000000 | tr 0f '\000\377' | od -t fL) || fail=1
+# With coreutils <= 8.7 we used to print "nan" for the above invalid value.
+# However since v8.7-22-ga71c22f we deferred to the system printf routines
+# through the use of the ftoastr module. So the following check would only
+# be valid on x86_64 if we again handle the conversion internally or
+# if this glibc bug is resolved:
+# https://sourceware.org/bugzilla/show_bug.cgi?id=17661
+#case "$*" in
+#*nan*) ;;
+#*) fail=1;;
+#esac
+
Exit $fail
diff --git a/tests/misc/od-j.sh b/tests/misc/od-j.sh
new file mode 100755
index 00000000..293aad5f
--- /dev/null
+++ b/tests/misc/od-j.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Verify that 'od -j N' skips N bytes of input.
+
+# Copyright 2014-2015 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ od
+
+for file in ${srcdir=.}/tests/init.sh /proc/version /sys/kernel/profiling; do
+ test -r $file || continue
+
+ cp -f $file copy &&
+ bytes=$(wc -c < copy) || framework_failure_
+
+ od -An $file > exp || fail=1
+ od -An -j $bytes $file $file > out || fail=1
+ compare exp out || fail=1
+
+ od -An -j 4096 copy copy > exp1 2> experr1; expstatus=$?
+ od -An -j 4096 $file $file > out1 2> err1; status=$?
+ test $status -eq $expstatus || fail=1
+ compare exp1 out1 || fail=1
+ compare experr1 err1 || fail=1
+done
+
+Exit $fail
diff --git a/tests/misc/od-multiple-t.sh b/tests/misc/od-multiple-t.sh
index 451fa2f5..07fc1a1f 100755
--- a/tests/misc/od-multiple-t.sh
+++ b/tests/misc/od-multiple-t.sh
@@ -2,7 +2,7 @@
# verify that multiple -t specifiers to od align well
# This would fail before coreutils-6.13.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/od-x8.sh b/tests/misc/od-x8.sh
index 6e72dee7..c10f07fb 100755
--- a/tests/misc/od-x8.sh
+++ b/tests/misc/od-x8.sh
@@ -2,7 +2,7 @@
# verify that od -t x8 works properly
# This would fail before coreutils-4.5.2.
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 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
diff --git a/tests/misc/od.pl b/tests/misc/od.pl
index edddf4e3..601fbbcb 100755
--- a/tests/misc/od.pl
+++ b/tests/misc/od.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Exercise od
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
diff --git a/tests/misc/paste.pl b/tests/misc/paste.pl
index 04f8ec07..8d957f46 100755
--- a/tests/misc/paste.pl
+++ b/tests/misc/paste.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test paste.
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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
diff --git a/tests/misc/pathchk1.sh b/tests/misc/pathchk1.sh
index 616e763f..6c8a5088 100755
--- a/tests/misc/pathchk1.sh
+++ b/tests/misc/pathchk1.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# pathchk tests
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 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
@@ -25,14 +25,14 @@ touch file || framework_failure_
# This should exit nonzero. Before 2.0.13, it gave a diagnostic,
# but exited successfully.
-pathchk file/x > /dev/null 2>&1 && fail=1
+returns_ 1 pathchk file/x > /dev/null 2>&1 || fail=1
# This should exit nonzero. Through 5.3.0 it exited with status zero.
-pathchk -p '' > /dev/null 2>&1 && fail=1
+returns_ 1 pathchk -p '' > /dev/null 2>&1 || fail=1
# This tests the new -P option.
-pathchk -P '' > /dev/null 2>&1 && fail=1
-pathchk -P -- - > /dev/null 2>&1 && fail=1
-pathchk -p -P x/- > /dev/null 2>&1 && fail=1
+returns_ 1 pathchk -P '' > /dev/null 2>&1 || fail=1
+returns_ 1 pathchk -P -- - > /dev/null 2>&1 || fail=1
+returns_ 1 pathchk -p -P x/- > /dev/null 2>&1 || fail=1
Exit $fail
diff --git a/tests/misc/printenv.sh b/tests/misc/printenv.sh
index 054b02c2..862b48ba 100755
--- a/tests/misc/printenv.sh
+++ b/tests/misc/printenv.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify behavior of printenv.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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,8 +23,12 @@ print_ver_ printenv
# printenv as a builtin, so we must invoke it via "env".
# But beware of $_, set by many shells to the last command run.
# Also, filter out LD_PRELOAD, which is set when running under valgrind.
-env | grep -Ev '^(_|LD_PRELOAD=)' > exp || framework_failure_
-env -- printenv | grep -Ev '^(_|LD_PRELOAD=)' > out || fail=1
+# Note the apparently redundant "env env": this is to ensure to get
+# env's output the same way as that of printenv and works around a bug
+# on aarch64 at least where libc's execvp reverses the order of the
+# output.
+env -- env | grep -Ev '^(_|LD_PRELOAD)=' > exp || framework_failure_
+env -- printenv | grep -Ev '^(_|LD_PRELOAD)=' > out || fail=1
compare exp out || fail=1
# POSIX is clear that environ may, but need not be, sorted.
diff --git a/tests/misc/printf-cov.pl b/tests/misc/printf-cov.pl
index 3d797284..4be97971 100755
--- a/tests/misc/printf-cov.pl
+++ b/tests/misc/printf-cov.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# improve printf.c test coverage
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/printf-hex.sh b/tests/misc/printf-hex.sh
index 27503fae..04044560 100755
--- a/tests/misc/printf-hex.sh
+++ b/tests/misc/printf-hex.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# make sure that only two hex. digits are consumed in a \xHHH sequence
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 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
diff --git a/tests/misc/printf-surprise.sh b/tests/misc/printf-surprise.sh
index 6083806d..20e6b098 100755
--- a/tests/misc/printf-surprise.sh
+++ b/tests/misc/printf-surprise.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Detect printf(3) failure even when it doesn't set stream error indicator
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
@@ -53,7 +53,10 @@ mkfifo_or_skip_ fifo
# http://bugs.debian.org/481543#77
export MALLOC_PERTURB_=0
-head -c 10 fifo > out &
+# Terminate any background process
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+
+head -c 10 fifo > out & pid=$!
# Choosing the virtual memory limit, 11000 is enough, but 10000 is too
# little and provokes a "memory exhausted" diagnostic on FreeBSD 9.0-p3.
@@ -63,7 +66,7 @@ exit=$?
# Map this longer, and rarer, diagnostic to the common one.
# printf: cannot perform formatted output: Cannot allocate memory" \
sed 's/cannot perform .*/write error/' err-msg > k && mv k err-msg
-err_msg=$(cat err-msg|tr '\n' :)
+err_msg=$(tr '\n' : < err-msg)
# By some bug, on Solaris 11 (5.11 snv_86), err_msg ends up
# containing '1> fifo:printf: write error:'. Recognize that, too.
diff --git a/tests/misc/printf.sh b/tests/misc/printf.sh
index b2292252..87ca489f 100755
--- a/tests/misc/printf.sh
+++ b/tests/misc/printf.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# basic tests for printf
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 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
@@ -25,7 +25,9 @@ getlimits_
# Verify the 3 methods of specifying "Escape":
-test $($prog "\x1b\n\33\n\e\n" | uniq -u) && fail=1
+printf '%s\n' . . . | tr . '\033' > exp
+$prog '\x1b\n\33\n\e\n' > out || fail=1
+compare exp out || fail=1
# This would fail (by printing the '--') for printf in sh-utils
# and in coreutils 4.5.1.
@@ -68,17 +70,17 @@ $prog '8 %b %b %b %b\n' '\1y' '\01y' '\001y' '\0001y'|tr '\1' = >> out
$prog '9 %*dx\n' -2 0 >>out || fail=1
$prog '10 %.*dx\n' $INT_UFLOW 0 >>out || fail=1
-$prog '%.*dx\n' $INT_OFLOW 0 >>out 2> /dev/null && fail=1
+returns_ 1 $prog '%.*dx\n' $INT_OFLOW 0 >>out 2> /dev/null || fail=1
$prog '11 %*c\n' 2 x >>out || fail=1
-$prog '%#d\n' 0 >>out 2> /dev/null && fail=1
+returns_ 1 $prog '%#d\n' 0 >>out 2> /dev/null || fail=1
-$prog '%0s\n' 0 >>out 2> /dev/null && fail=1
+returns_ 1 $prog '%0s\n' 0 >>out 2> /dev/null || fail=1
-$prog '%.9c\n' 0 >>out 2> /dev/null && fail=1
+returns_ 1 $prog '%.9c\n' 0 >>out 2> /dev/null || fail=1
-$prog '%'\''s\n' 0 >>out 2> /dev/null && fail=1
+returns_ 1 $prog '%'\''s\n' 0 >>out 2> /dev/null || fail=1
cat <<\EOF > exp
1 x y
diff --git a/tests/misc/ptx-overrun.sh b/tests/misc/ptx-overrun.sh
index be9fb524..301e8dc6 100755
--- a/tests/misc/ptx-overrun.sh
+++ b/tests/misc/ptx-overrun.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/ptx.pl b/tests/misc/ptx.pl
index 8a91d616..83583238 100755
--- a/tests/misc/ptx.pl
+++ b/tests/misc/ptx.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/pwd-long.sh b/tests/misc/pwd-long.sh
index 1ba0c1a9..3ced777a 100755
--- a/tests/misc/pwd-long.sh
+++ b/tests/misc/pwd-long.sh
@@ -2,7 +2,7 @@
# -*- perl -*-
# Ensure that pwd works even when run from a very deep directory.
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
@@ -56,7 +56,6 @@ sub normalize_to_cwd_relative ($$$)
}
# Set up a safe, well-known environment
-delete @ENV{qw(BASH_ENV CDPATH ENV)};
$ENV{IFS} = '';
# Taint checking requires a sanitized $PATH. This script performs no $PATH
diff --git a/tests/misc/pwd-option.sh b/tests/misc/pwd-option.sh
index 0eba9429..fb2ad15b 100755
--- a/tests/misc/pwd-option.sh
+++ b/tests/misc/pwd-option.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that pwd options work.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
diff --git a/tests/misc/readlink-fp-loop.sh b/tests/misc/readlink-fp-loop.sh
index 4ae2dc52..1c4428b9 100755
--- a/tests/misc/readlink-fp-loop.sh
+++ b/tests/misc/readlink-fp-loop.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# readlink from 6.9 would fail with a false-positive symlink loop error
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
diff --git a/tests/misc/readlink-root.sh b/tests/misc/readlink-root.sh
index f33574cb..44693bdf 100755
--- a/tests/misc/readlink-root.sh
+++ b/tests/misc/readlink-root.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# tests for canonicalize-existing mode (readlink -e) on /.
-# Copyright (C) 2012-2014 Free Software Foundation, Inc.
+# Copyright (C) 2012-2015 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
diff --git a/tests/misc/realpath.sh b/tests/misc/realpath.sh
index 257b9f24..ed4be396 100755
--- a/tests/misc/realpath.sh
+++ b/tests/misc/realpath.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate realpath operation
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2015 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
@@ -42,17 +42,17 @@ ln -s /// three || framework_failure_
# Basic operation
realpath -Pqz . >/dev/null || fail=1
# Operand is required
-realpath >/dev/null && fail=1
-realpath --relative-base . --relative-to . && fail=1
-realpath --relative-base . && fail=1
+returns_ 1 realpath >/dev/null || fail=1
+returns_ 1 realpath --relative-base . --relative-to . || fail=1
+returns_ 1 realpath --relative-base . || fail=1
# -e --relative-* require directories
-realpath -e --relative-to=dir1/f --relative-base=. . && fail=1
+returns_ 1 realpath -e --relative-to=dir1/f --relative-base=. . || fail=1
realpath -e --relative-to=dir1/ --relative-base=. . || fail=1
# Note NUL params are unconditionally rejected by canonicalize_filename_mode
-realpath -m '' && fail=1
-realpath --relative-base= --relative-to=. . && fail=1
+returns_ 1 realpath -m '' || fail=1
+returns_ 1 realpath --relative-base= --relative-to=. . || fail=1
# symlink resolution
this=$(realpath .)
diff --git a/tests/misc/runcon-no-reorder.sh b/tests/misc/runcon-no-reorder.sh
index ca8ad5b3..274d2d7d 100755
--- a/tests/misc/runcon-no-reorder.sh
+++ b/tests/misc/runcon-no-reorder.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that runcon does not reorder its arguments.
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
diff --git a/tests/misc/selinux.sh b/tests/misc/selinux.sh
index 2a8ad89f..1f906dde 100755
--- a/tests/misc/selinux.sh
+++ b/tests/misc/selinux.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test SELinux-related options.
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
@@ -47,7 +47,7 @@ c=$(ls -l f|cut -c11); test "$c" = . || fail=1
# Copy with an invalid context and ensure it fails
# Note this may succeed when root and selinux is in permissive mode
if test "$(getenforce)" = Enforcing; then
- cp --context='invalid-selinux-context' f f.cp && fail=1
+ returns_ 1 cp --context='invalid-selinux-context' f f.cp || fail=1
fi
# Copy each to a new directory and ensure that context is preserved.
diff --git a/tests/misc/seq-long-double.sh b/tests/misc/seq-long-double.sh
index 78ed50f5..dbc59386 100755
--- a/tests/misc/seq-long-double.sh
+++ b/tests/misc/seq-long-double.sh
@@ -3,7 +3,7 @@
# Ensure that seq prints exactly two numbers for a 2-number integral
# range at the limit of floating point precision.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/seq-precision.sh b/tests/misc/seq-precision.sh
new file mode 100755
index 00000000..b8382ca1
--- /dev/null
+++ b/tests/misc/seq-precision.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+# Test for output with appropriate precision
+
+# Copyright (C) 2015 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ seq
+
+# Integer only. Before v8.24 these would switch output format
+
+seq 999999 inf | head -n2 > out || fail=1
+printf "%s\n" 999999 1000000 > exp || framework_failure_
+compare exp out || fail=1
+
+# Excercise buffer handling in non floating point output
+for i in $(seq 100); do
+ n1="$(printf '%*s' $i '' | tr ' ' 9)"
+ n2="1$(echo $n1 | tr 9 0)"
+
+ seq $n1 $n2 > out || fail=1
+ printf "%s\n" "$n1" "$n2" > exp || framework_failure_
+ compare exp out || fail=1
+done
+
+seq 0xF423F 0xF4240 > out || fail=1
+printf "%s\n" 999999 1000000 > exp || framework_failure_
+compare exp out || fail=1
+
+# Ensure consistent precision for inf
+seq 1 .1 inf | head -n2 > out || fail=1
+printf "%s\n" 1.0 1.1 > exp || framework_failure_
+compare exp out || fail=1
+
+# Ensure standard output methods with inf start
+seq inf inf | head -n2 | uniq > out || fail=1
+test "$(wc -l < out)" = 1 || fail=1
+
+# Ensure auto precision for hex float
+seq 1 0x1p-1 2 > out || fail=1
+printf "%s\n" 1 1.5 2 > exp || framework_failure_
+compare exp out || fail=1
+
+# Ensure consistent precision for hex
+seq 1 .1 0x2 | head -n2 > out || fail=1
+printf "%s\n" 1.0 1.1 > exp || framework_failure_
+compare exp out || fail=1
+
+# Ensure consistent handling of precision/width for exponents
+
+seq 1.1e1 12 > out || fail=1
+printf "%s\n" 11 12 > exp || framework_failure_
+compare exp out || fail=1
+
+seq 11 1.2e1 > out || fail=1
+printf "%s\n" 11 12 > exp || framework_failure_
+compare exp out || fail=1
+
+seq -w 1.1e4 | head -n1 > out || fail=1
+printf "%s\n" 00001 > exp || framework_failure_
+compare exp out || fail=1
+
+seq -w 1.10000e5 1.10000e5 > out || fail=1
+printf "%s\n" 110000 > exp || framework_failure_
+compare exp out || fail=1
+
+Exit $fail
diff --git a/tests/misc/seq.pl b/tests/misc/seq.pl
index 92484363..d24acad1 100755
--- a/tests/misc/seq.pl
+++ b/tests/misc/seq.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "seq".
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2015 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
diff --git a/tests/misc/sha1sum-vec.pl b/tests/misc/sha1sum-vec.pl
index 14005a76..fdf20459 100755
--- a/tests/misc/sha1sum-vec.pl
+++ b/tests/misc/sha1sum-vec.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Sample vectors for "sha1sum".
-# Copyright (C) 2000-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000-2015 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
diff --git a/tests/misc/sha1sum.pl b/tests/misc/sha1sum.pl
index fdb243a0..de923b63 100755
--- a/tests/misc/sha1sum.pl
+++ b/tests/misc/sha1sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sha1sum".
-# Copyright (C) 2000-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000-2015 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
diff --git a/tests/misc/sha224sum.pl b/tests/misc/sha224sum.pl
index 384738b8..71464a6c 100755
--- a/tests/misc/sha224sum.pl
+++ b/tests/misc/sha224sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sha224sum".
-# Copyright (C) 2005-2014 Free Software Foundation, Inc.
+# Copyright (C) 2005-2015 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
diff --git a/tests/misc/sha256sum.pl b/tests/misc/sha256sum.pl
index e5f29392..ae724f50 100755
--- a/tests/misc/sha256sum.pl
+++ b/tests/misc/sha256sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sha256sum".
-# Copyright (C) 2005-2014 Free Software Foundation, Inc.
+# Copyright (C) 2005-2015 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
diff --git a/tests/misc/sha384sum.pl b/tests/misc/sha384sum.pl
index eafbf5b4..6cf8797c 100755
--- a/tests/misc/sha384sum.pl
+++ b/tests/misc/sha384sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sha384sum".
-# Copyright (C) 2005-2014 Free Software Foundation, Inc.
+# Copyright (C) 2005-2015 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
diff --git a/tests/misc/sha512sum.pl b/tests/misc/sha512sum.pl
index c4a1cd4a..157a1158 100755
--- a/tests/misc/sha512sum.pl
+++ b/tests/misc/sha512sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sha512sum".
-# Copyright (C) 2005-2014 Free Software Foundation, Inc.
+# Copyright (C) 2005-2015 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
diff --git a/tests/misc/shred-exact.sh b/tests/misc/shred-exact.sh
index 5434229c..679e2675 100755
--- a/tests/misc/shred-exact.sh
+++ b/tests/misc/shred-exact.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test functionality of --exact
-# Copyright (C) 2000-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000-2015 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
@@ -37,7 +37,7 @@ done
# make sure direct I/O is handled appropriately at end of file
# Create a 1MiB file as we'll probably not be using blocks larger than that
-# (i.e. we want to test failed writes not at the start).
+# (i.e., we want to test failed writes not at the start).
truncate -s1MiB file.slop || framework_failure_
truncate -s+1 file.slop || framework_failure_
shred --exact -n2 file.slop || fail=1
diff --git a/tests/misc/shred-passes.sh b/tests/misc/shred-passes.sh
index 268af950..0fa63be2 100755
--- a/tests/misc/shred-passes.sh
+++ b/tests/misc/shred-passes.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify the operations done by shred
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
diff --git a/tests/misc/shred-remove.sh b/tests/misc/shred-remove.sh
index 9765e352..cb27c1ca 100755
--- a/tests/misc/shred-remove.sh
+++ b/tests/misc/shred-remove.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise shred --remove
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2015 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
@@ -30,7 +30,7 @@ chmod u-w $file || framework_failure_
# This would take so long that it appears to infloop
# when using version from fileutils-4.0k.
# When the command completes, expect it to fail.
-shred -u $file > /dev/null 2>&1 && fail=1
+returns_ 1 shred -u $file > /dev/null 2>&1 || fail=1
rm -f $file || framework_failure_
# Ensure all --remove methods at least unlink the file
@@ -42,6 +42,6 @@ done
# Ensure incorrect params are diagnosed
touch $file || framework_failure_
-shred -n0 --remove=none $file 2>/dev/null && fail=1
+returns_ 1 shred -n0 --remove=none $file 2>/dev/null || fail=1
Exit $fail
diff --git a/tests/misc/shred-negative.sh b/tests/misc/shred-size.sh
index 86cbf3e0..c6ac2d07 100755
--- a/tests/misc/shred-negative.sh
+++ b/tests/misc/shred-size.sh
@@ -1,7 +1,7 @@
#!/bin/sh
-# Exercise shred -s-3 FILE
+# Exercise shred --size
-# Copyright (C) 2014 Free Software Foundation, Inc.
+# Copyright (C) 2014-2015 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
@@ -19,10 +19,16 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ shred
-echo 'shred: -2: invalid file size' > exp || framework_failure_
+# Negative size
+echo "shred: invalid file size: '-2'" > exp || framework_failure_
echo 1234 > f || framework_failure_
-
shred -s-2 f 2>err && fail=1
compare exp err || fail=1
+# Octal/Hex
+shred -s010 f || fail=1
+test $(stat --printf=%s f) = 8 || fail=1
+shred -s0x10 f || fail=1
+test $(stat --printf=%s f) = 16 || fail=1
+
Exit $fail
diff --git a/tests/misc/shuf-reservoir.sh b/tests/misc/shuf-reservoir.sh
index aa9edbea..3eea5e70 100755
--- a/tests/misc/shuf-reservoir.sh
+++ b/tests/misc/shuf-reservoir.sh
@@ -4,7 +4,7 @@
# These tests do not check valid randomness,
# they just check memory allocation related code.
-# Copyright (C) 2013-2014 Free Software Foundation, Inc.
+# Copyright (C) 2013-2015 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
diff --git a/tests/misc/shuf.sh b/tests/misc/shuf.sh
index d7251d1d..c7db14f6 100755
--- a/tests/misc/shuf.sh
+++ b/tests/misc/shuf.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that shuf randomizes its input.
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
@@ -47,6 +47,11 @@ test "$t" = 'a b c d e' || { fail=1; echo "not a permutation" 1>&2; }
shuf -er
test $? -eq 1 || fail=1
+# coreutils-8.22 and 8.23 dump core
+# with a single redundant operand with --input-range
+shuf -i0-0 1
+test $? -eq 1 || fail=1
+
# Before coreutils-6.3, this would infloop.
# "seq 1860" produces 8193 (8K + 1) bytes of output.
seq 1860 | shuf > /dev/null || fail=1
@@ -66,7 +71,7 @@ touch unreadable || framework_failure_
chmod 0 unreadable || framework_failure_
if ! test -r unreadable; then
shuf -n0 unreadable || fail=1
- shuf -n1 unreadable && fail=1
+ { shuf -n1 unreadable || test $? -ne 1; } && fail=1
fi
# Multiple -n is accepted, should use the smallest value
@@ -77,25 +82,25 @@ test "$c" -eq 3 || { fail=1; echo "Multiple -n failed">&2 ; }
# Test error conditions
# -i and -e must not be used together
-: | shuf -i0-9 -e A B &&
+: | { shuf -i0-9 -e A B || test $? -ne 1; } &&
{ fail=1; echo "shuf did not detect erroneous -e and -i usage.">&2 ; }
# Test invalid value for -n
-: | shuf -nA &&
+: | { shuf -nA || test $? -ne 1; } &&
{ fail=1; echo "shuf did not detect erroneous -n usage.">&2 ; }
# Test multiple -i
-shuf -i0-9 -n10 -i8-90 &&
+{ shuf -i0-9 -n10 -i8-90 || test $? -ne 1; } &&
{ fail=1; echo "shuf did not detect multiple -i usage.">&2 ; }
# Test invalid range
for ARG in '1' 'A' '1-' '1-A'; do
- shuf -i$ARG &&
+ { shuf -i$ARG || test $? -ne 1; } &&
{ fail=1; echo "shuf did not detect erroneous -i$ARG usage.">&2 ; }
done
# multiple -o are forbidden
-shuf -i0-9 -o A -o B &&
+{ shuf -i0-9 -o A -o B || test $? -ne 1; } &&
{ fail=1; echo "shuf did not detect erroneous multiple -o usage.">&2 ; }
# multiple random-sources are forbidden
-shuf -i0-9 --random-source A --random-source B &&
+{ shuf -i0-9 --random-source A --random-source B || test $? -ne 1; } &&
{ fail=1; echo "shuf did not detect multiple --random-source usage.">&2 ; }
# Test --repeat option
@@ -120,7 +125,7 @@ test "$c" = "0 1 2 3 4 5 6 7 8 9" ||
# check --repeat with non-zero low value
shuf --rep -i222-233 -n2000 > exp || framework_failure_
-c=$(cat exp | sort -nu | paste -s -d ' ') || framework_failure_
+c=$(sort -nu exp | paste -s -d ' ') || framework_failure_
test "$c" = "222 223 224 225 226 227 228 229 230 231 232 233" ||
{ fail=1; echo "--repeat produced bad output with non-zero low">&2 ; }
diff --git a/tests/misc/sort-NaN-infloop.sh b/tests/misc/sort-NaN-infloop.sh
index 9c6e021a..15fa4e52 100755
--- a/tests/misc/sort-NaN-infloop.sh
+++ b/tests/misc/sort-NaN-infloop.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise the NaN-infloop bug in coreutils-8.13
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2015 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
diff --git a/tests/misc/sort-benchmark-random.sh b/tests/misc/sort-benchmark-random.sh
index c074301f..d13073e2 100755
--- a/tests/misc/sort-benchmark-random.sh
+++ b/tests/misc/sort-benchmark-random.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Benchmark sort on randomly generated data.
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/sort-compress-hang.sh b/tests/misc/sort-compress-hang.sh
index cc1e6d36..dc101fea 100755
--- a/tests/misc/sort-compress-hang.sh
+++ b/tests/misc/sort-compress-hang.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test for sort --compress hang
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
@@ -20,8 +20,8 @@
print_ver_ sort
very_expensive_
-cat <<\EOF >compress || framework_failure_
-#!/bin/sh
+cat <<EOF >compress || framework_failure_
+#!$SHELL
tr 41 14 || exit
touch ok
EOF
diff --git a/tests/misc/sort-compress-proc.sh b/tests/misc/sort-compress-proc.sh
index d06eb56f..05017a54 100755
--- a/tests/misc/sort-compress-proc.sh
+++ b/tests/misc/sort-compress-proc.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test use of compression subprocesses by sort
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
@@ -20,6 +20,11 @@
print_ver_ sort
expensive_
+# Terminate any background processes
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+
+SORT_FAILURE=2
+
seq -w 2000 > exp || fail=1
tac exp > in || fail=1
insize=$(stat -c %s - <in) || fail=1
@@ -27,8 +32,9 @@ insize=$(stat -c %s - <in) || fail=1
# This compressor's behavior is adjustable via environment variables.
export PRE_COMPRESS=
export POST_COMPRESS=
-cat <<\EOF >compress || framework_failure_
-#!/bin/sh
+
+printf '%s\n' '#!'"$SHELL" >compress || framework_failure_
+cat <<\EOF >>compress || framework_failure_
eval "$PRE_COMPRESS"
tr 41 14 || exit
eval "$POST_COMPRESS"
@@ -52,7 +58,8 @@ do
exec >/dev/null 2>&1 <&1 || exit
expr $size "<" '"$insize"' / 2 || { sleep 1; exit 1; }
}
- ' sort --compress-program=./compress -S 1k --batch-size=2 in > out && fail=1
+ ' sort --compress-program=./compress -S 1k --batch-size=2 in > out
+ test $? -eq $SORT_FAILURE || fail=1
done
# "Pre-exec child" test
@@ -60,7 +67,7 @@ done
# Ignore a random child process created before 'sort' was exec'ed.
# This bug was also present in coreutils 8.7.
#
-( (sleep 1; exec false) &
+( (sleep 1; exec false) & pid=$!
PRE_COMPRESS='test -f ok || sleep 2'
POST_COMPRESS='touch ok'
exec sort --compress-program=./compress -S 1k in >out
diff --git a/tests/misc/sort-compress.sh b/tests/misc/sort-compress.sh
index 8f215b8b..584110e1 100755
--- a/tests/misc/sort-compress.sh
+++ b/tests/misc/sort-compress.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test use of compression by sort
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
@@ -27,8 +27,8 @@ sort -S 1k in > out || fail=1
compare exp out || fail=1
# Create our own gzip program that will be used as the default
-cat <<\EOF > gzip || fail=1
-#!/bin/sh
+cat <<EOF > gzip || fail=1
+#!$SHELL
tr 41 14
touch ok
EOF
diff --git a/tests/misc/sort-continue.sh b/tests/misc/sort-continue.sh
index 1c4030d9..0860287a 100755
--- a/tests/misc/sort-continue.sh
+++ b/tests/misc/sort-continue.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Tests for file descriptor exhaustion.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
diff --git a/tests/misc/sort-debug-keys.sh b/tests/misc/sort-debug-keys.sh
index ff1e19b6..776fb67c 100755
--- a/tests/misc/sort-debug-keys.sh
+++ b/tests/misc/sort-debug-keys.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test annotation of sort keys
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/sort-debug-warn.sh b/tests/misc/sort-debug-warn.sh
index fd16829b..19015664 100755
--- a/tests/misc/sort-debug-warn.sh
+++ b/tests/misc/sort-debug-warn.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test warnings for sort options
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/sort-discrim.sh b/tests/misc/sort-discrim.sh
index e3cd1907..9b7ad997 100755
--- a/tests/misc/sort-discrim.sh
+++ b/tests/misc/sort-discrim.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test discriminator-based sorting.
-# Copyright (C) 2012-2014 Free Software Foundation, Inc.
+# Copyright (C) 2012-2015 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
diff --git a/tests/misc/sort-exit-early.sh b/tests/misc/sort-exit-early.sh
index 2a70253e..c675503c 100755
--- a/tests/misc/sort-exit-early.sh
+++ b/tests/misc/sort-exit-early.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test 'sort' exits early on inaccessible inputs or output
-# Copyright (C) 2012-2014 Free Software Foundation, Inc.
+# Copyright (C) 2012-2015 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
@@ -20,18 +20,18 @@
print_ver_ sort
skip_if_root_
+SORT_FAILURE=2
+
# Check output is writable before starting to sort
touch input
chmod a-w input
-timeout 10 sort -o input && fail=1
-test $? = 124 && fail=1
+returns_ $SORT_FAILURE timeout 10 sort -o input || fail=1
# Check all inputs are readable before starting to sort
# Also ensure the output isn't created in this case
touch output
chmod a-r output
-timeout 10 sort -o typo - output && fail=1
-test $? = 124 && fail=1
+returns_ $SORT_FAILURE timeout 10 sort -o typo - output || fail=1
test -e typo && fail=1
Exit $fail
diff --git a/tests/misc/sort-files0-from.pl b/tests/misc/sort-files0-from.pl
index 77c1b1aa..63c5bb3e 100755
--- a/tests/misc/sort-files0-from.pl
+++ b/tests/misc/sort-files0-from.pl
@@ -2,7 +2,7 @@
# Exercise sort's --files0-from option.
# FIXME: keep this file in sync with tests/du/files0-from.
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
diff --git a/tests/misc/sort-float.sh b/tests/misc/sort-float.sh
index 7a4e8292..1c760baf 100755
--- a/tests/misc/sort-float.sh
+++ b/tests/misc/sort-float.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure sort -g sorts floating point limits correctly
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/sort-merge-fdlimit.sh b/tests/misc/sort-merge-fdlimit.sh
index 0df7aa66..ce1a6c48 100755
--- a/tests/misc/sort-merge-fdlimit.sh
+++ b/tests/misc/sort-merge-fdlimit.sh
@@ -2,7 +2,7 @@
# Test whether sort avoids opening more file descriptors than it is
# allowed when merging files.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
diff --git a/tests/misc/sort-merge.pl b/tests/misc/sort-merge.pl
index 06e3c15f..c60e2626 100755
--- a/tests/misc/sort-merge.pl
+++ b/tests/misc/sort-merge.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sort -m".
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 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
diff --git a/tests/misc/sort-month.sh b/tests/misc/sort-month.sh
index 40c814da..ab49cc28 100755
--- a/tests/misc/sort-month.sh
+++ b/tests/misc/sort-month.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test sorting of abbreviated months from the locale
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/sort-rand.sh b/tests/misc/sort-rand.sh
index 2397fb4b..3fc5fef2 100755
--- a/tests/misc/sort-rand.sh
+++ b/tests/misc/sort-rand.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that sort --sort-random doesn't sort.
-# Copyright (C) 2005-2014 Free Software Foundation, Inc.
+# Copyright (C) 2005-2015 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
diff --git a/tests/misc/sort-spinlock-abuse.sh b/tests/misc/sort-spinlock-abuse.sh
index 49ed920f..e81abf80 100755
--- a/tests/misc/sort-spinlock-abuse.sh
+++ b/tests/misc/sort-spinlock-abuse.sh
@@ -2,7 +2,7 @@
# trigger a bug that would make parallel sort use 100% of one or more
# CPU while blocked on output.
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
@@ -29,13 +29,16 @@ very_expensive_
grep '^#define HAVE_PTHREAD_T 1' "$CONFIG_HEADER" > /dev/null ||
skip_ 'requires pthreads'
+# Terminate any background processes
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+
seq 100000 > in || framework_failure_
mkfifo_or_skip_ fifo
# Arrange for sort to require 8.0+ seconds of wall-clock time,
# while actually using far less than 1 second of CPU time.
(for i in $(seq 80); do read line; echo $i; sleep .1; done
- cat > /dev/null) < fifo &
+ cat > /dev/null) < fifo & pid=$!
# However, under heavy load, it can easily take more than
# one second of CPU time, so set a permissive limit:
diff --git a/tests/misc/sort-stale-thread-mem.sh b/tests/misc/sort-stale-thread-mem.sh
index 78defd23..dd4789eb 100755
--- a/tests/misc/sort-stale-thread-mem.sh
+++ b/tests/misc/sort-stale-thread-mem.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Trigger a bug that would cause 'sort' to reference stale thread stack memory.
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/sort-u-FMR.sh b/tests/misc/sort-u-FMR.sh
index 3019cbe8..0720ed43 100755
--- a/tests/misc/sort-u-FMR.sh
+++ b/tests/misc/sort-u-FMR.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Before 8.19, this would trigger a free-memory read.
-# Copyright (C) 2012-2014 Free Software Foundation, Inc.
+# Copyright (C) 2012-2015 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
diff --git a/tests/misc/sort-unique-segv.sh b/tests/misc/sort-unique-segv.sh
index 148dc243..bd0dc575 100755
--- a/tests/misc/sort-unique-segv.sh
+++ b/tests/misc/sort-unique-segv.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# parallel sort with --unique (-u) would segfault
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/sort-unique.sh b/tests/misc/sort-unique.sh
index d7a7629c..eaaef681 100755
--- a/tests/misc/sort-unique.sh
+++ b/tests/misc/sort-unique.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test 'sort -u'.
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/sort-version.sh b/tests/misc/sort-version.sh
index d8db1e1c..383f100f 100755
--- a/tests/misc/sort-version.sh
+++ b/tests/misc/sort-version.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise sort's --sort=version option
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/sort.pl b/tests/misc/sort.pl
index db732094..f6a222c2 100755
--- a/tests/misc/sort.pl
+++ b/tests/misc/sort.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
@@ -271,11 +271,11 @@ my @Tests =
["18e", '-nb -k1.1,1.2', {IN=>" 901\n100\n"}, {OUT=>"100\n 901\n"}],
# When ignoring leading blanks for end position, ensure blanks from
-# next field are not included in the sort. I.E. order should not change here.
+# next field are not included in the sort. I.e., order should not change here.
["18f", '-k1,1b', {IN=>"a y\na z\n"}, {OUT=>"a y\na z\n"}],
# When ignoring leading blanks for start position, ensure blanks from
-# next field are not included in the sort. I.E. order should not change here.
+# next field are not included in the sort. I.e., order should not change here.
# This was noticed as an issue on fedora 8 (only in multibyte locales).
["18g", '-k1b,1', {IN=>"a y\na z\n"}, {OUT=>"a y\na z\n"},
{ENV => "LC_ALL=$mb_locale"}],
@@ -317,6 +317,10 @@ my @Tests =
["22a", '-k 2,2fd -k 1,1r', {IN=>"3 b\n4 B\n"}, {OUT=>"4 B\n3 b\n"}],
["22b", '-k 2,2d -k 1,1r', {IN=>"3 b\n4 b\n"}, {OUT=>"4 b\n3 b\n"}],
+# This fails in Fedora 20, per Göran Uddeborg in: http://bugs.gnu.org/18540
+["23", '-s -k1,1 -t/', {IN=>"a b/x\na-b-c/x\n"}, {OUT=>"a b/x\na-b-c/x\n"},
+ {ENV => "LC_ALL=$mb_locale"}],
+
["no-file1", 'no-file', {EXIT=>2}, {ERR=>$no_file}],
# This test failed until 1.22f. Sort didn't give an error.
# From Will Edgington.
diff --git a/tests/misc/stat-birthtime.sh b/tests/misc/stat-birthtime.sh
index f06ddea8..d7877c59 100755
--- a/tests/misc/stat-birthtime.sh
+++ b/tests/misc/stat-birthtime.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure that stat attempts birthtime access
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/stat-fmt.sh b/tests/misc/stat-fmt.sh
index 3982f23b..2a3e9d2a 100755
--- a/tests/misc/stat-fmt.sh
+++ b/tests/misc/stat-fmt.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure that stat properly handles a format string ending with %
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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
diff --git a/tests/misc/stat-hyphen.sh b/tests/misc/stat-hyphen.sh
index 9f090a0f..a2e0a3fb 100755
--- a/tests/misc/stat-hyphen.sh
+++ b/tests/misc/stat-hyphen.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# demonstrate that stat - works and stat -f - does not.
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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,7 +23,7 @@ printf -- '-\n' > exp || framework_failure_
touch f || framework_failure_
stat --format=%n - < f > out || fail=1
-stat -f - < f && fail=1
+returns_ 1 stat -f - < f || fail=1
compare exp out || fail=1
diff --git a/tests/misc/stat-mount.sh b/tests/misc/stat-mount.sh
index ab1ff479..34193875 100755
--- a/tests/misc/stat-mount.sh
+++ b/tests/misc/stat-mount.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test stat -c%m
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/stat-nanoseconds.sh b/tests/misc/stat-nanoseconds.sh
index 30c47c02..f08ac983 100755
--- a/tests/misc/stat-nanoseconds.sh
+++ b/tests/misc/stat-nanoseconds.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise format strings involving %:X, %:Y, etc.
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
diff --git a/tests/misc/stat-printf.pl b/tests/misc/stat-printf.pl
index 5021130d..967eef7d 100755
--- a/tests/misc/stat-printf.pl
+++ b/tests/misc/stat-printf.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "stat --printf".
-# Copyright (C) 2005-2014 Free Software Foundation, Inc.
+# Copyright (C) 2005-2015 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
diff --git a/tests/misc/stat-slash.sh b/tests/misc/stat-slash.sh
index 465de2ed..fecb7b69 100755
--- a/tests/misc/stat-slash.sh
+++ b/tests/misc/stat-slash.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# demonstrate that stat handles trailing slashes correctly
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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 @@ EOF
# This failed on Solaris 9 for coreutils 8.0.
stat --format=%n link1 > out || fail=1
-stat --format=%n link1/ >> out && fail=1
+returns_ 1 stat --format=%n link1/ >> out || fail=1
stat --format=%F link2 >> out || fail=1
stat -L --format=%F link2 >> out || fail=1
diff --git a/tests/misc/stdbuf.sh b/tests/misc/stdbuf.sh
index e0ca3530..428d4a2f 100755
--- a/tests/misc/stdbuf.sh
+++ b/tests/misc/stdbuf.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise stdbuf functionality
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
@@ -58,15 +58,18 @@ test $? = 126 || fail=1
stdbuf -o1 no_such # no such command
test $? = 127 || fail=1
+# Terminate any background processes
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+
# Ensure line buffering stdout takes effect
stdbuf_linebuffer()
{
local delay="$1"
printf '1\n' > exp
- dd count=1 if=fifo > out 2> err &
+ dd count=1 if=fifo > out 2> err & pid=$!
(printf '1\n'; sleep $delay; printf '2\n') | stdbuf -oL uniq > fifo
- wait # for dd to complete
+ wait $pid
compare exp out
}
@@ -78,16 +81,16 @@ stdbuf_unbuffer()
# Ensure un buffering stdout takes effect
printf '1\n' > exp
- dd count=1 if=fifo > out 2> err &
+ dd count=1 if=fifo > out 2> err & pid=$!
(printf '1\n'; sleep $delay; printf '2\n') | stdbuf -o0 uniq > fifo
- wait # for dd to complete
+ wait $pid
compare exp out
}
retry_delay_ stdbuf_unbuffer .1 6 || fail=1
# Ensure un buffering stdin takes effect
-# The following works for me, but is racy. I.E. we're depending
+# The following works for me, but is racy. I.e., we're depending
# on dd to run and close the fifo before the second write by uniq.
# If we add a sleep, then we're just testing -oL
# printf '3\n' > exp
diff --git a/tests/misc/stty-invalid.sh b/tests/misc/stty-invalid.sh
index 36bc8aa0..881146f6 100755
--- a/tests/misc/stty-invalid.sh
+++ b/tests/misc/stty-invalid.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that stty diagnoses invalid inputs, rather than silently misbehaving.
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
@@ -34,8 +34,10 @@ stty $saved_state || fail=1
# For each of the following, with coreutils-6.9 and earlier,
# stty would fail to diagnose the error on at least Solaris 10.
hex_2_64=10000000000000000
-stty $(echo $saved_state |sed 's/^[^:]*:/'$hex_2_64:/) 2>/dev/null && fail=1
-stty $(echo $saved_state |sed 's/:[0-9a-f]*$/:'$hex_2_64/) 2>/dev/null && fail=1
+returns_ 1 stty $(echo $saved_state |sed 's/^[^:]*:/'$hex_2_64:/) \
+ 2>/dev/null || fail=1
+returns_ 1 stty $(echo $saved_state |sed 's/:[0-9a-f]*$/:'$hex_2_64/) \
+ 2>/dev/null || fail=1
# Just in case either of the above mistakenly succeeds (and changes
# the state of our tty), try to restore the initial state.
diff --git a/tests/misc/stty-pairs.sh b/tests/misc/stty-pairs.sh
index 1a7c26cf..129c22f0 100755
--- a/tests/misc/stty-pairs.sh
+++ b/tests/misc/stty-pairs.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure stty can parse most of its options - in pairs [expensive].
-# Copyright (C) 1998-2014 Free Software Foundation, Inc.
+# Copyright (C) 1998-2015 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
diff --git a/tests/misc/stty-row-col.sh b/tests/misc/stty-row-col.sh
index 729d6f91..0616812e 100755
--- a/tests/misc/stty-row-col.sh
+++ b/tests/misc/stty-row-col.sh
@@ -1,7 +1,7 @@
#! /bin/sh
# Test "stty" with rows and columns.
-# Copyright (C) 1998-2014 Free Software Foundation, Inc.
+# Copyright (C) 1998-2015 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
@@ -47,6 +47,8 @@ tests='
7 rows_1 1_1
8 columns_80 1_80
9 rows_30 30_80
+10 rows_0x1E 30_80
+11 rows_036 30_80
NA LAST NA
'
set $tests
diff --git a/tests/misc/stty.sh b/tests/misc/stty.sh
index ab1c78de..5e39b72e 100755
--- a/tests/misc/stty.sh
+++ b/tests/misc/stty.sh
@@ -1,7 +1,7 @@
#! /bin/sh
# Make sure stty can parse most of its options.
-# Copyright (C) 1998-2014 Free Software Foundation, Inc.
+# Copyright (C) 1998-2015 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
@@ -34,9 +34,9 @@ stty $(cat $saved_state) || fail=1
stty erase - || fail=1
# These would improperly ignore invalid options through coreutils 5.2.1.
-stty -F 2>/dev/null && fail=1
-stty -raw -F no/such/file 2>/dev/null && fail=1
-stty -raw -a 2>/dev/null && fail=1
+returns_ 1 stty -F 2>/dev/null || fail=1
+returns_ 1 stty -raw -F no/such/file 2>/dev/null || fail=1
+returns_ 1 stty -raw -a 2>/dev/null || fail=1
# Build a list of all boolean options stty accepts on this system.
# Don't depend on terminal width. Put each option on its own line,
@@ -57,6 +57,10 @@ for opt in $options; do
cstopb|crtscts|cdtrdsr|icanon) continue;;
esac
+ # This is listed as supported on FreeBSD
+ # but the ioctl returns ENOTTY.
+ test $opt = extproc && continue
+
stty $opt || fail=1
# Likewise, 'stty -cread' would fail, so skip that, too.
diff --git a/tests/misc/sum-sysv.sh b/tests/misc/sum-sysv.sh
index 7624685f..8b732eef 100755
--- a/tests/misc/sum-sysv.sh
+++ b/tests/misc/sum-sysv.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# make sure 'sum -s' works for input whose sum of bytes is larger than 2^32
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2015 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
diff --git a/tests/misc/sum.pl b/tests/misc/sum.pl
index 696eda4b..7b9412ef 100755
--- a/tests/misc/sum.pl
+++ b/tests/misc/sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sum".
-# Copyright (C) 2000-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000-2015 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
diff --git a/tests/misc/sync.sh b/tests/misc/sync.sh
new file mode 100755
index 00000000..c6e09beb
--- /dev/null
+++ b/tests/misc/sync.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Test various sync(1) operations
+
+# Copyright (C) 2015 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ sync
+
+touch file
+
+# fdatasync+syncfs is nonsensical
+returns_ 1 sync --data --file-system || fail=1
+
+# fdatasync needs an operand
+returns_ 1 sync -d || fail=1
+
+# Test syncing of file (fsync) (little side effects)
+sync file || fail=1
+
+# Ensure multiple args are processed and diagnosed
+returns_ 1 sync file nofile || fail=1
+
+# Ensure inaccessible dirs give an appropriate error
+mkdir norw || framework_failure_
+chmod 0 norw || framework_failure_
+if ! test -r norw; then
+ sync norw 2>err
+ printf "sync: error opening 'norw': Permission denied\n" >exp
+ compare exp err || fail=1
+fi
+
+if test "$fail" != '1'; then
+ # Ensure a fifo doesn't block
+ mkfifo_or_skip_ fifo
+ timeout 10 sync fifo
+ test $? = 124 && fail=1
+fi
+
+Exit $fail
diff --git a/tests/misc/tac-2-nonseekable.sh b/tests/misc/tac-2-nonseekable.sh
index c27694c1..60f3dd4d 100755
--- a/tests/misc/tac-2-nonseekable.sh
+++ b/tests/misc/tac-2-nonseekable.sh
@@ -1,7 +1,7 @@
#!/bin/sh
-# ensure that tac works with two or more non-seekable inputs
+# ensure that tac works with non-seekable or quasi-seekable inputs
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2015 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,4 +24,16 @@ echo x > exp || fail=1
compare exp out || fail=1
compare /dev/null err || fail=1
+# Make sure it works on funny files in /proc and /sys.
+
+for file in /proc/version /sys/kernel/profiling; do
+ if test -r $file; then
+ cp -f $file copy &&
+ tac copy > exp1 || framework_failure_
+
+ tac $file > out1 || fail=1
+ compare exp1 out1 || fail=1
+ fi
+done
+
Exit $fail
diff --git a/tests/misc/tac-continue.sh b/tests/misc/tac-continue.sh
index d4280650..1389072b 100755
--- a/tests/misc/tac-continue.sh
+++ b/tests/misc/tac-continue.sh
@@ -3,7 +3,7 @@
# when it encounters an error with say the first one.
# With coreutils-5.2.1 and earlier, this test would fail.
-# Copyright (C) 2004-2014 Free Software Foundation, Inc.
+# Copyright (C) 2004-2015 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,9 +33,15 @@ if ! test -d "$FULL_PARTITION_TMPDIR"; then
fi
fp_tmp="$FULL_PARTITION_TMPDIR/tac-cont-$$"
-cleanup_() { rm -f "$fp_tmp"; }
-
-# Make sure we can create an empty file there (i.e. no shortage of inodes).
+cleanup_()
+{
+ # Terminate any background process
+ # and remove tmp dir
+ rm -f "$fp_tmp"
+ kill $pid 2>/dev/null && wait $pid
+}
+
+# Make sure we can create an empty file there (i.e., no shortage of inodes).
if ! touch $fp_tmp; then
echo "$0: $fp_tmp: cannot create empty file" 1>&2
Exit 1
@@ -54,7 +60,7 @@ seq 5 > in
# Give tac a fifo command line argument.
# This makes it try to create a temporary file in $TMPDIR.
mkfifo_or_skip_ fifo
-seq 1000 > fifo &
+seq 1000 > fifo & pid=$!
TMPDIR=$FULL_PARTITION_TMPDIR tac fifo in >out 2>err && fail=1
cat <<\EOF > exp || fail=1
diff --git a/tests/misc/tac.pl b/tests/misc/tac.pl
index 0f21affd..38196d23 100755
--- a/tests/misc/tac.pl
+++ b/tests/misc/tac.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/tail.pl b/tests/misc/tail.pl
index 6798eb05..7f113aaf 100755
--- a/tests/misc/tail.pl
+++ b/tests/misc/tail.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test tail.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
@@ -19,7 +19,7 @@
use strict;
my $prog = 'tail';
-my $normalize_filename = {ERR_SUBST => 's/^$prog: .*?:/$prog: -:/'};
+my $normalize_strerror = "s/': .*/'/";
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@@ -59,7 +59,7 @@ my @tv = (
"$prog: cannot open '+cl' for reading: No such file or directory\n"],
['err-2', '-cl', '', '', 1,
- "$prog: l: invalid number of bytes\n"],
+ "$prog: invalid number of bytes: 'l'\n", $normalize_strerror],
['err-3', '+2cz', '', '', 1,
"$prog: cannot open '+2cz' for reading: No such file or directory\n"],
@@ -72,9 +72,10 @@ my @tv = (
# the diagnostic: 'tail: 99999999999999999999: invalid number of bytes'
# on all systems... probably, for now, maybe.
['err-5', '-c99999999999999999999', '', '', 1,
- "$prog: 99999999999999999999: invalid number of bytes\n"],
+ "$prog: invalid number of bytes: '99999999999999999999'\n",
+ $normalize_strerror],
['err-6', '-c --', '', '', 1,
- "$prog: -: invalid number of bytes\n", $normalize_filename],
+ "$prog: invalid number of bytes: '-'\n", $normalize_strerror],
# Same as -n 10
['minus-1', '-', '', '', 0],
@@ -106,10 +107,10 @@ my @Tests;
foreach my $t (@tv)
{
- my ($test_name, $flags, $in, $exp, $ret, $err_msg) = @$t;
+ my ($test_name, $flags, $in, $exp, $ret, $err_msg, $err_sub) = @$t;
my $e = [$test_name, $flags, {IN=>$in}, {OUT=>$exp}];
$ret
- and push @$e, {EXIT=>$ret}, {ERR=>$err_msg};
+ and push @$e, {EXIT=>$ret}, {ERR=>$err_msg}, {ERR_SUBST=>$err_sub};
$test_name =~ /^(obs-plus-|minus-)/
and push @$e, {ENV=>'_POSIX2_VERSION=199209'};
diff --git a/tests/misc/tee.sh b/tests/misc/tee.sh
index f0072bfd..f457a0b7 100755
--- a/tests/misc/tee.sh
+++ b/tests/misc/tee.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# test for basic tee functionality.
-# Copyright (C) 2005-2014 Free Software Foundation, Inc.
+# Copyright (C) 2005-2015 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
@@ -20,15 +20,90 @@
print_ver_ tee
echo line >sample || framework_failure_
-nums=$(seq 9) || framework_failure_
-
-for n in 0 $nums; do
- files=$(seq $n)
- rm -f $files
- tee $files <sample >out || fail=1
- for f in out $files; do
- compare sample $f || fail=1
- done
+
+# POSIX says: "Processing of at least 13 file operands shall be supported."
+for n in 0 1 2 12 13; do
+ files=$(seq $n)
+ rm -f $files
+ tee $files <sample >out || fail=1
+ for f in out $files; do
+ compare sample $f || fail=1
+ done
done
+# Ensure tee treats '-' as the name of a file, as mandated by POSIX.
+# Between v5.3.0 and v8.23, a '-' argument caused tee to send another
+# copy of input to standard output.
+tee - <sample >out 2>err || fail=1
+compare sample ./- || fail=1
+compare sample out || fail=1
+compare /dev/null err || fail
+
+# Ensure tee exits early if no more writable outputs
+if test -w /dev/full && test -c /dev/full; then
+ yes | returns_ 1 timeout 10 tee /dev/full 2>err >/dev/full || fail=1
+ # Ensure an error for each of the 2 outputs
+ # (and no redundant errors for stdout).
+ test $(wc -l < err) = 2 || { cat err; fail=1; }
+
+
+ # Ensure we continue with outputs that are OK
+ seq 10000 > multi_read || framework_failure_
+
+ returns_ 1 tee /dev/full out2 2>err >out1 <multi_read || fail=1
+ cmp multi_read out1 || fail=1
+ cmp multi_read out2 || fail=1
+ # Ensure an error for failing output
+ test $(wc -l < err) = 1 || { cat err; fail=1; }
+
+ returns_ 1 tee out1 out2 2>err >/dev/full <multi_read || fail=1
+ cmp multi_read out1 || fail=1
+ cmp multi_read out2 || fail=1
+ # Ensure an error for failing output
+ test $(wc -l < err) = 1 || { cat err; fail=1; }
+fi
+
+
+# Ensure tee honors --output-error modes
+mkfifo_or_skip_ fifo
+read_fifo() { timeout 10 dd count=1 if=fifo of=/dev/null status=none & }
+
+# Determine platform sigpipe exit status
+read_fifo
+yes >fifo
+pipe_status=$?
+
+# Default operation is to continue on output errors but exit silently on SIGPIPE
+read_fifo
+yes | returns_ $pipe_status timeout 10 tee ./e/noent 2>err >fifo || fail=1
+test $(wc -l < err) = 1 || { cat err; fail=1; }
+
+# With -p, SIGPIPE is suppressed, exit 0 for EPIPE when all outputs finished
+read_fifo
+yes | timeout 10 tee -p 2>err >fifo || fail=1
+test $(wc -l < err) = 0 || { cat err; fail=1; }
+
+# With --output-error=warn, exit 1 for EPIPE when all outputs finished
+read_fifo
+yes | returns_ 1 timeout 10 tee --output-error=warn 2>err >fifo || fail=1
+test $(wc -l < err) = 1 || { cat err; fail=1; }
+
+# With --output-error=exit, exit 1 immediately for EPIPE
+read_fifo
+yes | returns_ 1 timeout 10 tee --output-error=exit /dev/null 2>err >fifo \
+ || fail=1
+test $(wc -l < err) = 1 || { cat err; fail=1; }
+
+# With --output-error=exit, exit 1 immediately on output error
+read_fifo
+yes | returns_ 1 timeout 10 tee --output-error=exit ./e/noent 2>err >fifo \
+ || fail=1
+test $(wc -l < err) = 1 || { cat err; fail=1; }
+
+# With --output-error=exit-nopipe, exit 0 for EPIPE
+read_fifo
+yes | timeout 10 tee --output-error=exit-nopipe 2>err >fifo || fail=1
+test $(wc -l < err) = 0 || { cat err; fail=1; }
+
+wait
Exit $fail
diff --git a/tests/misc/test-diag.pl b/tests/misc/test-diag.pl
index 14d0f4d5..f498d1a8 100755
--- a/tests/misc/test-diag.pl
+++ b/tests/misc/test-diag.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test the diagnostics of "test".
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
diff --git a/tests/misc/test.pl b/tests/misc/test.pl
index b27adb48..f4c1ed1a 100755
--- a/tests/misc/test.pl
+++ b/tests/misc/test.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/timeout-blocked.pl b/tests/misc/timeout-blocked.pl
index b5f31c96..77bf6667 100755
--- a/tests/misc/timeout-blocked.pl
+++ b/tests/misc/timeout-blocked.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test that timeout handles blocked SIGALRM from its parent.
-# Copyright (C) 2013-2014 Free Software Foundation, Inc.
+# Copyright (C) 2013-2015 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
diff --git a/tests/misc/timeout-group.sh b/tests/misc/timeout-group.sh
index 23c1b065..d47f0dc8 100755
--- a/tests/misc/timeout-group.sh
+++ b/tests/misc/timeout-group.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# test program group handling
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2015 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
@@ -30,8 +30,8 @@ print_ver_ timeout
setsid true || skip_ "setsid required to control groups"
-cat > timeout.cmd <<\EOF
-#!/bin/sh
+printf '%s\n' '#!'"$SHELL" > timeout.cmd || framework_failure_
+cat >> timeout.cmd <<\EOF
trap 'touch int.received; exit' INT
touch timeout.running
count=$1
@@ -42,8 +42,8 @@ done
EOF
chmod a+x timeout.cmd
-cat > group.sh <<\EOF
-#!/bin/sh
+cat > group.sh <<EOF
+#!$SHELL
trap '' INT
timeout --foreground 25 ./timeout.cmd 20&
wait
@@ -57,15 +57,17 @@ check_timeout_cmd_running()
{ sleep $delay; return 1; }
}
+# Terminate any background processes
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
# Start above script in its own group.
# We could use timeout for this, but that assumes an implementation.
-setsid ./group.sh &
+setsid ./group.sh & pid=$!
# Wait 6.3s for timeout.cmd to start
retry_delay_ check_timeout_cmd_running .1 6 || fail=1
# Simulate a Ctrl-C to the group to test timely exit
# Note dash doesn't support signalling groups (a leading -)
-env kill -INT -- -$!
+env kill -INT -- -$pid
wait
test -e int.received || fail=1
@@ -82,8 +84,7 @@ start=$(date +%s)
# Note the first timeout must send a signal that
# the second is handling for it to be propagated to the command.
# SIGINT, SIGTERM, SIGALRM etc. are implicit.
-timeout -sALRM 30 timeout -sINT 25 ./timeout.cmd 20&
-pid=$!
+timeout -sALRM 30 timeout -sINT 25 ./timeout.cmd 20 & pid=$!
# Wait 6.3s for timeout.cmd to start
retry_delay_ check_timeout_cmd_running .1 6 || fail=1
kill -ALRM $pid # trigger the alarm of the first timeout command
diff --git a/tests/misc/timeout-parameters.sh b/tests/misc/timeout-parameters.sh
index fca30f0b..0bdb38ac 100755
--- a/tests/misc/timeout-parameters.sh
+++ b/tests/misc/timeout-parameters.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate timeout parameter combinations
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/timeout.sh b/tests/misc/timeout.sh
index 8eaeef95..3cebd330 100755
--- a/tests/misc/timeout.sh
+++ b/tests/misc/timeout.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate timeout basic operation
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/tr-case-class.sh b/tests/misc/tr-case-class.sh
index 952aae45..07c37607 100755
--- a/tests/misc/tr-case-class.sh
+++ b/tests/misc/tr-case-class.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test case conversion classes
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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
@@ -29,11 +29,11 @@ tr '[:lower:][:lower:]' '[:upper:]0-9' > out || fail=1
compare exp out || fail=1
# Validate the alignment of case classes
-tr 'A-Z[:lower:]' 'a-y[:upper:]' < /dev/null && fail=1
-tr '[:upper:][:lower:]' 'a-y[:upper:]' < /dev/null && fail=1
-tr 'A-Y[:lower:]' 'a-z[:upper:]' < /dev/null && fail=1
-tr 'A-Z[:lower:]' '[:lower:][:upper:]' < /dev/null && fail=1
-tr 'A-Z[:lower:]' '[:lower:]A-Z' < /dev/null && fail=1
+returns_ 1 tr 'A-Z[:lower:]' 'a-y[:upper:]' </dev/null || fail=1
+returns_ 1 tr '[:upper:][:lower:]' 'a-y[:upper:]' </dev/null || fail=1
+returns_ 1 tr 'A-Y[:lower:]' 'a-z[:upper:]' </dev/null || fail=1
+returns_ 1 tr 'A-Z[:lower:]' '[:lower:][:upper:]' </dev/null || fail=1
+returns_ 1 tr 'A-Z[:lower:]' '[:lower:]A-Z' </dev/null || fail=1
tr '[:upper:][:lower:]' 'a-z[:upper:]' < /dev/null || fail=1
tr '[:upper:][:lower:]' '[:upper:]a-z' < /dev/null || fail=1
diff --git a/tests/misc/tr.pl b/tests/misc/tr.pl
index e7018e79..738df3cb 100755
--- a/tests/misc/tr.pl
+++ b/tests/misc/tr.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/truncate-dangling-symlink.sh b/tests/misc/truncate-dangling-symlink.sh
index c5bbc3b6..fe0edfbe 100755
--- a/tests/misc/truncate-dangling-symlink.sh
+++ b/tests/misc/truncate-dangling-symlink.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure truncate can create a file through a dangling symlink.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/truncate-dir-fail.sh b/tests/misc/truncate-dir-fail.sh
index 8ff09179..7787381e 100755
--- a/tests/misc/truncate-dir-fail.sh
+++ b/tests/misc/truncate-dir-fail.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure truncate fails for a directory.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
@@ -20,6 +20,6 @@
print_ver_ truncate
# truncate on dir not allowed
-truncate -s+0 . && fail=1
+returns_ 1 truncate -s+0 . || fail=1
Exit $fail
diff --git a/tests/misc/truncate-fail-diag.sh b/tests/misc/truncate-fail-diag.sh
index 9f242d34..e092d3f2 100755
--- a/tests/misc/truncate-fail-diag.sh
+++ b/tests/misc/truncate-fail-diag.sh
@@ -5,7 +5,7 @@
# open ("missing/", O_CREAT & (O_WRONLY | O_RDWR), ...) -> EISDIR
# open ("missing/file", O_CREAT & (O_WRONLY | O_RDWR), ...) -> ENOENT
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/truncate-fifo.sh b/tests/misc/truncate-fifo.sh
index c2c0bbfc..db2e5647 100755
--- a/tests/misc/truncate-fifo.sh
+++ b/tests/misc/truncate-fifo.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure truncate works on fifos without hanging
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/truncate-no-create-missing.sh b/tests/misc/truncate-no-create-missing.sh
index 1cf55330..fbac330e 100755
--- a/tests/misc/truncate-no-create-missing.sh
+++ b/tests/misc/truncate-no-create-missing.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that truncate -c no-such-file doesn't fail.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/truncate-overflow.sh b/tests/misc/truncate-overflow.sh
index 72ed626b..c690c406 100755
--- a/tests/misc/truncate-overflow.sh
+++ b/tests/misc/truncate-overflow.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate truncate integer overflow
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
@@ -27,13 +27,13 @@ truncate -s-1 create-zero-len-file || fail=1
echo > non-empty-file
# signed overflow
-truncate -s$OFF_T_OFLOW file && fail=1
+returns_ 1 truncate -s$OFF_T_OFLOW file || fail=1
# += signed overflow
-truncate -s+$OFF_T_MAX non-empty-file && fail=1
+returns_ 1 truncate -s+$OFF_T_MAX non-empty-file || fail=1
# *= signed overflow
IO_BLOCK_OFLOW=$(expr $OFF_T_MAX / $(stat -f -c%s .) + 1)
-truncate --io-blocks --size=$IO_BLOCK_OFLOW file && fail=1
+returns_ 1 truncate --io-blocks --size=$IO_BLOCK_OFLOW file || fail=1
Exit $fail
diff --git a/tests/misc/truncate-owned-by-other.sh b/tests/misc/truncate-owned-by-other.sh
index e70badb6..b224864f 100755
--- a/tests/misc/truncate-owned-by-other.sh
+++ b/tests/misc/truncate-owned-by-other.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Demonstrate that "truncate -s0 writable-but-owned-by-other" works.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
@@ -29,7 +29,7 @@ chmod g+w root-owned
# Ensure that the current directory is searchable by $NON_ROOT_USERNAME.
chmod g+x .
-chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" \
+chroot --skip-chdir --user=$NON_ROOT_USERNAME / env PATH="$PATH" \
truncate -s0 root-owned || fail=1
Exit $fail
diff --git a/tests/misc/truncate-parameters.sh b/tests/misc/truncate-parameters.sh
index d9e6d64d..d3cf5940 100755
--- a/tests/misc/truncate-parameters.sh
+++ b/tests/misc/truncate-parameters.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate truncate parameter combinations
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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,22 @@ print_ver_ truncate
# must specify at least 1 file
-truncate --size=0 && fail=1
+returns_ 1 truncate --size=0 || fail=1
# must specify size. don't default to 0
-truncate file && fail=1
+returns_ 1 truncate file || fail=1
# mixture of absolute size & reference not allowed
-truncate --size=0 --reference=file file && fail=1
+returns_ 1 truncate --size=0 --reference=file file || fail=1
# blocks without size is not valid
-truncate --io-blocks --reference=file file && fail=1
+returns_ 1 truncate --io-blocks --reference=file file || fail=1
# must specify valid numbers
-truncate --size="invalid" file && fail=1
+returns_ 1 truncate --size="invalid" file || fail=1
# spaces not significant around size
-truncate --size="> -1" file && fail=1
+returns_ 1 truncate --size="> -1" file || fail=1
truncate --size=" >1" file || fail=1 #file now 1
truncate --size=" +1" file || fail=1 #file now 2
test $(stat --format %s file) = 2 || fail=1
diff --git a/tests/misc/truncate-relative.sh b/tests/misc/truncate-relative.sh
index 3daa073e..97be8cb7 100755
--- a/tests/misc/truncate-relative.sh
+++ b/tests/misc/truncate-relative.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate truncate relative sizes
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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,15 +21,15 @@ print_ver_ truncate
# mixture of relative modifiers not allowed
-truncate --size="+>0" file && fail=1
+returns_ 1 truncate --size="+>0" file || fail=1
# mixture of relative modifiers not allowed
-truncate --size=">+0" file && fail=1
+returns_ 1 truncate --size=">+0" file || fail=1
# division by zero
-truncate --size="/0" file && fail=1
+returns_ 1 truncate --size="/0" file || fail=1
# division by zero
-truncate --size="%0" file && fail=1
+returns_ 1 truncate --size="%0" file || fail=1
Exit $fail
diff --git a/tests/misc/tsort.pl b/tests/misc/tsort.pl
index e59af328..4d04866a 100755
--- a/tests/misc/tsort.pl
+++ b/tests/misc/tsort.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "tsort".
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2015 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
diff --git a/tests/misc/tty-eof.pl b/tests/misc/tty-eof.pl
index b4d36de6..c49efc24 100755
--- a/tests/misc/tty-eof.pl
+++ b/tests/misc/tty-eof.pl
@@ -4,7 +4,7 @@
# Do the same for all programs that can read stdin,
# require no arguments and that write to standard output.
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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
diff --git a/tests/misc/unexpand.pl b/tests/misc/unexpand.pl
index 8c5b693b..548bc91c 100755
--- a/tests/misc/unexpand.pl
+++ b/tests/misc/unexpand.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "unexpand".
-# Copyright (C) 2000-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000-2015 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
diff --git a/tests/misc/uniq-perf.sh b/tests/misc/uniq-perf.sh
index 31c40e53..b8bac973 100755
--- a/tests/misc/uniq-perf.sh
+++ b/tests/misc/uniq-perf.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# before coreutils-8.10, seq 100000|uniq -f 10000000000 would run for days
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2015 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
@@ -20,6 +20,6 @@
print_ver_ uniq
seq 100 > in || fail=1
-timeout 1 uniq -f 10000000000 in || fail=1
+timeout 10 uniq -f 10000000000 in || fail=1
Exit $fail
diff --git a/tests/misc/uniq.pl b/tests/misc/uniq.pl
index d07f15f1..5eae7010 100755
--- a/tests/misc/uniq.pl
+++ b/tests/misc/uniq.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test uniq.
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 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
diff --git a/tests/misc/wc-files0-from.pl b/tests/misc/wc-files0-from.pl
index 4ff10019..cae3fc22 100755
--- a/tests/misc/wc-files0-from.pl
+++ b/tests/misc/wc-files0-from.pl
@@ -2,7 +2,7 @@
# Exercise wc's --files0-from option.
# FIXME: keep this file in sync with tests/du/files0-from.
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
diff --git a/tests/misc/wc-files0.sh b/tests/misc/wc-files0.sh
index 37fd1ab0..c52b8b0d 100755
--- a/tests/misc/wc-files0.sh
+++ b/tests/misc/wc-files0.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Show that wc's new --files0-from option works.
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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
diff --git a/tests/misc/wc-parallel.sh b/tests/misc/wc-parallel.sh
index 01005820..19497e04 100755
--- a/tests/misc/wc-parallel.sh
+++ b/tests/misc/wc-parallel.sh
@@ -2,7 +2,7 @@
# Ensure that wc prints counts atomically
# so that concurrent processes don't intersperse their output
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
@@ -20,13 +20,17 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ wc
+xargs -P2 </dev/null >/dev/null 2>&1 \
+ || skip_ 'xargs -P is required'
+
(mkdir tmp && cd tmp && seq 2000 | xargs touch)
# This will output at least 16KiB per process
# and start 3 processes, with 2 running concurrently,
# which triggers often on Fedora 11 at least.
-(find tmp tmp tmp -type f | xargs -n2000 -P2 wc) |
+(find tmp tmp tmp -type f | xargs -n2000 -P2 wc 2>err) |
sed -n '/0 0 0 /!p' |
grep . > /dev/null && fail=1
+compare /dev/null err || fail=1
Exit $fail
diff --git a/tests/misc/tee-dash.sh b/tests/misc/wc-proc.sh
index 761a4780..5b83aa41 100755
--- a/tests/misc/tee-dash.sh
+++ b/tests/misc/wc-proc.sh
@@ -1,7 +1,7 @@
#!/bin/sh
-# test for "tee -".
+# Test wc on /proc and /sys files.
-# Copyright (C) 2005-2014 Free Software Foundation, Inc.
+# Copyright 2014-2015 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
@@ -17,8 +17,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ tee
+print_ver_ wc
-tee - </dev/null || fail=1
+for file in /proc/version /sys/kernel/profiling; do
+ if test -r $file; then
+ cp -f $file copy &&
+ wc -c < copy > exp1 || framework_failure_
+
+ wc -c < $file > out1 || fail=1
+ compare exp1 out1 || fail=1
+ fi
+done
Exit $fail
diff --git a/tests/misc/wc.pl b/tests/misc/wc.pl
index 076ce049..3b8a6a23 100755
--- a/tests/misc/wc.pl
+++ b/tests/misc/wc.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Basic tests for "wc".
-# Copyright (C) 1997-2014 Free Software Foundation, Inc.
+# Copyright (C) 1997-2015 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
diff --git a/tests/misc/xattr.sh b/tests/misc/xattr.sh
index f208090f..56a40574 100755
--- a/tests/misc/xattr.sh
+++ b/tests/misc/xattr.sh
@@ -3,7 +3,7 @@
# attributes and install does not preserve extended attributes.
# cp -a should preserve xattr, error diagnostics should not be displayed
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 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
diff --git a/tests/misc/xstrtol.pl b/tests/misc/xstrtol.pl
index fed8d7d6..2140c1f8 100755
--- a/tests/misc/xstrtol.pl
+++ b/tests/misc/xstrtol.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# exercise xstrtol's diagnostics via pr
-# Copyright (C) 2007-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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
diff --git a/tests/misc/yes.sh b/tests/misc/yes.sh
new file mode 100755
index 00000000..79f8b87c
--- /dev/null
+++ b/tests/misc/yes.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+# Validate yes buffer handling
+
+# Copyright (C) 2015 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ yes
+
+# Check various single item sizes, with the most important
+# size being BUFSIZ used for the local buffer to yes(1).
+# Note a \n is added, so actual sizes required internally
+# are 1 more than the size used here.
+for size in 1 1999 4095 4096 8191 8192 16383 16384; do
+ printf "%${size}s\n" '' > out.1
+ yes "$(printf %${size}s '')" | head -n2 | uniq > out.2
+ compare out.1 out.2 || fail=1
+done
+
+# Check the many small items case,
+# both fitting and overflowing the internal buffer
+if env true $(seq 4000); then
+ for i in 100 4000; do
+ seq $i | paste -s -d ' ' | sed p > out.1
+ yes $(seq $i) | head -n2 > out.2
+ compare out.1 out.2 || fail=1
+ done
+fi
+
+Exit $fail