Mercurial > gnulib
annotate tests/test-rename.h @ 17363:5a51fb7777a9
sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin
Problem reported by Marco Atzeri in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>.
* lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]:
Simply delegate to the system <sys/select.h> in this case too.
Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only
if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to
be needed on Solaris either.
* lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]:
Simply delgate to the system <sys/time.h> in this case.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 19 Mar 2013 09:08:47 -0700 |
parents | e542fd46ad6f |
children | 344018b6e5d7 |
rev | line source |
---|---|
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
1 /* Test of rename() function. |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16201
diff
changeset
|
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
3 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
12520
e84eea643139
tests: fix license on several tests
Eric Blake <ebb9@byu.net>
parents:
12260
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
7 (at your option) any later version. |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
8 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
13 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
16 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
17 /* This file is designed to test both rename(a,b) and |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
18 renameat(AT_FDCWD,a,AT_FDCWD,b). FUNC is the function to test. |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
19 Assumes that BASE and ASSERT are already defined, and that |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
20 appropriate headers are already included. If PRINT, warn before |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
21 skipping symlink tests with status 77. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
22 |
13868
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
23 /* Tests whether a file, given by a file name without slashes, exists in |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
24 the current directory, by scanning the directory entries. */ |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
25 static bool |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
26 dentry_exists (const char *filename) |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
27 { |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
28 bool exists = false; |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
29 DIR *dir = opendir ("."); |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
30 |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
31 ASSERT (dir != NULL); |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
32 for (;;) |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
33 { |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
34 struct dirent *d = readdir (dir); |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
35 if (d == NULL) |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
36 break; |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
37 if (strcmp (d->d_name, filename) == 0) |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
38 { |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
39 exists = true; |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
40 break; |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
41 } |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
42 } |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
43 ASSERT (closedir (dir) == 0); |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
44 return exists; |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
45 } |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
46 |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
47 /* Asserts that a specific file, given by a file name without slashes, does |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
48 not exist in the current directory. */ |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
49 static void |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
50 assert_nonexistent (const char *filename) |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
51 { |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
52 struct stat st; |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
53 |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
54 /* The usual way to test the presence of a file is via stat() or lstat(). */ |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
55 errno = 0; |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
56 if (stat (filename, &st) == -1) |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
57 ASSERT (errno == ENOENT); |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
58 else |
14028
2d32f7c9e2d3
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
14006
diff
changeset
|
59 { |
2d32f7c9e2d3
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
14006
diff
changeset
|
60 /* But after renaming a directory over an empty directory on an NFS- |
2d32f7c9e2d3
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
14006
diff
changeset
|
61 mounted file system, on Linux 2.6.18, for a period of 30 seconds the |
2d32f7c9e2d3
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
14006
diff
changeset
|
62 old directory name is "present" according to stat() but "nonexistent" |
2d32f7c9e2d3
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
14006
diff
changeset
|
63 according to dentry_exists(). */ |
2d32f7c9e2d3
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
14006
diff
changeset
|
64 ASSERT (!dentry_exists (filename)); |
2d32f7c9e2d3
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
14006
diff
changeset
|
65 /* Remove the old directory name, so that subsequent mkdir calls |
2d32f7c9e2d3
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
14006
diff
changeset
|
66 succeed. */ |
2d32f7c9e2d3
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
14006
diff
changeset
|
67 (void) rmdir (filename); |
2d32f7c9e2d3
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
14006
diff
changeset
|
68 } |
13868
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
69 } |
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
70 |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
71 static int |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
72 test_rename (int (*func) (char const *, char const *), bool print) |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
73 { |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
74 /* Setup. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
75 struct stat st; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
76 int fd = creat (BASE "file", 0600); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
77 ASSERT (0 <= fd); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
78 ASSERT (write (fd, "hi", 2) == 2); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
79 ASSERT (close (fd) == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
80 ASSERT (mkdir (BASE "dir", 0700) == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
81 |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
82 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
83 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
84 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
85 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
86 |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
87 /* Obvious errors. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
88 |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
89 { /* Missing source. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
90 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
91 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
92 ASSERT (func (BASE "missing", BASE "missing") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
93 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
94 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
95 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
96 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
97 ASSERT (func (BASE "missing/", BASE "missing") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
98 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
99 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
100 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
101 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
102 ASSERT (func (BASE "missing", BASE "missing/") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
103 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
104 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
105 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
106 { /* Empty operand. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
107 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
108 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
109 ASSERT (func ("", BASE "missing") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
110 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
111 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
112 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
113 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
114 ASSERT (func (BASE "file", "") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
115 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
116 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
117 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
118 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
119 ASSERT (func (BASE "", "") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
120 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
121 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
122 } |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
123 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
124 /* Files. */ |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
125 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
126 { /* Trailing slash. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
127 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
128 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
129 ASSERT (func (BASE "file", BASE "file2/") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
130 ASSERT (errno == ENOENT || errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
131 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
132 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
133 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
134 ASSERT (func (BASE "file/", BASE "file2") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
135 ASSERT (errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
136 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
137 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
138 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
139 ASSERT (stat (BASE "file2", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
140 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
141 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
142 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
143 { /* Simple rename. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
144 ASSERT (func (BASE "file", BASE "file2") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
145 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
146 ASSERT (stat (BASE "file", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
147 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
148 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
149 ASSERT (stat (BASE "file2", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
150 ASSERT (st.st_size == 2); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
151 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
152 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
153 {BASE}file2 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
154 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
155 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
156 { /* Overwrite. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
157 ASSERT (close (creat (BASE "file", 0600)) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
158 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
159 ASSERT (func (BASE "file2", BASE "file/") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
160 ASSERT (errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
161 ASSERT (func (BASE "file2", BASE "file") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
162 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
163 ASSERT (stat (BASE "file", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
164 ASSERT (st.st_size == 2); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
165 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
166 ASSERT (stat (BASE "file2", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
167 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
168 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
169 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
170 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
171 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
172 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
173 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
174 /* Directories. */ |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
175 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
176 { /* Simple rename. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
177 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
178 ASSERT (func (BASE "dir", BASE "dir2/") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
179 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
180 ASSERT (stat (BASE "dir", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
181 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
182 ASSERT (stat (BASE "dir2", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
183 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
184 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
185 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
186 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
187 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
188 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
189 ASSERT (func (BASE "dir2/", BASE "dir") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
190 ASSERT (stat (BASE "dir", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
191 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
192 ASSERT (stat (BASE "dir2", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
193 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
194 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
195 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
196 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
197 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
198 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
199 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
200 ASSERT (func (BASE "dir", BASE "dir2") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
201 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
202 ASSERT (stat (BASE "dir", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
203 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
204 ASSERT (stat (BASE "dir2", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
205 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
206 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
207 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
208 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
209 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
210 { /* Empty onto empty. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
211 ASSERT (mkdir (BASE "dir", 0700) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
212 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
213 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
214 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
215 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
216 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
217 ASSERT (func (BASE "dir2", BASE "dir") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
218 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
219 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
220 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
221 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
222 ASSERT (mkdir (BASE "dir2", 0700) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
223 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
224 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
225 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
226 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
227 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
228 ASSERT (func (BASE "dir2", BASE "dir/") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
229 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
230 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
231 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
232 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
233 ASSERT (mkdir (BASE "dir2", 0700) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
234 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
235 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
236 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
237 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
238 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
239 ASSERT (func (BASE "dir2/", BASE "dir") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
240 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
241 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
242 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
243 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
244 ASSERT (mkdir (BASE "dir2", 0700) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
245 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
246 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
247 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
248 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
249 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
250 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
251 { /* Empty onto full. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
252 ASSERT (close (creat (BASE "dir/file", 0600)) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
253 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
254 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
255 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
256 {BASE}dir/file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
257 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
258 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
259 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
260 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
261 ASSERT (func (BASE "dir2", BASE "dir") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
262 ASSERT (errno == EEXIST || errno == ENOTEMPTY); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
263 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
264 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
265 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
266 ASSERT (func (BASE "dir2/", BASE "dir") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
267 ASSERT (errno == EEXIST || errno == ENOTEMPTY); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
268 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
269 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
270 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
271 ASSERT (func (BASE "dir2", BASE "dir/") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
272 ASSERT (errno == EEXIST || errno == ENOTEMPTY); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
273 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
274 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
275 { /* Full onto empty. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
276 ASSERT (func (BASE "dir", BASE "dir2") == 0); |
13868
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
277 assert_nonexistent (BASE "dir"); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
278 ASSERT (stat (BASE "dir2/file", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
279 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
280 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
281 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
282 {BASE}dir2/file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
283 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
284 ASSERT (mkdir (BASE "dir", 0700) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
285 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
286 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
287 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
288 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
289 {BASE}dir2/file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
290 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
291 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
292 ASSERT (func (BASE "dir2/", BASE "dir") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
293 ASSERT (stat (BASE "dir/file", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
294 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
295 ASSERT (stat (BASE "dir2", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
296 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
297 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
298 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
299 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
300 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
301 {BASE}dir/file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
302 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
303 ASSERT (mkdir (BASE "dir2", 0700) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
304 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
305 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
306 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
307 {BASE}dir/file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
308 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
309 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
310 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
311 ASSERT (func (BASE "dir", BASE "dir2/") == 0); |
13868
a6ec6c0554b0
rename, renameat: Avoid test failures at NFS mounted locations.
Bruno Haible <bruno@clisp.org>
parents:
13866
diff
changeset
|
312 assert_nonexistent (BASE "dir"); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
313 ASSERT (stat (BASE "dir2/file", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
314 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
315 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
316 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
317 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
318 {BASE}dir2/file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
319 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
320 ASSERT (unlink (BASE "dir2/file") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
321 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
322 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
323 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
324 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
325 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
326 { /* Reject trailing dot. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
327 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
328 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
329 ASSERT (func (BASE "dir2", BASE "dir/.") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
330 ASSERT (errno == EINVAL || errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
331 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
332 ASSERT (mkdir (BASE "dir", 0700) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
333 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
334 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
335 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
336 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
337 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
338 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
339 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
340 ASSERT (func (BASE "dir2", BASE "dir/.") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
341 ASSERT (errno == EINVAL || errno == EBUSY || errno == EISDIR |
15650
4cb21966f305
rename, renameat tests: Avoid test failures on FreeBSD 6.4.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
342 || errno == ENOTEMPTY || errno == EEXIST); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
343 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
344 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
345 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
346 ASSERT (func (BASE "dir2/.", BASE "dir") == -1); |
14006
6fb5b50662b4
rename, renameat: Avoid test failures on OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
13881
diff
changeset
|
347 ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
348 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
349 ASSERT (rmdir (BASE "dir") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
350 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
351 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
352 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
353 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
354 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
355 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
356 ASSERT (func (BASE "dir2", BASE "dir/.//") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
357 ASSERT (errno == EINVAL || errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
358 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
359 ASSERT (mkdir (BASE "dir", 0700) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
360 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
361 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
362 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
363 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
364 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
365 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
366 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
367 ASSERT (func (BASE "dir2", BASE "dir/.//") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
368 ASSERT (errno == EINVAL || errno == EBUSY || errno == EISDIR |
15650
4cb21966f305
rename, renameat tests: Avoid test failures on FreeBSD 6.4.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
369 || errno == ENOTEMPTY || errno == EEXIST); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
370 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
371 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
372 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
373 ASSERT (func (BASE "dir2/.//", BASE "dir") == -1); |
14006
6fb5b50662b4
rename, renameat: Avoid test failures on OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
13881
diff
changeset
|
374 ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
375 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
376 ASSERT (rmdir (BASE "dir2") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
377 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
378 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
379 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
380 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
381 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
382 { /* Move into subdir. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
383 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
384 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
385 ASSERT (func (BASE "dir", BASE "dir/sub") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
386 ASSERT (errno == EINVAL || errno == EACCES); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
387 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
388 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
389 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
390 ASSERT (stat (BASE "dir/sub", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
391 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
392 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
393 ASSERT (mkdir (BASE "dir/sub", 0700) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
394 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
395 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
396 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
397 {BASE}dir/sub/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
398 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
399 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
400 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
401 ASSERT (func (BASE "dir", BASE "dir/sub") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
402 ASSERT (errno == EINVAL); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
403 ASSERT (stat (BASE "dir/sub", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
404 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
405 ASSERT (rmdir (BASE "dir/sub") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
406 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
407 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
408 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
409 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
410 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
411 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
412 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
413 /* Mixing file and directory. */ |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
414 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
415 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
416 { /* File onto dir. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
417 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
418 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
419 ASSERT (func (BASE "file", BASE "dir") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
420 ASSERT (errno == EISDIR || errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
421 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
422 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
423 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
424 ASSERT (func (BASE "file", BASE "dir/") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
425 ASSERT (errno == EISDIR || errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
426 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
427 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
428 { /* Dir onto file. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
429 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
430 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
431 ASSERT (func (BASE "dir", BASE "file") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
432 ASSERT (errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
433 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
434 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
435 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
436 ASSERT (func (BASE "dir/", BASE "file") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
437 ASSERT (errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
438 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
439 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
440 } |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
441 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
442 /* Hard links. */ |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
443 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
444 { /* File onto self. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
445 ASSERT (func (BASE "file", BASE "file") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
446 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
447 ASSERT (stat (BASE "file", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
448 ASSERT (st.st_size == 2); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
449 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
450 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
451 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
452 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
453 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
454 { /* Empty dir onto self. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
455 ASSERT (func (BASE "dir", BASE "dir") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
456 ASSERT (stat (BASE "dir", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
457 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
458 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
459 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
460 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
461 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
462 ASSERT (close (creat (BASE "dir/file", 0600)) == 0); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
463 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
464 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
465 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
466 {BASE}dir/file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
467 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
468 { /* Full dir onto self. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
469 ASSERT (func (BASE "dir", BASE "dir") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
470 } |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
471 ASSERT (unlink (BASE "dir/file") == 0); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
472 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
473 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
474 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
475 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
476 { |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
477 /* Not all file systems support link. Mingw doesn't have |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
478 reliable st_nlink on hard links, but our implementation does |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
479 fail with EPERM on poor file systems, and we can detect the |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
480 inferior stat() via st_ino. Cygwin 1.5.x copies rather than |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
481 links files on those file systems, but there, st_nlink and |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
482 st_ino are reliable. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
483 int ret = link (BASE "file", BASE "file2"); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
484 if (!ret) |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
485 { |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
486 memset (&st, 0, sizeof st); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
487 ASSERT (stat (BASE "file2", &st) == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
488 if (st.st_ino && st.st_nlink != 2) |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
489 { |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
490 ASSERT (unlink (BASE "file2") == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
491 errno = EPERM; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
492 ret = -1; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
493 } |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
494 } |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
495 if (ret == -1) |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
496 { |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
497 /* If the device does not support hard links, errno is |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
498 EPERM on Linux, EOPNOTSUPP on FreeBSD. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
499 switch (errno) |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
500 { |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
501 case EPERM: |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
502 case EOPNOTSUPP: |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
503 if (print) |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
504 fputs ("skipping test: " |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
505 "hard links not supported on this file system\n", |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
506 stderr); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
507 ASSERT (unlink (BASE "file") == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
508 ASSERT (rmdir (BASE "dir") == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
509 return 77; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
510 default: |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
511 perror ("link"); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
512 return 1; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
513 } |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
514 } |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
515 ASSERT (ret == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
516 } |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
517 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
518 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
519 {BASE}file2 (hard link to file) |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
520 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
521 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
522 { /* File onto hard link. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
523 ASSERT (func (BASE "file", BASE "file2") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
524 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
525 ASSERT (stat (BASE "file", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
526 ASSERT (st.st_size == 2); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
527 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
528 ASSERT (stat (BASE "file2", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
529 ASSERT (st.st_size == 2); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
530 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
531 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
532 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
533 {BASE}file2 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
534 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
535 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
536 ASSERT (unlink (BASE "file2") == 0); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
537 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
538 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
539 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
540 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
541 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
542 /* Symlinks. */ |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
543 |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
544 if (symlink (BASE "file", BASE "link1")) |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
545 { |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
546 if (print) |
12146
e076a06bae48
maint: prefer 'file system' over 'filesystem'
Eric Blake <ebb9@byu.net>
parents:
12091
diff
changeset
|
547 fputs ("skipping test: symlinks not supported on this file system\n", |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
548 stderr); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
549 ASSERT (unlink (BASE "file") == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
550 ASSERT (rmdir (BASE "dir") == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
551 return 77; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
552 } |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
553 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
554 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
555 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
556 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
557 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
558 { /* Simple rename. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
559 ASSERT (func (BASE "link1", BASE "link2") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
560 ASSERT (stat (BASE "file", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
561 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
562 ASSERT (lstat (BASE "link1", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
563 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
564 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
565 ASSERT (lstat (BASE "link2", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
566 ASSERT (S_ISLNK (st.st_mode)); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
567 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
568 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
569 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
570 {BASE}link2 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
571 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
572 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
573 { /* Overwrite. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
574 ASSERT (symlink (BASE "nowhere", BASE "link1") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
575 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
576 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
577 {BASE}link1 -> {BASE}nowhere |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
578 {BASE}link2 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
579 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
580 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
581 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
582 ASSERT (func (BASE "link2", BASE "link1") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
583 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
584 ASSERT (stat (BASE "link1", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
585 ASSERT (st.st_size == 2); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
586 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
587 ASSERT (lstat (BASE "link2", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
588 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
589 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
590 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
591 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
592 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
593 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
594 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
595 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
596 { /* Symlink loop. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
597 ASSERT (symlink (BASE "link2", BASE "link2") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
598 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
599 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
600 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
601 {BASE}link2 -> {BASE}link2 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
602 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
603 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
604 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
605 ASSERT (func (BASE "link2", BASE "link2") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
606 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
607 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
608 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
609 ASSERT (func (BASE "link2/", BASE "link2") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
610 ASSERT (errno == ELOOP || errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
611 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
612 ASSERT (func (BASE "link2", BASE "link3") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
613 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
614 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
615 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
616 {BASE}link3 -> {BASE}link2 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
617 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
618 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
619 ASSERT (unlink (BASE "link3") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
620 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
621 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
622 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
623 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
624 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
625 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
626 { /* Dangling link. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
627 ASSERT (symlink (BASE "nowhere", BASE "link2") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
628 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
629 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
630 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
631 {BASE}link2 -> {BASE}nowhere |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
632 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
633 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
634 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
635 ASSERT (func (BASE "link2", BASE "link3") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
636 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
637 ASSERT (lstat (BASE "link2", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
638 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
639 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
640 ASSERT (lstat (BASE "link3", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
641 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
642 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
643 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
644 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
645 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
646 {BASE}link3 -> {BASE}nowhere |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
647 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
648 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
649 { /* Trailing slash on dangling. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
650 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
651 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
652 ASSERT (func (BASE "link3/", BASE "link2") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
653 ASSERT (errno == ENOENT || errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
654 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
655 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
656 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
657 ASSERT (func (BASE "link3", BASE "link2/") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
658 ASSERT (errno == ENOENT || errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
659 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
660 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
661 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
662 ASSERT (lstat (BASE "link2", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
663 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
664 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
665 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
666 ASSERT (lstat (BASE "link3", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
667 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
668 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
669 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
670 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
671 {BASE}link3 -> {BASE}nowhere |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
672 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
673 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
674 { /* Trailing slash on link to file. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
675 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
676 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
677 ASSERT (func (BASE "link1/", BASE "link2") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
678 ASSERT (errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
679 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
680 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
681 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
682 ASSERT (func (BASE "link1", BASE "link3/") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
683 ASSERT (errno == ENOENT || errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
684 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
685 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
686 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
687 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
688 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
689 {BASE}link3 -> {BASE}nowhere |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
690 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
691 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
692 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
693 /* Mixing symlink and file. */ |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
694 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
695 { /* File onto link. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
696 ASSERT (close (creat (BASE "file2", 0600)) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
697 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
698 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
699 {BASE}file2 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
700 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
701 {BASE}link3 -> {BASE}nowhere |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
702 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
703 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
704 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
705 ASSERT (func (BASE "file2", BASE "link3") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
706 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
707 ASSERT (stat (BASE "file2", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
708 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
709 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
710 ASSERT (lstat (BASE "link3", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
711 ASSERT (S_ISREG (st.st_mode)); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
712 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
713 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
714 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
715 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
716 {BASE}link3 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
717 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
718 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
719 ASSERT (unlink (BASE "link3") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
720 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
721 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
722 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
723 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
724 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
725 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
726 { /* Link onto file. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
727 ASSERT (symlink (BASE "nowhere", BASE "link2") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
728 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
729 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
730 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
731 {BASE}link2 -> {BASE}nowhere |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
732 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
733 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
734 ASSERT (close (creat (BASE "file2", 0600)) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
735 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
736 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
737 {BASE}file2 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
738 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
739 {BASE}link2 -> {BASE}nowhere |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
740 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
741 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
742 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
743 ASSERT (func (BASE "link2", BASE "file2") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
744 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
745 ASSERT (lstat (BASE "link2", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
746 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
747 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
748 ASSERT (lstat (BASE "file2", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
749 ASSERT (S_ISLNK (st.st_mode)); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
750 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
751 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
752 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
753 {BASE}file2 -> {BASE}nowhere |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
754 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
755 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
756 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
757 ASSERT (unlink (BASE "file2") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
758 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
759 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
760 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
761 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
762 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
763 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
764 { /* Trailing slash. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
765 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
766 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
767 ASSERT (func (BASE "file/", BASE "link1") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
768 ASSERT (errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
769 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
770 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
771 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
772 ASSERT (func (BASE "file", BASE "link1/") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
773 ASSERT (errno == ENOTDIR || errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
774 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
775 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
776 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
777 ASSERT (func (BASE "link1/", BASE "file") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
778 ASSERT (errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
779 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
780 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
781 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
782 ASSERT (func (BASE "link1", BASE "file/") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
783 ASSERT (errno == ENOTDIR || errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
784 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
785 ASSERT (lstat (BASE "file", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
786 ASSERT (S_ISREG (st.st_mode)); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
787 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
788 ASSERT (lstat (BASE "link1", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
789 ASSERT (S_ISLNK (st.st_mode)); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
790 } |
13881
b692389b222f
test-rename.h: fix compilation failure
Jim Meyering <meyering@redhat.com>
parents:
13868
diff
changeset
|
791 } |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
792 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
793 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
794 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
795 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
796 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
797 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
798 /* Mixing symlink and directory. */ |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
799 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
800 { /* Directory onto link. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
801 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
802 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
803 ASSERT (func (BASE "dir", BASE "link1") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
804 ASSERT (errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
805 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
806 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
807 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
808 ASSERT (func (BASE "dir/", BASE "link1") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
809 ASSERT (errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
810 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
811 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
812 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
813 ASSERT (func (BASE "dir", BASE "link1/") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
814 ASSERT (errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
815 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
816 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
817 { /* Link onto directory. */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
818 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
819 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
820 ASSERT (func (BASE "link1", BASE "dir") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
821 ASSERT (errno == EISDIR || errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
822 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
823 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
824 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
825 ASSERT (func (BASE "link1", BASE "dir/") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
826 ASSERT (errno == EISDIR || errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
827 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
828 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
829 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
830 ASSERT (func (BASE "link1/", BASE "dir") == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
831 ASSERT (errno == ENOTDIR); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
832 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
833 ASSERT (lstat (BASE "link1", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
834 ASSERT (S_ISLNK (st.st_mode)); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
835 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
836 ASSERT (lstat (BASE "dir", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
837 ASSERT (S_ISDIR (st.st_mode)); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
838 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
839 } |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
840 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
841 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
842 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
843 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
844 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
845 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
846 /* POSIX requires rename("link-to-dir/","other") to rename "dir" and |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
847 leave "link-to-dir" dangling, but GNU rejects this. POSIX |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
848 requires rename("dir","dangling/") to create the directory so |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
849 that "dangling/" now resolves, but GNU rejects this. While we |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
850 prefer GNU behavior, we don't enforce it. However, we do test |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
851 that the system either follows POSIX in both cases, or follows |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
852 GNU. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
853 { |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
854 int result; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
855 ASSERT (symlink (BASE "dir2", BASE "link2") == 0); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
856 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
857 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
858 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
859 {BASE}link2 -> {BASE}dir2 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
860 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
861 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
862 errno = 0; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
863 result = func (BASE "dir", BASE "link2/"); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
864 if (result == 0) |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
865 { |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
866 /* POSIX. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
867 errno = 0; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
868 ASSERT (lstat (BASE "dir", &st) == -1); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
869 ASSERT (errno == ENOENT); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
870 memset (&st, 0, sizeof st); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
871 ASSERT (lstat (BASE "dir2", &st) == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
872 ASSERT (S_ISDIR (st.st_mode)); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
873 memset (&st, 0, sizeof st); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
874 ASSERT (lstat (BASE "link2", &st) == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
875 ASSERT (S_ISLNK (st.st_mode)); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
876 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
877 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
878 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
879 {BASE}link2 -> {BASE}dir2 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
880 {BASE}dir2/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
881 */ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
882 { |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
883 ASSERT (func (BASE "link2/", BASE "dir") == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
884 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
885 ASSERT (lstat (BASE "dir", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
886 ASSERT (S_ISDIR (st.st_mode)); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
887 errno = 0; |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
888 ASSERT (lstat (BASE "dir2", &st) == -1); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
889 ASSERT (errno == ENOENT); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
890 memset (&st, 0, sizeof st); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
891 ASSERT (lstat (BASE "link2", &st) == 0); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
892 ASSERT (S_ISLNK (st.st_mode)); |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
893 } |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
894 } |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
895 else |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
896 { |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
897 /* GNU. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
898 ASSERT (result == -1); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
899 ASSERT (errno == ENOTDIR); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
900 memset (&st, 0, sizeof st); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
901 ASSERT (lstat (BASE "dir", &st) == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
902 ASSERT (S_ISDIR (st.st_mode)); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
903 errno = 0; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
904 ASSERT (lstat (BASE "dir2", &st) == -1); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
905 ASSERT (errno == ENOENT); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
906 memset (&st, 0, sizeof st); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
907 ASSERT (lstat (BASE "link2", &st) == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
908 ASSERT (S_ISLNK (st.st_mode)); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
909 ASSERT (unlink (BASE "link2") == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
910 ASSERT (symlink (BASE "dir", BASE "link2") == 0); |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
911 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
912 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
913 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
914 {BASE}link2 -> {BASE}dir |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
915 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
916 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
917 errno = 0; /* OpenBSD notices that link2/ and dir are the same. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
918 result = func (BASE "link2/", BASE "dir"); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
919 if (result) /* GNU/Linux rejects attempts to use link2/. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
920 { |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
921 ASSERT (result == -1); |
14006
6fb5b50662b4
rename, renameat: Avoid test failures on OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
13881
diff
changeset
|
922 ASSERT (errno == ENOTDIR || errno == EISDIR); |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
923 } |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
924 memset (&st, 0, sizeof st); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
925 ASSERT (lstat (BASE "dir", &st) == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
926 ASSERT (S_ISDIR (st.st_mode)); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
927 errno = 0; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
928 ASSERT (lstat (BASE "dir2", &st) == -1); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
929 ASSERT (errno == ENOENT); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
930 memset (&st, 0, sizeof st); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
931 ASSERT (lstat (BASE "link2", &st) == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
932 ASSERT (S_ISLNK (st.st_mode)); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
933 } |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
934 } |
13866
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
935 /* Files present here: |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
936 {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
937 {BASE}link1 -> {BASE}file |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
938 {BASE}link2 -> {BASE}dir or {BASE}dir2 |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
939 {BASE}dir/ |
3612503784bb
rename test: Add comments.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
940 */ |
12091
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
941 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
942 /* Clean up. */ |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
943 ASSERT (unlink (BASE "file") == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
944 ASSERT (rmdir (BASE "dir") == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
945 ASSERT (unlink (BASE "link1") == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
946 ASSERT (unlink (BASE "link2") == 0); |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
947 |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
948 return 0; |
4884000a2d0c
rename-tests: new test, exposes several platform bugs
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
949 } |