[PATCH 1/2] test/raw: add some messages likely to be multiples of buffer size
Tomi Ollila
tomi.ollila at iki.fi
Sun May 5 02:18:13 PDT 2019
On Sat, May 04 2019, David Bremner wrote:
> This highlights a bug where zero bytes are read at the end of the
> file, and we attempt to write those to stdout, causing spurious write
> failures.
> ---
> test/T210-raw.sh | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/test/T210-raw.sh b/test/T210-raw.sh
> index 99fdef72..0d57deb5 100755
> --- a/test/T210-raw.sh
> +++ b/test/T210-raw.sh
> @@ -30,4 +30,39 @@ Date: GENERATED_DATE
>
> This is just a test message (#2)"
>
> +test_python <<EOF
> +from email.message import EmailMessage
> +for pow in range(12,21):
.......................^ space. i.e. (12, 21)
from 4KiB to 1MiB. uh, perhaps I should have kept my fingers crossed.
(that said, my range would have been 10, 17 (1024 - 65536))
> + size = 2**pow
spaces around '**'
> + msg=EmailMessage()
spaces around '='
> + msg['Subject'] = 'message with {:07d} bytes'.format(size)
> + msg['From'] = 'Notmuch Test Suite <test_suite at notmuchmail.org>'
> + msg['To'] = msg['From']
> + msg['Message-Id'] = 'size-{0:07d}@notmuch-test-suite'.format(size)
for consistencty, size-{:07d} (python 2.7+ supported format) ...
> + content=""
spaces
> + msg.set_content("")
> + padding = size - len(bytes(msg))
> + lines = []
> + while padding > 0:
> + line = '.' * min(padding, 72)
> + lines.append(line)
> + padding = padding - len(line) - 1
> + content ='\n'.join(lines)
> + msg.set_content(content)
> + with open('mail/size-{0:07d}'.format(size),'wb') as f:
size-{:07d} , space before 'wb'
> + f.write(bytes(msg))
> +EOF
> +
> +notmuch new --quiet
> +
> +for pow in $(seq 12 20); do
{12..20} would do the above seq, w/o 2 forks and one execve :D
> + size=$(printf "%07d" $((2**$pow)))
printf -v size "%07d" $((2 ** pow))
> + test_begin_subtest "content, message of size $size"
> + notmuch show --format=raw subject:$size > OUTPUT
> + test_expect_equal_file mail/size-$size OUTPUT
> + test_begin_subtest "return value, message of size $size"
> + test_subtest_known_broken
> + test_expect_success "notmuch show --format=raw subject:$size > /dev/null"
> +done
> +
> test_done
> --
> 2.20.1
More information about the notmuch
mailing list