malloc/Makefile: Split and sort tests
[glibc.git] / stdio-common / tst-vfprintf-width-prec-alloc.c
bloba7c9b9c6f034ed0d8e9271b383521c70b6b710cf
1 /* Test large width or precision does not involve large allocation.
2 Copyright (C) 2020-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
19 #include <stdio.h>
20 #include <sys/resource.h>
21 #include <support/check.h>
23 char test_string[] = "test";
25 static int
26 do_test (void)
28 struct rlimit limit;
29 TEST_VERIFY_EXIT (getrlimit (RLIMIT_AS, &limit) == 0);
30 limit.rlim_cur = 200 * 1024 * 1024;
31 TEST_VERIFY_EXIT (setrlimit (RLIMIT_AS, &limit) == 0);
32 FILE *fp = fopen ("/dev/null", "w");
33 TEST_VERIFY_EXIT (fp != NULL);
34 TEST_COMPARE (fprintf (fp, "%1000000000d", 1), 1000000000);
35 TEST_COMPARE (fprintf (fp, "%.1000000000s", test_string), 4);
36 TEST_COMPARE (fprintf (fp, "%1000000000d %1000000000d", 1, 2), 2000000001);
37 TEST_COMPARE (fprintf (fp, "%2$.*1$s", 0x7fffffff, test_string), 4);
38 return 0;
41 #include <support/test-driver.c>