test case for fread() errors in C
<p>In one C application I'm maintaining,
there are a number of calls to <code>fread()</code>.</p>

<p>The return value is checked for the number of bytes read,
and stops when it reaches <code>0</code>,
meaning the file/stream end has been reached.</p>

<p>Now, that's not completely correct.
<code>fread()</code> may also return <code>0</code> if an error happens.
A way to check for that condition is to call <code>feof()</code> for example.</p>

<p>I can certainly add all these tests everywhere <code>fread()</code> is invoked. But that's not the point : it would be some kind of "blind fix". I need a test case to observe and repeat the problem, and observe the correction as part of CI tests.</p>

<p>So far, I have found none.
I have much less problems for <code>fwrite()</code>, where it's comparatively easier to create problems, but for <code>fread()</code>, I haven't found a reliable way to test issues <em>without also impacting</em> <code>fopen()</code>, which is a completely different situation already pretty well tested.</p>

<p>Any suggestion welcomed.</p>