tst-stderr-compat.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Test that fclose works on stderr from glibc 2.0.
  2. Copyright (C) 2024-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include <shlib-compat.h>
  16. #if TEST_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
  17. # define _LIBC
  18. # define _IO_USE_OLD_IO_FILE
  19. # include <stdio.h>
  20. # include <support/check.h>
  21. extern FILE _IO_stderr_;
  22. compat_symbol_reference (libc, _IO_stderr_, _IO_stderr_, GLIBC_2_0);
  23. compat_symbol_reference (libc, fclose, fclose, GLIBC_2_0);
  24. __attribute__ ((weak, noclone, noinline))
  25. void
  26. do_fclose (FILE *fp)
  27. {
  28. TEST_VERIFY_EXIT (fclose (fp) == 0);
  29. }
  30. static int
  31. do_test (void)
  32. {
  33. do_fclose (&_IO_stderr_);
  34. return 0;
  35. }
  36. #else
  37. static int
  38. do_test (void)
  39. {
  40. return 0;
  41. }
  42. #endif
  43. #include <support/test-driver.c>