Re: [PATCH 1/2] test: notmuch show --format=raw for 4096 byte messages.

Subject: Re: [PATCH 1/2] test: notmuch show --format=raw for 4096 byte messages.

Date: Wed, 01 May 2019 22:55:38 +0300

To: David Bremner, Rob Browning, notmuch@notmuchmail.org

Cc:

From: Tomi Ollila


On Sun, Apr 28 2019, David Bremner wrote:

> Rob Browning isolated a bug where files of exactly 4096 bytes generate
> errors because of a zero byte read.

This happens to be effective test in case where FILE buffering uses 4096
byte buffers. If it used any other size then this is null test. So this
test expects implementation detail of stdio (so IMO testing this is waste
of time).

What could be useful, is that we just happen to have 4096 byte file in
our test corpus, and some tests which test other functionality could 
accidentally fail due to this bug. We could also have 1024, 2048,
8192, 16384 bytes (we still cannot say how large buffers any stdio
buffering uses but... :D)

And if such messages were generated, instead of add_message those could
be written "verbatim" from script... so that the file size is not
dependent how add_message creates it...

Tomi

PS: uh, our test code gives always headache to me... just was^H^H^Hspent
hour to look and think the code below. I wonder whether i could spend
my time better than thinking these....


>  1 file changed, 29 insertions(+)
>
> diff --git a/test/T210-raw.sh b/test/T210-raw.sh
> index 99fdef72..e1dd6064 100755
> --- a/test/T210-raw.sh
> +++ b/test/T210-raw.sh
> @@ -30,4 +30,33 @@ Date: GENERATED_DATE
>  
>  This is just a test message (#2)"
>  
> +test_begin_subtest "generating 4096 byte message"
> +line=$(seq 1 72 | sed 's/.*/./' | tr -d '\n')
> +for i in $(seq 1 53); do
> +    printf "%s\n" "$line" >> BODY
> +done
> +# The last newline is added by add_message
> +printf "01234567890123456789012345" >> BODY
> +add_message '[subject]="4096"' '[body]="$(cat BODY)"'
> +output="$((`wc -c < $gen_msg_filename`))"
> +test_expect_equal 4096 "$output"
> +
> +test_begin_subtest "Show a raw message exactly 4096 bytes: no error"
> +test_subtest_known_broken
> +test_expect_success "notmuch show --format=raw subject:4096 1>/dev/null"
> +
> +test_begin_subtest "Show a raw message exactly 4096 bytes: correct output"
> +notmuch show --format=raw subject:4096 | notmuch_date_sanitize > OUTPUT
> +cat <<EOF > EXPECTED
> +From: Notmuch Test Suite <test_suite@notmuchmail.org>
> +To: Notmuch Test Suite <test_suite@notmuchmail.org>
> +Message-Id: <msg-003@notmuch-test-suite>
> +Subject: 4096
> +Date: GENERATED_DATE
> +
> +EOF
> +cat BODY >> EXPECTED
> +printf "\n" >> EXPECTED
> +test_expect_equal_file EXPECTED OUTPUT
> +
>  test_done
> -- 
> 2.20.1
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: