aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test-canon.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /stdlib/test-canon.c
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.bz2
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
2.5-18.1
Diffstat (limited to 'stdlib/test-canon.c')
-rw-r--r--stdlib/test-canon.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/stdlib/test-canon.c b/stdlib/test-canon.c
index f070df74a0..9261898795 100644
--- a/stdlib/test-canon.c
+++ b/stdlib/test-canon.c
@@ -1,5 +1,6 @@
/* Test program for returning the canonical absolute name of a given file.
- Copyright (C) 1996, 1997, 2000, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1996,1997,2000,2002,2004,2005,2006
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by David Mosberger <davidm@azstarnet.com>.
@@ -89,7 +90,10 @@ struct {
{"SYMLINK_5", 0, "./doesNotExist", ENOENT},
{"SYMLINK_5/foobar", 0, "./doesNotExist", ENOENT},
{"doesExist/../../stdlib/doesExist", "./doesExist"},
- {"doesExist/.././../stdlib/.", "."}
+ {"doesExist/.././../stdlib/.", "."},
+ /* 30 */
+ {"./doesExist/someFile/", 0, "./doesExist/someFile", ENOTDIR},
+ {"./doesExist/someFile/..", 0, "./doesExist/someFile", ENOTDIR},
};
@@ -118,7 +122,7 @@ int
do_test (int argc, char ** argv)
{
char * result;
- int fd, i, errors = 0;
+ int i, errors = 0;
char buf[PATH_MAX];
getcwd (cwd, sizeof(buf));
@@ -154,7 +158,9 @@ do_test (int argc, char ** argv)
for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i)
symlink (symlinks[i].value, symlinks[i].name);
- fd = open("doesExist", O_CREAT | O_EXCL, 0777);
+ int has_dir = mkdir ("doesExist", 0777) == 0;
+
+ int fd = has_dir ? creat ("doesExist/someFile", 0777) : -1;
for (i = 0; i < (int) (sizeof (tests) / sizeof (tests[0])); ++i)
{
@@ -208,7 +214,13 @@ do_test (int argc, char ** argv)
}
if (fd >= 0)
- unlink("doesExist");
+ {
+ close (fd);
+ unlink ("doesExist/someFile");
+ }
+
+ if (has_dir)
+ rmdir ("doesExist");
for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i)
unlink (symlinks[i].name);