]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: sort: check sort -m preserves long lines
authorSylvestre Ledru <sylvestre@debian.org>
Mon, 25 May 2026 17:35:42 +0000 (19:35 +0200)
committerPádraig Brady <P@draigBrady.com>
Fri, 29 May 2026 18:25:40 +0000 (19:25 +0100)
* tests/sort/sort-merge.pl: Add 'long-lines' case ensuring that
merging input whose lines exceed the read buffer does not split
lines on buffer boundaries.
https://github.com/coreutils/coreutils/pull/270

tests/sort/sort-merge.pl

index 33824790ba612ce72ceb45c082ec35e8b1d1b393..16a6b03009a296f2508fd43273858a2d9179f112 100755 (executable)
@@ -31,6 +31,11 @@ my @inputs = (+(map{{IN=> {"empty$_"=> ''}}}1..3), {IN=> {foo=> "foo\n"}});
 
 my $big_input = "aaa\n" x 1024;
 
+# lines longer than the default merge read buffer must not be split
+my $long_lines_in = ('a' x 32000) . "\n" .
+                    ('b' x 32000) . "\n" .
+                    ('c' x 32000) . "\n";
+
 # don't need to check for existence, since we're running in a temp dir
 my $badtmp = 'does/not/exist';
 
@@ -75,6 +80,11 @@ my @Tests =
      # buffer size would cause the buffer size to be set to the minimum.
      ['batch-size', "--batch-size=16 -T$badtmp", {IN=> {big=> $big_input}},
         {OUT=>$big_input}],
+
+     # Merging input with lines longer than the read buffer must
+     # preserve line boundaries.
+     ['long-lines', '-m', {IN=> {long=> $long_lines_in}},
+        {OUT=>$long_lines_in}],
     );
 
 my $save_temps = $ENV{DEBUG};