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