diff options
| author | dann frazier <dann.frazier@canonical.com> | 2023-11-29 18:32:34 -0700 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2023-12-01 23:01:32 +0000 |
| commit | 73d119f4f8052a9fb6cef13cd9e75d5a4e23311a (patch) | |
| tree | cb87887451ea5a0ebde68f0ccc8d311712d4bf6a /tests | |
| parent | numfmt: support lowercase 'k' for Kilo and Kibi (diff) | |
| download | coreutils-73d119f4f8052a9fb6cef13cd9e75d5a4e23311a.tar.gz coreutils-73d119f4f8052a9fb6cef13cd9e75d5a4e23311a.zip | |
tail: fix tailing sysfs files where PAGE_SIZE > BUFSIZ
* src/tail.c (file_lines): Ensure we use a buffer size >= PAGE_SIZE when
searching backwards to avoid seeking within a file,
which on sysfs files is accepted but also returns no data.
* tests/tail/tail-sysfs.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/67490
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/local.mk | 1 | ||||
| -rwxr-xr-x | tests/tail/tail-sysfs.sh | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/local.mk b/tests/local.mk index db4ee7ed8..bf03238c3 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -257,6 +257,7 @@ all_tests = \ tests/seq/seq-precision.sh \ tests/head/head.pl \ tests/head/head-elide-tail.pl \ + tests/tail/tail-sysfs.sh \ tests/tail/tail-n0f.sh \ tests/ls/ls-misc.pl \ tests/date/date.pl \ diff --git a/tests/tail/tail-sysfs.sh b/tests/tail/tail-sysfs.sh new file mode 100755 index 000000000..00874b3dc --- /dev/null +++ b/tests/tail/tail-sysfs.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# sysfs files have weird properties that can be influenced by page size + +# Copyright 2023 Free Software Foundation, Inc. + +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ tail + +file='/sys/kernel/profiling' + +test -r "$file" || skip_ "No $file file" + +cp -f "$file" exp || framework_failure_ + +tail -n1 "$file" > out || fail=1 +compare exp out || fail=1 + +tail -c2 "$file" > out || fail=1 +compare exp out || fail=1 + +Exit $fail |
