summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-02-16 14:42:43 +0000
committerIgor Pashev <pashev.igor@gmail.com>2013-02-16 14:42:43 +0000
commit974ab3dd887985e3aa347f3c6521f819296396a0 (patch)
tree802fb82c9f8ec8acd7a60fba7824c2df6f0073ad /tests/misc
parent8e7ba70eba02f88d4f3ba12e07ab9c7bdf32240a (diff)
downloadcoreutils-974ab3dd887985e3aa347f3c6521f819296396a0.tar.gz
Imported Upstream version 8.21upstream/8.21
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/arch.sh (renamed from tests/misc/arch)4
-rwxr-xr-xtests/misc/base64.pl (renamed from tests/misc/base64)2
-rwxr-xr-xtests/misc/basename.pl (renamed from tests/misc/basename)13
-rwxr-xr-xtests/misc/cat-buf.sh (renamed from tests/misc/cat-buf)4
-rwxr-xr-xtests/misc/cat-proc.sh (renamed from tests/misc/cat-proc)4
-rwxr-xr-xtests/misc/chcon-fail.sh (renamed from tests/misc/chcon-fail)4
-rwxr-xr-xtests/misc/chcon.sh (renamed from tests/misc/chcon)4
-rwxr-xr-xtests/misc/chroot-credentials.sh (renamed from tests/misc/chroot-credentials)4
-rwxr-xr-xtests/misc/chroot-fail.sh (renamed from tests/misc/chroot-fail)4
-rwxr-xr-xtests/misc/close-stdout.sh (renamed from tests/misc/close-stdout)4
-rwxr-xr-xtests/misc/comm.pl (renamed from tests/misc/comm)2
-rwxr-xr-xtests/misc/csplit-1000.sh (renamed from tests/misc/csplit-1000)4
-rwxr-xr-xtests/misc/csplit-heap.sh (renamed from tests/misc/csplit-heap)4
-rwxr-xr-xtests/misc/csplit.sh (renamed from tests/misc/csplit)4
-rwxr-xr-xtests/misc/cut-huge-to-eol-range.sh30
-rwxr-xr-xtests/misc/cut.pl (renamed from tests/misc/cut)70
-rwxr-xr-xtests/misc/date-next-dow.pl (renamed from tests/misc/date-next-dow)2
-rwxr-xr-xtests/misc/date-sec.sh (renamed from tests/misc/date-sec)4
-rwxr-xr-xtests/misc/date.pl (renamed from tests/misc/date)7
-rwxr-xr-xtests/misc/df28
-rwxr-xr-xtests/misc/df-P37
-rwxr-xr-xtests/misc/dircolors.pl (renamed from tests/misc/dircolors)2
-rwxr-xr-xtests/misc/dirname.pl (renamed from tests/misc/dirname)2
-rwxr-xr-xtests/misc/env-null.sh (renamed from tests/misc/env-null)4
-rwxr-xr-xtests/misc/env.sh (renamed from tests/misc/env)4
-rwxr-xr-xtests/misc/expand.pl (renamed from tests/misc/expand)2
-rwxr-xr-xtests/misc/expr.pl (renamed from tests/misc/expr)2
-rwxr-xr-xtests/misc/factor.pl (renamed from tests/misc/factor)20
-rwxr-xr-xtests/misc/false-status.sh (renamed from tests/misc/false-status)4
-rwxr-xr-xtests/misc/fold.pl (renamed from tests/misc/fold)2
-rwxr-xr-xtests/misc/groups-dash.sh (renamed from tests/misc/groups-dash)4
-rwxr-xr-xtests/misc/groups-version.sh (renamed from tests/misc/groups-version)4
-rwxr-xr-xtests/misc/head-c.sh (renamed from tests/misc/head-c)4
-rwxr-xr-xtests/misc/head-elide-tail.pl (renamed from tests/misc/head-elide-tail)4
-rwxr-xr-xtests/misc/head-pos.sh (renamed from tests/misc/head-pos)30
-rwxr-xr-xtests/misc/head.pl (renamed from tests/misc/head)2
-rwxr-xr-xtests/misc/help-version.sh (renamed from tests/misc/help-version)8
-rwxr-xr-xtests/misc/id-context.sh (renamed from tests/misc/id-context)4
-rwxr-xr-xtests/misc/id-groups.sh (renamed from tests/misc/id-groups)4
-rwxr-xr-xtests/misc/id-setgid.sh (renamed from tests/misc/id-setgid)4
-rwxr-xr-xtests/misc/invalid-opt.pl (renamed from tests/misc/invalid-opt)3
-rwxr-xr-xtests/misc/join.pl (renamed from tests/misc/join)6
-rwxr-xr-xtests/misc/ls-misc.pl (renamed from tests/misc/ls-misc)17
-rwxr-xr-xtests/misc/ls-time.sh (renamed from tests/misc/ls-time)4
-rwxr-xr-xtests/misc/md5sum-bsd41
-rwxr-xr-xtests/misc/md5sum-bsd.sh88
-rwxr-xr-xtests/misc/md5sum-newline.pl (renamed from tests/misc/md5sum-newline)2
-rwxr-xr-xtests/misc/md5sum-parallel.sh (renamed from tests/misc/md5sum-parallel)4
-rwxr-xr-xtests/misc/md5sum.pl (renamed from tests/misc/md5sum)2
-rwxr-xr-xtests/misc/mknod.sh (renamed from tests/misc/mknod)4
-rwxr-xr-xtests/misc/mktemp.pl (renamed from tests/misc/mktemp)2
-rwxr-xr-xtests/misc/nice-fail.sh (renamed from tests/misc/nice-fail)4
-rwxr-xr-xtests/misc/nice.sh (renamed from tests/misc/nice)4
-rwxr-xr-xtests/misc/nl.sh (renamed from tests/misc/nl)4
-rwxr-xr-xtests/misc/nohup.sh (renamed from tests/misc/nohup)4
-rwxr-xr-xtests/misc/nproc-avail.sh (renamed from tests/misc/nproc-avail)4
-rwxr-xr-xtests/misc/nproc-positive.sh (renamed from tests/misc/nproc-positive)4
-rw-r--r--tests/misc/numfmt.pl950
-rwxr-xr-xtests/misc/od-N.sh (renamed from tests/misc/od-N)4
-rwxr-xr-xtests/misc/od-float.sh (renamed from tests/misc/od-float)4
-rwxr-xr-xtests/misc/od-multiple-t.sh (renamed from tests/misc/od-multiple-t)4
-rwxr-xr-xtests/misc/od-x8.sh (renamed from tests/misc/od-x8)4
-rwxr-xr-xtests/misc/od.pl (renamed from tests/misc/od)2
-rwxr-xr-xtests/misc/paste.pl (renamed from tests/misc/paste)2
-rwxr-xr-xtests/misc/pathchk1.sh (renamed from tests/misc/pathchk1)4
-rwxr-xr-xtests/misc/pr43
-rwxr-xr-xtests/misc/printenv.sh (renamed from tests/misc/printenv)4
-rwxr-xr-xtests/misc/printf-cov.pl (renamed from tests/misc/printf-cov)2
-rwxr-xr-xtests/misc/printf-hex.sh (renamed from tests/misc/printf-hex)4
-rwxr-xr-xtests/misc/printf-surprise.sh (renamed from tests/misc/printf-surprise)9
-rwxr-xr-xtests/misc/printf.sh (renamed from tests/misc/printf)4
-rwxr-xr-xtests/misc/ptx-overrun.sh (renamed from tests/misc/ptx-overrun)4
-rwxr-xr-xtests/misc/ptx.pl (renamed from tests/misc/ptx)2
-rwxr-xr-xtests/misc/pwd-long.sh (renamed from tests/misc/pwd-long)6
-rwxr-xr-xtests/misc/pwd-option.sh (renamed from tests/misc/pwd-option)4
-rwxr-xr-xtests/misc/readlink-fp-loop.sh (renamed from tests/misc/readlink-fp-loop)4
-rwxr-xr-xtests/misc/readlink-root.sh (renamed from tests/misc/readlink-root)4
-rwxr-xr-xtests/misc/realpath.sh (renamed from tests/misc/realpath)4
-rwxr-xr-xtests/misc/runcon-no-reorder.sh (renamed from tests/misc/runcon-no-reorder)4
-rwxr-xr-xtests/misc/selinux.sh (renamed from tests/misc/selinux)4
-rwxr-xr-xtests/misc/seq-long-double.sh (renamed from tests/misc/seq-long-double)4
-rwxr-xr-xtests/misc/seq.pl (renamed from tests/misc/seq)43
-rwxr-xr-xtests/misc/sha1sum-vec.pl (renamed from tests/misc/sha1sum-vec)2
-rwxr-xr-xtests/misc/sha1sum.pl (renamed from tests/misc/sha1sum)2
-rwxr-xr-xtests/misc/sha224sum.pl (renamed from tests/misc/sha224sum)2
-rwxr-xr-xtests/misc/sha256sum.pl (renamed from tests/misc/sha256sum)2
-rwxr-xr-xtests/misc/sha384sum.pl (renamed from tests/misc/sha384sum)2
-rwxr-xr-xtests/misc/sha512sum.pl (renamed from tests/misc/sha512sum)2
-rwxr-xr-xtests/misc/shred-exact.sh (renamed from tests/misc/shred-exact)4
-rwxr-xr-xtests/misc/shred-passes.sh (renamed from tests/misc/shred-passes)4
-rwxr-xr-xtests/misc/shred-remove.sh (renamed from tests/misc/shred-remove)4
-rwxr-xr-xtests/misc/shuf.sh (renamed from tests/misc/shuf)4
-rwxr-xr-xtests/misc/sort-NaN-infloop.sh (renamed from tests/misc/sort-NaN-infloop)4
-rwxr-xr-xtests/misc/sort-benchmark-random.sh (renamed from tests/misc/sort-benchmark-random)4
-rwxr-xr-xtests/misc/sort-compress-hang.sh (renamed from tests/misc/sort-compress-hang)4
-rwxr-xr-xtests/misc/sort-compress-proc.sh (renamed from tests/misc/sort-compress-proc)4
-rwxr-xr-xtests/misc/sort-compress.sh (renamed from tests/misc/sort-compress)4
-rwxr-xr-xtests/misc/sort-continue.sh (renamed from tests/misc/sort-continue)4
-rwxr-xr-xtests/misc/sort-debug-keys.sh (renamed from tests/misc/sort-debug-keys)4
-rwxr-xr-xtests/misc/sort-debug-warn.sh (renamed from tests/misc/sort-debug-warn)4
-rwxr-xr-xtests/misc/sort-discrim.sh (renamed from tests/misc/sort-discrim)4
-rwxr-xr-xtests/misc/sort-exit-early.sh37
-rwxr-xr-xtests/misc/sort-files0-from.pl (renamed from tests/misc/sort-files0-from)2
-rwxr-xr-xtests/misc/sort-float.sh (renamed from tests/misc/sort-float)4
-rwxr-xr-xtests/misc/sort-merge-fdlimit.sh (renamed from tests/misc/sort-merge-fdlimit)4
-rwxr-xr-xtests/misc/sort-merge.pl (renamed from tests/misc/sort-merge)2
-rwxr-xr-xtests/misc/sort-month.sh (renamed from tests/misc/sort-month)4
-rwxr-xr-xtests/misc/sort-rand.sh (renamed from tests/misc/sort-rand)6
-rwxr-xr-xtests/misc/sort-spinlock-abuse.sh (renamed from tests/misc/sort-spinlock-abuse)4
-rwxr-xr-xtests/misc/sort-stale-thread-mem.sh (renamed from tests/misc/sort-stale-thread-mem)6
-rwxr-xr-xtests/misc/sort-u-FMR.sh29
-rwxr-xr-xtests/misc/sort-unique-segv.sh (renamed from tests/misc/sort-unique-segv)4
-rwxr-xr-xtests/misc/sort-unique.sh (renamed from tests/misc/sort-unique)4
-rwxr-xr-xtests/misc/sort-version.sh (renamed from tests/misc/sort-version)4
-rwxr-xr-xtests/misc/sort.pl (renamed from tests/misc/sort)19
-rwxr-xr-xtests/misc/stat-birthtime.sh (renamed from tests/misc/stat-birthtime)4
-rwxr-xr-xtests/misc/stat-fmt.sh (renamed from tests/misc/stat-fmt)4
-rwxr-xr-xtests/misc/stat-hyphen.sh (renamed from tests/misc/stat-hyphen)4
-rwxr-xr-xtests/misc/stat-mount.sh (renamed from tests/misc/stat-mount)4
-rwxr-xr-xtests/misc/stat-nanoseconds.sh (renamed from tests/misc/stat-nanoseconds)4
-rwxr-xr-xtests/misc/stat-printf.pl (renamed from tests/misc/stat-printf)2
-rwxr-xr-xtests/misc/stat-slash.sh (renamed from tests/misc/stat-slash)4
-rwxr-xr-xtests/misc/stdbuf.sh (renamed from tests/misc/stdbuf)4
-rwxr-xr-xtests/misc/stty-invalid.sh (renamed from tests/misc/stty-invalid)4
-rwxr-xr-xtests/misc/stty-pairs.sh (renamed from tests/misc/stty-pairs)4
-rwxr-xr-xtests/misc/stty-row-col.sh (renamed from tests/misc/stty-row-col)4
-rwxr-xr-xtests/misc/stty.sh (renamed from tests/misc/stty)6
-rwxr-xr-xtests/misc/su-fail30
-rwxr-xr-xtests/misc/sum-sysv.sh (renamed from tests/misc/sum-sysv)4
-rwxr-xr-xtests/misc/sum.pl (renamed from tests/misc/sum)2
-rwxr-xr-xtests/misc/tac-2-nonseekable.sh (renamed from tests/misc/tac-2-nonseekable)4
-rwxr-xr-xtests/misc/tac-continue.sh (renamed from tests/misc/tac-continue)4
-rwxr-xr-xtests/misc/tac.pl (renamed from tests/misc/tac)2
-rwxr-xr-xtests/misc/tail.pl (renamed from tests/misc/tail)2
-rwxr-xr-xtests/misc/tee-dash.sh (renamed from tests/misc/tee-dash)4
-rwxr-xr-xtests/misc/tee.sh (renamed from tests/misc/tee)4
-rwxr-xr-xtests/misc/test-diag.pl (renamed from tests/misc/test-diag)2
-rwxr-xr-xtests/misc/test.pl (renamed from tests/misc/test)2
-rwxr-xr-xtests/misc/timeout-blocked.pl48
-rwxr-xr-xtests/misc/timeout-group.sh (renamed from tests/misc/timeout-group)10
-rwxr-xr-xtests/misc/timeout-parameters.sh (renamed from tests/misc/timeout-parameters)4
-rwxr-xr-xtests/misc/timeout.sh (renamed from tests/misc/timeout)15
-rwxr-xr-xtests/misc/tr-case-class.sh (renamed from tests/misc/tr-case-class)4
-rwxr-xr-xtests/misc/tr.pl (renamed from tests/misc/tr)2
-rwxr-xr-xtests/misc/truncate-dangling-symlink.sh (renamed from tests/misc/truncate-dangling-symlink)4
-rwxr-xr-xtests/misc/truncate-dir-fail.sh (renamed from tests/misc/truncate-dir-fail)4
-rwxr-xr-xtests/misc/truncate-fail-diag.sh (renamed from tests/misc/truncate-fail-diag)6
-rwxr-xr-xtests/misc/truncate-fifo.sh (renamed from tests/misc/truncate-fifo)4
-rwxr-xr-xtests/misc/truncate-no-create-missing.sh (renamed from tests/misc/truncate-no-create-missing)4
-rwxr-xr-xtests/misc/truncate-overflow.sh (renamed from tests/misc/truncate-overflow)4
-rwxr-xr-xtests/misc/truncate-owned-by-other.sh (renamed from tests/misc/truncate-owned-by-other)4
-rwxr-xr-xtests/misc/truncate-parameters.sh (renamed from tests/misc/truncate-parameters)4
-rwxr-xr-xtests/misc/truncate-relative.sh (renamed from tests/misc/truncate-relative)4
-rwxr-xr-xtests/misc/tsort.pl (renamed from tests/misc/tsort)2
-rwxr-xr-xtests/misc/tty-eof.pl (renamed from tests/misc/tty-eof)2
-rwxr-xr-xtests/misc/unexpand.pl (renamed from tests/misc/unexpand)2
-rwxr-xr-xtests/misc/uniq-perf.sh (renamed from tests/misc/uniq-perf)4
-rwxr-xr-xtests/misc/uniq.pl (renamed from tests/misc/uniq)2
-rwxr-xr-xtests/misc/wc-files0-from.pl (renamed from tests/misc/wc-files0-from)2
-rwxr-xr-xtests/misc/wc-files0.sh (renamed from tests/misc/wc-files0)4
-rwxr-xr-xtests/misc/wc-parallel.sh (renamed from tests/misc/wc-parallel)6
-rwxr-xr-xtests/misc/wc.pl (renamed from tests/misc/wc)2
-rwxr-xr-xtests/misc/xattr.sh (renamed from tests/misc/xattr)6
-rwxr-xr-xtests/misc/xstrtol.pl (renamed from tests/misc/xstrtol)2
164 files changed, 1647 insertions, 478 deletions
diff --git a/tests/misc/arch b/tests/misc/arch.sh
index e1d73089..db2b784f 100755
--- a/tests/misc/arch
+++ b/tests/misc/arch.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that arch output is equal to uname -m
-# Copyright (C) 2007-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ arch
require_built_ arch
diff --git a/tests/misc/base64 b/tests/misc/base64.pl
index 44a79275..5d1d2621 100755
--- a/tests/misc/base64
+++ b/tests/misc/base64.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Exercise base64.
-# Copyright (C) 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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 b/tests/misc/basename.pl
index d0ab57bf..b84412bb 100755
--- a/tests/misc/basename
+++ b/tests/misc/basename.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# Test basename.
-# Copyright (C) 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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
@@ -61,9 +61,17 @@ my @Tests =
['8', qw(fs x), {OUT => 'fs'}],
['9', qw(fs ''), {OUT => 'fs'}],
['10', qw(fs/ s/), {OUT => 'fs'}],
+
+ # Exercise -z option.
+ ['z0', qw(-z a), {OUT => "a\0"}],
+ ['z1', qw(--zero a), {OUT => "a\0"}],
+ ['z2', qw(-za a b), {OUT => "a\0b\0"}],
+ ['z3', qw(-z ba a), {OUT => "b\0"}],
+ ['z4', qw(-z -s a ba), {OUT => "b\0"}],
);
# Append a newline to end of each expected 'OUT' string.
+# Skip -z tests, i.e. those whose 'OUT' string has a trailing '\0'.
my $t;
foreach $t (@Tests)
{
@@ -72,7 +80,8 @@ foreach $t (@Tests)
foreach $e (@$t)
{
$e->{OUT} = "$e->{OUT}\n"
- if ref $e eq 'HASH' and exists $e->{OUT};
+ if ref $e eq 'HASH' and exists $e->{OUT}
+ and not $e->{OUT} =~ /\0$/;
}
}
diff --git a/tests/misc/cat-buf b/tests/misc/cat-buf.sh
index 2b6ba2a6..17fd936f 100755
--- a/tests/misc/cat-buf
+++ b/tests/misc/cat-buf.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that cat outputs processed data immediately.
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ cat
# Use a fifo rather than a pipe in the tests below
diff --git a/tests/misc/cat-proc b/tests/misc/cat-proc.sh
index 082c727e..77f548e4 100755
--- a/tests/misc/cat-proc
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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,7 +17,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ cat
diff --git a/tests/misc/chcon-fail b/tests/misc/chcon-fail.sh
index d9f6c21b..c9b651b7 100755
--- a/tests/misc/chcon-fail
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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,7 +17,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ chcon
diff --git a/tests/misc/chcon b/tests/misc/chcon.sh
index 6b445803..aace5389 100755
--- a/tests/misc/chcon
+++ b/tests/misc/chcon.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise chcon
-# Copyright (C) 2007-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ chcon
require_root_
require_selinux_
diff --git a/tests/misc/chroot-credentials b/tests/misc/chroot-credentials.sh
index bae9d425..8eb658d9 100755
--- a/tests/misc/chroot-credentials
+++ b/tests/misc/chroot-credentials.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify that the credentials are changed correctly.
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ chroot
require_root_
diff --git a/tests/misc/chroot-fail b/tests/misc/chroot-fail.sh
index 6a5ecf32..86095f3c 100755
--- a/tests/misc/chroot-fail
+++ b/tests/misc/chroot-fail.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify that internal failure in chroot gives exact status.
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ chroot
diff --git a/tests/misc/close-stdout b/tests/misc/close-stdout.sh
index 8584dfea..8ea08487 100755
--- a/tests/misc/close-stdout
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2004-2013 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,7 +17,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ rm
p=$abs_top_builddir
diff --git a/tests/misc/comm b/tests/misc/comm.pl
index 0de4f699..62711bda 100755
--- a/tests/misc/comm
+++ b/tests/misc/comm.pl
@@ -2,7 +2,7 @@
# -*- perl -*-
# Test comm
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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 b/tests/misc/csplit-1000.sh
index 217097e5..26cb8a8c 100755
--- a/tests/misc/csplit-1000
+++ b/tests/misc/csplit-1000.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# cause a 1-byte heap buffer overrun
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ csplit
# Before coreutils-8.7, this would overrun the 6-byte filename_space buffer.
diff --git a/tests/misc/csplit-heap b/tests/misc/csplit-heap.sh
index f12f9fe0..82945a78 100755
--- a/tests/misc/csplit-heap
+++ b/tests/misc/csplit-heap.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure that csplit uses a bounded amount of memory
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ csplit
require_ulimit_
diff --git a/tests/misc/csplit b/tests/misc/csplit.sh
index aea2e918..24c21aaf 100755
--- a/tests/misc/csplit
+++ b/tests/misc/csplit.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# various csplit tests
-# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ csplit
diff --git a/tests/misc/cut-huge-to-eol-range.sh b/tests/misc/cut-huge-to-eol-range.sh
new file mode 100755
index 00000000..42cecfd7
--- /dev/null
+++ b/tests/misc/cut-huge-to-eol-range.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Ensure that cut does not allocate mem for a range like -b9999999999999-
+
+# Copyright (C) 2012-2013 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_ cut
+require_ulimit_
+getlimits_
+
+# From coreutils-8.10 through 8.20, this would make cut try to allocate
+# a 256MiB bit vector. With a 20MB limit on VM, the following would fail.
+(ulimit -v 20000; : | cut -b$INT_MAX- > err 2>&1) || fail=1
+
+compare /dev/null err || fail=1
+
+Exit $fail
diff --git a/tests/misc/cut b/tests/misc/cut.pl
index 0ce051ab..41e9e209 100755
--- a/tests/misc/cut
+++ b/tests/misc/cut.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "cut".
-# Copyright (C) 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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,10 @@ my $mb_locale = $ENV{LOCALE_FR_UTF8};
my $prog = 'cut';
my $try = "Try '$prog --help' for more information.\n";
my $from_1 = "$prog: fields and positions are numbered from 1\n$try";
-my $inval = "$prog: invalid byte or field list\n$try";
+my $inval = "$prog: invalid byte, character or field list\n$try";
my $no_endpoint = "$prog: invalid range with no endpoint: -\n$try";
+my $nofield = "$prog: an input delimiter may be specified only when " .
+ "operating on fields\n$try";
my @Tests =
(
@@ -46,6 +48,11 @@ my @Tests =
# It was treated just like "-2".
['zero-2', '-f0-2', {ERR=>$from_1}, {EXIT => 1} ],
+ # Up to coreutils-8.20, specifying a range of 0- was not an error.
+ ['zero-3b', '-b0-', {ERR=>$from_1}, {EXIT => 1} ],
+ ['zero-3c', '-c0-', {ERR=>$from_1}, {EXIT => 1} ],
+ ['zero-3f', '-f0-', {ERR=>$from_1}, {EXIT => 1} ],
+
['1', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}],
['2', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}],
['3', qw(-d: -f2-), {IN=>"a:b:c\n"}, {OUT=>"b:c\n"}],
@@ -113,10 +120,40 @@ my @Tests =
['multichar-od', qw(-d: --out=_._), '-f2,3', {IN=>"a:b:c\n"},
{OUT=>"b_._c\n"}],
+ # Ensure delim is not allowed without a field
+ # Prior to 8.21, a NUL delim was allowed without a field
+ ['delim-no-field1', qw(-d ''), '-b1', {EXIT=>1}, {ERR=>$nofield}],
+ ['delim-no-field2', qw(-d:), '-b1', {EXIT=>1}, {ERR=>$nofield}],
+
# Prior to 1.22i, you couldn't use a delimiter that would sign-extend.
['8bit-delim', '-d', "\255", '--out=_', '-f2,3', {IN=>"a\255b\255c\n"},
{OUT=>"b_c\n"}],
+ # newline processing for fields
+ ['newline-1', '-f1-', {IN=>"a\nb"}, {OUT=>"a\nb\n"}],
+ ['newline-2', '-f1-', {IN=>""}, {OUT=>""}],
+ ['newline-3', '-d:', '-f1', {IN=>"a:1\nb:2\n"}, {OUT=>"a\nb\n"}],
+ ['newline-4', '-d:', '-f1', {IN=>"a:1\nb:2"}, {OUT=>"a\nb\n"}],
+ ['newline-5', '-d:', '-f2', {IN=>"a:1\nb:2\n"}, {OUT=>"1\n2\n"}],
+ ['newline-6', '-d:', '-f2', {IN=>"a:1\nb:2"}, {OUT=>"1\n2\n"}],
+ ['newline-7', '-s', '-d:', '-f1', {IN=>"a:1\nb:2"}, {OUT=>"a\nb\n"}],
+ ['newline-8', '-s', '-d:', '-f1', {IN=>"a:1\nb:2\n"}, {OUT=>"a\nb\n"}],
+ ['newline-9', '-s', '-d:', '-f1', {IN=>"a1\nb2"}, {OUT=>""}],
+ ['newline-10', '-s', '-d:', '-f1,2', {IN=>"a:1\nb:2"}, {OUT=>"a:1\nb:2\n"}],
+ ['newline-11', '-s', '-d:', '-f1,2', {IN=>"a:1\nb:2\n"}, {OUT=>"a:1\nb:2\n"}],
+ ['newline-12', '-s', '-d:', '-f1', {IN=>"a:1\nb:"}, {OUT=>"a\nb\n"}],
+ ['newline-13', '-d:', '-f1-', {IN=>"a1:\n:"}, {OUT=>"a1:\n:\n"}],
+ # newline processing for fields when -d == '\n'
+ ['newline-14', "-d'\n'", '-f1', {IN=>"a:1\nb:"}, {OUT=>"a:1\nb:\n"}],
+ ['newline-15', '-s', "-d'\n'", '-f1', {IN=>"a:1\nb:"}, {OUT=>"a:1\n"}],
+ ['newline-16', '-s', "-d'\n'", '-f2', {IN=>"\nb"}, {OUT=>""}],
+ ['newline-17', '-s', "-d'\n'", '-f1', {IN=>"\nb"}, {OUT=>"\n"}],
+ ['newline-18', "-d'\n'", '-f2', {IN=>"\nb"}, {OUT=>"\nb\n"}],
+ ['newline-19', "-d'\n'", '-f1', {IN=>"\nb"}, {OUT=>"\nb\n"}],
+ ['newline-20', '-s', "-d'\n'", '-f1-', {IN=>"\n"}, {OUT=>"\n"}],
+ ['newline-21', '-s', "-d'\n'", '-f1-', {IN=>"\nb"}, {OUT=>"\n"}],
+ ['newline-22', "-d'\n'", '-f1-', {IN=>"\nb"}, {OUT=>"\nb\n"}],
+
# New functionality:
['out-delim1', '-c1-3,5-', '--output-d=:', {IN=>"abcdefg\n"},
{OUT=>"abc:efg\n"}],
@@ -154,10 +191,25 @@ my @Tests =
{ERR=>$no_endpoint}],
['inval5', '-f', '1-,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}],
['inval6', '-f', '-1,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}],
- # This would evoke a segfault from 5.3.0..6.10
+ # This would evoke a segfault from 5.3.0..8.10
['big-unbounded-b', '--output-d=:', '-b1234567890-', {IN=>''}, {OUT=>''}],
+ ['big-unbounded-b2a', '--output-d=:', '-b1,9-', {IN=>'123456789'},
+ {OUT=>"1:9\n"}],
+ ['big-unbounded-b2b', '--output-d=:', '-b1,1234567890-', {IN=>''}, {OUT=>''}],
['big-unbounded-c', '--output-d=:', '-c1234567890-', {IN=>''}, {OUT=>''}],
['big-unbounded-f', '--output-d=:', '-f1234567890-', {IN=>''}, {OUT=>''}],
+
+ ['overlapping-unbounded-1', '-b3-,2-', {IN=>"1234\n"}, {OUT=>"234\n"}],
+ ['overlapping-unbounded-2', '-b2-,3-', {IN=>"1234\n"}, {OUT=>"234\n"}],
+
+ # When printing output delimiters, and with one or more ranges subsumed
+ # by a to-EOL range, cut 8.20 and earlier would print extraneous delimiters.
+ ['EOL-subsumed-1', '--output-d=: -b2-,3,4-4,5',
+ {IN=>"123456\n"}, {OUT=>"23456\n"}],
+ ['EOL-subsumed-2', '--output-d=: -b3,4-4,5,2-',
+ {IN=>"123456\n"}, {OUT=>"23456\n"}],
+ ['EOL-subsumed-3', '--complement -b3,4-4,5,2-',
+ {IN=>"123456\n"}, {OUT=>"1\n"}],
);
if ($mb_locale ne 'C')
@@ -171,18 +223,6 @@ if ($mb_locale ne 'C')
my @new_t = @$t;
my $test_name = shift @new_t;
- # Depending on whether cut is multi-byte-patched,
- # it emits different diagnostics:
- # non-MB: invalid byte or field list
- # MB: invalid byte, character or field list
- # Adjust the expected error output accordingly.
- if (grep {ref $_ eq 'HASH' && exists $_->{ERR} && $_->{ERR} eq $inval}
- (@new_t))
- {
- my $sub = {ERR_SUBST => 's/, character//'};
- push @new_t, $sub;
- push @$t, $sub;
- }
push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
}
push @Tests, @new;
diff --git a/tests/misc/date-next-dow b/tests/misc/date-next-dow.pl
index 7c85d238..3c79e22a 100755
--- a/tests/misc/date-next-dow
+++ b/tests/misc/date-next-dow.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "date".
-# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+# Copyright (C) 2005-2013 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 b/tests/misc/date-sec.sh
index a46b4790..67048c13 100755
--- a/tests/misc/date-sec
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2004-2013 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
@@ -18,7 +18,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ date
diff --git a/tests/misc/date b/tests/misc/date.pl
index 8a23ca9c..d0b3517c 100755
--- a/tests/misc/date
+++ b/tests/misc/date.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "date".
-# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+# Copyright (C) 2005-2013 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
@@ -282,6 +282,11 @@ my @Tests =
# most others print 'WED DEC 8 07:30:00 1999'.
{OUT_SUBST => 's/ [ 0]8.*//'},
{OUT=>'WED DEC'}],
+
+ ['invalid-high-bit-set', "-d '\xb0'",
+ {ERR => "date: invalid date '\\260'\n"},
+ {EXIT => 1},
+ ],
);
# Repeat the cross-dst test, using Jan 1, 2005 and every interval from 1..364.
diff --git a/tests/misc/df b/tests/misc/df
deleted file mode 100755
index 4fc626e8..00000000
--- a/tests/misc/df
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-# Ensure that "df ." outputs a header.
-
-# Copyright (C) 2006-2012 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=.}/init.sh"; path_prepend_ ../src
-print_ver_ df
-
-case $(df .) in
-*'
-'*) ;;
-*) fail=1;;
-esac
-
-Exit $fail
diff --git a/tests/misc/df-P b/tests/misc/df-P
deleted file mode 100755
index dfce4141..00000000
--- a/tests/misc/df-P
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-# Ensure that df -P is not affected by BLOCK_SIZE settings
-
-# Copyright (C) 2007-2012 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=.}/init.sh"; path_prepend_ ../src
-print_ver_ df
-
-
- df -P . > t1 || fail=1
-BLOCK_SIZE=1M df -P . > t2 || fail=1
-
-# Since disk utilization may be changing, compare only df's header line.
-# That records the block size. E.g., for "1M", it would be:
-# Filesystem 1048576-blocks Used Available Capacity Mounted on
-# while for 1K, it would be
-# Filesystem 1024-blocks Used Available Capacity Mounted on
-
-head -n1 t1 > exp || fail=1
-head -n1 t2 > out || fail=1
-
-compare exp out || fail=1
-
-Exit $fail
diff --git a/tests/misc/dircolors b/tests/misc/dircolors.pl
index e2a703e3..061e372f 100755
--- a/tests/misc/dircolors
+++ b/tests/misc/dircolors.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Simple dircolors tests.
-# Copyright (C) 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1998-2013 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 b/tests/misc/dirname.pl
index 00218367..43182a8c 100755
--- a/tests/misc/dirname
+++ b/tests/misc/dirname.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "dirname".
-# Copyright (C) 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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 b/tests/misc/env-null.sh
index 0190bf41..3cbbcbd5 100755
--- a/tests/misc/env-null
+++ b/tests/misc/env-null.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify behavior of env -0 and printenv -0.
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ env printenv
# POSIX is clear that environ may, but need not be, sorted.
diff --git a/tests/misc/env b/tests/misc/env.sh
index 6f8c064c..7c9e8fdc 100755
--- a/tests/misc/env
+++ b/tests/misc/env.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify behavior of env.
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ env
diff --git a/tests/misc/expand b/tests/misc/expand.pl
index 581a912d..30be9f91 100755
--- a/tests/misc/expand
+++ b/tests/misc/expand.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Exercise expand.
-# Copyright (C) 2004-2012 Free Software Foundation, Inc.
+# Copyright (C) 2004-2013 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 b/tests/misc/expr.pl
index c298d4c2..9b957a5c 100755
--- a/tests/misc/expr
+++ b/tests/misc/expr.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Basic tests for "expr".
-# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 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 b/tests/misc/factor.pl
index 47f93430..042a8469 100755
--- a/tests/misc/factor
+++ b/tests/misc/factor.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Basic tests for "factor".
-# Copyright (C) 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1998-2013 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
@@ -28,6 +28,7 @@ my @Tests =
(
['1', '9', {OUT => '3 3'}],
['1a', '7', {OUT => '7'}],
+ ['1b', ' +7', {OUT => '7'}],
['2', '4294967291', {OUT => '4294967291'}],
['3', '4294967292', {OUT => '2 2 3 3 7 11 31 151 331'}],
['4', '4294967293', {OUT => '9241 464773'}],
@@ -67,8 +68,23 @@ my @Tests =
{OUT => "4: 2 2\n"},
{ERR => "$prog: 'a' is not a valid positive integer\n"},
{EXIT => 1}],
+ ['bug-2012-a', '465658903', {OUT => '15259 30517'}],
+ ['bug-2012-b', '2242724851', {OUT => '33487 66973'}],
+ ['bug-2012-c', '6635692801', {OUT => '57601 115201'}],
+ ['bug-2012-d', '17709149503', {OUT => '94099 188197'}],
+ ['bug-2012-e', '17754345703', {OUT => '94219 188437'}],
);
+# If we have GMP support, append tests to exercise it.
+(system "grep '^#define HAVE_GMP 1' $ENV{CONFIG_HEADER} > /dev/null") == 0
+ and push (@Tests,
+ ['bug-gmp-2_sup_128', '340282366920938463463374607431768211456',
+ {OUT => '2 'x127 . '2'}],
+ ['bug-gmp-2_sup_256',
+ '115792089237316195423570985008687907853'
+ . '269984665640564039457584007913129639936',
+ {OUT => '2 'x255 . '2'}]);
+
# Prepend the command line argument and append a newline to end
# of each expected 'OUT' string.
my $t;
@@ -76,7 +92,7 @@ my $t;
Test:
foreach $t (@Tests)
{
- my $arg1 = $t->[1];
+ (my $arg1 = $t->[1]) =~ s| *\+?||;
# Don't fiddle with expected OUT string if there's a nonzero exit status.
foreach my $e (@$t)
diff --git a/tests/misc/false-status b/tests/misc/false-status.sh
index d192bbd7..33afc0f3 100755
--- a/tests/misc/false-status
+++ b/tests/misc/false-status.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure that false exits nonzero even with --help or --version
-# Copyright (C) 2003-2012 Free Software Foundation, Inc.
+# Copyright (C) 2003-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ false
false --version > /dev/null && fail=1
diff --git a/tests/misc/fold b/tests/misc/fold.pl
index 8291a70e..1d197bb4 100755
--- a/tests/misc/fold
+++ b/tests/misc/fold.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Exercise fold.
-# Copyright (C) 2003-2012 Free Software Foundation, Inc.
+# Copyright (C) 2003-2013 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 b/tests/misc/groups-dash.sh
index 24e7b9a7..598c3164 100755
--- a/tests/misc/groups-dash
+++ b/tests/misc/groups-dash.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure groups handles -- sanely
-# Copyright (C) 2007-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ groups
require_built_ groups
diff --git a/tests/misc/groups-version b/tests/misc/groups-version.sh
index 9a8bf392..5f87b325 100755
--- a/tests/misc/groups-version
+++ b/tests/misc/groups-version.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure groups --version output is similar to id --version
-# Copyright (C) 2007-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ groups
require_built_ groups
diff --git a/tests/misc/head-c b/tests/misc/head-c.sh
index 32f86d2f..6807c4d5 100755
--- a/tests/misc/head-c
+++ b/tests/misc/head-c.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise the fix of 2001-08-18, based on test case from Ian Bruce
-# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ head
echo abc > in || framework_failure_
diff --git a/tests/misc/head-elide-tail b/tests/misc/head-elide-tail.pl
index de4896bc..71e00c6c 100755
--- a/tests/misc/head-elide-tail
+++ b/tests/misc/head-elide-tail.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Exercise head's --bytes=-N option.
-# Copyright (C) 2003-2012 Free Software Foundation, Inc.
+# Copyright (C) 2003-2013 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,7 +26,7 @@ $ENV{PROG} = 'head';
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
# This should match the definition in head.c.
-my $READ_BUFSIZE = 4096;
+my $READ_BUFSIZE = 8192;
my @Tests =
(
diff --git a/tests/misc/head-pos b/tests/misc/head-pos.sh
index 3d96261f..cb08d72e 100755
--- a/tests/misc/head-pos
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 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,16 +17,28 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ head
(echo a; echo b) > in || framework_failure_
-
-(head -n 1 >/dev/null; cat) < in > out || fail=1
-cat <<EOF > exp
-b
-EOF
-
-compare exp out || fail=1
+echo b > exp || framework_failure_
+
+for i in -1 1; do
+ (head -n $i >/dev/null; cat) < in > out || fail=1
+ compare exp out || fail=1
+done
+
+# Exercise the (start_pos < pos) block in elide_tail_lines_seekable.
+# So far, this is the only test to do that.
+# Do that by creating a file larger than BUFSIZ (I've seen 128K) and
+# elide a suffix of it (by line count) that is also larger than BUFSIZ.
+# 50000 lines times 6 bytes per line gives us enough leeway even on a
+# system with a BUFSIZ of 256K.
+n_lines=50000
+seq 70000 > in2 || framework_failure_
+echo $n_lines > exp-n || framework_failure_
+
+(head -n-$n_lines>/dev/null; wc -l) < in2 > n
+compare exp-n n || fail=1
Exit $fail
diff --git a/tests/misc/head b/tests/misc/head.pl
index 2355e6ab..d92a0a5c 100755
--- a/tests/misc/head
+++ b/tests/misc/head.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# test head
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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 b/tests/misc/help-version.sh
index 7416062f..00f30cd0 100755
--- a/tests/misc/help-version
+++ b/tests/misc/help-version.sh
@@ -1,8 +1,8 @@
#! /bin/sh
-# Make sure all these programs work properly
+# Make sure all of these programs work properly
# when invoked with --help or --version.
-# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+# Copyright (C) 2000-2013 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,14 +23,13 @@
test "x$SHELL" = x && SHELL=/bin/sh
export SHELL
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
expected_failure_status_chroot=125
expected_failure_status_env=125
expected_failure_status_nice=125
expected_failure_status_nohup=125
expected_failure_status_stdbuf=125
-expected_failure_status_su=125
expected_failure_status_timeout=125
expected_failure_status_printenv=2
expected_failure_status_tty=3
@@ -208,7 +207,6 @@ nohup_setup () { args=--version; }
printf_setup () { args=foo; }
seq_setup () { args=10; }
sleep_setup () { args=0; }
-su_setup () { args=--version; }
stdbuf_setup () { args="-oL true"; }
timeout_setup () { args=--version; }
diff --git a/tests/misc/id-context b/tests/misc/id-context.sh
index 73645a0e..dc023033 100755
--- a/tests/misc/id-context
+++ b/tests/misc/id-context.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Ensure that "id" outputs SELinux context only without specified user
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -15,7 +15,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ id
# Require selinux - when selinux is disabled, id never prints scontext.
require_selinux_
diff --git a/tests/misc/id-groups b/tests/misc/id-groups.sh
index 815dd552..ff3dc59f 100755
--- a/tests/misc/id-groups
+++ b/tests/misc/id-groups.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Ensure that "id" outputs groups for a user
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -15,7 +15,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ id
id -G $(id -nu) || fail=1
diff --git a/tests/misc/id-setgid b/tests/misc/id-setgid.sh
index 12fab381..f29eec07 100755
--- a/tests/misc/id-setgid
+++ b/tests/misc/id-setgid.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify that id -G prints the right group when run set-GID.
-# Copyright (C) 2012 Free Software Foundation, Inc.
+# Copyright (C) 2012-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ id
require_root_
diff --git a/tests/misc/invalid-opt b/tests/misc/invalid-opt.pl
index 8eae3c27..1d7701f0 100755
--- a/tests/misc/invalid-opt
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -36,7 +36,6 @@ my %exit_status =
nohup => 125,
sort => 2,
stdbuf => 125,
- su => 125,
test => 0,
timeout => 125,
true => 0,
diff --git a/tests/misc/join b/tests/misc/join.pl
index a3fd1a8f..9b93794d 100755
--- a/tests/misc/join
+++ b/tests/misc/join.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test join.
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -147,6 +147,10 @@ my @tv = (
["a,1,,2\nb,1,2\n", "a,3,4\nb,3,4\n"],
"a,1,,2,3,4\nb,1,2,,3,4\n"],
+# For -v2, print the match field correctly with the default output format,
+# when that match field is different between file 1 and file 2. Fixed in 8.10
+['v2-order', '-v2 -2 2', ["", "2 1\n"], "1 2\n", 0],
+
# From Tim Smithers: fixed in 1.22l
['trailing-sp', '-t: -1 1 -2 1', ["a:x \n", "a:y \n"], "a:x :y \n", 0],
diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc.pl
index 71647f9d..5bf7b9eb 100755
--- a/tests/misc/ls-misc
+++ b/tests/misc/ls-misc.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1998-2013 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
@@ -263,6 +263,21 @@ my @Tests =
{POST => sub {unlink 's' or die "s: $!\n";
restore_ls_colors; }},
],
+ # 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
+ # rather than the symlink directly.
+ ['sl-dangle9', '--color=always d',
+ {OUT => "$e\e[1;36ms$e\n"},
+ {PRE => sub {mkdir 'd',0755 or die "d: $!\n";
+ symlink 'dangle', 'd/s' or die "d/s: $!\n";
+ push_ls_colors('ln=1;36:or=:')
+ }},
+ {POST => sub {unlink 'd/s' or die "d/s: $!\n";
+ rmdir 'd' or die "d: $!\n";
+ restore_ls_colors; }},
+ ],
# Test for a bug that was introduced in coreutils-4.5.4; fixed in 4.5.5.
# To demonstrate it, the file in question (with executable bit set)
diff --git a/tests/misc/ls-time b/tests/misc/ls-time.sh
index 7d1f205f..80e400f4 100755
--- a/tests/misc/ls-time
+++ b/tests/misc/ls-time.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test some of ls's sorting options.
-# Copyright (C) 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1998-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ ls
# Avoid any possible glitches due to daylight-saving changes near the
diff --git a/tests/misc/md5sum-bsd b/tests/misc/md5sum-bsd
deleted file mode 100755
index 8226d7ab..00000000
--- a/tests/misc/md5sum-bsd
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-# make sure 'md5sum -c' works for alternate BSD format (md5 -r)
-
-# Copyright (C) 2011-2012 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=.}/init.sh"; path_prepend_ ../src
-print_ver_ md5sum
-
-# Note we start this list with a name
-# that's unambiguous in BSD format.
-# I.E. one not starting with ' ' or '*'
-for i in 'a' ' b' '*c' 'dd' ' '; do
- echo "$i" > "$i"
- md5sum "$i" >> check.md5sum
-done
-sed 's/ / /' check.md5sum > check.md5
-
-# Note only a single format is supported per run
-md5sum --strict -c check.md5sum || fail=1
-md5sum --strict -c check.md5 || fail=1
-
-# If we skip the first entry in the BSD format checksums
-# 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
-
-Exit $fail
diff --git a/tests/misc/md5sum-bsd.sh b/tests/misc/md5sum-bsd.sh
new file mode 100755
index 00000000..6b70f21a
--- /dev/null
+++ b/tests/misc/md5sum-bsd.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+# 'md5sum' tests for generation and checking of
+# BSD traditional and alternate formats (md5 [-r])
+
+# Copyright (C) 2011-2013 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_ md5sum
+
+## BSD alternate format tests ##
+
+# 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 '*'
+for i in 'a' ' b' '*c' 'dd' ' '; do
+ echo "$i" > "$i"
+ md5sum "$i" >> check.md5sum
+done
+sed 's/ / /' check.md5sum > check.md5
+
+# Note only a single format is supported per run
+md5sum --strict -c check.md5sum || fail=1
+md5sum --strict -c check.md5 || fail=1
+
+# If we skip the first entry in the BSD format checksums
+# 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
+
+
+## BSD traditional format tests (--tag option) ##
+
+# Ensure --tag and --check are mutually exclusive
+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
+
+# Ensure we can --check BSD traditional format we produce
+rm check.md5
+for i in 'a' ' b' '*c' 'dd' ' '; do
+ echo "$i" > "$i"
+ md5sum --tag "$i" >> check.md5
+done
+md5sum --strict -c check.md5 || fail=1
+
+# Ensure we can --check BSD traditional format we produce
+# with the GNU extension of escaped newlines
+nl='
+'
+tab=' '
+rm check.md5
+for i in 'a\b' 'a\' "a${nl}b" "a${tab}b"; do
+ :> "$i"
+ md5sum --tag "$i" >> check.md5
+done
+md5sum --strict -c check.md5 || fail=1
+
+# Ensure BSD traditional format with GNU extension escapes
+# is in the expected format
+ex_file='test
+\\file'
+ex_output='\MD5 (test\n\\\\file) = d41d8cd98f00b204e9800998ecf8427e'
+touch "$ex_file"
+printf "%s\n" "$ex_output" > exp
+md5sum --tag "$ex_file" > out
+compare exp out || fail=1
+
+Exit $fail
diff --git a/tests/misc/md5sum-newline b/tests/misc/md5sum-newline.pl
index 777241ff..ad1b6acb 100755
--- a/tests/misc/md5sum-newline
+++ b/tests/misc/md5sum-newline.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Newline tests for "md5sum".
-# Copyright (C) 1999-2012 Free Software Foundation, Inc.
+# Copyright (C) 1999-2013 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 b/tests/misc/md5sum-parallel.sh
index 0bf5fa9c..648bfa5b 100755
--- a/tests/misc/md5sum-parallel
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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,7 +17,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ md5sum
(mkdir tmp && cd tmp && seq 500 | xargs touch)
diff --git a/tests/misc/md5sum b/tests/misc/md5sum.pl
index 946eee86..5192d55f 100755
--- a/tests/misc/md5sum
+++ b/tests/misc/md5sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Basic tests for "md5sum".
-# Copyright (C) 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1998-2013 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 b/tests/misc/mknod.sh
index b9e33ad2..30f363f6 100755
--- a/tests/misc/mknod
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2004-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ mknod
# Ensure fifos are supported
diff --git a/tests/misc/mktemp b/tests/misc/mktemp.pl
index 49dfde49..b15b6694 100755
--- a/tests/misc/mktemp
+++ b/tests/misc/mktemp.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "mktemp".
-# Copyright (C) 2007-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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 b/tests/misc/nice-fail.sh
index 599c981f..3e054354 100755
--- a/tests/misc/nice-fail
+++ b/tests/misc/nice-fail.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify that internal failure in nice gives exact status.
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ nice
diff --git a/tests/misc/nice b/tests/misc/nice.sh
index ac8ea04e..acee0f44 100755
--- a/tests/misc/nice
+++ b/tests/misc/nice.sh
@@ -1,7 +1,7 @@
#! /bin/sh
# Test "nice".
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ nice
tests='
diff --git a/tests/misc/nl b/tests/misc/nl.sh
index b5a4ac63..dfa7b237 100755
--- a/tests/misc/nl
+++ b/tests/misc/nl.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise nl functionality
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ nl
diff --git a/tests/misc/nohup b/tests/misc/nohup.sh
index 76f676d8..91d9e6a2 100755
--- a/tests/misc/nohup
+++ b/tests/misc/nohup.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# test nohup
-# Copyright (C) 2003-2012 Free Software Foundation, Inc.
+# Copyright (C) 2003-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ nohup
diff --git a/tests/misc/nproc-avail b/tests/misc/nproc-avail.sh
index cf0846cc..8b0e8dcb 100755
--- a/tests/misc/nproc-avail
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ nproc
all=$(nproc --all)
diff --git a/tests/misc/nproc-positive b/tests/misc/nproc-positive.sh
index d930fb89..d82dc930 100755
--- a/tests/misc/nproc-positive
+++ b/tests/misc/nproc-positive.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that nproc prints a number > 0
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ nproc
for mode in --all ''; do
diff --git a/tests/misc/numfmt.pl b/tests/misc/numfmt.pl
new file mode 100644
index 00000000..61917fb8
--- /dev/null
+++ b/tests/misc/numfmt.pl
@@ -0,0 +1,950 @@
+#!/usr/bin/perl
+# Basic tests for "numfmt".
+
+# Copyright (C) 2012 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/>.
+
+use strict;
+
+(my $program_name = $0) =~ s|.*/||;
+my $prog = 'numfmt';
+
+# TODO: add localization tests with "grouping"
+# Turn off localization of executable's output.
+@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+
+my $locale = $ENV{LOCALE_FR_UTF8};
+! defined $locale || $locale eq 'none'
+ and $locale = 'C';
+
+my @Tests =
+ (
+ ['1', '1234', {OUT => "1234"}],
+ ['2', '--from=si 1K', {OUT => "1000"}],
+ ['3', '--from=iec 1K', {OUT => "1024"}],
+ ['4', '--from=auto 1K', {OUT => "1000"}],
+ ['5', '--from=auto 1Ki', {OUT => "1024"}],
+ ['5.1', '--from=iec-i 1Ki', {OUT => "1024"}],
+
+ ['6', {IN_PIPE => "1234\n"}, {OUT => "1234"}],
+ ['7', '--from=si', {IN_PIPE => "2K\n"}, {OUT => "2000"}],
+ ['7a', '--invalid=fail', {IN_PIPE => "no_NL"}, {OUT => "no_NL"},
+ {ERR => "$prog: invalid number: 'no_NL'\n"},
+ {EXIT => '2'}],
+
+ ['8', '--to=si 2000', {OUT => "2.0K"}],
+ ['9', '--to=si 2001', {OUT => "2.1K"}],
+ ['10', '--to=si 1999', {OUT => "2.0K"}],
+ ['11', '--to=si --round=down 2001', {OUT => "2.0K"}],
+ ['12', '--to=si --round=down 1999', {OUT => "1.9K"}],
+ ['13', '--to=si --round=up 1901', {OUT => "2.0K"}],
+ ['14', '--to=si --round=down 1901', {OUT => "1.9K"}],
+ ['15', '--to=si --round=nearest 1901', {OUT => "1.9K"}],
+ ['16', '--to=si --round=nearest 1945', {OUT => "1.9K"}],
+ ['17', '--to=si --round=nearest 1955', {OUT => "2.0K"}],
+
+ ['18', '--to=iec 2048', {OUT => "2.0K"}],
+ ['19', '--to=iec 2049', {OUT => "2.1K"}],
+ ['20', '--to=iec 2047', {OUT => "2.0K"}],
+ ['21', '--to=iec --round=down 2049', {OUT => "2.0K"}],
+ ['22', '--to=iec --round=down 2047', {OUT => "1.9K"}],
+ ['23', '--to=iec --round=up 2040', {OUT => "2.0K"}],
+ ['24', '--to=iec --round=down 2040', {OUT => "1.9K"}],
+ ['25', '--to=iec --round=nearest 1996', {OUT => "1.9K"}],
+ ['26', '--to=iec --round=nearest 1997', {OUT => "2.0K"}],
+ ['27', '--to=iec-i 2048', {OUT => "2.0Ki"}],
+
+ ['neg-1', '-- -1234', {OUT => "-1234"}],
+ ['neg-2', '--padding=5 -- -1234', {OUT => "-1234"}],
+ ['neg-3', '--padding=6 -- -1234', {OUT => " -1234"}],
+ ['neg-4', '--to=iec -- 9100 -9100', {OUT => "8.9K\n-8.9K"}],
+ ['neg-5', '-- -0.1', {OUT => "-0.1"}],
+ ['neg-6', '-- -0', {OUT => "0"}],
+ ['neg-7', '-- -0.-1',
+ {ERR => "$prog: invalid number: '-0.-1'\n"},
+ {EXIT => '2'}],
+
+ ['float-1', '1.1', {OUT => "1.1"}],
+ ['float-2', '1.22', {OUT => "1.22"}],
+ ['float-3', '1.22.',
+ {ERR => "$prog: invalid suffix in input: '1.22.'\n"},
+ {EXIT => '2'}],
+
+ ['unit-1', '--from-unit=512 4', {OUT => "2048"}],
+ ['unit-2', '--to-unit=512 2048', {OUT => "4"}],
+ ['unit-3', '--from-unit=512 --from=si 4M', {OUT => "2048000000"}],
+ ['unit-4', '--from-unit=512 --from=iec --to=iec 4M', {OUT => "2.0G"}],
+ ['unit-5', '--from-unit=AA --from=iec --to=iec 4M',
+ {ERR => "$prog: invalid unit size: 'AA'\n"},
+ {EXIT => '1'}],
+ ['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"},
+ {EXIT => '1'}],
+ ['unit-9', '--from-unit=0 1',
+ {ERR => "$prog: invalid unit size: '0'\n"},
+ {EXIT => '1'}],
+ ['unit-10', '--to-unit=0 1',
+ {ERR => "$prog: invalid unit size: '0'\n"},
+ {EXIT => '1'}],
+
+ # Test Suffix logic
+ ['suf-1', '4000', {OUT=>'4000'}],
+ ['suf-2', '4Q',
+ {ERR => "$prog: invalid suffix in input: '4Q'\n"},
+ {EXIT => '2'}],
+ ['suf-2.1', '4M',
+ {ERR => "$prog: rejecting suffix " .
+ "in input: '4M' (consider using --from)\n"},
+ {EXIT => '2'}],
+ ['suf-3', '--from=si 4M', {OUT=>'4000000'}],
+ ['suf-4', '--from=si 4Q',
+ {ERR => "$prog: invalid suffix in input: '4Q'\n"},
+ {EXIT => '2'}],
+ ['suf-5', '--from=si 4MQ',
+ {ERR => "$prog: invalid suffix in input '4MQ': 'Q'\n"},
+ {EXIT => '2'}],
+
+ ['suf-6', '--from=iec 4M', {OUT=>'4194304'}],
+ ['suf-7', '--from=auto 4M', {OUT=>'4000000'}],
+ ['suf-8', '--from=auto 4Mi', {OUT=>'4194304'}],
+ ['suf-9', '--from=auto 4MiQ',
+ {ERR => "$prog: invalid suffix in input '4MiQ': 'Q'\n"},
+ {EXIT => '2'}],
+ ['suf-10', '--from=auto 4QiQ',
+ {ERR => "$prog: invalid suffix in input: '4QiQ'\n"},
+ {EXIT => '2'}],
+
+ # characters after a white space are OK - printed as-is
+ ['suf-11', '"4 M"', {OUT=>'4 M'}],
+
+ # Custom suffix
+ ['suf-12', '--suffix=Foo 70Foo', {OUT=>'70Foo'}],
+ ['suf-13', '--suffix=Foo 70', {OUT=>'70Foo'}],
+ ['suf-14', '--suffix=Foo --from=si 70K', {OUT=>'70000Foo'}],
+ ['suf-15', '--suffix=Foo --from=si 70KFoo', {OUT=>'70000Foo'}],
+ ['suf-16', '--suffix=Foo --to=si 7000Foo', {OUT=>'7.0KFoo'}],
+ ['suf-17', '--suffix=Foo --to=si 7000Bar',
+ {ERR => "$prog: invalid suffix in input: '7000Bar'\n"},
+ {EXIT => '2'}],
+ ['suf-18', '--suffix=Foo --to=si 7000FooF',
+ {ERR => "$prog: invalid suffix in input: '7000FooF'\n"},
+ {EXIT => '2'}],
+ # space(s) between number and suffix. Note only field 1 is used
+ # by default so specify the NUL delimiter to consider the whole "line".
+ ['suf-19', "-d '' --from=si '4.0 K'", {OUT => "4000"}],
+
+ ## GROUPING
+
+ # "C" locale - no grouping (locale-specific tests, below)
+ ['grp-1', '--from=si --grouping 7M', {OUT=>'7000000'}],
+ ['grp-2', '--from=si --to=si --grouping 7M',
+ {ERR => "$prog: grouping cannot be combined with --to\n"},
+ {EXIT => '1'}],
+
+
+ ## Padding
+ ['pad-1', '--padding=10 5', {OUT=>' 5'}],
+ ['pad-2', '--padding=-10 5', {OUT=>'5 '}],
+ ['pad-3', '--padding=A 5',
+ {ERR => "$prog: invalid padding value 'A'\n"},
+ {EXIT => '1'}],
+ ['pad-3.1', '--padding=0 5',
+ {ERR => "$prog: invalid padding value '0'\n"},
+ {EXIT => '1'}],
+ ['pad-4', '--padding=10 --to=si 50000', {OUT=>' 50K'}],
+ ['pad-5', '--padding=-10 --to=si 50000', {OUT=>'50K '}],
+
+ # padding too narrow
+ ['pad-6', '--padding=2 --to=si 1000', {OUT=>'1.0K'}],
+
+
+ # Padding + suffix
+ ['pad-7', '--padding=10 --suffix=foo --to=si 50000',
+ {OUT=>' 50Kfoo'}],
+ ['pad-8', '--padding=-10 --suffix=foo --to=si 50000',
+ {OUT=>'50Kfoo '}],
+
+
+ # Delimiters
+ ['delim-1', '--delimiter=: --from=auto 40M:', {OUT=>'40000000:'}],
+ ['delim-2', '--delimiter="" --from=auto "40 M"',{OUT=>'40000000'}],
+ ['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"}],
+
+ #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"',
+ {ERR=>"$prog: invalid number: 'World'\n"},
+ {EXIT => 2},],
+ # Last field - no text after number
+ ['field-4', '--field 4 --from=auto "Hello 40M World 90G"',
+ {OUT=>"Hello 40M World 90000000000"}],
+ # Last field - a delimiter after the number
+ ['field-5', '--field 4 --from=auto "Hello 40M World 90G "',
+ {OUT=>"Hello 40M World 90000000000 "}],
+
+ # Mix Fields + Delimiters
+ ['field-6', '--delimiter=: --field 2 --from=auto "Hello:40M:World:90G"',
+ {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"}],
+
+ # Auto-consume white-space, setup auto-padding
+ ['whitespace-1', '--to=si --field 2 "A 500 B"', {OUT=>"A 500 B"}],
+ ['whitespace-2', '--to=si --field 2 "A 5000 B"', {OUT=>"A 5.0K B"}],
+ ['whitespace-3', '--to=si " 500"', {OUT=>" 500"}],
+ ['whitespace-4', '--to=si " 6500"', {OUT=>" 6.5K"}],
+ # NOTE: auto-padding is not enabled if the value is on the first
+ # field and there's no white-space before it.
+ ['whitespace-5', '--to=si "6000000"', {OUT=>"6.0M"}],
+ # but if there is whitespace, assume auto-padding is desired.
+ ['whitespace-6', '--to=si " 6000000"', {OUT=>" 6.0M"}],
+
+ # auto-padding - lines have same padding-width
+ # (padding_buffer will be alloc'd just once)
+ ['whitespace-7', '--to=si --field 2',
+ {IN_PIPE=>"rootfs 100000\n" .
+ "udevxx 2000000\n"},
+ {OUT =>"rootfs 100K\n" .
+ "udevxx 2.0M"}],
+ # auto-padding - second line requires a
+ # larger padding (padding-buffer needs to be realloc'd)
+ ['whitespace-8', '--to=si --field 2',
+ {IN_PIPE=>"rootfs 100000\n" .
+ "udev 20000000\n"},
+ {OUT =>"rootfs 100K\n" .
+ "udev 20M"}],
+
+
+ # Corner-cases:
+ # weird mix of identical suffix,delimiters
+ # The priority is:
+ # 1. delimiters (and fields) are parsed (in process_line()
+ # 2. optional custom suffix is removed (in process_suffixed_number())
+ # 3. Remaining suffixes must be valid SI/IEC (in human_xstrtol())
+
+ # custom suffix comes BEFORE SI/IEC suffix,
+ # so these are 40 of "M", not 40,000,000.
+ ['mix-1', '--suffix=M --from=si 40M', {OUT=>"40M"}],
+
+ # These are fourty-million Ms .
+ ['mix-2', '--suffix=M --from=si 40MM', {OUT=>"40000000M"}],
+
+ ['mix-3', '--suffix=M --from=auto 40MM', {OUT=>"40000000M"}],
+ ['mix-4', '--suffix=M --from=auto 40MiM', {OUT=>"41943040M"}],
+ ['mix-5', '--suffix=M --to=si --from=si 4MM', {OUT=>"4.0MM"}],
+
+ # This might be confusing to the user, but it's legit:
+ # The M in the output is the custom suffix, not Mega.
+ ['mix-6', '--suffix=M 40', {OUT=>"40M"}],
+ ['mix-7', '--suffix=M 4000000', {OUT=>"4000000M"}],
+ ['mix-8', '--suffix=M --to=si 4000000', {OUT=>"4.0MM"}],
+
+ # The output 'M' is the custom suffix.
+ ['mix-10', '--delimiter=M --suffix=M 40', {OUT=>"40M"}],
+
+ # The INPUT 'M' is a delimiter (delimiters are top priority)
+ # The output contains one M for custom suffix, and one 'M' delimiter.
+ ['mix-11', '--delimiter=M --suffix=M 40M', {OUT=>"40MM"}],
+
+ # Same as above, the "M" is NOT treated as a mega SI prefix,
+ ['mix-12', '--delimiter=M --from=si --suffix=M 40M', {OUT=>"40MM"}],
+
+ # The 'M' is treated as a delimiter, and so the input value is '4000'
+ ['mix-13', '--delimiter=M --to=si --from=auto 4000M5000M9000',
+ {OUT=>"4.0KM5000M9000"}],
+ # 'M' is the delimiter, so the second input field is '5000'
+ ['mix-14', '--delimiter=M --field 2 --from=auto --to=si 4000M5000M9000',
+ {OUT=>"4000M5.0KM9000"}],
+
+
+
+ ## Header testing
+
+ # header - silently ignored with command line parameters
+ ['header-1', '--header --to=iec 4096', {OUT=>"4.0K"}],
+
+ # header warning with --debug
+ ['header-2', '--debug --header --to=iec 4096', {OUT=>"4.0K"},
+ {ERR=>"$prog: --header ignored with command-line input\n"}],
+
+ ['header-3', '--header=A',
+ {ERR=>"$prog: invalid header value 'A'\n"},
+ {EXIT => 1},],
+ ['header-4', '--header=0',
+ {ERR=>"$prog: invalid header value '0'\n"},
+ {EXIT => 1},],
+ ['header-5', '--header=-6',
+ {ERR=>"$prog: invalid header value '-6'\n"},
+ {EXIT => 1},],
+ ['header-6', '--debug --header --to=iec',
+ {IN_PIPE=>"size\n5000\n90000\n"},
+ {OUT=>"size\n4.9K\n88K"}],
+ ['header-7', '--debug --header=3 --to=iec',
+ {IN_PIPE=>"hello\nworld\nsize\n5000\n90000\n"},
+ {OUT=>"hello\nworld\nsize\n4.9K\n88K"}],
+ # header, but no actual content
+ ['header-8', '--header=2 --to=iec',
+ {IN_PIPE=>"hello\nworld\n"},
+ {OUT=>"hello\nworld"}],
+ # not enough header lines
+ ['header-9', '--header=3 --to=iec',
+ {IN_PIPE=>"hello\nworld\n"},
+ {OUT=>"hello\nworld"}],
+
+
+ ## human_strtod testing
+
+ # NO_DIGITS_FOUND
+ ['strtod-1', '--from=si "foo"',
+ {ERR=>"$prog: invalid number: 'foo'\n"},
+ {EXIT=> 2}],
+ ['strtod-2', '--from=si ""',
+ {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"},
+ {EXIT=>2}],
+ ['strtod-6', '--from=si 12.K',
+ {ERR=>"$prog: invalid number: '12.K'\n"},
+ {EXIT=>2}],
+
+ # whitespace is not allowed after decimal-point
+ ['strtod-6.1', '--from=si --delimiter=, "12. 2"',
+ {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"},
+ {EXIT=>2}],
+
+ # VALID_BUT_FORBIDDEN_SUFFIX
+ ['strtod-10', '12M',
+ {ERR => "$prog: rejecting suffix " .
+ "in input: '12M' (consider using --from)\n"},
+ {EXIT=>2}],
+
+ # MISSING_I_SUFFIX
+ ['strtod-11', '--from=iec-i 12M',
+ {ERR => "$prog: missing 'i' suffix in input: " .
+ "'12M' (e.g Ki/Mi/Gi)\n"},
+ {EXIT=>2}],
+
+ #
+ # Test double_to_human()
+ #
+
+ # 1K and smaller
+ ['dbl-to-human-1','--to=si 800', {OUT=>"800"}],
+ ['dbl-to-human-2','--to=si 0', {OUT=>"0"}],
+ ['dbl-to-human-2.1','--to=si 999', {OUT=>"999"}],
+ ['dbl-to-human-2.2','--to=si 1000', {OUT=>"1.0K"}],
+ #NOTE: the following are consistent with "ls -lh" output
+ ['dbl-to-human-2.3','--to=iec 999', {OUT=>"999"}],
+ ['dbl-to-human-2.4','--to=iec 1023', {OUT=>"1023"}],
+ ['dbl-to-human-2.5','--to=iec 1024', {OUT=>"1.0K"}],
+ ['dbl-to-human-2.6','--to=iec 1025', {OUT=>"1.1K"}],
+ ['dbl-to-human-2.7','--to=iec 0', {OUT=>"0"}],
+ # no "i" suffix if output has no suffix
+ ['dbl-to-human-2.8','--to=iec-i 0', {OUT=>"0"}],
+
+ # values resulting in "N.Nx" output
+ ['dbl-to-human-3','--to=si 8000', {OUT=>"8.0K"}],
+ ['dbl-to-human-3.1','--to=si 8001', {OUT=>"8.1K"}],
+ ['dbl-to-human-4','--to=si --round=down 8001', {OUT=>"8.0K"}],
+
+ ['dbl-to-human-5','--to=si --round=down 3500', {OUT=>"3.5K"}],
+ ['dbl-to-human-6','--to=si --round=nearest 3500', {OUT=>"3.5K"}],
+ ['dbl-to-human-7','--to=si --round=up 3500', {OUT=>"3.5K"}],
+
+ ['dbl-to-human-8','--to=si --round=down 3501', {OUT=>"3.5K"}],
+ ['dbl-to-human-9','--to=si --round=nearest 3501', {OUT=>"3.5K"}],
+ ['dbl-to-human-10','--to=si --round=up 3501', {OUT=>"3.6K"}],
+
+ ['dbl-to-human-11','--to=si --round=nearest 3550', {OUT=>"3.6K"}],
+ ['dbl-to-human-12','--to=si --from=si 999.89K', {OUT=>"1.0M"}],
+ ['dbl-to-human-13','--to=si --from=si 9.9K', {OUT=>"9.9K"}],
+ ['dbl-to-human-14','--to=si 9900', {OUT=>"9.9K"}],
+ ['dbl-to-human-15','--to=iec --from=si 3.3K', {OUT=>"3.3K"}],
+ ['dbl-to-human-16','--to=iec --round=down --from=si 3.3K', {OUT=>"3.2K"}],
+
+ # values resulting in 'NNx' output
+ ['dbl-to-human-17','--to=si 9999', {OUT=>"10K"}],
+ ['dbl-to-human-18','--to=si --round=down 35000', {OUT=>"35K"}],
+ ['dbl-to-human-19','--to=iec 35000', {OUT=>"35K"}],
+ ['dbl-to-human-20','--to=iec --round=down 35000', {OUT=>"34K"}],
+ ['dbl-to-human-21','--to=iec 35000000', {OUT=>"34M"}],
+ ['dbl-to-human-22','--to=iec --round=down 35000000', {OUT=>"33M"}],
+ ['dbl-to-human-23','--to=si 35000001', {OUT=>"36M"}],
+ ['dbl-to-human-24','--to=si --from=si 9.99M', {OUT=>"10M"}],
+ ['dbl-to-human-25','--to=si --from=iec 9.99M', {OUT=>"11M"}],
+ ['dbl-to-human-25.1','--to=iec 99999', {OUT=>"98K"}],
+
+ # values resulting in 'NNNx' output
+ ['dbl-to-human-26','--to=si 999000000000', {OUT=>"999G"}],
+ ['dbl-to-human-27','--to=iec 999000000000', {OUT=>"931G"}],
+ ['dbl-to-human-28','--to=si 123600000000000', {OUT=>"124T"}],
+ ['dbl-to-human-29','--to=si 998123', {OUT=>"999K"}],
+ ['dbl-to-human-30','--to=si --round=nearest 998123', {OUT=>"998K"}],
+ ['dbl-to-human-31','--to=si 99999', {OUT=>"100K"}],
+ ['dbl-to-human-32','--to=iec 102399', {OUT=>"100K"}],
+ ['dbl-to-human-33','--to=iec-i 102399', {OUT=>"100Ki"}],
+
+
+ # Default --round=from-zero
+ ['round-1','--to-unit=1024 -- 6000 -6000',
+ {OUT=>"6\n-6"}],
+ ['round-2','--to-unit=1024 -- 6000.0 -6000.0',
+ {OUT=>"5.9\n-5.9"}],
+ ['round-3','--to-unit=1024 -- 6000.00 -6000.00',
+ {OUT=>"5.86\n-5.86"}],
+ ['round-4','--to-unit=1024 -- 6000.000 -6000.000',
+ {OUT=>"5.860\n-5.860"}],
+ ['round-5','--to-unit=1024 -- 6000.0000 -6000.0000',
+ {OUT=>"5.8594\n-5.8594"}],
+ # --round=up
+ ['round-1-up','--round=up --to-unit=1024 -- 6000 -6000',
+ {OUT=>"6\n-5"}],
+ ['round-2-up','--round=up --to-unit=1024 -- 6000.0 -6000.0',
+ {OUT=>"5.9\n-5.8"}],
+ ['round-3-up','--round=up --to-unit=1024 -- 6000.00 -6000.00',
+ {OUT=>"5.86\n-5.85"}],
+ ['round-4-up','--round=up --to-unit=1024 -- 6000.000 -6000.000',
+ {OUT=>"5.860\n-5.859"}],
+ ['round-5-up','--round=up --to-unit=1024 -- 6000.0000 -6000.0000',
+ {OUT=>"5.8594\n-5.8593"}],
+ # --round=down
+ ['round-1-down','--round=down --to-unit=1024 -- 6000 -6000',
+ {OUT=>"5\n-6"}],
+ ['round-2-down','--round=down --to-unit=1024 -- 6000.0 -6000.0',
+ {OUT=>"5.8\n-5.9"}],
+ ['round-3-down','--round=down --to-unit=1024 -- 6000.00 -6000.00',
+ {OUT=>"5.85\n-5.86"}],
+ ['round-4-down','--round=down --to-unit=1024 -- 6000.000 -6000.000',
+ {OUT=>"5.859\n-5.860"}],
+ ['round-5-down','--round=down --to-unit=1024 -- 6000.0000 -6000.0000',
+ {OUT=>"5.8593\n-5.8594"}],
+ # --round=towards-zero
+ ['round-1-to-zero','--ro=towards-zero --to-u=1024 -- 6000 -6000',
+ {OUT=>"5\n-5"}],
+ ['round-2-to-zero','--ro=towards-zero --to-u=1024 -- 6000.0 -6000.0',
+ {OUT=>"5.8\n-5.8"}],
+ ['round-3-to-zero','--ro=towards-zero --to-u=1024 -- 6000.00 -6000.00',
+ {OUT=>"5.85\n-5.85"}],
+ ['round-4-to-zero','--ro=towards-zero --to-u=1024 -- 6000.000 -6000.000',
+ {OUT=>"5.859\n-5.859"}],
+ ['round-5-to-zero','--ro=towards-zero --to-u=1024 -- 6000.0000 -6000.0000',
+ {OUT=>"5.8593\n-5.8593"}],
+ # --round=nearest
+ ['round-1-near','--ro=nearest --to-u=1024 -- 6000 -6000',
+ {OUT=>"6\n-6"}],
+ ['round-2-near','--ro=nearest --to-u=1024 -- 6000.0 -6000.0',
+ {OUT=>"5.9\n-5.9"}],
+ ['round-3-near','--ro=nearest --to-u=1024 -- 6000.00 -6000.00',
+ {OUT=>"5.86\n-5.86"}],
+ ['round-4-near','--ro=nearest --to-u=1024 -- 6000.000 -6000.000',
+ {OUT=>"5.859\n-5.859"}],
+ ['round-5-near','--ro=nearest --to-u=1024 -- 6000.0000 -6000.0000',
+ {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"},
+ {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}],
+
+ # debug warnings
+ ['debug-1', '--debug 4096', {OUT=>"4096"},
+ {ERR=>"$prog: no conversion option specified\n"}],
+ # '--padding' is a valid conversion option - no warning should be printed
+ ['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.
+ ['devdebug-1', '---debug --from=si 4.9K', {OUT=>"4900"},
+ {ERR=>""},
+ {ERR_SUBST=>"s/.*//msg"}],
+ ['devdebug-2', '---debug 4900', {OUT=>"4900"},
+ {ERR=>""},
+ {ERR_SUBST=>"s/.*//msg"}],
+ ['devdebug-3', '---debug --from=auto 4Mi', {OUT=>"4194304"},
+ {ERR=>""},
+ {ERR_SUBST=>"s/.*//msg"}],
+ ['devdebug-4', '---debug --to=si 4000000', {OUT=>"4.0M"},
+ {ERR=>""},
+ {ERR_SUBST=>"s/.*//msg"}],
+ ['devdebug-5', '---debug --to=si --padding=5 4000000', {OUT=>" 4.0M"},
+ {ERR=>""},
+ {ERR_SUBST=>"s/.*//msg"}],
+ ['devdebug-6', '---debug --suffix=Foo 1234Foo', {OUT=>"1234Foo"},
+ {ERR=>""},
+ {ERR_SUBST=>"s/.*//msg"}],
+ ['devdebug-7', '---debug --suffix=Foo 1234', {OUT=>"1234Foo"},
+ {ERR=>""},
+ {ERR_SUBST=>"s/.*//msg"}],
+ ['devdebug-9', '---debug --grouping 10000', {OUT=>"10000"},
+ {ERR=>""},
+ {ERR_SUBST=>"s/.*//msg"}],
+ ['devdebug-10', '---debug --format %f 10000', {OUT=>"10000"},
+ {ERR=>""},
+ {ERR_SUBST=>"s/.*//msg"}],
+ ['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" .
+ "Try '$prog --help' for more information.\n"},
+ {EXIT=>1}],
+
+ ## Format string - check error detection
+ ['fmt-err-1', '--format ""',
+ {ERR=>"$prog: format '' has no % directive\n"},
+ {EXIT=>1}],
+ ['fmt-err-2', '--format "hello"',
+ {ERR=>"$prog: format 'hello' has no % directive\n"},
+ {EXIT=>1}],
+ ['fmt-err-3', '--format "hello%"',
+ {ERR=>"$prog: format 'hello%' ends in %\n"},
+ {EXIT=>1}],
+ ['fmt-err-4', '--format "%d"',
+ {ERR=>"$prog: invalid format '%d', " .
+ "directive must be %['][-][N]f\n"},
+ {EXIT=>1}],
+ ['fmt-err-5', '--format "% -43 f"',
+ {ERR=>"$prog: invalid format '% -43 f', " .
+ "directive must be %['][-][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'".
+ " (width overflow)\n"},
+ {EXIT=>1}],
+ ['fmt-err-8', '--format "%f" --padding 20',
+ {ERR=>"$prog: --padding cannot be combined with --format\n"},
+ {EXIT=>1}],
+ ['fmt-err-9', '--format "%f" --grouping',
+ {ERR=>"$prog: --grouping cannot be combined with --format\n"},
+ {EXIT=>1}],
+ ['fmt-err-10', '--format "%\'f" --to=si',
+ {ERR=>"$prog: grouping cannot be combined with --to\n"},
+ {EXIT=>1}],
+ ['fmt-err-11', '--debug --format "%\'f" 5000', {OUT=>"5000"},
+ {ERR=>"$prog: grouping has no effect in this locale\n"}],
+
+ ## Format string - check some corner cases
+ ['fmt-1', '--format "%% %f" 5000', {OUT=>"%%5000"}],
+ ['fmt-2', '--format "%f %%" 5000', {OUT=>"5000 %%"}],
+
+ ['fmt-3', '--format "--%f--" 5000000', {OUT=>"--5000000--"}],
+ ['fmt-4', '--format "--%f--" --to=si 5000000', {OUT=>"--5.0M--"}],
+
+ ['fmt-5', '--format "--%10f--" --to=si 5000000',{OUT=>"-- 5.0M--"}],
+ ['fmt-6', '--format "--%-10f--" --to=si 5000000',{OUT=>"--5.0M --"}],
+ ['fmt-7', '--format "--%10f--" 5000000',{OUT=>"-- 5000000--"}],
+ ['fmt-8', '--format "--%-10f--" 5000000',{OUT=>"--5000000 --"}],
+
+ # too-short width
+ ['fmt-9', '--format "--%5f--" 5000000',{OUT=>"--5000000--"}],
+
+ # Format + Suffix
+ ['fmt-10', '--format "--%10f--" --suffix Foo 50', {OUT=>"-- 50Foo--"}],
+ ['fmt-11', '--format "--%-10f--" --suffix Foo 50',{OUT=>"--50Foo --"}],
+
+ # Grouping in C locale - no grouping effect
+ ['fmt-12', '--format "%\'f" 50000',{OUT=>"50000"}],
+ ['fmt-13', '--format "%\'10f" 50000', {OUT=>" 50000"}],
+ ['fmt-14', '--format "%\'-10f" 50000',{OUT=>"50000 "}],
+
+ # Very large format strings
+ ['fmt-15', '--format "--%100000f--" --to=si 4200',
+ {OUT=>"--" . " " x 99996 . "4.2K--" }],
+
+
+ ## Check all errors again, this time with --invalid=fail
+ ## Input will be printed without conversion,
+ ## and exit code will be 2
+ ['ign-err-1', '--invalid=fail 4Q',
+ {ERR => "$prog: invalid suffix in input: '4Q'\n"},
+ {OUT => "4Q\n"},
+ {EXIT => 2}],
+ ['ign-err-2', '--invalid=fail 4M',
+ {ERR => "$prog: rejecting suffix " .
+ "in input: '4M' (consider using --from)\n"},
+ {OUT => "4M\n"},
+ {EXIT => 2}],
+ ['ign-err-3', '--invalid=fail --from=si 4MQ',
+ {ERR => "$prog: invalid suffix in input '4MQ': 'Q'\n"},
+ {OUT => "4MQ\n"},
+ {EXIT => 2}],
+ ['ign-err-4', '--invalid=fail --suffix=Foo --to=si 7000FooF',
+ {ERR => "$prog: invalid suffix in input: '7000FooF'\n"},
+ {OUT => "7000FooF\n"},
+ {EXIT => 2}],
+ ['ign-err-5','--invalid=fail --field 3 --from=auto "Hello 40M World 90G"',
+ {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"},
+ {EXIT=> 2}],
+ ['ign-err-8', '--invalid=fail 12M',
+ {ERR => "$prog: rejecting suffix " .
+ "in input: '12M' (consider using --from)\n"},
+ {OUT => "12M\n"},
+ {EXIT => 2}],
+ ['ign-err-9', '--invalid=fail --from=iec-i 12M',
+ {ERR => "$prog: missing 'i' suffix in input: " .
+ "'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',
+ {OUT => "1.0K\n2.0K\nbad\n3.0K"},
+ {EXIT => 0}],
+ ['ign-err-m1.1', '--invalid=ignore --to=si',
+ {IN_PIPE => "1000\n2000\nbad\n3000\n"},
+ {OUT => "1.0K\n2.0K\nbad\n3.0K"},
+ {EXIT => 0}],
+ ['ign-err-m1.3', '--invalid=fail --debug --to=si 1000 2000 3000',
+ {OUT => "1.0K\n2.0K\n3.0K"},
+ {EXIT => 0}],
+ ['ign-err-m2', '--invalid=fail --to=si 1000 Foo 3000',
+ {OUT => "1.0K\nFoo\n3.0K\n"},
+ {ERR => "$prog: invalid number: 'Foo'\n"},
+ {EXIT => 2}],
+ ['ign-err-m2.1', '--invalid=warn --to=si',
+ {IN_PIPE => "1000\nFoo\n3000\n"},
+ {OUT => "1.0K\nFoo\n3.0K"},
+ {ERR => "$prog: invalid number: 'Foo'\n"},
+ {EXIT => 0}],
+
+ # --debug will trigger a final warning at EOF
+ ['ign-err-m2.2', '--invalid=fail --debug --to=si 1000 Foo 3000',
+ {OUT => "1.0K\nFoo\n3.0K\n"},
+ {ERR => "$prog: invalid number: 'Foo'\n" .
+ "$prog: failed to convert some of the input numbers\n"},
+ {EXIT => 2}],
+
+ ['ign-err-m3', '--invalid=fail --field 2 --from=si --to=iec',
+ {IN_PIPE => "A 1K x\nB 2M y\nC 3G z\n"},
+ {OUT => "A 1000 x\nB 2.0M y\nC 2.8G z"},
+ {EXIT => 0}],
+ # invalid input on one of the fields
+ ['ign-err-m3.1', '--invalid=fail --field 2 --from=si --to=iec',
+ {IN_PIPE => "A 1K x\nB Foo y\nC 3G z\n"},
+ {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 @Locale_Tests =
+ (
+ # Locale that supports grouping, but without '--grouping' parameter
+ ['lcl-grp-1', '--from=si 7M', {OUT=>"7000000"},
+ {ENV=>"LC_ALL=$locale"}],
+
+ # Locale with grouping
+ ['lcl-grp-2', '--from=si --grouping 7M', {OUT=>"7 000 000"},
+ {ENV=>"LC_ALL=$locale"}],
+
+ # Locale with grouping and debug - no debug warning message
+ ['lcl-grp-3', '--from=si --debug --grouping 7M', {OUT=>"7 000 000"},
+ {ENV=>"LC_ALL=$locale"}],
+
+ # Input with locale'd decimal-point
+ ['lcl-stdtod-1', '--from=si 12,2K', {OUT=>"12200"},
+ {ENV=>"LC_ALL=$locale"}],
+
+ ['lcl-dbl-to-human-1', '--to=si 1100', {OUT=>"1,1K"},
+ {ENV=>"LC_ALL=$locale"}],
+
+ # Format + Grouping
+ ['lcl-fmt-1', '--format "%\'f" 50000',{OUT=>"50 000"},
+ {ENV=>"LC_ALL=$locale"}],
+ ['lcl-fmt-2', '--format "--%\'10f--" 50000', {OUT=>"-- 50 000--"},
+ {ENV=>"LC_ALL=$locale"}],
+ ['lcl-fmt-3', '--format "--%\'-10f--" 50000',{OUT=>"--50 000 --"},
+ {ENV=>"LC_ALL=$locale"}],
+ ['lcl-fmt-4', '--format "--%-10f--" --to=si 5000000',
+ {OUT=>"--5,0M --"},
+ {ENV=>"LC_ALL=$locale"}],
+
+ );
+if ($locale ne 'C')
+ {
+ # Reset locale to 'C' if LOCALE_FR_UTF8 doesn't output as expected
+ # as determined by the separate printf program.
+ open(LOC_NUM, "LC_ALL=$locale printf \"%'d\" 1234|")
+ or die "Can't fork command: $!";
+ my $loc_num = <LOC_NUM>;
+ close(LOC_NUM) || die "Failed to read grouped number from printf";
+ if ($loc_num ne '1 234')
+ {
+ warn "skipping locale grouping tests as 1234 groups like $loc_num\n";
+ $locale = 'C';
+ }
+ }
+push @Tests, @Locale_Tests if $locale ne 'C';
+
+## Check all valid/invalid suffixes
+foreach my $suf ( 'A' .. 'Z', 'a' .. 'z' ) {
+ if ( $suf =~ /^[KMGTPEZY]$/ )
+ {
+ push @Tests, ["auto-suf-si-$suf","--from=si --to=si 1$suf",
+ {OUT=>"1.0$suf"}];
+ push @Tests, ["auto-suf-iec-$suf","--from=iec --to=iec 1$suf",
+ {OUT=>"1.0$suf"}];
+ push @Tests, ["auto-suf-auto-$suf","--from=auto --to=iec 1${suf}i",
+ {OUT=>"1.0$suf"}];
+ push @Tests, ["auto-suf-iec-to-ieci-$suf","--from=iec --to=iec-i 1${suf}",
+ {OUT=>"1.0${suf}i"}];
+ push @Tests, ["auto-suf-ieci-to-iec-$suf",
+ "--from=iec-i --to=iec 1${suf}i",{OUT=>"1.0${suf}"}];
+ }
+ else
+ {
+ push @Tests, ["auto-suf-si-$suf","--from=si --to=si 1$suf",
+ {ERR=>"$prog: invalid suffix in input: '1${suf}'\n"},
+ {EXIT=>2}];
+ }
+}
+
+# Prepend the command line argument and append a newline to end
+# of each expected 'OUT' string.
+my $t;
+
+Test:
+foreach $t (@Tests)
+ {
+ # Don't fiddle with expected OUT string if there's a nonzero exit status.
+ foreach my $e (@$t)
+ {
+ ref $e eq 'HASH' && exists $e->{EXIT} && $e->{EXIT}
+ and next Test;
+ }
+
+ foreach my $e (@$t)
+ {
+ ref $e eq 'HASH' && exists $e->{OUT}
+ and $e->{OUT} .= "\n"
+ }
+ }
+
+my $save_temps = $ENV{SAVE_TEMPS};
+my $verbose = $ENV{VERBOSE};
+
+my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
+exit $fail;
diff --git a/tests/misc/od-N b/tests/misc/od-N.sh
index 00d956a5..8a741fb1 100755
--- a/tests/misc/od-N
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ od
echo abcdefg > in || framework_failure_
diff --git a/tests/misc/od-float b/tests/misc/od-float.sh
index a23a8f35..306c3abe 100755
--- a/tests/misc/od-float
+++ b/tests/misc/od-float.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test od on floating-point values.
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ od
export LC_ALL=C
diff --git a/tests/misc/od-multiple-t b/tests/misc/od-multiple-t.sh
index 049273cd..2b8de711 100755
--- a/tests/misc/od-multiple-t
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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,7 +17,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ od
# Choose 48 bytes for the input, as that is lcm for 1, 2, 4, 8, 12, 16;
diff --git a/tests/misc/od-x8 b/tests/misc/od-x8.sh
index 98a9fe97..f55e1b70 100755
--- a/tests/misc/od-x8
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 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,7 +17,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ od
od -t x8 /dev/null >/dev/null ||
diff --git a/tests/misc/od b/tests/misc/od.pl
index 46d4601d..0649b1c6 100755
--- a/tests/misc/od
+++ b/tests/misc/od.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Exercise od
-# Copyright (C) 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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 b/tests/misc/paste.pl
index 3d5b4119..783a5d42 100755
--- a/tests/misc/paste
+++ b/tests/misc/paste.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test paste.
-# Copyright (C) 2003-2012 Free Software Foundation, Inc.
+# Copyright (C) 2003-2013 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 b/tests/misc/pathchk1.sh
index 373b545d..eed71d5f 100755
--- a/tests/misc/pathchk1
+++ b/tests/misc/pathchk1.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# pathchk tests
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ pathchk
skip_if_root_
diff --git a/tests/misc/pr b/tests/misc/pr
deleted file mode 100755
index 0f25e253..00000000
--- a/tests/misc/pr
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/perl
-# Exercise a bug with pr -m -s
-
-# Copyright (C) 2007-2012 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/>.
-
-use strict;
-
-(my $program_name = $0) =~ s|.*/||;
-
-$ENV{PROG} = 'pr';
-my $ME = $ENV{PROG};
-
-# Turn off localization of executable's output.
-@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
-
-my @Tests =
- (
- ['merge-w-tabs', '-m -s -t',
- {IN=>{1=>"a\tb\tc\n"}},
- {IN=>{2=>"m\tn\to\n"}},
- {IN=>{3=>"x\ty\tz\n"}},
- {OUT=>join("\t", qw(a b c m n o x y z)) . "\n"} ],
- );
-
-my $save_temps = $ENV{DEBUG};
-my $verbose = $ENV{VERBOSE};
-
-my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
-my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
-exit $fail;
diff --git a/tests/misc/printenv b/tests/misc/printenv.sh
index bbce8ef0..e7dbbeef 100755
--- a/tests/misc/printenv
+++ b/tests/misc/printenv.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify behavior of printenv.
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ printenv
# Without arguments, printenv behaves like env. Some shells provide
diff --git a/tests/misc/printf-cov b/tests/misc/printf-cov.pl
index 64f2d95b..44250aab 100755
--- a/tests/misc/printf-cov
+++ b/tests/misc/printf-cov.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# improve printf.c test coverage
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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 b/tests/misc/printf-hex.sh
index 23a218fa..d59899cb 100755
--- a/tests/misc/printf-hex
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ printf
env printf '\x7e3\n' > out || fail=1
diff --git a/tests/misc/printf-surprise b/tests/misc/printf-surprise.sh
index d15987bc..0db6f7b1 100755
--- a/tests/misc/printf-surprise
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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
@@ -18,7 +18,7 @@
prog=printf
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ printf
require_ulimit_
@@ -55,7 +55,10 @@ mkfifo_or_skip_ fifo
export MALLOC_PERTURB_=0
head -c 10 fifo > out &
-( ulimit -v 10000; env $prog %20000000f 0 2>err-msg > fifo )
+
+# Choosing the virtual memory limit, 11000 is enough, but 10000 is too
+# little and provokes a "memory exhausted" diagnostic on FreeBSD 9.0-p3.
+( ulimit -v 15000; env $prog %20000000f 0 2>err-msg > fifo )
exit=$?
# Map this longer, and rarer, diagnostic to the common one.
diff --git a/tests/misc/printf b/tests/misc/printf.sh
index 987e452a..d2ff3edb 100755
--- a/tests/misc/printf
+++ b/tests/misc/printf.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# basic tests for printf
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 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
@@ -18,7 +18,7 @@
prog='env printf'
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ printf
getlimits_
diff --git a/tests/misc/ptx-overrun b/tests/misc/ptx-overrun.sh
index e7eaf0b3..a89a1b2c 100755
--- a/tests/misc/ptx-overrun
+++ b/tests/misc/ptx-overrun.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Trigger a heap-clobbering bug in ptx from coreutils-6.10 and earlier.
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ ptx
# Using a long file name makes an abort more likely.
diff --git a/tests/misc/ptx b/tests/misc/ptx.pl
index 50ee0e8d..b36eeb98 100755
--- a/tests/misc/ptx
+++ b/tests/misc/ptx.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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 b/tests/misc/pwd-long.sh
index 051509a7..3b3f83d4 100755
--- a/tests/misc/pwd-long
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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,7 +17,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ pwd
require_readable_root_
@@ -28,7 +28,7 @@ export ARGV_0
# Don't use CuTmpdir here, since File::Temp's use of rmtree can't
# remove the deep tree we create.
-$PERL -Tw -I"$abs_srcdir" -MCuSkip -- - <<\EOF
+$PERL -Tw -I"$abs_srcdir/tests" -MCuSkip -- - <<\EOF
# Show that pwd works even when the length of the resulting
# directory name is longer than PATH_MAX.
diff --git a/tests/misc/pwd-option b/tests/misc/pwd-option.sh
index a7a4737e..9733e108 100755
--- a/tests/misc/pwd-option
+++ b/tests/misc/pwd-option.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that pwd options work.
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ pwd
mkdir -p a/b || framework_failure_
diff --git a/tests/misc/readlink-fp-loop b/tests/misc/readlink-fp-loop.sh
index 65fab782..6c7f70ac 100755
--- a/tests/misc/readlink-fp-loop
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ readlink
cwd=$("$abs_top_builddir/src/pwd")
diff --git a/tests/misc/readlink-root b/tests/misc/readlink-root.sh
index f69bad6a..ddd49092 100755
--- a/tests/misc/readlink-root
+++ b/tests/misc/readlink-root.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# tests for canonicalize-existing mode (readlink -e) on /.
-# Copyright (C) 2012 Free Software Foundation, Inc.
+# Copyright (C) 2012-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ readlink
stat_single=$(stat -c %d:%i /) || framework_failure_
diff --git a/tests/misc/realpath b/tests/misc/realpath.sh
index 9484ac4c..7a8bf497 100755
--- a/tests/misc/realpath
+++ b/tests/misc/realpath.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate realpath operation
-# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+# Copyright (C) 2011-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ realpath
stat_single=$(stat -c %d:%i /) || framework_failure_
diff --git a/tests/misc/runcon-no-reorder b/tests/misc/runcon-no-reorder.sh
index 351896ef..27656c7d 100755
--- a/tests/misc/runcon-no-reorder
+++ b/tests/misc/runcon-no-reorder.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that runcon does not reorder its arguments.
-# Copyright (C) 2007-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ runcon
diag='runcon: runcon may be used only on a SELinux kernel'
diff --git a/tests/misc/selinux b/tests/misc/selinux.sh
index 12ae15f4..b30bcbcf 100755
--- a/tests/misc/selinux
+++ b/tests/misc/selinux.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test SELinux-related options.
-# Copyright (C) 2007-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ chcon cp ls mv stat
require_root_
diff --git a/tests/misc/seq-long-double b/tests/misc/seq-long-double.sh
index 5a511d70..45e2f05f 100755
--- a/tests/misc/seq-long-double
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -18,7 +18,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ seq
getlimits_
diff --git a/tests/misc/seq b/tests/misc/seq.pl
index 2517d999..b3496d62 100755
--- a/tests/misc/seq
+++ b/tests/misc/seq.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "seq".
-# Copyright (C) 1999-2012 Free Software Foundation, Inc.
+# Copyright (C) 1999-2013 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,6 +30,11 @@ my $locale = $ENV{LOCALE_FR_UTF8};
! defined $locale || $locale eq 'none'
and $locale = 'C';
+my $p = '9' x 81;
+(my $q = $p) =~ s/9/0/g;
+$q = "1$q";
+(my $r = $q) =~ s/0$/1/;
+
my @Tests =
(
['onearg-1', qw(10), {OUT => [(1..10)]}],
@@ -65,6 +70,17 @@ my @Tests =
['eq-wid-6', qw(-w +1 2), {OUT => [qw(1 2)]}],
['eq-wid-7', qw(-w " .1" " .1"), {OUT => [qw(0.1)]}],
['eq-wid-8', qw(-w 9 0.5 10), {OUT => [qw(09.0 09.5 10.0)]}],
+ # Prior to 8.21, these tests involving numbers in scentific notation
+ # would fail with misalignment or wrong widths.
+ ['eq-wid-9', qw(-w -1e-3 1), {OUT => [qw(-0.001 00.999)]}],
+ ['eq-wid-10',qw(-w -1e-003 1), {OUT => [qw(-0.001 00.999)]}],
+ ['eq-wid-11',qw(-w -1.e-3 1), {OUT => [qw(-0.001 00.999)]}],
+ ['eq-wid-12',qw(-w -1.0e-4 1), {OUT => [qw(-0.00010 00.99990)]}],
+ ['eq-wid-13',qw(-w 999 1e3), {OUT => [qw(0999 1000)]}],
+ # Prior to 8.21, if the start value hadn't a precision, while step did,
+ # then misalignment would occur if the sequence narrowed.
+ ['eq-wid-14',qw(-w -1 1.0 0), {OUT => [qw(-1.0 00.0)]}],
+ ['eq-wid-15',qw(-w 10 -.1 9.9), {OUT => [qw(10.0 09.9)]}],
# Prior to coreutils-4.5.11, some of these were not accepted.
['fmt-1', qw(-f %2.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}],
@@ -107,6 +123,31 @@ my @Tests =
{ENV => "LC_ALL=$locale"},
{OUT_SUBST => 's/,/./g'},
],
+
+ # With coreutils-8.19 and prior, this would infloop.
+ ['long-1', "$p $r", {OUT => [$p, $q, $r]}],
+
+ # Exercise the code that trims leading zeros.
+ ['long-leading-zeros1', qw(000 2), {OUT => [qw(0 1 2)]}],
+ ['long-leading-zeros2', qw(000 02), {OUT => [qw(0 1 2)]}],
+ ['long-leading-zeros3', qw(00 02), {OUT => [qw(0 1 2)]}],
+ ['long-leading-zeros4', qw(0 02), {OUT => [qw(0 1 2)]}],
+
+ # Exercise the -s option, which was broken in 8.20
+ ['sep-1', qw(-s, 1 3), {OUT => [qw(1,2,3)]}],
+ ['sep-2', qw(-s, 1 1), {OUT => [qw(1)]}],
+ ['sep-3', qw(-s,, 1 3), {OUT => [qw(1,,2,,3)]}],
+
+ # Exercise fast path avoidance logic.
+ # In 8.20 a step value != 1, with positive integer start and end was broken
+ ['not-fast-1', qw(1 3 1), {OUT => [qw(1)]}],
+ ['not-fast-2', qw(1 1 4.2), {OUT => [qw(1 2 3 4)]}],
+ ['not-fast-3', qw(1 1 0)],
+
+ # Ensure the correct parameters are passed to the fast path
+ ['fast-1', qw(4), {OUT => [qw(1 2 3 4)]}],
+ ['fast-2', qw(1 4), {OUT => [qw(1 2 3 4)]}],
+ ['fast-3', qw(1 1 4), {OUT => [qw(1 2 3 4)]}],
);
# Append a newline to each entry in the OUT array.
diff --git a/tests/misc/sha1sum-vec b/tests/misc/sha1sum-vec.pl
index 48da107d..6df91d64 100755
--- a/tests/misc/sha1sum-vec
+++ b/tests/misc/sha1sum-vec.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Sample vectors for "sha1sum".
-# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+# Copyright (C) 2000-2013 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 b/tests/misc/sha1sum.pl
index 2b08c7fc..327c4dd8 100755
--- a/tests/misc/sha1sum
+++ b/tests/misc/sha1sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sha1sum".
-# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+# Copyright (C) 2000-2013 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 b/tests/misc/sha224sum.pl
index 1da67381..ef881280 100755
--- a/tests/misc/sha224sum
+++ b/tests/misc/sha224sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sha224sum".
-# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+# Copyright (C) 2005-2013 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 b/tests/misc/sha256sum.pl
index fa408a63..2ad38e6e 100755
--- a/tests/misc/sha256sum
+++ b/tests/misc/sha256sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sha256sum".
-# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+# Copyright (C) 2005-2013 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 b/tests/misc/sha384sum.pl
index 921268b7..22e95e15 100755
--- a/tests/misc/sha384sum
+++ b/tests/misc/sha384sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sha384sum".
-# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+# Copyright (C) 2005-2013 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 b/tests/misc/sha512sum.pl
index 7fdb396a..5e121339 100755
--- a/tests/misc/sha512sum
+++ b/tests/misc/sha512sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sha512sum".
-# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+# Copyright (C) 2005-2013 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 b/tests/misc/shred-exact.sh
index 22d14c30..0cdc91fc 100755
--- a/tests/misc/shred-exact
+++ b/tests/misc/shred-exact.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# make sure that neither --exact nor --zero gobbles a command line argument
-# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+# Copyright (C) 2000-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ shred
diff --git a/tests/misc/shred-passes b/tests/misc/shred-passes.sh
index 4ff80d74..cfdd68e9 100755
--- a/tests/misc/shred-passes
+++ b/tests/misc/shred-passes.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify the operations done by shred
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ shred
diff --git a/tests/misc/shred-remove b/tests/misc/shred-remove.sh
index c060a21c..891dc2d2 100755
--- a/tests/misc/shred-remove
+++ b/tests/misc/shred-remove.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise a bug that was fixed in shred-4.0l
-# Copyright (C) 1999-2012 Free Software Foundation, Inc.
+# Copyright (C) 1999-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ shred
skip_if_root_
diff --git a/tests/misc/shuf b/tests/misc/shuf.sh
index 243c0498..9c9526d4 100755
--- a/tests/misc/shuf
+++ b/tests/misc/shuf.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that shuf randomizes its input.
-# Copyright (C) 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ shuf
getlimits_
diff --git a/tests/misc/sort-NaN-infloop b/tests/misc/sort-NaN-infloop.sh
index e64d3859..2ec13ee0 100755
--- a/tests/misc/sort-NaN-infloop
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2011-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
echo nan > F || fail=1
diff --git a/tests/misc/sort-benchmark-random b/tests/misc/sort-benchmark-random.sh
index 9eb9a63f..04f2af99 100755
--- a/tests/misc/sort-benchmark-random
+++ b/tests/misc/sort-benchmark-random.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Benchmark sort on randomly generated data.
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -18,7 +18,7 @@
# Written by Glen Lenker.
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
very_expensive_
diff --git a/tests/misc/sort-compress-hang b/tests/misc/sort-compress-hang.sh
index e1b8ff0f..1b1f3a9c 100755
--- a/tests/misc/sort-compress-hang
+++ b/tests/misc/sort-compress-hang.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test for sort --compress hang
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
very_expensive_
diff --git a/tests/misc/sort-compress-proc b/tests/misc/sort-compress-proc.sh
index 7ee0fd1f..3888fdb6 100755
--- a/tests/misc/sort-compress-proc
+++ b/tests/misc/sort-compress-proc.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test use of compression subprocesses by sort
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
expensive_
diff --git a/tests/misc/sort-compress b/tests/misc/sort-compress.sh
index 00dcf06a..c7587c43 100755
--- a/tests/misc/sort-compress
+++ b/tests/misc/sort-compress.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test use of compression by sort
-# Copyright (C) 2007-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
seq -w 2000 > exp || framework_failure_
diff --git a/tests/misc/sort-continue b/tests/misc/sort-continue.sh
index 1491dbf6..bd569d0d 100755
--- a/tests/misc/sort-continue
+++ b/tests/misc/sort-continue.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Tests for file descriptor exhaustion.
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
# Skip the test when running under valgrind.
diff --git a/tests/misc/sort-debug-keys b/tests/misc/sort-debug-keys.sh
index a284e84c..9d4f8295 100755
--- a/tests/misc/sort-debug-keys
+++ b/tests/misc/sort-debug-keys.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test annotation of sort keys
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
number() { cat -n | sed 's/^ *//'; }
diff --git a/tests/misc/sort-debug-warn b/tests/misc/sort-debug-warn.sh
index 504a2d2b..c9f1b9f3 100755
--- a/tests/misc/sort-debug-warn
+++ b/tests/misc/sort-debug-warn.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test warnings for sort options
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
cat <<\EOF > exp
diff --git a/tests/misc/sort-discrim b/tests/misc/sort-discrim.sh
index fced2049..0dac3a9d 100755
--- a/tests/misc/sort-discrim
+++ b/tests/misc/sort-discrim.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test discriminator-based sorting.
-# Copyright (C) 2012 Free Software Foundation, Inc.
+# Copyright (C) 2012-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
# Set limit variables.
diff --git a/tests/misc/sort-exit-early.sh b/tests/misc/sort-exit-early.sh
new file mode 100755
index 00000000..83a55f51
--- /dev/null
+++ b/tests/misc/sort-exit-early.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Test 'sort' exits early on inaccessible inputs or output
+
+# Copyright (C) 2012-2013 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_ sort
+skip_if_root_
+
+# 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
+
+# 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
+test -e typo && fail=1
+
+Exit $fail
diff --git a/tests/misc/sort-files0-from b/tests/misc/sort-files0-from.pl
index 6aa10acc..d843b646 100755
--- a/tests/misc/sort-files0-from
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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 b/tests/misc/sort-float.sh
index b585b9bf..dd3c079c 100755
--- a/tests/misc/sort-float
+++ b/tests/misc/sort-float.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure sort -g sorts floating point limits correctly
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
# Return 0 if LDBL_MIN is smaller than DBL_MIN, else 1.
diff --git a/tests/misc/sort-merge-fdlimit b/tests/misc/sort-merge-fdlimit.sh
index 7ce109c1..bcd023ae 100755
--- a/tests/misc/sort-merge-fdlimit
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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,7 +17,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
require_ulimit_
diff --git a/tests/misc/sort-merge b/tests/misc/sort-merge.pl
index 7a56dc12..5b940f25 100755
--- a/tests/misc/sort-merge
+++ b/tests/misc/sort-merge.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sort -m".
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 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 b/tests/misc/sort-month.sh
index fa1e6957..99008367 100755
--- a/tests/misc/sort-month
+++ b/tests/misc/sort-month.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test sorting of abbreviated months from the locale
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
locale --version >/dev/null 2>&1 ||
diff --git a/tests/misc/sort-rand b/tests/misc/sort-rand.sh
index 79730e95..4313eb2f 100755
--- a/tests/misc/sort-rand
+++ b/tests/misc/sort-rand.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that sort --sort-random doesn't sort.
-# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+# Copyright (C) 2005-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
seq 100 > in || framework_failure_
@@ -35,7 +35,7 @@ compare in out1 || { fail=1; echo "not a permutation" 1>&2; }
# If locale is available then use it to find a random non-C locale.
if (locale --version) > /dev/null 2>&1; then
- locale=$(locale -a | sort --random-sort | awk '/^.._/{print;exit}')
+ locale=$(locale -a | sort --random-sort | $AWK '/^.._/{print;exit}')
LC_ALL=$locale sort --random-sort in > out1 || fail=1
LC_ALL=$locale sort --random-sort in > out2 || fail=1
diff --git a/tests/misc/sort-spinlock-abuse b/tests/misc/sort-spinlock-abuse.sh
index 628326fd..768fc1f4 100755
--- a/tests/misc/sort-spinlock-abuse
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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,7 +17,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
# This isn't terribly expensive, but it must not be run under heavy load.
diff --git a/tests/misc/sort-stale-thread-mem b/tests/misc/sort-stale-thread-mem.sh
index c19f62ee..78fa2cda 100755
--- a/tests/misc/sort-stale-thread-mem
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -18,12 +18,12 @@
# written by Jim Meyering and Paul Eggert
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
very_expensive_
+require_valgrind_
-valgrind --help >/dev/null || skip_ "requires valgrind"
grep '^#define HAVE_PTHREAD_T 1' "$CONFIG_HEADER" > /dev/null ||
skip_ 'requires pthreads'
diff --git a/tests/misc/sort-u-FMR.sh b/tests/misc/sort-u-FMR.sh
new file mode 100755
index 00000000..c13e9823
--- /dev/null
+++ b/tests/misc/sort-u-FMR.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Before 8.19, this would trigger a free-memory read.
+
+# Copyright (C) 2012-2013 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_ sort
+require_valgrind_
+
+{ echo 0; printf '%0900d\n' 1; } > in || framework_failure_
+
+valgrind --error-exitcode=1 sort --p=1 -S32b -u in > out || fail=1
+
+compare in out || fail=1
+
+Exit $fail
diff --git a/tests/misc/sort-unique-segv b/tests/misc/sort-unique-segv.sh
index b853cfe4..58893158 100755
--- a/tests/misc/sort-unique-segv
+++ b/tests/misc/sort-unique-segv.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# parallel sort with --unique (-u) would segfault
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
grep '^#define HAVE_PTHREAD_T 1' "$CONFIG_HEADER" > /dev/null ||
diff --git a/tests/misc/sort-unique b/tests/misc/sort-unique.sh
index 275cbeb0..f34df96e 100755
--- a/tests/misc/sort-unique
+++ b/tests/misc/sort-unique.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test 'sort -u'.
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
cat > in <<\EOF
diff --git a/tests/misc/sort-version b/tests/misc/sort-version.sh
index cb9acab7..d9686fbe 100755
--- a/tests/misc/sort-version
+++ b/tests/misc/sort-version.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise sort's --sort=version option
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort
cat > in << _EOF_
diff --git a/tests/misc/sort b/tests/misc/sort.pl
index 5be00a01..59c30e56 100755
--- a/tests/misc/sort
+++ b/tests/misc/sort.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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 @@ my $mb_locale = $ENV{LOCALE_FR_UTF8};
# Normalize each diagnostic to use '-'.
my $normalize_filename = {ERR_SUBST => 's/^$prog: .*?:/$prog: -:/'};
-my $no_file = "$prog: open failed: no-file: No such file or directory\n";
+my $no_file = "$prog: cannot read: no-file: No such file or directory\n";
my @Tests =
(
@@ -227,6 +227,21 @@ my @Tests =
["15d", '-i -u', {IN=>"\1a\na\n"}, {OUT=>"\1a\n"}],
["15e", '-i -u', {IN=>"a\n\1\1\1\1\1a\1\1\1\1\n"}, {OUT=>"a\n"}],
+# This would fail (printing only the 7) for 8.6..8.18.
+# Use --parallel=1 for reproducibility, and a small buffer size
+# to let us trigger the problem with a smaller input.
+["unique-1", '--p=1 -S32b -u', {IN=>"7\n"x11 . "1\n"}, {OUT=>"1\n7\n"}],
+# Demonstrate that 8.19's key-spec-adjusting code is required.
+# These are more finicky in that they are arch-dependent.
+["unique-key-i686", '-u -k2,2 --p=1 -S32b',
+ {IN=>"a 7\n"x10 . "b 1\n"}, {OUT=>"b 1\na 7\n"}],
+["unique-key-x86_64", '-u -k2,2 --p=1 -S32b',
+ {IN=>"a 7\n"x11 . "b 1\n"}, {OUT=>"b 1\na 7\n"}],
+# Before 8.19, this would trigger a free-memory read.
+["unique-free-mem-read", '-u --p=1 -S32b',
+ {IN=>"a\n"."b"x900 ."\n"},
+ {OUT=>"a\n"."b"x900 ."\n"}],
+
# From Erick Branderhorst -- fixed around 1.19e
["16a", '-f',
{IN=>"éminence\nüberhaupt\n's-Gravenhage\naëroclub\nAag\naagtappels\n"},
diff --git a/tests/misc/stat-birthtime b/tests/misc/stat-birthtime.sh
index dd68e675..b30c972b 100755
--- a/tests/misc/stat-birthtime
+++ b/tests/misc/stat-birthtime.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure that stat attempts birthtime access
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ stat
# Whether birthtime is supported or not, it better not change even when
diff --git a/tests/misc/stat-fmt b/tests/misc/stat-fmt.sh
index 8952a7ab..547f5b8f 100755
--- a/tests/misc/stat-fmt
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2003-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ stat
diff --git a/tests/misc/stat-hyphen b/tests/misc/stat-hyphen.sh
index a6b52436..a817b285 100755
--- a/tests/misc/stat-hyphen
+++ b/tests/misc/stat-hyphen.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# demonstrate that stat - works and stat -f - does not.
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ stat
printf -- '-\n' > exp || framework_failure_
diff --git a/tests/misc/stat-mount b/tests/misc/stat-mount.sh
index c93d8dcb..f94c77cb 100755
--- a/tests/misc/stat-mount
+++ b/tests/misc/stat-mount.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test stat -c%m
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ stat
df_mnt=$(df -P . | sed -n '2s/.* \([^ ]*$\)/\1/p')
diff --git a/tests/misc/stat-nanoseconds b/tests/misc/stat-nanoseconds.sh
index 1afb610f..9c891b76 100755
--- a/tests/misc/stat-nanoseconds
+++ b/tests/misc/stat-nanoseconds.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise format strings involving %:X, %:Y, etc.
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
print_ver_ stat
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
# Set this to avoid problems with weird time zones.
TZ=UTC0
diff --git a/tests/misc/stat-printf b/tests/misc/stat-printf.pl
index 929b255e..fb31043f 100755
--- a/tests/misc/stat-printf
+++ b/tests/misc/stat-printf.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "stat --printf".
-# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+# Copyright (C) 2005-2013 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 b/tests/misc/stat-slash.sh
index ff122eb0..47aa7907 100755
--- a/tests/misc/stat-slash
+++ b/tests/misc/stat-slash.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# demonstrate that stat handles trailing slashes correctly
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ stat
touch file || framework_failure_
diff --git a/tests/misc/stdbuf b/tests/misc/stdbuf.sh
index 3164df1b..12347ecc 100755
--- a/tests/misc/stdbuf
+++ b/tests/misc/stdbuf.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise stdbuf functionality
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ stdbuf
getlimits_
diff --git a/tests/misc/stty-invalid b/tests/misc/stty-invalid.sh
index 3b035ece..c6400fcf 100755
--- a/tests/misc/stty-invalid
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ stty
require_controlling_input_terminal_
trap '' TTOU # Ignore SIGTTOU
diff --git a/tests/misc/stty-pairs b/tests/misc/stty-pairs.sh
index e59da043..be5b6f84 100755
--- a/tests/misc/stty-pairs
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 1998-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ stty
expensive_
diff --git a/tests/misc/stty-row-col b/tests/misc/stty-row-col.sh
index d7151d5b..586674ad 100755
--- a/tests/misc/stty-row-col
+++ b/tests/misc/stty-row-col.sh
@@ -1,7 +1,7 @@
#! /bin/sh
# Test "stty" with rows and columns.
-# Copyright (C) 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1998-2013 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
@@ -28,7 +28,7 @@ export COLUMNS
LC_ALL=C
export LC_ALL
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ stty
require_controlling_input_terminal_
diff --git a/tests/misc/stty b/tests/misc/stty.sh
index ae656564..2f9b9a3b 100755
--- a/tests/misc/stty
+++ b/tests/misc/stty.sh
@@ -1,7 +1,7 @@
#! /bin/sh
# Make sure stty can parse most of its options.
-# Copyright (C) 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1998-2013 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,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Make sure there's a tty on stdin.
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ stty
require_controlling_input_terminal_
@@ -52,7 +52,7 @@ for opt in $options; do
# other serial control settings give the same error. So skip them.
# Also on ppc*|sparc* glibc platforms 'icanon' gives the same error.
# See: http://debbugs.gnu.org/7228#14
- case $opt in parenb|parodd|cstopb|crtscts|icanon) continue;; esac
+ case $opt in parenb|parodd|cstopb|crtscts|cdtrdsr|icanon) continue;; esac
stty $opt || fail=1
diff --git a/tests/misc/su-fail b/tests/misc/su-fail
deleted file mode 100755
index c2e0475d..00000000
--- a/tests/misc/su-fail
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-# Test su failure cases
-
-# Copyright (C) 2009-2012 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=.}/init.sh"; path_prepend_ ../src
-print_ver_ su
-
-require_built_ su
-
-# Very little that we can test without a root password
-su --- / true # unknown option
-test $? = 125 || fail=1
-su no_such_user
-test $? = 125 || fail=1
-
-Exit $fail
diff --git a/tests/misc/sum-sysv b/tests/misc/sum-sysv.sh
index 9cdf07fc..a1e8cee9 100755
--- a/tests/misc/sum-sysv
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 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,7 +22,7 @@
LC_ALL=C
export LC_ALL
-. "${srcdir=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sum
require_perl_
diff --git a/tests/misc/sum b/tests/misc/sum.pl
index 8aaa6350..3cabcc53 100755
--- a/tests/misc/sum
+++ b/tests/misc/sum.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "sum".
-# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+# Copyright (C) 2000-2013 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/tac-2-nonseekable b/tests/misc/tac-2-nonseekable.sh
index f980f3b8..ef434807 100755
--- a/tests/misc/tac-2-nonseekable
+++ b/tests/misc/tac-2-nonseekable.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure that tac works with two or more non-seekable inputs
-# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+# Copyright (C) 2011-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tac
echo x | tac - - > out 2> err || fail=1
diff --git a/tests/misc/tac-continue b/tests/misc/tac-continue.sh
index d9cc550a..95f37d7b 100755
--- a/tests/misc/tac-continue
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2004-2013 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
@@ -18,7 +18,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tac
# See if the envvar is defined.
diff --git a/tests/misc/tac b/tests/misc/tac.pl
index 077cc0c9..b064b9d2 100755
--- a/tests/misc/tac
+++ b/tests/misc/tac.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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 b/tests/misc/tail.pl
index 41c2f9a9..bc6e6d4a 100755
--- a/tests/misc/tail
+++ b/tests/misc/tail.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test tail.
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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/tee-dash b/tests/misc/tee-dash.sh
index 8ee0820b..9e511beb 100755
--- a/tests/misc/tee-dash
+++ b/tests/misc/tee-dash.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# test for "tee -".
-# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+# Copyright (C) 2005-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tee
tee - </dev/null || fail=1
diff --git a/tests/misc/tee b/tests/misc/tee.sh
index 4c17316d..bbaf99b7 100755
--- a/tests/misc/tee
+++ b/tests/misc/tee.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# test for basic tee functionality.
-# Copyright (C) 2005-2012 Free Software Foundation, Inc.
+# Copyright (C) 2005-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tee
echo line >sample || framework_failure_
diff --git a/tests/misc/test-diag b/tests/misc/test-diag.pl
index 9c0ce227..81ab60d8 100755
--- a/tests/misc/test-diag
+++ b/tests/misc/test-diag.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test the diagnostics of "test".
-# Copyright (C) 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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 b/tests/misc/test.pl
index ac30c379..ee9150d7 100755
--- a/tests/misc/test
+++ b/tests/misc/test.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
new file mode 100755
index 00000000..6f16ba4c
--- /dev/null
+++ b/tests/misc/timeout-blocked.pl
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+# Test that timeout handles blocked SIGALRM from its parent.
+
+# Copyright (C) 2013 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/>.
+
+use strict;
+
+(my $ME = $0) =~ s|.*/||;
+
+eval { require POSIX; };
+$@
+ and CuSkip::skip "$ME: this script requires Perl's POSIX module\n";
+
+use POSIX qw(:signal_h);
+my $sigset = POSIX::SigSet->new(SIGALRM); # define the signals to block
+my $old_sigset = POSIX::SigSet->new; # where the old sigmask will be kept
+unless (defined sigprocmask(SIG_BLOCK, $sigset, $old_sigset)) {
+ CuSkip::skip "$ME: sigprocmask failed; skipped";
+}
+
+my @Tests =
+ (
+ # test-name, [option, option, ...] {OUT=>"expected-output"}
+ #
+
+ ['block-alrm', ".1 sleep 10", {EXIT => 124}],
+ );
+
+my $save_temps = $ENV{DEBUG};
+my $verbose = $ENV{VERBOSE};
+
+my $prog = 'timeout';
+my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose);
+
+exit $fail;
diff --git a/tests/misc/timeout-group b/tests/misc/timeout-group.sh
index 7a08bb3a..35a6be0b 100755
--- a/tests/misc/timeout-group
+++ b/tests/misc/timeout-group.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# test program group handling
-# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+# Copyright (C) 2011-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ timeout
# construct a program group hierarchy as follows:
@@ -34,7 +34,11 @@ cat > timeout.cmd <<\EOF
#!/bin/sh
trap 'touch int.received; exit' INT
touch timeout.running
-sleep $1
+count=$1
+until test -e int.received || test $count = 0; do
+ sleep 1
+ count=$(expr $count - 1)
+done
EOF
chmod a+x timeout.cmd
diff --git a/tests/misc/timeout-parameters b/tests/misc/timeout-parameters.sh
index c7d66309..06cdfb39 100755
--- a/tests/misc/timeout-parameters
+++ b/tests/misc/timeout-parameters.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate timeout parameter combinations
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ timeout
getlimits_
diff --git a/tests/misc/timeout b/tests/misc/timeout.sh
index 5f4e9ec2..6b5a6f10 100755
--- a/tests/misc/timeout
+++ b/tests/misc/timeout.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate timeout basic operation
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ timeout
# no timeout
@@ -33,13 +33,18 @@ timeout 10 sh -c 'exit 2'
test $? = 2 || fail=1
# timeout
-timeout 1 sleep 10
+timeout .1 sleep 10
test $? = 124 || fail=1
+# exit status propagation even on timeout
+timeout --preserve-status .1 sleep 10
+# exit status should be 128+TERM
+test $? = 124 && fail=1
+
# kill delay. Note once the initial timeout triggers,
# the exit status will be 124 even if the command
# exits on its own accord.
-timeout -s0 -k1 1 sleep 10
+timeout -s0 -k1 .1 sleep 10
test $? = 124 && fail=1
# Ensure 'timeout' is immune to parent's SIGCHLD handler
@@ -52,7 +57,7 @@ test $? = 124 && fail=1
) || fail=1
# Don't be confused when starting off with a child (Bug#9098).
-out=$(sleep 1 & exec timeout 2 sh -c 'sleep 3; echo foo')
+out=$(sleep .1 & exec timeout .5 sh -c 'sleep 2; echo foo')
status=$?
test "$out" = "" && test $status = 124 || fail=1
diff --git a/tests/misc/tr-case-class b/tests/misc/tr-case-class.sh
index 2f70f4eb..1294f965 100755
--- a/tests/misc/tr-case-class
+++ b/tests/misc/tr-case-class.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test case conversion classes
-# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Copyright (C) 2010-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tr
# Ensure we support translation of case classes with extension
diff --git a/tests/misc/tr b/tests/misc/tr.pl
index 89f77775..89693f91 100755
--- a/tests/misc/tr
+++ b/tests/misc/tr.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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 b/tests/misc/truncate-dangling-symlink.sh
index d9175d4e..5386ce2d 100755
--- a/tests/misc/truncate-dangling-symlink
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ truncate
ln -s truncate-target t-symlink
diff --git a/tests/misc/truncate-dir-fail b/tests/misc/truncate-dir-fail.sh
index 54a31479..8bd67b6e 100755
--- a/tests/misc/truncate-dir-fail
+++ b/tests/misc/truncate-dir-fail.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure truncate fails for a directory.
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ truncate
# truncate on dir not allowed
diff --git a/tests/misc/truncate-fail-diag b/tests/misc/truncate-fail-diag.sh
index f9cdabf3..8e5f07ba 100755
--- a/tests/misc/truncate-fail-diag
+++ b/tests/misc/truncate-fail-diag.sh
@@ -1,11 +1,11 @@
#!/bin/sh
# make sure truncate gives reasonable diagnostics
-# Note open() checks for trailing '/' before checking for existance
+# Note open() checks for trailing '/' before checking for existence
# open (".", O_CREAT & (O_WRONLY | O_RDWR), ...) -> EISDIR
# open ("missing/", O_CREAT & (O_WRONLY | O_RDWR), ...) -> EISDIR
# open ("missing/file", O_CREAT & (O_WRONLY | O_RDWR), ...) -> ENOENT
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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,7 +20,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ truncate
skip_if_root_
diff --git a/tests/misc/truncate-fifo b/tests/misc/truncate-fifo.sh
index 6588f0a2..58e5c14e 100755
--- a/tests/misc/truncate-fifo
+++ b/tests/misc/truncate-fifo.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure truncate works on fifos without hanging
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ truncate
mkfifo_or_skip_ fifo
diff --git a/tests/misc/truncate-no-create-missing b/tests/misc/truncate-no-create-missing.sh
index 56b2ac18..6fa1f0c6 100755
--- a/tests/misc/truncate-no-create-missing
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ truncate
diff --git a/tests/misc/truncate-overflow b/tests/misc/truncate-overflow.sh
index 9ec353fa..dd0fc730 100755
--- a/tests/misc/truncate-overflow
+++ b/tests/misc/truncate-overflow.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate truncate integer overflow
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ truncate
getlimits_
diff --git a/tests/misc/truncate-owned-by-other b/tests/misc/truncate-owned-by-other.sh
index 93160869..e7f7157c 100755
--- a/tests/misc/truncate-owned-by-other
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ truncate
require_root_
diff --git a/tests/misc/truncate-parameters b/tests/misc/truncate-parameters.sh
index 13a8475e..21713d99 100755
--- a/tests/misc/truncate-parameters
+++ b/tests/misc/truncate-parameters.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate truncate parameter combinations
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ truncate
diff --git a/tests/misc/truncate-relative b/tests/misc/truncate-relative.sh
index 19543db6..fbbd4f97 100755
--- a/tests/misc/truncate-relative
+++ b/tests/misc/truncate-relative.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Validate truncate relative sizes
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ truncate
diff --git a/tests/misc/tsort b/tests/misc/tsort.pl
index cc8ac957..5e598c74 100755
--- a/tests/misc/tsort
+++ b/tests/misc/tsort.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "tsort".
-# Copyright (C) 1999-2012 Free Software Foundation, Inc.
+# Copyright (C) 1999-2013 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 b/tests/misc/tty-eof.pl
index e9eed2ea..755ffac0 100755
--- a/tests/misc/tty-eof
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2003-2013 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 b/tests/misc/unexpand.pl
index 633a1603..a1ce5c52 100755
--- a/tests/misc/unexpand
+++ b/tests/misc/unexpand.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test "unexpand".
-# Copyright (C) 2000-2012 Free Software Foundation, Inc.
+# Copyright (C) 2000-2013 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 b/tests/misc/uniq-perf.sh
index 57794c3b..35dff8e5 100755
--- a/tests/misc/uniq-perf
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2011-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ uniq
seq 100 > in || fail=1
diff --git a/tests/misc/uniq b/tests/misc/uniq.pl
index d0e6d151..140a49b4 100755
--- a/tests/misc/uniq
+++ b/tests/misc/uniq.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Test uniq.
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 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 b/tests/misc/wc-files0-from.pl
index 0f99aeeb..a14bf97f 100755
--- a/tests/misc/wc-files0-from
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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 b/tests/misc/wc-files0.sh
index 9a0d0501..06be054d 100755
--- a/tests/misc/wc-files0
+++ b/tests/misc/wc-files0.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Show that wc's new --files0-from option works.
-# Copyright (C) 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 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
@@ -16,7 +16,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ wc
echo 2 > 2b || framework_failure_
diff --git a/tests/misc/wc-parallel b/tests/misc/wc-parallel.sh
index 074160fd..bf6b7b29 100755
--- a/tests/misc/wc-parallel
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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,8 @@
# 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=.}/init.sh"; path_prepend_ ../src
-print_ver_ md5sum
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ wc
(mkdir tmp && cd tmp && seq 2000 | xargs touch)
diff --git a/tests/misc/wc b/tests/misc/wc.pl
index 713663f7..ed2feafd 100755
--- a/tests/misc/wc
+++ b/tests/misc/wc.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# Basic tests for "wc".
-# Copyright (C) 1997-2012 Free Software Foundation, Inc.
+# Copyright (C) 1997-2013 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 b/tests/misc/xattr.sh
index ff50e6c9..6eccc10d 100755
--- a/tests/misc/xattr
+++ 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-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 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
@@ -18,7 +18,7 @@
# 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=.}/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ cp mv ginstall
# Skip this test if cp was built without xattr support:
@@ -28,7 +28,7 @@ cp --preserve=xattr -n src dest \
# this code was taken from test mv/backup-is-src
cleanup_() { rm -rf "$other_partition_tmpdir"; }
-. "$abs_srcdir/other-fs-tmpdir"
+. "$abs_srcdir/tests/other-fs-tmpdir"
b_other="$other_partition_tmpdir/b"
rm -f "$b_other" || framework_failure_
diff --git a/tests/misc/xstrtol b/tests/misc/xstrtol.pl
index fa0056fc..b2f38b61 100755
--- a/tests/misc/xstrtol
+++ b/tests/misc/xstrtol.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# exercise xstrtol's diagnostics via pr
-# Copyright (C) 2007-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 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