fdstreamtest: Print more info on read failure

It helps with debugging if we know what's the return value of
saferead().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Michal Privoznik 2017-04-11 09:51:41 +02:00
parent 1cb23be2a5
commit b8ef4758f3
1 changed files with 5 additions and 3 deletions

View File

@ -250,14 +250,16 @@ static int testFDStreamWriteCommon(const char *scratchdir, bool blocking)
goto cleanup;
for (i = 0; i < 10; i++) {
size_t want;
size_t want, got;
if (i == 9)
want = PATTERN_LEN / 2;
else
want = PATTERN_LEN;
if (saferead(fd, buf, want) != want) {
virFilePrintf(stderr, "Short read from data\n");
if ((got = saferead(fd, buf, want)) != want) {
virFilePrintf(stderr,
"Short read from data, i=%zu got=%zu want=%zu\n",
i, got, want);
goto cleanup;
}