Refer to C23 in place of C2X in glibc
[glibc.git] / stdlib / tst-realpath-toolong.c
bloba071fe75446f36489265e7409adac5ae4e33082a
1 /* Verify that realpath returns NULL with ENAMETOOLONG if the result exceeds
2 NAME_MAX.
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/>. */
20 #include <errno.h>
21 #include <limits.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <unistd.h>
25 #include <support/check.h>
26 #include <support/temp_file.h>
27 #include <support/test-driver.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
31 #define BASENAME "tst-realpath-toolong."
33 int
34 do_test (void)
36 #ifndef PATH_MAX
37 return EXIT_UNSUPPORTED;
38 #else
39 char *base = support_create_and_chdir_toolong_temp_directory (BASENAME);
41 char buf[PATH_MAX + 1];
42 const char *res = realpath (".", buf);
44 /* canonicalize.c states that if the real path is >= PATH_MAX, then
45 realpath returns NULL and sets ENAMETOOLONG. */
46 TEST_VERIFY (res == NULL);
47 TEST_VERIFY (errno == ENAMETOOLONG);
49 free (base);
50 return 0;
51 #endif
54 #include <support/test-driver.c>