diff options
author | Pádraig Brady <P@draigBrady.com> | 2011-05-24 09:59:08 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2011-05-24 16:29:48 +0100 |
commit | 7d44751f0ea9d353c14edffbf89dc61dcafa8f22 (patch) | |
tree | bc5c62e21f1a4feb2173e6f9b6fd2a9113c1a36a /tests/misc | |
parent | 9ead32a9be9543af3f1b73080a7391c89b1d784b (diff) | |
download | coreutils-7d44751f0ea9d353c14edffbf89dc61dcafa8f22.tar.xz |
split: fix cases where -n l/... creates extraneous files
* src/split.c (lines_chunk_split): Ensure that data is only
written to stdout when k specified. Also ensure that
extra files are not created when there is more data available
than reported in the file size.
* tests/misc/split-lchunk: Verify that split -n l/k/n doesn't
generate any files, and that -n l/n always generates n files.
* NEWS: Mention the fix.
Diffstat (limited to 'tests/misc')
-rwxr-xr-x | tests/misc/split-lchunk | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/misc/split-lchunk b/tests/misc/split-lchunk index 0f1693b3c..762138b97 100755 --- a/tests/misc/split-lchunk +++ b/tests/misc/split-lchunk @@ -34,6 +34,12 @@ split -n l/10 /dev/null || fail=1 test "$(stat -c %s x* | uniq -c | sed 's/^ *//; s/ /x/')" = "10x0" || fail=1 rm x?? +# Ensure the correct number of files written +# even if there is more data than the reported file size +split -n l/2 /dev/zero +test "$(stat -c %s x* | wc -l)" = '2' || fail=1 +rm x?? + # Ensure --elide-empty-files is honored split -e -n l/10 /dev/null || fail=1 stat x?? 2>/dev/null && fail=1 @@ -66,9 +72,19 @@ for ELIDE_EMPTY in '' '-e'; do test "$DEBUGGING" && printf "\n---io-blk-size=$IO_BLKSIZE $ELIDE_EMPTY\n" for N in 6 8 12 15 22; do rm -f x* + + if test -z "$ELIDE_EMPTY"; then + split ---io-blksize=$IO_BLKSIZE $ELIDE_EMPTY -n l/2/$N in > chunk.k + stat x* >/dev/null 2>/dev/null && fail=1 + fi + split ---io-blksize=$IO_BLKSIZE $ELIDE_EMPTY -n l/$N in echo $(stat -c "%02s" x*) >> out + if test -z "$ELIDE_EMPTY"; then + compare chunk.k xab || fail=1 + fi + if test "$DEBUGGING"; then # Output partition pattern size=$(printf "%s" "$lines" | wc -c) |