summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBo Borgerson <gigabo@gmail.com>2008-04-05 13:33:51 -0400
committerJim Meyering <meyering@redhat.com>2008-06-17 22:36:51 +0200
commit20905b0cdcb960c9949763c606f15e7e09d02e00 (patch)
tree4857729dfcb9dfa816027a106567c166e8260271 /tests
parent322c6f2e5cd3d09ed31d9d8dea2310d70f47842a (diff)
downloadcoreutils-20905b0cdcb960c9949763c606f15e7e09d02e00.tar.xz
sort: accept new option --batch-size=NMERGE
* src/sort.c: (static unsigned int nmerge) Replace constant NMERGE. (specify_nmerge) Validate and apply new option. (mergefps) Replace some arrays with pointers to xnmalloc'd storage. * tests/misc/sort-merge: Test new option. * doc/coreutils.texi: Describe new option. * NEWS: Advertise new option.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/sort-merge43
1 files changed, 41 insertions, 2 deletions
diff --git a/tests/misc/sort-merge b/tests/misc/sort-merge
index f90ba9bce..a2524c40c 100755
--- a/tests/misc/sort-merge
+++ b/tests/misc/sort-merge
@@ -19,18 +19,57 @@
use strict;
(my $program_name = $0) =~ s|.*/||;
+my $prog = 'sort';
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+# three empty files and one that says 'foo'
+my @inputs = (+(map{{IN=> {"empty$_"=> ''}}}1..3), {IN=> {foo=> "foo\n"}});
+
+# don't need to check for existence, since we're running in a temp dir
+my $badtmp = 'does/not/exist';
+
+# 2^64+1
+my $bigint = "18446744073709551617";
+
my @Tests =
(
- ['m1', '-m', {IN=> {empty=> ''}}, {IN=> {f=> "foo\n"}}, {OUT=>"foo\n"}],
+ ['m1', '-m', @inputs, {OUT=>"foo\n"}],
+
+ # check validation of --batch-size option
+ ['nmerge-0', "-m --batch-size=0", @inputs,
+ {ERR=>"$prog: invalid --batch-size argument `0'\n".
+ "$prog: minimum --batch-size argument is `2'\n"}, {EXIT=>2}],
+
+ ['nmerge-1', "-m --batch-size=1", @inputs,
+ {ERR=>"$prog: invalid --batch-size argument `1'\n".
+ "$prog: minimum --batch-size argument is `2'\n"}, {EXIT=>2}],
+
+ ['nmerge-neg', "-m --batch-size=-1", @inputs,
+ {ERR=>"$prog: invalid --batch-size argument `-1'\n"}, {EXIT=>2}],
+
+ ['nmerge-nan', "-m --batch-size=a", @inputs,
+ {ERR=>"$prog: invalid --batch-size argument `a'\n"}, {EXIT=>2}],
+
+ ['nmerge-big', "-m --batch-size=$bigint", @inputs,
+ {ERR_SUBST=>'s/current rlimit is .+\n/current rlimit is/'},
+ {ERR=>"$prog: --batch-size argument `$bigint' too large\n".
+ "$prog: maximum --batch-size argument with current rlimit is"},
+ {EXIT=>2}],
+
+ # This should work since nmerge >= the number of input files
+ ['nmerge-yes', "-m --batch-size=4 -T$badtmp", @inputs, {OUT=>"foo\n"}],
+
+ # this should fail since nmerge < # of input files, so
+ # temp files are needed
+ ['nmerge-no', "-m --batch-size=2 -T$badtmp", @inputs,
+ {ERR_SUBST=>"s|: $badtmp/sort.+||"},
+ {ERR=>"$prog: cannot create temporary file\n"}, {EXIT=>2}],
);
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
-my $prog = 'sort';
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
exit $fail;