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

David Bremner david at tethera.net
Sun Apr 28 09:29:05 PDT 2019


Rob Browning isolated a bug where files of exactly 4096 bytes generate
errors because of a zero byte read.
---
 test/T210-raw.sh | 29 +++++++++++++++++++++++++++++
 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 at notmuchmail.org>
+To: Notmuch Test Suite <test_suite at notmuchmail.org>
+Message-Id: <msg-003 at 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



More information about the notmuch mailing list