1 /* test36: pathconf() fpathconf() Author: Jan-mark Wams */
18 #define System(cmd) if (system(cmd) != 0) printf("``%s'' failed\n", cmd)
19 #define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir)
20 #define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a)
30 int not_provided_option(int _option
);
31 int provided_option(int _option
, int _minimum_value
);
32 int variating_option(int _option
, int _minimum_value
);
56 int main(int argc
, char *argv
[])
62 if (argc
== 2) m
= atoi(argv
[1]);
63 superuser
= (geteuid() == 0);
65 for (i
= 0; i
< ITERATIONS
; i
++) {
66 if (m
& 0001) test36a();
67 if (m
& 0002) test36b();
68 if (m
& 0004) test36c();
69 if (m
& 0010) test36d();
76 { /* Test normal operation. */
78 System("rm -rf ../DIR_36/*");
80 #ifdef _POSIX_CHOWN_RESTRICTED
81 # if _POSIX_CHOWN_RESTRICTED - 0 == -1
82 if (not_provided_option(_PC_CHOWN_RESTRICTED
) != 0) e(1);
84 if (provided_option(_PC_CHOWN_RESTRICTED
, 0) != 0) e(2);
87 if (variating_option(_PC_CHOWN_RESTRICTED
, 0) != 0) e(3);
90 #ifdef _POSIX_NO_TRUNC
91 # if _POSIX_NO_TRUNC - 0 == -1
92 if (not_provided_option(_PC_NO_TRUNC
) != 0) e(4);
94 if (provided_option(_PC_NO_TRUNC
, 0) != 0) e(5);
97 if (variating_option(_PC_NO_TRUNC
, 0) != 0) e(6);
100 #ifdef _POSIX_VDISABLE
102 int _posix_vdisable
= _POSIX_VDISABLE
;
103 if(_posix_vdisable
== -1) {
104 if (not_provided_option(_PC_VDISABLE
) != 0) e(7);
106 if (provided_option(_PC_VDISABLE
, 0) != 0) e(8);
110 if (variating_option(_PC_VDISABLE
, 0) != 0) e(9);
118 System("rm -rf ../DIR_36/*");
124 System("rm -rf ../DIR_36/*");
130 System("rm -rf ../DIR_36/*");
133 int not_provided_option(option
)
138 for (p
= testfiles
; *p
!= (char *) NULL
; p
++) {
139 if (pathconf(*p
, option
) != -1) return printf("*p == %s\n", *p
), 1;
144 int provided_option(option
, minimum
)
149 /* These three options are only defined on directorys. */
150 if (option
== _PC_NO_TRUNC
151 || option
== _PC_NAME_MAX
152 || option
== _PC_PATH_MAX
)
157 for (; *p
!= NULL
; p
++) {
158 if (pathconf(*p
, option
) < minimum
)
159 return printf("*p == %s\n", *p
), 1;
164 int variating_option(option
, minimum
)
169 /* These three options are only defined on directorys. */
170 if (option
== _PC_NO_TRUNC
171 || option
== _PC_NAME_MAX
172 || option
== _PC_PATH_MAX
)
177 for (; *p
!= NULL
; p
++) {
178 if (pathconf(*p
, option
) < minimum
)
179 return printf("*p == %s\n", *p
), 1;