1 /*
2 * Copyright (c) 2022 Meta
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include "_common.h"
8
9 #ifdef CONFIG_POSIX_API
10 #include <unistd.h>
11 #else
12 #include <zephyr/posix/unistd.h>
13 #endif
14
15 /**
16 * @brief existence test for `<unistd.h>`
17 *
18 * @see <a href="https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html">unistd.h</a>
19 */
ZTEST(posix_headers,test_unistd_h)20 ZTEST(posix_headers, test_unistd_h)
21 {
22 /* zassert_not_equal(-1, F_OK); */ /* not implemented */
23 /* zassert_not_equal(-1, R_OK); */ /* not implemented */
24 /* zassert_not_equal(-1, W_OK); */ /* not implemented */
25 /* zassert_not_equal(-1, X_OK); */ /* not implemented */
26
27 zassert_not_equal(INT_MIN, _CS_PATH);
28 zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFF32_CFLAGS);
29 zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFF32_LDFLAGS);
30 zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFF32_LIBS);
31 zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS);
32 zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS);
33 zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFFBIG_LIBS);
34 zassert_not_equal(INT_MIN, _CS_POSIX_V7_LP64_OFF64_CFLAGS);
35 zassert_not_equal(INT_MIN, _CS_POSIX_V7_LP64_OFF64_LDFLAGS);
36 zassert_not_equal(INT_MIN, _CS_POSIX_V7_LP64_OFF64_LIBS);
37 zassert_not_equal(INT_MIN, _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS);
38 zassert_not_equal(INT_MIN, _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS);
39 zassert_not_equal(INT_MIN, _CS_POSIX_V7_LPBIG_OFFBIG_LIBS);
40 zassert_not_equal(INT_MIN, _CS_POSIX_V7_THREADS_CFLAGS);
41 zassert_not_equal(INT_MIN, _CS_POSIX_V7_THREADS_LDFLAGS);
42 zassert_not_equal(INT_MIN, _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS);
43 zassert_not_equal(INT_MIN, _CS_V7_ENV);
44
45 /* zassert_not_equal(-1, F_LOCK); */ /* not implemented */
46 /* zassert_not_equal(-1, F_TEST); */ /* not implemented */
47 /* zassert_not_equal(-1, F_TLOCK); */ /* not implemented */
48 /* zassert_not_equal(-1, F_ULOCK); */ /* not implemented */
49
50 /* zassert_not_equal(INT_MIN, _PC_2_SYMLINKS); */ /* not implemented */
51 /* zassert_not_equal(INT_MIN, _PC_ALLOC_SIZE_MIN); */ /* not implemented */
52 /* zassert_not_equal(INT_MIN, _PC_ASYNC_IO); */ /* not implemented */
53 /* zassert_not_equal(INT_MIN, _PC_CHOWN_RESTRICTED); */ /* not implemented */
54 /* zassert_not_equal(INT_MIN, _PC_FILESIZEBITS); */ /* not implemented */
55 /* zassert_not_equal(INT_MIN, _PC_LINK_MAX); */ /* not implemented */
56 /* zassert_not_equal(INT_MIN, _PC_MAX_CANON); */ /* not implemented */
57 /* zassert_not_equal(INT_MIN, _PC_MAX_INPUT); */ /* not implemented */
58 /* zassert_not_equal(INT_MIN, _PC_NAME_MAX); */ /* not implemented */
59 /* zassert_not_equal(INT_MIN, _PC_NO_TRUNC); */ /* not implemented */
60 /* zassert_not_equal(INT_MIN, _PC_PATH_MAX); */ /* not implemented */
61 /* zassert_not_equal(INT_MIN, _PC_PIPE_BUF); */ /* not imp``lemented */
62 /* zassert_not_equal(INT_MIN, _PC_PRIO_IO); */ /* not implemented */
63 /* zassert_not_equal(INT_MIN, _PC_REC_INCR_XFER_SIZE); */ /* not implemented */
64 /* zassert_not_equal(INT_MIN, _PC_REC_MAX_XFER_SIZE); */ /* not implemented */
65 /* zassert_not_equal(INT_MIN, _PC_REC_MIN_XFER_SIZE); */ /* not implemented */
66 /* zassert_not_equal(INT_MIN, _PC_REC_XFER_ALIGN); */ /* not implemented */
67 /* zassert_not_equal(INT_MIN, _PC_SYMLINK_MAX); */ /* not implemented */
68 /* zassert_not_equal(INT_MIN, _PC_SYNC_IO); */ /* not implemented */
69 /* zassert_not_equal(INT_MIN, _PC_TIMESTAMP_RESOLUTION); */ /* not implemented */
70 /* zassert_not_equal(INT_MIN, _PC_VDISABLE); */ /* not implemented */
71
72 zassert_not_equal(INT_MIN, _SC_2_C_BIND);
73 zassert_not_equal(INT_MIN, _SC_2_C_DEV);
74 zassert_not_equal(INT_MIN, _SC_2_CHAR_TERM);
75 zassert_not_equal(INT_MIN, _SC_2_FORT_DEV);
76 zassert_not_equal(INT_MIN, _SC_2_FORT_RUN);
77 zassert_not_equal(INT_MIN, _SC_2_LOCALEDEF);
78 zassert_not_equal(INT_MIN, _SC_2_PBS);
79 zassert_not_equal(INT_MIN, _SC_2_PBS_ACCOUNTING);
80 zassert_not_equal(INT_MIN, _SC_2_PBS_CHECKPOINT);
81 zassert_not_equal(INT_MIN, _SC_2_PBS_LOCATE);
82 zassert_not_equal(INT_MIN, _SC_2_PBS_MESSAGE);
83 zassert_not_equal(INT_MIN, _SC_2_PBS_TRACK);
84 zassert_not_equal(INT_MIN, _SC_2_SW_DEV);
85 zassert_not_equal(INT_MIN, _SC_2_UPE);
86 zassert_not_equal(INT_MIN, _SC_2_VERSION);
87 zassert_not_equal(INT_MIN, _SC_ADVISORY_INFO);
88 zassert_not_equal(INT_MIN, _SC_AIO_LISTIO_MAX);
89 zassert_not_equal(INT_MIN, _SC_AIO_MAX);
90 zassert_not_equal(INT_MIN, _SC_AIO_PRIO_DELTA_MAX);
91 zassert_not_equal(INT_MIN, _SC_ARG_MAX);
92 zassert_not_equal(INT_MIN, _SC_ASYNCHRONOUS_IO);
93 zassert_not_equal(INT_MIN, _SC_ATEXIT_MAX);
94 zassert_not_equal(INT_MIN, _SC_BARRIERS);
95 zassert_not_equal(INT_MIN, _SC_BC_BASE_MAX);
96 zassert_not_equal(INT_MIN, _SC_BC_DIM_MAX);
97 zassert_not_equal(INT_MIN, _SC_BC_SCALE_MAX);
98 zassert_not_equal(INT_MIN, _SC_BC_STRING_MAX);
99 zassert_not_equal(INT_MIN, _SC_CHILD_MAX);
100 zassert_not_equal(INT_MIN, _SC_CLK_TCK);
101 zassert_not_equal(INT_MIN, _SC_CLOCK_SELECTION);
102 zassert_not_equal(INT_MIN, _SC_COLL_WEIGHTS_MAX);
103 zassert_not_equal(INT_MIN, _SC_CPUTIME);
104 zassert_not_equal(INT_MIN, _SC_DELAYTIMER_MAX);
105 zassert_not_equal(INT_MIN, _SC_EXPR_NEST_MAX);
106 zassert_not_equal(INT_MIN, _SC_FSYNC);
107 zassert_not_equal(INT_MIN, _SC_GETGR_R_SIZE_MAX);
108 zassert_not_equal(INT_MIN, _SC_GETPW_R_SIZE_MAX);
109 zassert_not_equal(INT_MIN, _SC_HOST_NAME_MAX);
110 zassert_not_equal(INT_MIN, _SC_IOV_MAX);
111 zassert_not_equal(INT_MIN, _SC_IPV6);
112 zassert_not_equal(INT_MIN, _SC_JOB_CONTROL);
113 zassert_not_equal(INT_MIN, _SC_LINE_MAX);
114 zassert_not_equal(INT_MIN, _SC_LOGIN_NAME_MAX);
115 zassert_not_equal(INT_MIN, _SC_MAPPED_FILES);
116 zassert_not_equal(INT_MIN, _SC_MEMLOCK);
117 zassert_not_equal(INT_MIN, _SC_MEMLOCK_RANGE);
118 zassert_not_equal(INT_MIN, _SC_MEMORY_PROTECTION);
119 zassert_not_equal(INT_MIN, _SC_MESSAGE_PASSING);
120 zassert_not_equal(INT_MIN, _SC_MONOTONIC_CLOCK);
121 zassert_not_equal(INT_MIN, _SC_MQ_OPEN_MAX);
122 zassert_not_equal(INT_MIN, _SC_MQ_PRIO_MAX);
123 zassert_not_equal(INT_MIN, _SC_NGROUPS_MAX);
124 zassert_not_equal(INT_MIN, _SC_OPEN_MAX);
125 zassert_not_equal(INT_MIN, _SC_PAGE_SIZE);
126 zassert_not_equal(INT_MIN, _SC_PAGESIZE);
127 zassert_not_equal(INT_MIN, _SC_PRIORITIZED_IO);
128 zassert_not_equal(INT_MIN, _SC_PRIORITY_SCHEDULING);
129 zassert_not_equal(INT_MIN, _SC_RAW_SOCKETS);
130 zassert_not_equal(INT_MIN, _SC_RE_DUP_MAX);
131 zassert_not_equal(INT_MIN, _SC_READER_WRITER_LOCKS);
132 zassert_not_equal(INT_MIN, _SC_REALTIME_SIGNALS);
133 zassert_not_equal(INT_MIN, _SC_REGEXP);
134 zassert_not_equal(INT_MIN, _SC_RTSIG_MAX);
135 zassert_not_equal(INT_MIN, _SC_SAVED_IDS);
136 zassert_not_equal(INT_MIN, _SC_SEM_NSEMS_MAX);
137 zassert_not_equal(INT_MIN, _SC_SEM_VALUE_MAX);
138 zassert_not_equal(INT_MIN, _SC_SEMAPHORES);
139 zassert_not_equal(INT_MIN, _SC_SHARED_MEMORY_OBJECTS);
140 zassert_not_equal(INT_MIN, _SC_SHELL);
141 zassert_not_equal(INT_MIN, _SC_SIGQUEUE_MAX);
142 zassert_not_equal(INT_MIN, _SC_SPAWN);
143 zassert_not_equal(INT_MIN, _SC_SPIN_LOCKS);
144 zassert_not_equal(INT_MIN, _SC_SPORADIC_SERVER);
145 zassert_not_equal(INT_MIN, _SC_SS_REPL_MAX);
146 zassert_not_equal(INT_MIN, _SC_STREAM_MAX);
147 zassert_not_equal(INT_MIN, _SC_SYMLOOP_MAX);
148 zassert_not_equal(INT_MIN, _SC_SYNCHRONIZED_IO);
149 zassert_not_equal(INT_MIN, _SC_THREAD_ATTR_STACKADDR);
150 zassert_not_equal(INT_MIN, _SC_THREAD_ATTR_STACKSIZE);
151 zassert_not_equal(INT_MIN, _SC_THREAD_CPUTIME);
152 zassert_not_equal(INT_MIN, _SC_THREAD_DESTRUCTOR_ITERATIONS);
153 zassert_not_equal(INT_MIN, _SC_THREAD_KEYS_MAX);
154 zassert_not_equal(INT_MIN, _SC_THREAD_PRIO_INHERIT);
155 zassert_not_equal(INT_MIN, _SC_THREAD_PRIO_PROTECT);
156 zassert_not_equal(INT_MIN, _SC_THREAD_PRIORITY_SCHEDULING);
157 zassert_not_equal(INT_MIN, _SC_THREAD_PROCESS_SHARED);
158 zassert_not_equal(INT_MIN, _SC_THREAD_ROBUST_PRIO_INHERIT);
159 zassert_not_equal(INT_MIN, _SC_THREAD_ROBUST_PRIO_PROTECT);
160 zassert_not_equal(INT_MIN, _SC_THREAD_SAFE_FUNCTIONS);
161 zassert_not_equal(INT_MIN, _SC_THREAD_SPORADIC_SERVER);
162 zassert_not_equal(INT_MIN, _SC_THREAD_STACK_MIN);
163 zassert_not_equal(INT_MIN, _SC_THREAD_THREADS_MAX);
164 zassert_not_equal(INT_MIN, _SC_THREADS);
165 zassert_not_equal(INT_MIN, _SC_TIMEOUTS);
166 zassert_not_equal(INT_MIN, _SC_TIMER_MAX);
167 zassert_not_equal(INT_MIN, _SC_TIMERS);
168 zassert_not_equal(INT_MIN, _SC_TRACE);
169 zassert_not_equal(INT_MIN, _SC_TRACE_EVENT_FILTER);
170 zassert_not_equal(INT_MIN, _SC_TRACE_EVENT_NAME_MAX);
171 zassert_not_equal(INT_MIN, _SC_TRACE_INHERIT);
172 zassert_not_equal(INT_MIN, _SC_TRACE_LOG);
173 zassert_not_equal(INT_MIN, _SC_TRACE_NAME_MAX);
174 zassert_not_equal(INT_MIN, _SC_TRACE_SYS_MAX);
175 zassert_not_equal(INT_MIN, _SC_TRACE_USER_EVENT_MAX);
176 zassert_not_equal(INT_MIN, _SC_TTY_NAME_MAX);
177 zassert_not_equal(INT_MIN, _SC_TYPED_MEMORY_OBJECTS);
178 zassert_not_equal(INT_MIN, _SC_TZNAME_MAX);
179 zassert_not_equal(INT_MIN, _SC_V7_ILP32_OFF32);
180 zassert_not_equal(INT_MIN, _SC_V7_ILP32_OFFBIG);
181 zassert_not_equal(INT_MIN, _SC_V7_LP64_OFF64);
182 zassert_not_equal(INT_MIN, _SC_V7_LPBIG_OFFBIG);
183 zassert_not_equal(INT_MIN, _SC_V6_ILP32_OFF32);
184 zassert_not_equal(INT_MIN, _SC_V6_ILP32_OFFBIG);
185 zassert_not_equal(INT_MIN, _SC_V6_LP64_OFF64);
186 zassert_not_equal(INT_MIN, _SC_V6_LPBIG_OFFBIG);
187 zassert_not_equal(INT_MIN, _SC_VERSION);
188 zassert_not_equal(INT_MIN, _SC_XOPEN_CRYPT);
189 zassert_not_equal(INT_MIN, _SC_XOPEN_ENH_I18N);
190 zassert_not_equal(INT_MIN, _SC_XOPEN_REALTIME);
191 zassert_not_equal(INT_MIN, _SC_XOPEN_REALTIME_THREADS);
192 zassert_not_equal(INT_MIN, _SC_XOPEN_SHM);
193 zassert_not_equal(INT_MIN, _SC_XOPEN_STREAMS);
194 zassert_not_equal(INT_MIN, _SC_XOPEN_UNIX);
195 zassert_not_equal(INT_MIN, _SC_XOPEN_UUCP);
196 zassert_not_equal(INT_MIN, _SC_XOPEN_VERSION);
197
198 /* zassert_equal(STDERR_FILENO, 2); */ /* not implemented */
199 /* zassert_equal(STDIN_FILENO, 0); */ /* not implemented */
200 /* zassert_equal(STDOUT_FILENO, 1); */ /* not implemented */
201
202 zassert_not_equal(INT_MIN, _POSIX_VDISABLE);
203
204 /*
205 * FIXME: this should really use IS_ENABLED()
206 * When CONFIG_POSIX_API is n-selected (i.e. POSIX headers can only be
207 * included with <zephyr/posix/...>, i.e. are namespaced), then there
208 * should be no reason to conditionally declare standard posix
209 * function prototypes.
210 */
211 #ifdef CONFIG_POSIX_API
212 /* zassert_not_null(access); */ /* not implemented */
213 /* zassert_not_null(alarm); */ /* not implemented */
214 /* zassert_not_null(chdir); */ /* not implemented */
215 /* zassert_not_null(chown); */ /* not implemented */
216 zassert_not_null(close);
217 /* zassert_not_null(confstr); */ /* not implemented */
218 /* zassert_not_null(crypt); */ /* not implemented */
219 /* zassert_not_null(dup); */ /* not implemented */
220 /* zassert_not_null(dup2); */ /* not implemented */
221 zassert_not_null(_exit);
222 /* zassert_not_null(encrypt); */ /* not implemented */
223 /* zassert_not_null(execl); */ /* not implemented */
224 /* zassert_not_null(execle); */ /* not implemented */
225 /* zassert_not_null(execlp); */ /* not implemented */
226 /* zassert_not_null(execv); */ /* not implemented */
227 /* zassert_not_null(execve); */ /* not implemented */
228 /* zassert_not_null(execvp); */ /* not implemented */
229 /* zassert_not_null(faccessat); */ /* not implemented */
230 /* zassert_not_null(fchdir); */ /* not implemented */
231 /* zassert_not_null(fchown); */ /* not implemented */
232 /* zassert_not_null(fchownat); */ /* not implemented */
233 zassert_not_null(fdatasync);
234 /* zassert_not_null(fexecve); */ /* not implemented */
235 /* zassert_not_null(fork); */ /* not implemented */
236 /* zassert_not_null(fpathconf); */ /* not implemented */
237 zassert_not_null(fsync);
238 zassert_not_null(ftruncate);
239 /* zassert_not_null(getcwd); */ /* not implemented */
240 /* zassert_not_null(getegid); */ /* not implemented */
241 /* zassert_not_null(geteuid); */ /* not implemented */
242 /* zassert_not_null(getgid); */ /* not implemented */
243 /* zassert_not_null(getgroups); */ /* not implemented */
244 /* zassert_not_null(gethostid); */ /* not implemented */
245 /* zassert_not_null(gethostname); */ /* not implemented */
246 /* zassert_not_null(getlogin); */ /* not implemented */
247 /* zassert_not_null(getlogin_r); */ /* not implemented */
248 zassert_not_null(getopt);
249 /* zassert_not_null(getpgid); */ /* not implemented */
250 /* zassert_not_null(getpgrp); */ /* not implemented */
251 zassert_not_null(getpid);
252 /* zassert_not_null(getppid); */ /* not implemented */
253 /* zassert_not_null(getsid); */ /* not implemented */
254 /* zassert_not_null(getuid); */ /* not implemented */
255 /* zassert_not_null(isatty); */ /* not implemented */
256 /* zassert_not_null(lchown); */ /* not implemented */
257 /* zassert_not_null(link); */ /* not implemented */
258 /* zassert_not_null(linkat); */ /* not implemented */
259 /* zassert_not_null(lockf); */ /* not implemented */
260 zassert_not_null(lseek);
261 /* zassert_not_null(nice); */ /* not implemented */
262 /* zassert_not_null(pathconf); */ /* not implemented */
263 /* zassert_not_null(pause); */ /* not implemented */
264 /* zassert_not_null(pipe); */ /* not implemented */
265 /* zassert_not_null(pread); */ /* not implemented */
266 /* zassert_not_null(pwrite); */ /* not implemented */
267 zassert_not_null(read);
268 /* zassert_not_null(readlink); */ /* not implemented */
269 /* zassert_not_null(readlinkat); */ /* not implemented */
270 /* zassert_not_null(rmdir); */ /* not implemented */
271 /* zassert_not_null(setegid); */ /* not implemented */
272 /* zassert_not_null(seteuid); */ /* not implemented */
273 /* zassert_not_null(setgid); */ /* not implemented */
274 /* zassert_not_null(setpgid); */ /* not implemented */
275 /* zassert_not_null(setpgrp); */ /* not implemented */
276 /* zassert_not_null(setregid); */ /* not implemented */
277 /* zassert_not_null(setreuid); */ /* not implemented */
278 /* zassert_not_null(setsid); */ /* not implemented */
279 /* zassert_not_null(setuid); */ /* not implemented */
280 zassert_not_null(sleep);
281 /* zassert_not_null(swab); */ /* not implemented */
282 /* zassert_not_null(symlink); */ /* not implemented */
283 /* zassert_not_null(symlinkat); */ /* not implemented */
284 /* zassert_not_null(sync); */ /* not implemented */
285 /* zassert_not_null(sysconf); */ /* not implemented */
286 /* zassert_not_null(tcgetpgrp); */ /* not implemented */
287 /* zassert_not_null(tcsetpgrp); */ /* not implemented */
288 /* zassert_not_null(truncate); */ /* not implemented */
289 /* zassert_not_null(ttyname); */ /* not implemented */
290 /* zassert_not_null(ttyname_r); */ /* not implemented */
291 zassert_not_null(unlink);
292 /* zassert_not_null(unlinkat); */ /* not implemented */
293 zassert_not_null(write);
294 #endif
295 }
296