This source file includes following definitions.
- test_areadlink
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
26 static int
27 test_areadlink (char * (*func) (char const *, size_t), bool print)
28 {
29
30
31 errno = 0;
32 ASSERT (func ("no_such", 1) == NULL);
33 ASSERT (errno == ENOENT);
34 errno = 0;
35 ASSERT (func ("no_such/", 1) == NULL);
36 ASSERT (errno == ENOENT);
37 errno = 0;
38 ASSERT (func ("", 1) == NULL);
39 ASSERT (errno == ENOENT || errno == EINVAL);
40 errno = 0;
41 ASSERT (func (".", 1) == NULL);
42 ASSERT (errno == EINVAL);
43 errno = 0;
44 ASSERT (func ("./", 1) == NULL);
45 ASSERT (errno == EINVAL);
46 ASSERT (close (creat (BASE "file", 0600)) == 0);
47 errno = 0;
48 ASSERT (func (BASE "file", 1) == NULL);
49 ASSERT (errno == EINVAL);
50 errno = 0;
51 ASSERT (func (BASE "file/", 1) == NULL);
52 ASSERT (errno == ENOTDIR || errno == EINVAL);
53 ASSERT (unlink (BASE "file") == 0);
54
55
56 if (symlink (BASE "dir", BASE "link"))
57 {
58 if (print)
59 fputs ("skipping test: symlinks not supported on this file system\n",
60 stderr);
61 return 77;
62 }
63 ASSERT (mkdir (BASE "dir", 0700) == 0);
64 errno = 0;
65 ASSERT (func (BASE "link/", 1) == NULL);
66 ASSERT (errno == EINVAL);
67 {
68
69 char *buf = func (BASE "link", 1);
70 ASSERT (buf);
71 ASSERT (strcmp (buf, BASE "dir") == 0);
72 free (buf);
73
74 buf = func (BASE "link", 10000000);
75 ASSERT (buf);
76 ASSERT (strcmp (buf, BASE "dir") == 0);
77 free (buf);
78 }
79 ASSERT (rmdir (BASE "dir") == 0);
80 ASSERT (unlink (BASE "link") == 0);
81
82 return 0;
83 }