This source file includes following definitions.
- test_symlink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 static int
26 test_symlink (int (*func) (char const *, char const *), bool print)
27 {
28 if (func ("nowhere", BASE "link1"))
29 {
30 if (print)
31 fputs ("skipping test: symlinks not supported on this file system\n",
32 stderr);
33 return 77;
34 }
35
36
37
38 {
39 int status;
40 errno = 0;
41 status = func ("", BASE "link2");
42 if (status == -1)
43 ASSERT (errno == ENOENT || errno == EINVAL);
44 else
45 {
46 ASSERT (status == 0);
47 ASSERT (unlink (BASE "link2") == 0);
48 }
49 }
50
51
52 errno = 0;
53 ASSERT (func ("nowhere", "") == -1);
54 ASSERT (errno == ENOENT);
55 errno = 0;
56 ASSERT (func ("nowhere", ".") == -1);
57 ASSERT (errno == EEXIST || errno == EINVAL);
58 errno = 0;
59 ASSERT (func ("somewhere", BASE "link1") == -1);
60 ASSERT (errno == EEXIST);
61 errno = 0;
62 ASSERT (func ("nowhere", BASE "link2/") == -1);
63 ASSERT (errno == ENOTDIR || errno == ENOENT);
64 ASSERT (mkdir (BASE "dir", 0700) == 0);
65 errno = 0;
66 ASSERT (func ("nowhere", BASE "dir") == -1);
67 ASSERT (errno == EEXIST);
68 errno = 0;
69 ASSERT (func ("nowhere", BASE "dir/") == -1);
70 ASSERT (errno == EEXIST || errno == EINVAL
71 || errno == ENOENT );
72 ASSERT (close (creat (BASE "file", 0600)) == 0);
73 errno = 0;
74 ASSERT (func ("nowhere", BASE "file") == -1);
75 ASSERT (errno == EEXIST);
76 errno = 0;
77 ASSERT (func ("nowhere", BASE "file/") == -1);
78 ASSERT (errno == EEXIST || errno == ENOTDIR || errno == ENOENT);
79
80
81 ASSERT (unlink (BASE "link1") == 0);
82 ASSERT (func (BASE "link2", BASE "link1") == 0);
83 errno = 0;
84 ASSERT (func (BASE "nowhere", BASE "link1/") == -1);
85 ASSERT (errno == EEXIST || errno == ENOTDIR || errno == ENOENT);
86 errno = 0;
87 ASSERT (unlink (BASE "link2") == -1);
88 ASSERT (errno == ENOENT);
89
90
91 ASSERT (rmdir (BASE "dir") == 0);
92 ASSERT (unlink (BASE "file") == 0);
93 ASSERT (unlink (BASE "link1") == 0);
94
95 return 0;
96 }