annotate tests/test-link.h @ 40057:b06060465f09

maint: Run 'make update-copyright'
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 01 Jan 2019 00:25:11 +0100
parents 10eb9086bea0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
1 /* Test of link() function.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2009-2019 Free Software Foundation, Inc.
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
3
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
14cddb59cb05 linkat: new module
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: 12263
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
7 (at your option) any later version.
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
8
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
12 GNU General Public License for more details.
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
13
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
16
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
17 /* This file is designed to test both link(a,b) and
12084
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
18 linkat(AT_FDCWD,a,AT_FDCWD,b,0). FUNC is the function to test.
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
19 Assumes that BASE and ASSERT are already defined, and that
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
20 appropriate headers are already included. If PRINT, warn before
12263
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
21 skipping tests with status 77. This test does not try to create
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
22 hard links to symlinks, but does test other aspects of symlink. */
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
23
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
24 static int
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
25 test_link (int (*func) (char const *, char const *), bool print)
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
26 {
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
27 int fd;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
28 int ret;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
29
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
30 /* Create first file. */
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
31 fd = open (BASE "a", O_CREAT | O_EXCL | O_WRONLY, 0600);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
32 ASSERT (0 <= fd);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
33 ASSERT (write (fd, "hello", 5) == 5);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
34 ASSERT (close (fd) == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
35
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
36 /* Not all file systems support link. Mingw doesn't have reliable
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
37 st_nlink on hard links, but our implementation does fail with
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
38 EPERM on poor file systems, and we can detect the inferior stat()
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
39 via st_ino. Cygwin 1.5.x copies rather than links files on those
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
40 file systems, but there, st_nlink and st_ino are reliable. */
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
41 ret = func (BASE "a", BASE "b");
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
42 if (!ret)
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
43 {
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
44 struct stat st;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
45 ASSERT (stat (BASE "b", &st) == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
46 if (st.st_ino && st.st_nlink != 2)
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
47 {
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
48 ASSERT (unlink (BASE "b") == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
49 errno = EPERM;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
50 ret = -1;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
51 }
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
52 }
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
53 if (ret == -1)
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
54 {
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
55 /* If the device does not support hard links, errno is
12102
3ba227551e1d maint: cleanup whitespace in recent commits
Eric Blake <ebb9@byu.net>
parents: 12084
diff changeset
56 EPERM on Linux, EOPNOTSUPP on FreeBSD. */
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
57 switch (errno)
12102
3ba227551e1d maint: cleanup whitespace in recent commits
Eric Blake <ebb9@byu.net>
parents: 12084
diff changeset
58 {
3ba227551e1d maint: cleanup whitespace in recent commits
Eric Blake <ebb9@byu.net>
parents: 12084
diff changeset
59 case EPERM:
3ba227551e1d maint: cleanup whitespace in recent commits
Eric Blake <ebb9@byu.net>
parents: 12084
diff changeset
60 case EOPNOTSUPP:
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
61 if (print)
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
62 fputs ("skipping test: "
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
63 "hard links not supported on this file system\n",
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
64 stderr);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
65 ASSERT (unlink (BASE "a") == 0);
12102
3ba227551e1d maint: cleanup whitespace in recent commits
Eric Blake <ebb9@byu.net>
parents: 12084
diff changeset
66 return 77;
3ba227551e1d maint: cleanup whitespace in recent commits
Eric Blake <ebb9@byu.net>
parents: 12084
diff changeset
67 default:
3ba227551e1d maint: cleanup whitespace in recent commits
Eric Blake <ebb9@byu.net>
parents: 12084
diff changeset
68 perror ("link");
3ba227551e1d maint: cleanup whitespace in recent commits
Eric Blake <ebb9@byu.net>
parents: 12084
diff changeset
69 return 1;
3ba227551e1d maint: cleanup whitespace in recent commits
Eric Blake <ebb9@byu.net>
parents: 12084
diff changeset
70 }
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
71 }
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
72 ASSERT (ret == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
73
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
74 /* Now, for some behavior tests. Modify the contents of 'b', and
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
75 ensure that 'a' can see it, both while 'b' exists and after. */
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
76 fd = open (BASE "b", O_APPEND | O_WRONLY);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
77 ASSERT (0 <= fd);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
78 ASSERT (write (fd, "world", 5) == 5);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
79 ASSERT (close (fd) == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
80 {
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
81 char buf[11] = { 0 };
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
82 fd = open (BASE "a", O_RDONLY);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
83 ASSERT (0 <= fd);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
84 ASSERT (read (fd, buf, 10) == 10);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
85 ASSERT (strcmp (buf, "helloworld") == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
86 ASSERT (close (fd) == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
87 ASSERT (unlink (BASE "b") == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
88 fd = open (BASE "a", O_RDONLY);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
89 ASSERT (0 <= fd);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
90 ASSERT (read (fd, buf, 10) == 10);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
91 ASSERT (strcmp (buf, "helloworld") == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
92 ASSERT (close (fd) == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
93 }
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
94
12084
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
95 /* Test for various error conditions. */
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
96 ASSERT (mkdir (BASE "d", 0700) == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
97 errno = 0;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
98 ASSERT (func (BASE "a", ".") == -1);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
99 ASSERT (errno == EEXIST || errno == EINVAL);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
100 errno = 0;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
101 ASSERT (func (BASE "a", BASE "a") == -1);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
102 ASSERT (errno == EEXIST);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
103 ASSERT (func (BASE "a", BASE "b") == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
104 errno = 0;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
105 ASSERT (func (BASE "a", BASE "b") == -1);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
106 ASSERT (errno == EEXIST);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
107 errno = 0;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
108 ASSERT (func (BASE "a", BASE "d") == -1);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
109 ASSERT (errno == EEXIST);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
110 errno = 0;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
111 ASSERT (func (BASE "c", BASE "e") == -1);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
112 ASSERT (errno == ENOENT);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
113 errno = 0;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
114 ASSERT (func (BASE "a", BASE "c/.") == -1);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
115 ASSERT (errno == ENOENT);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
116 errno = 0;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
117 ASSERT (func (BASE "a/", BASE "c") == -1);
15298
9f6aa6c9dd0e linkat test: Avoid test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents: 14403
diff changeset
118 ASSERT (errno == ENOTDIR || errno == EINVAL);
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
119 errno = 0;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
120 ASSERT (func (BASE "a", BASE "c/") == -1);
15298
9f6aa6c9dd0e linkat test: Avoid test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents: 14403
diff changeset
121 ASSERT (errno == ENOTDIR || errno == ENOENT || errno == EINVAL);
12084
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
122
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
123 /* Most platforms reject hard links to directories, and even on
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
124 those that do permit it, most users can't create them. We assume
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
125 that if this test is run as root and we managed to create a hard
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
126 link, then unlink better be able to clean it up. */
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
127 {
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
128 int result;
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
129 errno = 0;
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
130 result = func (BASE "d", BASE "c");
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
131 if (result == 0)
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
132 {
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
133 /* Probably root on Solaris. */
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
134 ASSERT (unlink (BASE "c") == 0);
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
135 }
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
136 else
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
137 {
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
138 /* Most everyone else. */
14403
9e98f6d3aacd test-link: work on Hurd
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
139 ASSERT (errno == EPERM || errno == EACCES || errno == EISDIR);
12084
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
140 errno = 0;
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
141 ASSERT (func (BASE "d/.", BASE "c") == -1);
14403
9e98f6d3aacd test-link: work on Hurd
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
142 ASSERT (errno == EPERM || errno == EACCES || errno == EISDIR
9e98f6d3aacd test-link: work on Hurd
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
143 || errno == EINVAL);
12084
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
144 errno = 0;
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
145 ASSERT (func (BASE "d/.//", BASE "c") == -1);
14403
9e98f6d3aacd test-link: work on Hurd
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
146 ASSERT (errno == EPERM || errno == EACCES || errno == EISDIR
9e98f6d3aacd test-link: work on Hurd
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
147 || errno == EINVAL);
12084
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
148 }
34277de50e87 tests: tighten link, rmdir, and remove tests
Eric Blake <ebb9@byu.net>
parents: 12068
diff changeset
149 }
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
150 ASSERT (unlink (BASE "a") == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
151 errno = 0;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
152 ASSERT (unlink (BASE "c") == -1);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
153 ASSERT (errno == ENOENT);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
154 ASSERT (rmdir (BASE "d") == 0);
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
155
12263
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
156 /* Test invalid use of symlink. */
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
157 if (symlink (BASE "a", BASE "link") != 0)
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
158 {
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
159 ASSERT (unlink (BASE "b") == 0);
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
160 if (print)
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
161 fputs ("skipping test: symlinks not supported on this file system\n",
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
162 stderr);
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
163 return 77;
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
164 }
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
165 errno = 0;
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
166 ASSERT (func (BASE "b", BASE "link/") == -1);
15298
9f6aa6c9dd0e linkat test: Avoid test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents: 14403
diff changeset
167 ASSERT (errno == ENOTDIR || errno == ENOENT || errno == EEXIST
9f6aa6c9dd0e linkat test: Avoid test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents: 14403
diff changeset
168 || errno == EINVAL);
15313
8dfa469e2ba8 link: work around IRIX bug
Eric Blake <eblake@redhat.com>
parents: 15298
diff changeset
169 errno = 0;
8dfa469e2ba8 link: work around IRIX bug
Eric Blake <eblake@redhat.com>
parents: 15298
diff changeset
170 ASSERT (func (BASE "b", BASE "link") == -1);
8dfa469e2ba8 link: work around IRIX bug
Eric Blake <eblake@redhat.com>
parents: 15298
diff changeset
171 ASSERT (errno == EEXIST);
12263
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
172 ASSERT (rename (BASE "b", BASE "a") == 0);
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
173 errno = 0;
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
174 ASSERT (func (BASE "link/", BASE "b") == -1);
15298
9f6aa6c9dd0e linkat test: Avoid test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents: 14403
diff changeset
175 ASSERT (errno == ENOTDIR || errno == EEXIST || errno == EINVAL);
12263
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
176
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
177 /* Clean up. */
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
178 ASSERT (unlink (BASE "a") == 0);
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
179 ASSERT (unlink (BASE "link") == 0);
c689d1419da9 link: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12102
diff changeset
180
12068
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
181 return 0;
14cddb59cb05 linkat: new module
Eric Blake <ebb9@byu.net>
parents:
diff changeset
182 }