This source file includes following definitions.
- test_rmdir_func
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_rmdir_func (int (*func) (char const *name), bool print)
27 {
28
29 ASSERT (mkdir (BASE "dir", 0700) == 0);
30 ASSERT (close (creat (BASE "dir/file", 0600)) == 0);
31
32
33 errno = 0;
34 ASSERT (func ("") == -1);
35 ASSERT (errno == ENOENT);
36 errno = 0;
37 ASSERT (func (BASE "nosuch") == -1);
38 ASSERT (errno == ENOENT);
39 errno = 0;
40 ASSERT (func (BASE "nosuch/") == -1);
41 ASSERT (errno == ENOENT);
42 errno = 0;
43 ASSERT (func (".") == -1);
44 ASSERT (errno == EINVAL || errno == EBUSY);
45
46
47
48 ASSERT (func ("..") == -1);
49 ASSERT (func ("/") == -1);
50 ASSERT (func ("///") == -1);
51 errno = 0;
52 ASSERT (func (BASE "dir/file/") == -1);
53 ASSERT (errno == ENOTDIR);
54
55
56 errno = 0;
57 ASSERT (func (BASE "dir") == -1);
58 ASSERT (errno == EEXIST || errno == ENOTEMPTY);
59
60
61 errno = 0;
62 ASSERT (func (BASE "dir/file") == -1);
63 ASSERT (errno == ENOTDIR);
64
65
66 ASSERT (unlink (BASE "dir/file") == 0);
67 errno = 0;
68 ASSERT (func (BASE "dir/.//") == -1);
69 ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST
70 || errno == ENOTEMPTY);
71 ASSERT (func (BASE "dir") == 0);
72
73
74
75
76
77
78 if (symlink (BASE "dir", BASE "link") != 0)
79 {
80 if (print)
81 fputs ("skipping test: symlinks not supported on this file system\n",
82 stderr);
83 return 77;
84 }
85 ASSERT (mkdir (BASE "dir", 0700) == 0);
86 errno = 0;
87 if (func (BASE "link/") == 0)
88 {
89 struct stat st;
90 errno = 0;
91 ASSERT (stat (BASE "link", &st) == -1);
92 ASSERT (errno == ENOENT);
93 }
94 else
95 {
96 ASSERT (errno == ENOTDIR);
97 ASSERT (func (BASE "dir") == 0);
98 }
99 ASSERT (unlink (BASE "link") == 0);
100
101 return 0;
102 }