<sys/socket.h>: turn off MSG_NOSIGNAL
[minix3.git] / test / test36.c
blob948992ee42ced209e6d8c19965bd427f16ba94ed
1 /* test36: pathconf() fpathconf() Author: Jan-mark Wams */
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <sys/wait.h>
6 #include <stdlib.h>
7 #include <unistd.h>
8 #include <string.h>
9 #include <fcntl.h>
10 #include <limits.h>
11 #include <errno.h>
12 #include <time.h>
13 #include <stdio.h>
15 int max_error = 4;
16 #include "common.h"
18 #define ITERATIONS 10
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)
25 int superuser;
27 void test36a(void);
28 void test36b(void);
29 void test36c(void);
30 void test36d(void);
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);
35 char *testdirs[] = {
36 "/",
37 "/etc",
38 "/tmp",
39 "/usr",
40 "/usr/bin",
41 ".",
42 NULL
45 char *testfiles[] = {
46 "/",
47 "/etc",
48 "/etc/passwd",
49 "/tmp",
50 "/dev/tty",
51 "/usr",
52 "/usr/bin",
53 ".",
54 NULL
57 int main(int argc, char *argv[])
59 int i, m = 0xFFFF;
61 sync();
62 start(36);
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();
72 quit();
73 return 1;
76 void test36a()
77 { /* Test normal operation. */
78 subtest = 1;
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);
84 # else
85 if (provided_option(_PC_CHOWN_RESTRICTED, 0) != 0) e(2);
86 # endif
87 #else
88 if (variating_option(_PC_CHOWN_RESTRICTED, 0) != 0) e(3);
89 #endif
91 #ifdef _POSIX_NO_TRUNC
92 # if _POSIX_NO_TRUNC - 0 == -1
93 if (not_provided_option(_PC_NO_TRUNC) != 0) e(4);
94 # else
95 if (provided_option(_PC_NO_TRUNC, 0) != 0) e(5);
96 # endif
97 #else
98 if (variating_option(_PC_NO_TRUNC, 0) != 0) e(6);
99 #endif
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);
106 } else {
107 if (provided_option(_PC_VDISABLE, 0) != 0) e(8);
110 #else
111 if (variating_option(_PC_VDISABLE, 0) != 0) e(9);
112 #endif
116 void test36b()
118 subtest = 2;
119 System("rm -rf ../DIR_36/*");
122 void test36c()
124 subtest = 3;
125 System("rm -rf ../DIR_36/*");
128 void test36d()
130 subtest = 4;
131 System("rm -rf ../DIR_36/*");
134 int not_provided_option(option)
135 int option;
137 char **p;
139 for (p = testfiles; *p != (char *) NULL; p++) {
140 if (pathconf(*p, option) != -1) return printf("*p == %s\n", *p), 1;
142 return 0;
145 int provided_option(option, minimum)
146 int option, minimum;
148 char **p;
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)
154 p = testdirs;
155 else
156 p = testfiles;
158 for (; *p != NULL; p++) {
159 if (pathconf(*p, option) < minimum)
160 return printf("*p == %s\n", *p), 1;
162 return 0;
165 int variating_option(option, minimum)
166 int option, minimum;
168 char **p;
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)
174 p = testdirs;
175 else
176 p = testfiles;
178 for (; *p != NULL; p++) {
179 if (pathconf(*p, option) < minimum)
180 return printf("*p == %s\n", *p), 1;
182 return 0;