2008-05-14 09:37:02 +02:00
|
|
|
#!/usr/bin/perl
|
2008-05-09 08:04:59 +02:00
|
|
|
|
2013-01-01 03:54:51 +01:00
|
|
|
# Copyright (C) 2008-2013 Free Software Foundation, Inc.
|
2008-05-09 08:04:59 +02:00
|
|
|
|
|
|
|
|
# This 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;
|
|
|
|
|
|
2008-12-12 10:25:34 +00:00
|
|
|
my $limits = getlimits ();
|
|
|
|
|
|
2008-05-09 08:04:59 +02:00
|
|
|
my $prog = 'sort';
|
|
|
|
|
|
|
|
|
|
# Turn off localization of executable's output.
|
|
|
|
|
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
|
|
|
|
|
|
2009-02-27 08:40:42 +00:00
|
|
|
my $mb_locale = $ENV{LOCALE_FR_UTF8};
|
|
|
|
|
! defined $mb_locale || $mb_locale eq 'none'
|
|
|
|
|
and $mb_locale = 'C';
|
|
|
|
|
|
2008-05-09 08:04:59 +02:00
|
|
|
# Since each test is run with a file name and with redirected stdin,
|
|
|
|
|
# the name in the diagnostic is either the file name or "-".
|
|
|
|
|
# Normalize each diagnostic to use '-'.
|
|
|
|
|
my $normalize_filename = {ERR_SUBST => 's/^$prog: .*?:/$prog: -:/'};
|
|
|
|
|
|
2012-07-01 01:14:42 +01:00
|
|
|
my $no_file = "$prog: cannot read: no-file: No such file or directory\n";
|
2008-05-09 08:04:59 +02:00
|
|
|
|
|
|
|
|
my @Tests =
|
|
|
|
|
(
|
|
|
|
|
["n1", '-n', {IN=>".01\n0\n"}, {OUT=>"0\n.01\n"}],
|
|
|
|
|
["n2", '-n', {IN=>".02\n.01\n"}, {OUT=>".01\n.02\n"}],
|
|
|
|
|
["n3", '-n', {IN=>".02\n.00\n"}, {OUT=>".00\n.02\n"}],
|
|
|
|
|
["n4", '-n', {IN=>".02\n.000\n"}, {OUT=>".000\n.02\n"}],
|
|
|
|
|
["n5", '-n', {IN=>".021\n.029\n"}, {OUT=>".021\n.029\n"}],
|
|
|
|
|
|
|
|
|
|
["n6", '-n', {IN=>".02\n.0*\n"}, {OUT=>".0*\n.02\n"}],
|
|
|
|
|
["n7", '-n', {IN=>".02\n.*\n"}, {OUT=>".*\n.02\n"}],
|
|
|
|
|
["n8a", '-s -n -k1,1', {IN=>".0a\n.0b\n"}, {OUT=>".0a\n.0b\n"}],
|
|
|
|
|
["n8b", '-s -n -k1,1', {IN=>".0b\n.0a\n"}, {OUT=>".0b\n.0a\n"}],
|
|
|
|
|
["n9a", '-s -n -k1,1', {IN=>".000a\n.000b\n"}, {OUT=>".000a\n.000b\n"}],
|
|
|
|
|
["n9b", '-s -n -k1,1', {IN=>".000b\n.000a\n"}, {OUT=>".000b\n.000a\n"}],
|
|
|
|
|
["n10a", '-s -n -k1,1', {IN=>".00a\n.000b\n"}, {OUT=>".00a\n.000b\n"}],
|
|
|
|
|
["n10b", '-s -n -k1,1', {IN=>".00b\n.000a\n"}, {OUT=>".00b\n.000a\n"}],
|
|
|
|
|
["n11a", '-s -n -k1,1', {IN=>".01a\n.010\n"}, {OUT=>".01a\n.010\n"}],
|
|
|
|
|
["n11b", '-s -n -k1,1', {IN=>".010\n.01a\n"}, {OUT=>".010\n.01a\n"}],
|
|
|
|
|
|
2009-04-27 14:51:29 +01:00
|
|
|
# human readable suffixes
|
coreutils: keep lines within 80-column limits
* cfg.mk (LINE_LEN_MAX, FILTER_LONG_LINES): New macros.
(sc_long_lines): New rule.
* HACKING: Use shorter URLs to the same material.
* doc/Makefile.am, doc/coreutils.texi, m4/boottime.m4:
* man/help2man, man/stdbuf.x, src/Makefile.am, src/cat.c, src/copy.c:
* src/cp.c, src/dd.c, src/df.c, src/du.c, src/groups.c, src/install.c:
* src/ls.c, src/md5sum.c, src/mv.c, src/od.c, src/pinky.c, src/ptx.c:
* src/readlink.c, src/remove.c, src/rmdir.c, src/setuidgid.c:
* src/sort.c, src/tail.c, src/touch.c, tests/Coreutils.pm:
* tests/cp/existing-perm-race, tests/cp/perm, tests/cp/preserve-gid:
* tests/du/2g, tests/du/long-from-unreadable, tests/init.sh:
* tests/install/basic-1, tests/ls/nameless-uid:
* tests/ls/readdir-mountpoint-inode, tests/misc/chroot-credentials:
* tests/misc/cut, tests/misc/date, tests/misc/join, tests/misc/md5sum:
* tests/misc/sha1sum, tests/misc/sha224sum, tests/misc/sort:
* tests/misc/sort-continue, tests/misc/sort-files0-from:
* tests/misc/sort-rand, tests/misc/stdbuf, tests/misc/tr:
* tests/misc/uniq, tests/mv/atomic, tests/mv/part-fail:
* tests/mv/part-symlink, tests/mv/sticky-to-xpart, tests/pr/pr-tests:
* tests/rm/fail-2eperm, tests/rm/interactive-always:
Reformat to fit within 80 columns.
* doc/Makefile.am (BAD_POSIX_PERL): New macro.
* doc/coreutils.texi: Reword slightly, to make menus and
index lines shorter.
* src/md5sum.c: Redo --help output so that it fits within 79
columns, since that's a bit more portable and all the other --help
strings fit in 79 columns.
2010-12-28 12:28:48 -08:00
|
|
|
["h1", '-h',
|
|
|
|
|
{IN=>"1Y\n1Z\n1E\n1P\n1T\n1G\n1M\n1K\n02\n1\nY\n-1k\n-1M\n-1G\n-1T\n"
|
|
|
|
|
. "-1P\n-1E\n-1Z\n-1Y\n"},
|
|
|
|
|
{OUT=>"-1Y\n-1Z\n-1E\n-1P\n-1T\n-1G\n-1M\n-1k\nY\n1\n02\n1K\n1M\n1G\n1T\n"
|
|
|
|
|
. "1P\n1E\n1Z\n1Y\n"}],
|
2009-04-27 14:51:29 +01:00
|
|
|
["h2", '-h', {IN=>"1M\n-2G\n-3K"}, {OUT=>"-2G\n-3K\n1M\n"}],
|
sort: revert recent -h changes and use a more-conservative approach
* NEWS: Document changes to sort -h, which are now minor with
respect to the pre-July-30th version.
* doc/coreutils.texi (sort invocation): Likewise. The
documentation now describes how -h comparison is done rather than
being vague with border cases.
* src/sort.c (long_double, strtold): Move back to general_numcompare.
(LD, compute_human): Remove.
(find_unit_order): Remove THOU_SEP parameter, since thousands
separators are now allowed by all callers. Revert to previous
behavior of sorting by suffix, and returning the order rather than
2 * order + binary, since we no longer care whether binary powers
are being used. However, treat all zeros the same, instead of
sorting 0M before 0G; this is more consistent with the desired
behavior of sorting -1G before -1M.
* tests/misc/sort (h1, h3, h6): Adjust to match mostly-reverted
behavior. However, check that all zeros sort together.
* tests/misc/sort-debug-keys: Omit a "_", since the trailing "i"
in "1234Gi" is no longer part of the key.
2010-08-02 19:18:01 -07:00
|
|
|
# check that it works with powers of 1024
|
|
|
|
|
["h3", '-k 2,2h -k 1,1', {IN=>"a 1G\nb 1023M\n"}, {OUT=>"b 1023M\na 1G\n"}],
|
2010-07-30 01:52:59 -06:00
|
|
|
# decimal at end => allowed
|
|
|
|
|
["h4", '-h', {IN=>"1.E\n2.M\n"}, {OUT=>"2.M\n1.E\n"}],
|
2009-04-27 14:51:29 +01:00
|
|
|
# double decimal => ignore suffix
|
|
|
|
|
["h5", '-h', {IN=>"1..2E\n2..2M\n"}, {OUT=>"1..2E\n2..2M\n"}],
|
sort: revert recent -h changes and use a more-conservative approach
* NEWS: Document changes to sort -h, which are now minor with
respect to the pre-July-30th version.
* doc/coreutils.texi (sort invocation): Likewise. The
documentation now describes how -h comparison is done rather than
being vague with border cases.
* src/sort.c (long_double, strtold): Move back to general_numcompare.
(LD, compute_human): Remove.
(find_unit_order): Remove THOU_SEP parameter, since thousands
separators are now allowed by all callers. Revert to previous
behavior of sorting by suffix, and returning the order rather than
2 * order + binary, since we no longer care whether binary powers
are being used. However, treat all zeros the same, instead of
sorting 0M before 0G; this is more consistent with the desired
behavior of sorting -1G before -1M.
* tests/misc/sort (h1, h3, h6): Adjust to match mostly-reverted
behavior. However, check that all zeros sort together.
* tests/misc/sort-debug-keys: Omit a "_", since the trailing "i"
in "1234Gi" is no longer part of the key.
2010-08-02 19:18:01 -07:00
|
|
|
# "M" sorts before "G" regardless of the positive number attached.
|
|
|
|
|
["h6", '-h', {IN=>"1GiB\n1030MiB\n"}, {OUT=>"1030MiB\n1GiB\n"}],
|
2009-04-27 14:51:29 +01:00
|
|
|
# check option incompatibility
|
|
|
|
|
["h7", '-hn', {IN=>""}, {OUT=>""}, {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: options '-hn' are incompatible\n"}],
|
2009-04-27 14:51:29 +01:00
|
|
|
# check key processing
|
|
|
|
|
["h8", '-n -k2,2h', {IN=>"1 1E\n2 2M\n"}, {OUT=>"2 2M\n1 1E\n"}],
|
2009-06-30 00:52:43 +01:00
|
|
|
# SI and IEC prefixes on separate keys allowed
|
|
|
|
|
["h9", '-h -k1,1 -k2,2', {IN=>"1M 1Mi\n1M 1Mi\n"}, {OUT=>"1M 1Mi\n1M 1Mi\n"}],
|
|
|
|
|
# This invalid SI and IEC prefix mixture is not significant so not noticed
|
|
|
|
|
["h10", '-h -k1,1 -k2,2', {IN=>"1M 2M\n2M 1Mi\n"}, {OUT=>"1M 2M\n2M 1Mi\n"}],
|
2009-04-27 14:51:29 +01:00
|
|
|
|
2008-05-09 08:04:59 +02:00
|
|
|
["01a", '', {IN=>"A\nB\nC\n"}, {OUT=>"A\nB\nC\n"}],
|
|
|
|
|
#
|
|
|
|
|
["02a", '-c', {IN=>"A\nB\nC\n"}, {OUT=>''}],
|
|
|
|
|
["02b", '-c', {IN=>"A\nC\nB\n"}, {OUT=>''}, {EXIT=>1},
|
|
|
|
|
{ERR=>"$prog: -:3: disorder: B\n"}, $normalize_filename],
|
2008-05-14 09:37:02 +02:00
|
|
|
["02c", '-c -k1,1', {IN=>"a\na b\n"}, {OUT=>''}],
|
2008-05-09 08:04:59 +02:00
|
|
|
["02d", '-C', {IN=>"A\nB\nC\n"}, {OUT=>''}],
|
|
|
|
|
["02e", '-C', {IN=>"A\nC\nB\n"}, {OUT=>''}, {EXIT=>1}],
|
|
|
|
|
# This should fail because there are duplicate keys
|
|
|
|
|
["02m", '-cu', {IN=>"A\nA\n"}, {OUT=>''}, {EXIT=>1},
|
|
|
|
|
{ERR=>"$prog: -:2: disorder: A\n"}, $normalize_filename],
|
|
|
|
|
["02n", '-cu', {IN=>"A\nB\n"}, {OUT=>''}],
|
|
|
|
|
["02o", '-cu', {IN=>"A\nB\nB\n"}, {OUT=>''}, {EXIT=>1},
|
|
|
|
|
{ERR=>"$prog: -:3: disorder: B\n"}, $normalize_filename],
|
|
|
|
|
["02p", '-cu', {IN=>"B\nA\nB\n"}, {OUT=>''}, {EXIT=>1},
|
|
|
|
|
{ERR=>"$prog: -:2: disorder: A\n"}, $normalize_filename],
|
sort: support all combinations of -d, -f, -i, -R, and -V
* NEWS: Document this.
* src/sort.c (getmonth): Omit LEN arg, as MONTH is now null-terminated.
(compare_random): Don't null-terminate keys, as caller now does that.
(compare_version): Remove.
(debug_key): Null-terminate string for getmonth.
(keycompare): Support combining -R with any of -d, -f, -i, -V.
Also, support combining -V with any of -d, -i.
(check_ordering_compatibility): Allow newly-supported combinations.
* tests/misc/sort (02q, 02r, 02s): New tests, for new combinations.
(incompat2): Now test -nR, since -fR are now compatible.
2010-08-06 21:30:17 -07:00
|
|
|
["02q", '-c -k 1,1fR', {IN=>"ABC\nABc\nAbC\nAbc\naBC\naBc\nabC\nabc\n"}],
|
|
|
|
|
["02r", '-c -k 1,1fV', {IN=>"ABC\nABc\nAbC\nAbc\naBC\naBc\nabC\nabc\n"}],
|
|
|
|
|
["02s", '-c -k 1,1dfR',
|
|
|
|
|
{IN=>".ABC\n.ABc.\nA.bC\nA.bc.\naB.C\naB.c.\nabC.\nabc..\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
#
|
|
|
|
|
["03a", '-k1', {IN=>"B\nA\n"}, {OUT=>"A\nB\n"}],
|
|
|
|
|
["03b", '-k1,1', {IN=>"B\nA\n"}, {OUT=>"A\nB\n"}],
|
2008-05-14 09:37:02 +02:00
|
|
|
["03c", '-k1 -k2', {IN=>"A b\nA a\n"}, {OUT=>"A a\nA b\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
# Fail with a diagnostic when -k specifies field == 0.
|
|
|
|
|
["03d", '-k0', {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: -: invalid field specification '0'\n"},
|
2008-05-09 08:04:59 +02:00
|
|
|
$normalize_filename],
|
|
|
|
|
# Fail with a diagnostic when -k specifies character == 0.
|
|
|
|
|
["03e", '-k1.0', {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: character offset is zero: invalid field specification '1.0'\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
["03f", '-k1.1,-k0', {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: invalid number after ',': invalid count at start of '-k0'\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
# This is ok.
|
2008-05-14 09:37:02 +02:00
|
|
|
["03g", '-k1.1,1.0', {IN=>''}],
|
2008-05-09 08:04:59 +02:00
|
|
|
# This is equivalent to 3f.
|
2008-05-14 09:37:02 +02:00
|
|
|
["03h", '-k1.1,1', {IN=>''}],
|
2008-05-09 08:04:59 +02:00
|
|
|
# This too, is equivalent to 3f.
|
2008-05-14 09:37:02 +02:00
|
|
|
["03i", '-k1,1', {IN=>''}],
|
2008-05-09 08:04:59 +02:00
|
|
|
#
|
|
|
|
|
["04a", '-nc', {IN=>"2\n11\n"}],
|
|
|
|
|
["04b", '-n', {IN=>"11\n2\n"}, {OUT=>"2\n11\n"}],
|
|
|
|
|
["04c", '-k1n', {IN=>"11\n2\n"}, {OUT=>"2\n11\n"}],
|
|
|
|
|
["04d", '-k1', {IN=>"11\n2\n"}, {OUT=>"11\n2\n"}],
|
|
|
|
|
["04e", '-k2', {IN=>"ignored B\nz-ig A\n"}, {OUT=>"z-ig A\nignored B\n"}],
|
|
|
|
|
#
|
|
|
|
|
["05a", '-k1,2', {IN=>"A B\nA A\n"}, {OUT=>"A A\nA B\n"}],
|
|
|
|
|
["05b", '-k1,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}],
|
2008-05-14 09:37:02 +02:00
|
|
|
["05c", '-k1 -k2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
["05d", '-k2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}],
|
|
|
|
|
["05e", '-k2,2', {IN=>"A B Z\nA A A\n"}, {OUT=>"A A A\nA B Z\n"}],
|
|
|
|
|
["05f", '-k2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}],
|
|
|
|
|
#
|
2008-05-14 09:37:02 +02:00
|
|
|
["06a", '-k 1,2', {IN=>"A B\nA A\n"}, {OUT=>"A A\nA B\n"}],
|
|
|
|
|
["06b", '-k 1,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}],
|
|
|
|
|
["06c", '-k 1 -k 2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}],
|
|
|
|
|
["06d", '-k 2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}],
|
|
|
|
|
["06e", '-k 2,2', {IN=>"A B Z\nA A A\n"}, {OUT=>"A A A\nA B Z\n"}],
|
|
|
|
|
["06f", '-k 2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
#
|
2008-05-14 09:37:02 +02:00
|
|
|
["07a", '-k 2,3', {IN=>"9 a b\n7 a a\n"}, {OUT=>"7 a a\n9 a b\n"}],
|
|
|
|
|
["07b", '-k 2,3', {IN=>"a a b\nz a a\n"}, {OUT=>"z a a\na a b\n"}],
|
|
|
|
|
["07c", '-k 2,3', {IN=>"y k b\nz k a\n"}, {OUT=>"z k a\ny k b\n"}],
|
|
|
|
|
["07d", '+1 -3', {IN=>"y k b\nz k a\n"}, {OUT=>"z k a\ny k b\n"}],
|
2009-02-24 08:37:18 +00:00
|
|
|
# ensure a character position of 0 includes whole field
|
|
|
|
|
["07e", '-k 2,3.0', {IN=>"a a b\nz a a\n"}, {OUT=>"z a a\na a b\n"}],
|
2009-06-11 18:30:32 +01:00
|
|
|
# ensure fields with end position before start are ignored
|
|
|
|
|
["07f", '-n -k1.3,1.1', {IN=>"a 2\nb 1\n"}, {OUT=>"a 2\nb 1\n"}],
|
|
|
|
|
["07g", '-n -k2.2,1.2', {IN=>"aa 2\nbb 1\n"}, {OUT=>"aa 2\nbb 1\n"}],
|
|
|
|
|
["07h", '-k1.3nb,1.3', {IN=>" a 2\n b 1\n"}, {OUT=>" a 2\n b 1\n"}],
|
2010-04-20 16:25:55 +01:00
|
|
|
# ensure obsolescent key limits are handled correctly
|
|
|
|
|
["07i", '-s +0 -1', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}],
|
|
|
|
|
["07j", '-s +0 -1.0', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}],
|
|
|
|
|
["07k", '-s +0 -1.1', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}],
|
|
|
|
|
["07l", '-s +0 -1.2', {IN=>"a c\na b\n"}, {OUT=>"a b\na c\n"}],
|
|
|
|
|
["07m", '-s +0 -1.1b', {IN=>"a c\na b\n"}, {OUT=>"a b\na c\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
#
|
2012-01-07 17:47:58 +01:00
|
|
|
# report an error for '.' without following char spec
|
2008-05-14 09:37:02 +02:00
|
|
|
["08a", '-k 2.,3', {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: invalid number after '.': invalid count at start of ',3'\n"}],
|
2012-01-07 17:47:58 +01:00
|
|
|
# report an error for ',' without following POS2
|
2008-05-14 09:37:02 +02:00
|
|
|
["08b", '-k 2,', {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: invalid number after ',': invalid count at start of ''\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
#
|
|
|
|
|
# Test new -g option.
|
|
|
|
|
["09a", '-g', {IN=>"1e2\n2e1\n"}, {OUT=>"2e1\n1e2\n"}],
|
|
|
|
|
# Make sure -n works how we expect.
|
|
|
|
|
["09b", '-n', {IN=>"1e2\n2e1\n"}, {OUT=>"1e2\n2e1\n"}],
|
|
|
|
|
["09c", '-n', {IN=>"2e1\n1e2\n"}, {OUT=>"1e2\n2e1\n"}],
|
|
|
|
|
["09d", '-k2g', {IN=>"a 1e2\nb 2e1\n"}, {OUT=>"b 2e1\na 1e2\n"}],
|
|
|
|
|
#
|
|
|
|
|
# Bug reported by Roger Peel <R.Peel@ee.surrey.ac.uk>
|
2008-05-14 09:37:02 +02:00
|
|
|
["10a", '-t : -k 2.2,2.2', {IN=>":ba\n:ab\n"}, {OUT=>":ba\n:ab\n"}],
|
2012-01-07 17:47:58 +01:00
|
|
|
# Equivalent to above, but using obsolescent '+pos -pos' option syntax.
|
2008-05-14 09:37:02 +02:00
|
|
|
["10b", '-t : +1.1 -1.2', {IN=>":ba\n:ab\n"}, {OUT=>":ba\n:ab\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
#
|
|
|
|
|
# The same as the preceding two, but with input lines reversed.
|
2008-05-14 09:37:02 +02:00
|
|
|
["10c", '-t : -k 2.2,2.2', {IN=>":ab\n:ba\n"}, {OUT=>":ba\n:ab\n"}],
|
2012-01-07 17:47:58 +01:00
|
|
|
# Equivalent to above, but using obsolescent '+pos -pos' option syntax.
|
2008-05-14 09:37:02 +02:00
|
|
|
["10d", '-t : +1.1 -1.2', {IN=>":ab\n:ba\n"}, {OUT=>":ba\n:ab\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
# Try without -t...
|
|
|
|
|
# But note that we have to count the delimiting space at the beginning
|
|
|
|
|
# of each field that has it.
|
2008-05-14 09:37:02 +02:00
|
|
|
["10a0", '-k 2.3,2.3', {IN=>"z ba\nz ab\n"}, {OUT=>"z ba\nz ab\n"}],
|
|
|
|
|
["10a1", '-k 1.2,1.2', {IN=>"ba\nab\n"}, {OUT=>"ba\nab\n"}],
|
|
|
|
|
["10a2", '-b -k 2.2,2.2', {IN=>"z ba\nz ab\n"}, {OUT=>"z ba\nz ab\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
#
|
|
|
|
|
# An even simpler example demonstrating the bug.
|
2008-05-14 09:37:02 +02:00
|
|
|
["10e", '-k 1.2,1.2', {IN=>"ab\nba\n"}, {OUT=>"ba\nab\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
#
|
|
|
|
|
# The way sort works on these inputs (10f and 10g) seems wrong to me.
|
|
|
|
|
# See http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=3c467c0d223
|
|
|
|
|
# POSIX doesn't seem to say one way or the other, but that's the way all
|
|
|
|
|
# other sort implementations work.
|
2008-05-14 09:37:02 +02:00
|
|
|
["10f", '-t : -k 1.3,1.3', {IN=>":ab\n:ba\n"}, {OUT=>":ba\n:ab\n"}],
|
|
|
|
|
["10g", '-k 1.4,1.4', {IN=>"a ab\nb ba\n"}, {OUT=>"b ba\na ab\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
#
|
|
|
|
|
# Exercise bug re using -b to skip trailing blanks.
|
2008-05-14 09:37:02 +02:00
|
|
|
["11a", '-t: -k1,1b -k2,2', {IN=>"a\t:a\na :b\n"}, {OUT=>"a\t:a\na :b\n"}],
|
|
|
|
|
["11b", '-t: -k1,1b -k2,2', {IN=>"a :b\na\t:a\n"}, {OUT=>"a\t:a\na :b\n"}],
|
|
|
|
|
["11c", '-t: -k2,2b -k3,3', {IN=>"z:a\t:a\na :b\n"}, {OUT=>"z:a\t:a\na :b\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
# Before 1.22m, the first key comparison reported equality.
|
|
|
|
|
# With 1.22m, they compare different: "a" sorts before "a\n",
|
|
|
|
|
# and the second key spec isn't even used.
|
2008-05-14 09:37:02 +02:00
|
|
|
["11d", '-t: -k2,2b -k3,3', {IN=>"z:a :b\na\t:a\n"}, {OUT=>"a\t:a\nz:a :b\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
#
|
2012-01-07 17:47:58 +01:00
|
|
|
# Exercise bug re comparing '-' and integers.
|
2008-05-14 09:37:02 +02:00
|
|
|
["12a", '-n -t: +1', {IN=>"a:1\nb:-\n"}, {OUT=>"b:-\na:1\n"}],
|
|
|
|
|
["12b", '-n -t: +1', {IN=>"b:-\na:1\n"}, {OUT=>"b:-\na:1\n"}],
|
2012-01-07 17:47:58 +01:00
|
|
|
# Try some other (e.g. 'X') invalid character.
|
2008-05-14 09:37:02 +02:00
|
|
|
["12c", '-n -t: +1', {IN=>"a:1\nb:X\n"}, {OUT=>"b:X\na:1\n"}],
|
|
|
|
|
["12d", '-n -t: +1', {IN=>"b:X\na:1\n"}, {OUT=>"b:X\na:1\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
# From Karl Heuer
|
|
|
|
|
["13a", '+0.1n', {IN=>"axx\nb-1\n"}, {OUT=>"b-1\naxx\n"}],
|
|
|
|
|
["13b", '+0.1n', {IN=>"b-1\naxx\n"}, {OUT=>"b-1\naxx\n"}],
|
|
|
|
|
#
|
|
|
|
|
# From Carl Johnson <carlj@cjlinux.home.org>
|
2008-05-14 09:37:02 +02:00
|
|
|
["14a", '-d -u', {IN=>"mal\nmal-\nmala\n"}, {OUT=>"mal\nmala\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
# Be sure to fix the (translate && ignore) case in keycompare.
|
2008-05-14 09:37:02 +02:00
|
|
|
["14b", '-f -d -u', {IN=>"mal\nmal-\nmala\n"}, {OUT=>"mal\nmala\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
#
|
|
|
|
|
# Experiment with -i.
|
2008-05-14 09:37:02 +02:00
|
|
|
["15a", '-i -u', {IN=>"a\na\1\n"}, {OUT=>"a\n"}],
|
|
|
|
|
["15b", '-i -u', {IN=>"a\n\1a\n"}, {OUT=>"a\n"}],
|
|
|
|
|
["15c", '-i -u', {IN=>"a\1\na\n"}, {OUT=>"a\1\n"}],
|
|
|
|
|
["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"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
|
sort: sort --unique (-u) could cause data loss
sort -u could omit one or more lines of expected output.
This bug arose because sort recorded the most recently printed line via
reference, and if you were unlucky, the storage for that line would be
reused (overwritten) as additional input was read into memory. If you
were doubly unlucky, the new value of the "saved" line would not only
match the very next line, but if that next line were also the first in
a series of identical, not-yet-printed lines, then the corrupted "saved"
line value would result in the omission of all matching lines.
* src/sort.c (saved_line): New static/global, renamed and moved from...
(write_unique): ...here. Old name was "saved", which was too generic
for its new role as file-scoped global.
(fillbuf): With --unique, when we're about to read into a buffer that
overlaps the saved "preceding" line (saved_line), copy the line's .text
member to a realloc'd-as-needed temporary buffer and adjust the line's
key-defining members if they're set.
(overlap): New function.
* tests/misc/sort: New tests.
* NEWS (Bug fixes): Mention it.
* THANKS.in: Update.
Bug introduced via commit v8.5-89-g9face83.
Reported by Rasmus Borup Hansen in
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/23173/focus=24647
2012-08-15 12:30:44 +02:00
|
|
|
# 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"}],
|
2012-08-18 07:26:30 +02:00
|
|
|
# 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"}],
|
sort: sort --unique (-u) could cause data loss
sort -u could omit one or more lines of expected output.
This bug arose because sort recorded the most recently printed line via
reference, and if you were unlucky, the storage for that line would be
reused (overwritten) as additional input was read into memory. If you
were doubly unlucky, the new value of the "saved" line would not only
match the very next line, but if that next line were also the first in
a series of identical, not-yet-printed lines, then the corrupted "saved"
line value would result in the omission of all matching lines.
* src/sort.c (saved_line): New static/global, renamed and moved from...
(write_unique): ...here. Old name was "saved", which was too generic
for its new role as file-scoped global.
(fillbuf): With --unique, when we're about to read into a buffer that
overlaps the saved "preceding" line (saved_line), copy the line's .text
member to a realloc'd-as-needed temporary buffer and adjust the line's
key-defining members if they're set.
(overlap): New function.
* tests/misc/sort: New tests.
* NEWS (Bug fixes): Mention it.
* THANKS.in: Update.
Bug introduced via commit v8.5-89-g9face83.
Reported by Rasmus Borup Hansen in
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/23173/focus=24647
2012-08-15 12:30:44 +02:00
|
|
|
|
2008-05-09 08:04:59 +02:00
|
|
|
# From Erick Branderhorst -- fixed around 1.19e
|
|
|
|
|
["16a", '-f',
|
|
|
|
|
{IN=>"éminence\nüberhaupt\n's-Gravenhage\naëroclub\nAag\naagtappels\n"},
|
|
|
|
|
{OUT=>"'s-Gravenhage\nAag\naagtappels\naëroclub\néminence\nüberhaupt\n"}],
|
|
|
|
|
|
|
|
|
|
# This provokes a one-byte memory overrun of a malloc'd block for versions
|
|
|
|
|
# of sort from textutils-1.19p and before.
|
|
|
|
|
["17", '-c', {IN=>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"}],
|
|
|
|
|
|
2012-01-07 17:47:58 +01:00
|
|
|
# POSIX says -n no longer implies -b, so here we're comparing ' 9' and '10'.
|
2008-05-09 08:04:59 +02:00
|
|
|
["18a", '-k1.1,1.2n', {IN=>" 901\n100\n"}, {OUT=>" 901\n100\n"}],
|
|
|
|
|
|
2012-01-07 17:47:58 +01:00
|
|
|
# Just like above, because the global '-b' has no effect on the
|
|
|
|
|
# key specifier when a key-specific option ('n' in this case) is used.
|
2008-05-14 09:37:02 +02:00
|
|
|
["18b", '-b -k1.1,1.2n', {IN=>" 901\n100\n"}, {OUT=>" 901\n100\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
|
2012-01-07 17:47:58 +01:00
|
|
|
# Here we're comparing ' 90' and '10', because the 'b' on the key-end specifier
|
2008-05-09 08:04:59 +02:00
|
|
|
# makes sort ignore leading blanks when determining that key's *end*.
|
|
|
|
|
["18c", '-k1.1,1.2nb', {IN=>" 901\n100\n"}, {OUT=>"100\n 901\n"}],
|
|
|
|
|
|
2012-01-07 17:47:58 +01:00
|
|
|
# Here we're comparing '9' and '10', because the 'b' on the key-start specifier
|
2008-05-09 08:04:59 +02:00
|
|
|
# makes sort ignore leading blanks when determining that key's *start*.
|
|
|
|
|
["18d", '-k1.1b,1.2n', {IN=>" 901\n100\n"}, {OUT=>" 901\n100\n"}],
|
|
|
|
|
|
2012-01-07 17:47:58 +01:00
|
|
|
# This compares '90' and '10', as it ignores leading blanks for both
|
2008-05-09 08:04:59 +02:00
|
|
|
# key start and key end.
|
2008-05-14 09:37:02 +02:00
|
|
|
["18e", '-nb -k1.1,1.2', {IN=>" 901\n100\n"}, {OUT=>"100\n 901\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
|
2009-02-24 08:37:18 +00:00
|
|
|
# When ignoring leading blanks for end position, ensure blanks from
|
|
|
|
|
# next field are not included in the sort. I.E. order should not change here.
|
|
|
|
|
["18f", '-k1,1b', {IN=>"a y\na z\n"}, {OUT=>"a y\na z\n"}],
|
|
|
|
|
|
2009-02-27 08:40:42 +00:00
|
|
|
# When ignoring leading blanks for start position, ensure blanks from
|
|
|
|
|
# next field are not included in the sort. I.E. order should not change here.
|
|
|
|
|
# This was noticed as an issue on fedora 8 (only in multibyte locales).
|
|
|
|
|
["18g", '-k1b,1', {IN=>"a y\na z\n"}, {OUT=>"a y\na z\n"},
|
|
|
|
|
{ENV => "LC_ALL=$mb_locale"}],
|
|
|
|
|
|
2008-05-09 08:04:59 +02:00
|
|
|
# This looks odd, but works properly -- 2nd keyspec is never
|
|
|
|
|
# used because all lines are different.
|
2008-05-14 09:37:02 +02:00
|
|
|
["19a", '+0 +1nr', {IN=>"b 2\nb 1\nb 3\n"}, {OUT=>"b 1\nb 2\nb 3\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
|
|
|
|
|
# The test *intended* by the author of the above, but using the
|
|
|
|
|
# more-intuitive POSIX-style -k options.
|
2008-05-14 09:37:02 +02:00
|
|
|
["19b", '-k1,1 -k2nr', {IN=>"b 2\nb 1\nb 3\n"}, {OUT=>"b 3\nb 2\nb 1\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
|
|
|
|
|
# This test failed when sort-1.22 was compiled on a Next x86 system
|
|
|
|
|
# without optimization. Without optimization gcc uses the buggy version
|
|
|
|
|
# of memcmp in the Next C library. With optimization, gcc uses its
|
|
|
|
|
# (working) builtin version. Test case form William Lewis.
|
|
|
|
|
["20a", '',
|
coreutils: keep lines within 80-column limits
* cfg.mk (LINE_LEN_MAX, FILTER_LONG_LINES): New macros.
(sc_long_lines): New rule.
* HACKING: Use shorter URLs to the same material.
* doc/Makefile.am, doc/coreutils.texi, m4/boottime.m4:
* man/help2man, man/stdbuf.x, src/Makefile.am, src/cat.c, src/copy.c:
* src/cp.c, src/dd.c, src/df.c, src/du.c, src/groups.c, src/install.c:
* src/ls.c, src/md5sum.c, src/mv.c, src/od.c, src/pinky.c, src/ptx.c:
* src/readlink.c, src/remove.c, src/rmdir.c, src/setuidgid.c:
* src/sort.c, src/tail.c, src/touch.c, tests/Coreutils.pm:
* tests/cp/existing-perm-race, tests/cp/perm, tests/cp/preserve-gid:
* tests/du/2g, tests/du/long-from-unreadable, tests/init.sh:
* tests/install/basic-1, tests/ls/nameless-uid:
* tests/ls/readdir-mountpoint-inode, tests/misc/chroot-credentials:
* tests/misc/cut, tests/misc/date, tests/misc/join, tests/misc/md5sum:
* tests/misc/sha1sum, tests/misc/sha224sum, tests/misc/sort:
* tests/misc/sort-continue, tests/misc/sort-files0-from:
* tests/misc/sort-rand, tests/misc/stdbuf, tests/misc/tr:
* tests/misc/uniq, tests/mv/atomic, tests/mv/part-fail:
* tests/mv/part-symlink, tests/mv/sticky-to-xpart, tests/pr/pr-tests:
* tests/rm/fail-2eperm, tests/rm/interactive-always:
Reformat to fit within 80 columns.
* doc/Makefile.am (BAD_POSIX_PERL): New macro.
* doc/coreutils.texi: Reword slightly, to make menus and
index lines shorter.
* src/md5sum.c: Redo --help output so that it fits within 79
columns, since that's a bit more portable and all the other --help
strings fit in 79 columns.
2010-12-28 12:28:48 -08:00
|
|
|
{IN=>"_________U__free\n_________U__malloc\n_________U__abort\n"
|
|
|
|
|
. "_________U__memcpy\n_________U__memset\n"
|
|
|
|
|
. "_________U_dyld_stub_binding_helper\n_________U__malloc\n"
|
|
|
|
|
. "_________U___iob\n_________U__abort\n_________U__fprintf\n"},
|
|
|
|
|
{OUT=>"_________U___iob\n_________U__abort\n_________U__abort\n"
|
|
|
|
|
. "_________U__fprintf\n_________U__free\n_________U__malloc\n"
|
|
|
|
|
. "_________U__malloc\n_________U__memcpy\n_________U__memset\n"
|
|
|
|
|
. "_________U_dyld_stub_binding_helper\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
|
|
|
|
|
# Demonstrate that folding changes the ordering of e.g. A, a, and _
|
|
|
|
|
# because while they normally (in the C locale) collate like A, _, a,
|
2012-01-07 17:47:58 +01:00
|
|
|
# when using -f, 'a' is compared as if it were 'A'.
|
2008-05-09 08:04:59 +02:00
|
|
|
["21a", '', {IN=>"A\na\n_\n"}, {OUT=>"A\n_\na\n"}],
|
|
|
|
|
["21b", '-f', {IN=>"A\na\n_\n"}, {OUT=>"A\na\n_\n"}],
|
|
|
|
|
["21c", '-f', {IN=>"a\nA\n_\n"}, {OUT=>"A\na\n_\n"}],
|
|
|
|
|
["21d", '-f', {IN=>"_\na\nA\n"}, {OUT=>"A\na\n_\n"}],
|
|
|
|
|
["21e", '-f', {IN=>"a\n_\nA\n"}, {OUT=>"A\na\n_\n"}],
|
|
|
|
|
["21f", '-fs', {IN=>"A\na\n_\n"}, {OUT=>"A\na\n_\n"}],
|
|
|
|
|
["21g", '-fu', {IN=>"a\n_\n"}, {OUT=>"a\n_\n"}],
|
|
|
|
|
|
|
|
|
|
# This test failed until 1.22f. From Zvi Har'El.
|
2008-05-14 09:37:02 +02:00
|
|
|
["22a", '-k 2,2fd -k 1,1r', {IN=>"3 b\n4 B\n"}, {OUT=>"4 B\n3 b\n"}],
|
|
|
|
|
["22b", '-k 2,2d -k 1,1r', {IN=>"3 b\n4 b\n"}, {OUT=>"4 b\n3 b\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
|
|
|
|
|
["no-file1", 'no-file', {EXIT=>2}, {ERR=>$no_file}],
|
|
|
|
|
# This test failed until 1.22f. Sort didn't give an error.
|
|
|
|
|
# From Will Edgington.
|
|
|
|
|
["o-no-file1", qw(-o no-file no-file), {EXIT=>2}, {ERR=>$no_file}],
|
|
|
|
|
|
|
|
|
|
["create-empty", qw(-o no/such/file /dev/null), {EXIT=>2},
|
|
|
|
|
{ERR=>"$prog: open failed: no/such/file: No such file or directory\n"}],
|
|
|
|
|
|
|
|
|
|
# From Paul Eggert. This was fixed in textutils-1.22k.
|
|
|
|
|
["neg-nls", '-n', {IN=>"-1\n-9\n"}, {OUT=>"-9\n-1\n"}],
|
|
|
|
|
|
|
|
|
|
# From Paul Eggert. This was fixed in textutils-1.22m.
|
|
|
|
|
# The bug was visible only when using the internationalized sorting code
|
|
|
|
|
# (i.e., not when configured with --disable-nls).
|
|
|
|
|
["nul-nls", '', {IN=>"\0b\n\0a\n"}, {OUT=>"\0a\n\0b\n"}],
|
|
|
|
|
|
|
|
|
|
# Paul Eggert wrote:
|
2010-08-13 15:57:01 -07:00
|
|
|
# A previous version of POSIX incorrectly required that the newline
|
|
|
|
|
# at the end of the input line contributed to the sort, which would
|
|
|
|
|
# mean that an empty line should sort after a line starting with a tab
|
|
|
|
|
# (because \t precedes \n in the ASCII collating sequence).
|
|
|
|
|
# GNU 'sort' was altered to do this, but was changed back once it
|
|
|
|
|
# was discovered to be a POSIX bug (and the POSIX bug was fixed).
|
|
|
|
|
# Check that 'sort' conforms to the fixed POSIX, not to the buggy one.
|
2008-05-09 08:04:59 +02:00
|
|
|
["use-nl", '', {IN=>"\n\t\n"}, {OUT=>"\n\t\n"}],
|
|
|
|
|
|
|
|
|
|
# Specifying two -o options should evoke a failure
|
|
|
|
|
["o2", qw(-o x -o y), {EXIT=>2},
|
|
|
|
|
{ERR=>"foo\n"}, {ERR_SUBST => 's/^$prog: .*/foo/'}],
|
|
|
|
|
|
|
|
|
|
# Specifying incompatible options should evoke a failure.
|
|
|
|
|
["incompat1", '-in', {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: options '-in' are incompatible\n"}],
|
sort: support all combinations of -d, -f, -i, -R, and -V
* NEWS: Document this.
* src/sort.c (getmonth): Omit LEN arg, as MONTH is now null-terminated.
(compare_random): Don't null-terminate keys, as caller now does that.
(compare_version): Remove.
(debug_key): Null-terminate string for getmonth.
(keycompare): Support combining -R with any of -d, -f, -i, -V.
Also, support combining -V with any of -d, -i.
(check_ordering_compatibility): Allow newly-supported combinations.
* tests/misc/sort (02q, 02r, 02s): New tests, for new combinations.
(incompat2): Now test -nR, since -fR are now compatible.
2010-08-06 21:30:17 -07:00
|
|
|
["incompat2", '-nR', {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: options '-nR' are incompatible\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
["incompat3", '-dfgiMnR', {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: options '-dfgMnR' are incompatible\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
["incompat4", qw(-c -o /dev/null), {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: options '-co' are incompatible\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
["incompat5", qw(-C -o /dev/null), {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: options '-Co' are incompatible\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
["incompat6", '-cC', {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: options '-cC' are incompatible\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
["incompat7", qw(--sort=random -n), {EXIT=>2},
|
2012-01-07 20:55:10 +01:00
|
|
|
{ERR=>"$prog: options '-nR' are incompatible\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
|
|
|
|
|
# -t '\0' is accepted, as of coreutils-5.0.91
|
|
|
|
|
['nul-tab', "-k2,2 -t '\\0'",
|
|
|
|
|
{IN=>"a\0z\01\nb\0y\02\n"}, {OUT=>"b\0y\02\na\0z\01\n"}],
|
|
|
|
|
|
2008-12-12 10:25:34 +00:00
|
|
|
# fields > SIZE_MAX are silently interpreted as SIZE_MAX
|
2010-05-15 17:58:52 +02:00
|
|
|
["bigfield1", "-k $limits->{UINTMAX_OFLOW}",
|
2008-12-12 10:25:34 +00:00
|
|
|
{IN=>"2\n1\n"}, {OUT=>"1\n2\n"}],
|
2010-05-15 17:58:52 +02:00
|
|
|
["bigfield2", "-k $limits->{SIZE_OFLOW}",
|
2008-05-09 08:04:59 +02:00
|
|
|
{IN=>"2\n1\n"}, {OUT=>"1\n2\n"}],
|
|
|
|
|
|
|
|
|
|
# Using an old-style key-specifying option like +1 with an invalid
|
|
|
|
|
# ordering-option character would cause sort to try to free an invalid
|
|
|
|
|
# (non-malloc'd) pointer. This bug affects coreutils-6.5 through 6.9.
|
|
|
|
|
['obs-inval', '+1x', {EXIT=>2},
|
|
|
|
|
{ERR=>"foo\n"}, {ERR_SUBST => 's/^$prog: .*/foo/'}],
|
|
|
|
|
|
|
|
|
|
# Exercise the code that enlarges the line buffer. See the thread here:
|
|
|
|
|
# http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/11006
|
|
|
|
|
['realloc-buf', '-S1', {IN=>'a'x4000 ."\n"}, {OUT=>'a'x4000 ."\n"}],
|
2010-07-26 20:51:02 -07:00
|
|
|
['realloc-buf-2', '-S1', {IN=>'a'x5 ."\n"}, {OUT=>'a'x5 ."\n"}],
|
2008-05-09 08:04:59 +02:00
|
|
|
|
|
|
|
|
["sort-numeric", '--sort=numeric', {IN=>".01\n0\n"}, {OUT=>"0\n.01\n"}],
|
|
|
|
|
["sort-gennum", '--sort=general-numeric',
|
|
|
|
|
{IN=>"1e2\n2e1\n"}, {OUT=>"2e1\n1e2\n"}],
|
2009-04-22 08:45:27 +02:00
|
|
|
|
|
|
|
|
# -m with output file also used as an input file
|
|
|
|
|
# In coreutils-7.2, this caused a segfault.
|
|
|
|
|
# This test looks a little strange. Here's why:
|
|
|
|
|
# since we're using "-o f", standard output will be empty, hence OUT=>''
|
|
|
|
|
# We still want to ensure that the output file, "f" has expected contents,
|
|
|
|
|
# hence the added CMP=> directive.
|
|
|
|
|
["output-is-input", '-m -o f', {IN=> {f=> "a\n"}}, {OUT=>''},
|
|
|
|
|
{CMP=> ["a\n", {'f'=> undef}]} ],
|
|
|
|
|
["output-is-input-2", '-m -o f', {OUT=>''},
|
|
|
|
|
{IN=> {f=> "a\n"}}, {IN=> {g=> "b\n"}}, {IN=> {h=> "c\n"}},
|
|
|
|
|
{CMP=> ["a\nb\nc\n", {'f'=> undef}]} ],
|
|
|
|
|
["output-is-input-3", '-m -o f', {OUT=>''},
|
|
|
|
|
{IN=> {g=> "a\n"}}, {IN=> {h=> "b\n"}}, {IN=> {f=> "c\n"}},
|
|
|
|
|
{CMP=> ["a\nb\nc\n", {'f'=> undef}]} ],
|
2008-05-09 08:04:59 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
# Add _POSIX2_VERSION=199209 to the environment of each test
|
|
|
|
|
# that uses an old-style option like +1.
|
|
|
|
|
foreach my $t (@Tests)
|
|
|
|
|
{
|
|
|
|
|
foreach my $e (@$t)
|
|
|
|
|
{
|
|
|
|
|
!ref $e && $e =~ /\+\d/
|
|
|
|
|
and push (@$t, {ENV=>'_POSIX2_VERSION=199209'}), last;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Tests = triple_test \@Tests;
|
|
|
|
|
|
2009-04-24 21:34:59 +02:00
|
|
|
# Remember that triple_test creates from each test with exactly one "IN"
|
|
|
|
|
# file two more tests (.p and .r suffix on name) corresponding to reading
|
|
|
|
|
# input from a file and from a pipe. The pipe-reading test would fail
|
|
|
|
|
# due to a race condition about 1 in 20 times.
|
|
|
|
|
# Remove the IN_PIPE version of the "output-is-input" test above.
|
|
|
|
|
# The others aren't susceptible because they have three inputs each.
|
|
|
|
|
@Tests = grep {$_->[0] ne 'output-is-input.p'} @Tests;
|
|
|
|
|
|
2008-05-09 08:04:59 +02:00
|
|
|
my $save_temps = $ENV{DEBUG};
|
|
|
|
|
my $verbose = $ENV{VERBOSE};
|
|
|
|
|
|
|
|
|
|
my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose);
|
|
|
|
|
exit $fail;
|