1 /* Regression test for 20632.
2 Copyright (C) 2024-2025 Free Software Foundation, Inc.
3 Copyright The GNU Toolchain Authors.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
23 #include <support/check.h>
24 #include <support/xunistd.h>
28 # define TEST_NAME "fputs-unbuffered-full"
31 # define TEXT "0123456789ABCDEF"
34 # define TEST_NAME "fputws-unbuffered-full"
37 # define TEXT L"0123456789ABCDEF"
44 /* Open an unbuffered stream to /dev/full. */
45 FILE *fp
= fopen ("/dev/full", "w");
46 TEST_VERIFY_EXIT (fp
!= NULL
);
47 int ret
= setvbuf (fp
, NULL
, _IONBF
, 0);
48 TEST_VERIFY_EXIT (ret
== 0);
50 /* Output a long string. */
52 CHAR
*buff
= calloc (sz
+1, sizeof *buff
);
53 for (int i
=0; i
< sz
; i
++)
55 buff
[sz
] = (CHAR
) '\0';
57 ret
= FPUTS (buff
, fp
);
58 TEST_VERIFY (ret
== EOF
);
59 TEST_VERIFY (errno
== ENOSPC
);
62 /* Output shorter strings. */
63 for (int i
=0; i
< 1024; i
++)
66 ret
= FPUTS (TEXT
, fp
);
67 TEST_VERIFY (ret
== EOF
);
68 TEST_VERIFY (errno
== ENOSPC
);
70 /* Call malloc, triggering a crash if its
71 function pointers have been overwritten. */
72 void *volatile ptr
= malloc (1);
78 #include <support/test-driver.c>