1 /* test36: pathconf() fpathconf() Author: Jan-mark Wams */
20 #define System(cmd) if (system(cmd) != 0) printf("``%s'' failed\n", cmd)
21 #define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir)
22 #define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a)
31 int not_provided_option(int _option
);
32 int provided_option(int _option
, int _minimum_value
);
33 int variating_option(int _option
, int _minimum_value
);
57 int main(int argc
, char *argv
[])
63 if (argc
== 2) m
= atoi(argv
[1]);
64 superuser
= (geteuid() == 0);
66 for (i
= 0; i
< ITERATIONS
; i
++) {
67 if (m
& 0001) test36a();
68 if (m
& 0002) test36b();
69 if (m
& 0004) test36c();
70 if (m
& 0010) test36d();
77 { /* Test normal operation. */
79 System("rm -rf ../DIR_36/*");
81 #ifdef _POSIX_CHOWN_RESTRICTED
82 # if _POSIX_CHOWN_RESTRICTED - 0 == -1
83 if (not_provided_option(_PC_CHOWN_RESTRICTED
) != 0) e(1);
85 if (provided_option(_PC_CHOWN_RESTRICTED
, 0) != 0) e(2);
88 if (variating_option(_PC_CHOWN_RESTRICTED
, 0) != 0) e(3);
91 #ifdef _POSIX_NO_TRUNC
92 # if _POSIX_NO_TRUNC - 0 == -1
93 if (not_provided_option(_PC_NO_TRUNC
) != 0) e(4);
95 if (provided_option(_PC_NO_TRUNC
, 0) != 0) e(5);
98 if (variating_option(_PC_NO_TRUNC
, 0) != 0) e(6);
101 #ifdef _POSIX_VDISABLE
103 int _posix_vdisable
= _POSIX_VDISABLE
;
104 if(_posix_vdisable
== -1) {
105 if (not_provided_option(_PC_VDISABLE
) != 0) e(7);
107 if (provided_option(_PC_VDISABLE
, 0) != 0) e(8);
111 if (variating_option(_PC_VDISABLE
, 0) != 0) e(9);
119 System("rm -rf ../DIR_36/*");
125 System("rm -rf ../DIR_36/*");
131 System("rm -rf ../DIR_36/*");
134 int not_provided_option(option
)
139 for (p
= testfiles
; *p
!= (char *) NULL
; p
++) {
140 if (pathconf(*p
, option
) != -1) return printf("*p == %s\n", *p
), 1;
145 int provided_option(option
, minimum
)
150 /* These three options are only defined on directorys. */
151 if (option
== _PC_NO_TRUNC
152 || option
== _PC_NAME_MAX
153 || option
== _PC_PATH_MAX
)
158 for (; *p
!= NULL
; p
++) {
159 if (pathconf(*p
, option
) < minimum
)
160 return printf("*p == %s\n", *p
), 1;
165 int variating_option(option
, minimum
)
170 /* These three options are only defined on directorys. */
171 if (option
== _PC_NO_TRUNC
172 || option
== _PC_NAME_MAX
173 || option
== _PC_PATH_MAX
)
178 for (; *p
!= NULL
; p
++) {
179 if (pathconf(*p
, option
) < minimum
)
180 return printf("*p == %s\n", *p
), 1;