[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 03:06:13 PDT 2019


On Sun, May 05 2019, Tomi Ollila wrote:

> On Sat, May 04 2019, David Bremner wrote:
>
>>  
>> +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))

except that...

if fread(3) (and friends) used 1024 byte buffer, for 4096 byte message
it would read full buffer 4 times (and not yet noticing EOF), and then
next fread() would return 0 (and now flag EOF)...

... and then the same would apply for 4096 byte message and we could
just test 65536 byte message.

(so, one alternative could be testing e.g. 4096 and 65536 byte messages)

linux namual page does not exactly say, whether reading full request
is "guaranteed", but 2 other documents found in the wild said:

" The total number of elements successfully read is returned.
    
  If this number differs from the count parameter, either a reading error
  occurred or the end-of-file was reached while reading. In both cases, the
  proper indicator is set, which can be checked with ferror and feof,
  respectively."

(so the fix could be different in other email, but at least it is short :D)

... anyway, fread could internally read(2) less than BUFSIZ, copy that to
output buffer and then read(2) more... but at least most of the times
this test in question can protect against regressions in this particular
case)


Tomi


More information about the notmuch mailing list