This source file includes following definitions.
- test_mkfifo
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_mkfifo (int (*func) (char const *, mode_t), bool print)
27 {
28 int result = func (BASE "fifo", 0600);
29 struct stat st;
30 if (result == -1 && errno == ENOSYS)
31 {
32 if (print)
33 fputs ("skipping test: no support for named fifos\n", stderr);
34 return 77;
35 }
36 ASSERT (result == 0);
37 ASSERT (stat (BASE "fifo", &st) == 0);
38 ASSERT (S_ISFIFO (st.st_mode));
39
40
41 errno = 0;
42 ASSERT (func ("", S_IRUSR | S_IWUSR) == -1);
43 ASSERT (errno == ENOENT);
44 errno = 0;
45 ASSERT (func (".", 0600) == -1);
46
47
48
49 ASSERT (errno == EEXIST || errno == EINVAL || errno == EISDIR);
50 errno = 0;
51 ASSERT (func (BASE "fifo", 0600) == -1);
52 ASSERT (errno == EEXIST);
53 ASSERT (unlink (BASE "fifo") == 0);
54 errno = 0;
55 ASSERT (func (BASE "fifo/", 0600) == -1);
56 ASSERT (errno == ENOENT || errno == ENOTDIR);
57
58
59 if (symlink (BASE "fifo", BASE "link"))
60 {
61 if (print)
62 fputs ("skipping test: symlinks not supported on this file system\n",
63 stderr);
64 return 77;
65 }
66 errno = 0;
67 ASSERT (func (BASE "link", 0600) == -1);
68 ASSERT (errno == EEXIST);
69 errno = 0;
70 ASSERT (func (BASE "link/", 0600) == -1);
71 ASSERT (errno == EEXIST || errno == ENOENT || errno == ENOTDIR);
72 errno = 0;
73 ASSERT (unlink (BASE "fifo") == -1);
74 ASSERT (errno == ENOENT);
75 ASSERT (unlink (BASE "link") == 0);
76 return 0;
77 }