AArch64: Remove SVE erf and erfc tables
[glibc.git] / io / tst-ftw-bz28126.c
blobd3c484f418514d8e48cafcffe70a74f17f122aa2
1 /* Check if internal buffer reallocation work for large paths (BZ #28126)
2 Copyright (C) 2021-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 <errno.h>
20 #include <ftw.h>
21 #include <limits.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include <support/check.h>
25 #include <support/support.h>
26 #include <support/temp_file.h>
27 #include <support/xunistd.h>
28 #include <stdio.h>
30 static int
31 my_func (const char *file, const struct stat *sb, int flag)
33 return 0;
36 static const char folder[NAME_MAX] = { [0 ... 253] = 'a', [254] = '\0' };
38 #define NSUBFOLDERS 16
39 static int nsubfolders;
41 static void
42 do_cleanup (void)
44 xchdir ("..");
45 for (int i = 0; i < nsubfolders; i++)
47 remove (folder);
48 xchdir ("..");
50 remove (folder);
52 #define CLEANUP_HANDLER do_cleanup
54 static void
55 check_mkdir (const char *path)
57 int r = mkdir (path, 0777);
58 /* Some filesystem such as overlayfs does not support larger path required
59 to trigger the internal buffer reallocation. */
60 if (r != 0)
62 if (errno == ENAMETOOLONG)
63 FAIL_UNSUPPORTED ("the filesystem does not support the required"
64 "large path");
65 else
66 FAIL_EXIT1 ("mkdir (\"%s\", 0%o): %m", folder, 0777);
70 static int
71 do_test (void)
73 char *tempdir = support_create_temp_directory ("tst-bz28126");
75 /* Create path with various subfolders to force an internal buffer
76 reallocation within ntfw. */
77 char *path = xasprintf ("%s/%s", tempdir, folder);
78 check_mkdir (path);
79 xchdir (path);
80 free (path);
81 for (int i = 0; i < NSUBFOLDERS - 1; i++)
83 check_mkdir (folder);
84 xchdir (folder);
85 nsubfolders++;
88 TEST_COMPARE (ftw (tempdir, my_func, 20), 0);
90 free (tempdir);
92 do_cleanup ();
94 return 0;
97 #include <support/test-driver.c>