diff options
| author | Pádraig Brady <P@draigBrady.com> | 2021-01-25 14:12:48 +0000 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2021-01-25 21:39:09 +0000 |
| commit | bb21daa125aeb4e32546309d370918ca47e612db (patch) | |
| tree | 4ea33eb5f5e6cce1cf144535e5063c93058510d2 /tests/split | |
| parent | eebed78799a7996dd80b66c493a0fc199705dea3 (diff) | |
| download | coreutils-bb21daa125aeb4e32546309d370918ca47e612db.tar.gz coreutils-bb21daa125aeb4e32546309d370918ca47e612db.zip | |
split: fix --number=K/N to output correct part of file
This functionality regressed with the adjustments
in commit v8.25-4-g62e7af032
* src/split.c (bytes_chunk_extract): Account for already read data
when seeking into the file.
* tests/split/b-chunk.sh: Use the hidden ---io-blksize option,
to test this functionality.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/46048
Diffstat (limited to 'tests/split')
| -rwxr-xr-x | tests/split/b-chunk.sh | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/tests/split/b-chunk.sh b/tests/split/b-chunk.sh index 8238dcb6d..dbed681f7 100755 --- a/tests/split/b-chunk.sh +++ b/tests/split/b-chunk.sh @@ -35,32 +35,39 @@ split -e -n 10 /dev/null || fail=1 returns_ 1 stat x?? 2>/dev/null || fail=1 printf '1\n2\n3\n4\n5\n' > input || framework_failure_ +printf '1\n2' > exp-1 || framework_failure_ +printf '\n3\n' > exp-2 || framework_failure_ +printf '4\n5\n' > exp-3 || framework_failure_ for file in input /proc/version /sys/kernel/profiling; do test -f $file || continue - split -n 3 $file > out || fail=1 - split -n 1/3 $file > b1 || fail=1 - split -n 2/3 $file > b2 || fail=1 - split -n 3/3 $file > b3 || fail=1 + for blksize in 1 2 4096; do + if ! test "$file" = 'input'; then + # For /proc like files we must be able to read all + # into the internal buffer to be able to determine size. + test "$blksize" = 4096 || continue + fi - case $file in - input) - printf '1\n2' > exp-1 - printf '\n3\n' > exp-2 - printf '4\n5\n' > exp-3 + split -n 3 ---io-blksize=$blksize $file > out || fail=1 + split -n 1/3 ---io-blksize=$blksize $file > b1 || fail=1 + split -n 2/3 ---io-blksize=$blksize $file > b2 || fail=1 + split -n 3/3 ---io-blksize=$blksize $file > b3 || fail=1 - compare exp-1 xaa || fail=1 - compare exp-2 xab || fail=1 - compare exp-3 xac || fail=1 - ;; - esac + case $file in + input) + compare exp-1 xaa || fail=1 + compare exp-2 xab || fail=1 + compare exp-3 xac || fail=1 + ;; + esac - compare xaa b1 || fail=1 - compare xab b2 || fail=1 - compare xac b3 || fail=1 - cat xaa xab xac | compare - $file || fail=1 - test -f xad && fail=1 + compare xaa b1 || fail=1 + compare xab b2 || fail=1 + compare xac b3 || fail=1 + cat xaa xab xac | compare - $file || fail=1 + test -f xad && fail=1 + done done Exit $fail |
