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