summaryrefslogtreecommitdiff
path: root/tests/misc/yes.sh
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivano@gnu.org>2015-03-10 12:25:48 +0000
committerPádraig Brady <P@draigBrady.com>2015-03-10 12:30:33 +0000
commite2e11119e0ac653bd0bdab91c189b7803f8df1f0 (patch)
tree47b82ed120099802b15c5422849c35bcd13402ff /tests/misc/yes.sh
parent35217221c211f3116f374f305654462195aa634a (diff)
downloadcoreutils-e2e11119e0ac653bd0bdab91c189b7803f8df1f0.tar.xz
yes: improve efficiency when all args aren't buffered
* src/yes.c (main): Even when the internal buffer isn't large enough, output what we've buffered already, and interate over the rest. This improves the performance in the edge case where there are many small arguments that overflow the buffer. * tests/misc/yes.sh: Add a test case for the many small arguments case.
Diffstat (limited to 'tests/misc/yes.sh')
-rwxr-xr-xtests/misc/yes.sh12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/misc/yes.sh b/tests/misc/yes.sh
index 4ed300a4f..79f8b87c0 100755
--- a/tests/misc/yes.sh
+++ b/tests/misc/yes.sh
@@ -19,7 +19,7 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ yes
-# Check various buffer sizes, with the most important
+# Check various single item sizes, with the most important
# size being BUFSIZ used for the local buffer to yes(1).
# Note a \n is added, so actual sizes required internally
# are 1 more than the size used here.
@@ -29,4 +29,14 @@ for size in 1 1999 4095 4096 8191 8192 16383 16384; do
compare out.1 out.2 || fail=1
done
+# Check the many small items case,
+# both fitting and overflowing the internal buffer
+if env true $(seq 4000); then
+ for i in 100 4000; do
+ seq $i | paste -s -d ' ' | sed p > out.1
+ yes $(seq $i) | head -n2 > out.2
+ compare out.1 out.2 || fail=1
+ done
+fi
+
Exit $fail