testsuite: Update tests for 'xfclose' use

Convert (some) tests to use 'xfclose' rather than using plain 'fclose'
call with no error checking or plain missing such a call.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
This commit is contained in:
Maciej W. Rozycki 2025-09-05 11:53:31 +01:00
parent 2d47b01de0
commit 5d45da09e6
9 changed files with 12 additions and 4 deletions

View File

@ -44,5 +44,5 @@ compare_output (void *buffer, size_t length, const char *ref[], size_t reflen)
TEST_COMPARE (found[i], true);
free (line);
fclose (in);
xfclose (in);
}

View File

@ -158,7 +158,7 @@ do_test (void)
TEST_COMPARE (interpreter_found, true);
TEST_COMPARE (libc_found, true);
fclose (out);
xfclose (out);
}
support_capture_subprocess_free (&pldd);

View File

@ -47,7 +47,7 @@ do_test (void)
TEST_COMPARE_BLOB (lineptr, 4, "abc\0", 4);
TEST_VERIFY (getdelim (&lineptr, &linelen, '\0', memstream) != -1);
TEST_COMPARE_BLOB (lineptr, 5, "d\nef\0", 5);
fclose (memstream);
xfclose (memstream);
free (lineptr);
return 0;

View File

@ -48,6 +48,8 @@ do_test (void)
DIAG_POP_NEEDS_COMMENT;
xfclose (f);
return 0;
}

View File

@ -53,6 +53,8 @@ do_test (void)
DIAG_POP_NEEDS_COMMENT;
xfclose (f);
return 0;
}

View File

@ -45,6 +45,8 @@ do_test (void)
TEST_VERIFY_EXIT (fgetc (f) == 0xd9);
TEST_VERIFY_EXIT (fgetc (f) == 0xab);
xfclose (f);
return 0;
}

View File

@ -87,7 +87,7 @@ do_test (void)
TEST_COMPARE(tests[i].mnt_freq, ret->mnt_freq);
TEST_COMPARE(tests[i].mnt_passno, ret->mnt_passno);
fclose (fp);
xfclose (fp);
}
return 0;

View File

@ -34,6 +34,7 @@ main (void)
input. */
lost |= (fscanf (f, "%lf", &d) != 0);
c = fgetc (f);
xfclose (f);
lost |= c != 'e';
puts (lost ? "Test FAILED!" : "Test succeeded.");
return lost;

View File

@ -14,6 +14,7 @@ do_test (void)
int res = bp != buf;
bp = fgets_unlocked (buf, sizeof (buf), fp);
printf ("fgets_unlocked: %s\n", bp == buf ? "OK" : "ERROR");
xfclose (fp);
res |= bp != buf;
return res;
}