[PATCH 3/3] testsuite: Update tests for 'xfclose' use
Maciej W. Rozycki
macro@orcam.me.uk
Sun Aug 24 20:22:37 GMT 2025
From: Maciej W. Rozycki <macro@redhat.com>
Convert (some) tests to use 'xfclose' rather than using plain 'fclose'
call with no error checking or plain missing such a call.
---
elf/tst-audit25.h | 2 +-
elf/tst-pldd.c | 2 +-
libio/tst-getdelim.c | 2 +-
localedata/tst-bz13988.c | 2 ++
localedata/tst-scanf-width-digit.c | 2 ++
localedata/tst-scanf-width-point.c | 2 ++
misc/tst-mntent-escape.c | 2 +-
stdio-common/bug26.c | 1 +
stdio-common/tst-fgets.c | 1 +
9 files changed, 12 insertions(+), 4 deletions(-)
glibc-test-xfclose.diff
Index: glibc/elf/tst-audit25.h
===================================================================
--- glibc.orig/elf/tst-audit25.h
+++ glibc/elf/tst-audit25.h
@@ -44,5 +44,5 @@ compare_output (void *buffer, size_t len
TEST_COMPARE (found[i], true);
free (line);
- fclose (in);
+ xfclose (in);
}
Index: glibc/elf/tst-pldd.c
===================================================================
--- glibc.orig/elf/tst-pldd.c
+++ glibc/elf/tst-pldd.c
@@ -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);
Index: glibc/libio/tst-getdelim.c
===================================================================
--- glibc.orig/libio/tst-getdelim.c
+++ glibc/libio/tst-getdelim.c
@@ -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;
Index: glibc/localedata/tst-bz13988.c
===================================================================
--- glibc.orig/localedata/tst-bz13988.c
+++ glibc/localedata/tst-bz13988.c
@@ -48,6 +48,8 @@ do_test (void)
DIAG_POP_NEEDS_COMMENT;
+ xfclose (f);
+
return 0;
}
Index: glibc/localedata/tst-scanf-width-digit.c
===================================================================
--- glibc.orig/localedata/tst-scanf-width-digit.c
+++ glibc/localedata/tst-scanf-width-digit.c
@@ -53,6 +53,8 @@ do_test (void)
DIAG_POP_NEEDS_COMMENT;
+ xfclose (f);
+
return 0;
}
Index: glibc/localedata/tst-scanf-width-point.c
===================================================================
--- glibc.orig/localedata/tst-scanf-width-point.c
+++ glibc/localedata/tst-scanf-width-point.c
@@ -45,6 +45,8 @@ do_test (void)
TEST_VERIFY_EXIT (fgetc (f) == 0xd9);
TEST_VERIFY_EXIT (fgetc (f) == 0xab);
+ xfclose (f);
+
return 0;
}
Index: glibc/misc/tst-mntent-escape.c
===================================================================
--- glibc.orig/misc/tst-mntent-escape.c
+++ glibc/misc/tst-mntent-escape.c
@@ -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;
Index: glibc/stdio-common/bug26.c
===================================================================
--- glibc.orig/stdio-common/bug26.c
+++ glibc/stdio-common/bug26.c
@@ -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;
Index: glibc/stdio-common/tst-fgets.c
===================================================================
--- glibc.orig/stdio-common/tst-fgets.c
+++ glibc/stdio-common/tst-fgets.c
@@ -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;
}
More information about the Libc-alpha
mailing list