Remove powerpc, sparc fdim inlines (bug 22987).
[glibc.git] / io / tst-getcwd-abspath.c
blob3a3636f2ede78157dfa19fc92da4b683af839e23
1 /* BZ #22679 getcwd(3) should not succeed without returning an absolute path.
3 Copyright (C) 2018 Free Software Foundation, Inc.
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 <stdio.h>
22 #include <stdlib.h>
23 #include <support/check.h>
24 #include <support/namespace.h>
25 #include <support/support.h>
26 #include <support/temp_file.h>
27 #include <support/test-driver.h>
28 #include <support/xunistd.h>
29 #include <unistd.h>
31 static char *chroot_dir;
33 /* The actual test. Run it in a subprocess, so that the test harness
34 can remove the temporary directory in --direct mode. */
35 static void
36 getcwd_callback (void *closure)
38 xchroot (chroot_dir);
40 errno = 0;
41 char *cwd = getcwd (NULL, 0);
42 TEST_COMPARE (errno, ENOENT);
43 TEST_VERIFY (cwd == NULL);
45 errno = 0;
46 cwd = realpath (".", NULL);
47 TEST_COMPARE (errno, ENOENT);
48 TEST_VERIFY (cwd == NULL);
50 _exit (0);
53 static int
54 do_test (void)
56 support_become_root ();
57 if (!support_can_chroot ())
58 return EXIT_UNSUPPORTED;
60 chroot_dir = support_create_temp_directory ("tst-getcwd-abspath-");
61 support_isolate_in_subprocess (getcwd_callback, NULL);
63 return 0;
66 #include <support/test-driver.c>