1 /* BZ #22679 getcwd(3) should not succeed without returning an absolute path.
3 Copyright (C) 2018-2019 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/>. */
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>
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. */
36 getcwd_callback (void *closure
)
41 char *cwd
= getcwd (NULL
, 0);
42 TEST_COMPARE (errno
, ENOENT
);
43 TEST_VERIFY (cwd
== NULL
);
46 cwd
= realpath (".", NULL
);
47 TEST_COMPARE (errno
, ENOENT
);
48 TEST_VERIFY (cwd
== NULL
);
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
);
66 #include <support/test-driver.c>