summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/head-elide-tail2
-rwxr-xr-xtests/misc/head-pos26
2 files changed, 20 insertions, 8 deletions
diff --git a/tests/misc/head-elide-tail b/tests/misc/head-elide-tail
index de4896bc5..85f509d26 100755
--- a/tests/misc/head-elide-tail
+++ b/tests/misc/head-elide-tail
@@ -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
index 3d96261f9..fa3284e90 100755
--- a/tests/misc/head-pos
+++ b/tests/misc/head-pos
@@ -21,12 +21,24 @@
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