xref: /netbsd-src/tests/include/t_errno.c (revision 558ea2bcabd4e05fb764145ee1c7813c38524742)
1 /*	$NetBSD: t_errno.c,v 1.2 2020/03/08 22:09:43 mgorny Exp $ */
2 
3 /*-
4  * Copyright (c) 2011 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jukka Ruohonen.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 #include <sys/cdefs.h>
32 __RCSID("$NetBSD: t_errno.c,v 1.2 2020/03/08 22:09:43 mgorny Exp $");
33 
34 #include <atf-c.h>
35 #include <errno.h>
36 
37 ATF_TC(errno_constants);
ATF_TC_HEAD(errno_constants,tc)38 ATF_TC_HEAD(errno_constants, tc)
39 {
40 	atf_tc_set_md_var(tc, "descr", "Test POSIX constants in <errno.h>");
41 }
42 
ATF_TC_BODY(errno_constants,tc)43 ATF_TC_BODY(errno_constants, tc)
44 {
45 	bool fail;
46 
47 	/*
48 	 * The following definitions should be available
49 	 * according to IEEE Std 1003.1-2008, issue 7.
50 	 */
51 
52 	fail = true;
53 
54 #ifdef E2BIG
55 	fail = false;
56 #endif
57 	if (fail != false)
58 		atf_tc_fail_nonfatal("E2BIG not defined");
59 
60 	fail = true;
61 
62 #ifdef EACCES
63 	fail = false;
64 #endif
65 	if (fail != false)
66 		atf_tc_fail_nonfatal("EACCES not defined");
67 
68 	fail = true;
69 
70 #ifdef EADDRINUSE
71 	fail = false;
72 #endif
73 	if (fail != false)
74 		atf_tc_fail_nonfatal("EADDRINUSE not defined");
75 
76 	fail = true;
77 
78 #ifdef EADDRNOTAVAIL
79 	fail = false;
80 #endif
81 	if (fail != false)
82 		atf_tc_fail_nonfatal("EADDRNOTAVAIL not defined");
83 
84 	fail = true;
85 
86 #ifdef EAFNOSUPPORT
87 	fail = false;
88 #endif
89 	if (fail != false)
90 		atf_tc_fail_nonfatal("EAFNOSUPPORT not defined");
91 
92 	fail = true;
93 
94 #ifdef EAGAIN
95 	fail = false;
96 #endif
97 	if (fail != false)
98 		atf_tc_fail_nonfatal("EAGAIN not defined");
99 
100 	fail = true;
101 
102 #ifdef EALREADY
103 	fail = false;
104 #endif
105 	if (fail != false)
106 		atf_tc_fail_nonfatal("EALREADY not defined");
107 
108 	fail = true;
109 
110 #ifdef EBADF
111 	fail = false;
112 #endif
113 	if (fail != false)
114 		atf_tc_fail_nonfatal("EBADF not defined");
115 
116 	fail = true;
117 
118 #ifdef EBADMSG
119 	fail = false;
120 #endif
121 	if (fail != false)
122 		atf_tc_fail_nonfatal("EBADMSG not defined");
123 
124 	fail = true;
125 
126 #ifdef EBUSY
127 	fail = false;
128 #endif
129 	if (fail != false)
130 		atf_tc_fail_nonfatal("EBUSY not defined");
131 
132 	fail = true;
133 
134 #ifdef ECANCELED
135 	fail = false;
136 #endif
137 	if (fail != false)
138 		atf_tc_fail_nonfatal("ECANCELED not defined");
139 
140 	fail = true;
141 
142 #ifdef ECHILD
143 	fail = false;
144 #endif
145 	if (fail != false)
146 		atf_tc_fail_nonfatal("ECHILD not defined");
147 
148 	fail = true;
149 
150 #ifdef ECONNABORTED
151 	fail = false;
152 #endif
153 	if (fail != false)
154 		atf_tc_fail_nonfatal("ECONNABORTED not defined");
155 
156 	fail = true;
157 
158 #ifdef ECONNREFUSED
159 	fail = false;
160 #endif
161 	if (fail != false)
162 		atf_tc_fail_nonfatal("ECONNREFUSED not defined");
163 
164 	fail = true;
165 
166 #ifdef ECONNRESET
167 	fail = false;
168 #endif
169 	if (fail != false)
170 		atf_tc_fail_nonfatal("ECONNRESET not defined");
171 
172 	fail = true;
173 
174 #ifdef EDEADLK
175 	fail = false;
176 #endif
177 	if (fail != false)
178 		atf_tc_fail_nonfatal("EDEADLK not defined");
179 
180 	fail = true;
181 
182 #ifdef EDESTADDRREQ
183 	fail = false;
184 #endif
185 	if (fail != false)
186 		atf_tc_fail_nonfatal("EDESTADDRREQ not defined");
187 
188 	fail = true;
189 
190 #ifdef EDOM
191 	fail = false;
192 #endif
193 	if (fail != false)
194 		atf_tc_fail_nonfatal("EDOM not defined");
195 
196 	fail = true;
197 
198 #ifdef EDQUOT
199 	fail = false;
200 #endif
201 	if (fail != false)
202 		atf_tc_fail_nonfatal("EDQUOT not defined");
203 
204 	fail = true;
205 
206 #ifdef EEXIST
207 	fail = false;
208 #endif
209 	if (fail != false)
210 		atf_tc_fail_nonfatal("EEXIST not defined");
211 
212 	fail = true;
213 
214 #ifdef EFAULT
215 	fail = false;
216 #endif
217 	if (fail != false)
218 		atf_tc_fail_nonfatal("EFAULT not defined");
219 
220 	fail = true;
221 
222 #ifdef EFBIG
223 	fail = false;
224 #endif
225 	if (fail != false)
226 		atf_tc_fail_nonfatal("EFBIG not defined");
227 
228 	fail = true;
229 
230 #ifdef EHOSTUNREACH
231 	fail = false;
232 #endif
233 	if (fail != false)
234 		atf_tc_fail_nonfatal("EHOSTUNREACH not defined");
235 
236 	fail = true;
237 
238 #ifdef EIDRM
239 	fail = false;
240 #endif
241 	if (fail != false)
242 		atf_tc_fail_nonfatal("EIDRM not defined");
243 
244 	fail = true;
245 
246 #ifdef EILSEQ
247 	fail = false;
248 #endif
249 
250 	if (fail != false)
251 		atf_tc_fail_nonfatal("EILSEQ not defined");
252 
253 	fail = true;
254 
255 #ifdef EINPROGRESS
256 	fail = false;
257 #endif
258 
259 	if (fail != false)
260 		atf_tc_fail_nonfatal("EINPROGRESS not defined");
261 
262 	fail = true;
263 
264 #ifdef EINTR
265 	fail = false;
266 #endif
267 
268 	if (fail != false)
269 		atf_tc_fail_nonfatal("EINTR not defined");
270 
271 	fail = true;
272 
273 #ifdef EINVAL
274 	fail = false;
275 #endif
276 
277 	if (fail != false)
278 		atf_tc_fail_nonfatal("EINVAL not defined");
279 
280 	fail = true;
281 
282 #ifdef EIO
283 	fail = false;
284 #endif
285 
286 	if (fail != false)
287 		atf_tc_fail_nonfatal("EIO not defined");
288 
289 	fail = true;
290 
291 #ifdef EISCONN
292 	fail = false;
293 #endif
294 
295 	if (fail != false)
296 		atf_tc_fail_nonfatal("EISCONN not defined");
297 
298 	fail = true;
299 
300 #ifdef EISDIR
301 	fail = false;
302 #endif
303 
304 	if (fail != false)
305 		atf_tc_fail_nonfatal("EISDIR not defined");
306 
307 	fail = true;
308 
309 #ifdef ELOOP
310 	fail = false;
311 #endif
312 
313 	if (fail != false)
314 		atf_tc_fail_nonfatal("ELOOP not defined");
315 
316 	fail = true;
317 
318 #ifdef EMFILE
319 	fail = false;
320 #endif
321 
322 	if (fail != false)
323 		atf_tc_fail_nonfatal("EMFILE not defined");
324 
325 	fail = true;
326 
327 #ifdef EMLINK
328 	fail = false;
329 #endif
330 
331 	if (fail != false)
332 		atf_tc_fail_nonfatal("EMLINK not defined");
333 
334 	fail = true;
335 
336 #ifdef EMSGSIZE
337 	fail = false;
338 #endif
339 
340 	if (fail != false)
341 		atf_tc_fail_nonfatal("EMSGSIZE not defined");
342 
343 	fail = true;
344 
345 #ifdef EMULTIHOP
346 	fail = false;
347 #endif
348 
349 	if (fail != false)
350 		atf_tc_fail_nonfatal("EMULTIHOP not defined");
351 
352 	fail = true;
353 
354 #ifdef ENAMETOOLONG
355 	fail = false;
356 #endif
357 
358 	if (fail != false)
359 		atf_tc_fail_nonfatal("ENAMETOOLONG not defined");
360 
361 	fail = true;
362 
363 #ifdef ENETDOWN
364 	fail = false;
365 #endif
366 
367 	if (fail != false)
368 		atf_tc_fail_nonfatal("ENETDOWN not defined");
369 
370 	fail = true;
371 
372 #ifdef ENETRESET
373 	fail = false;
374 #endif
375 
376 	if (fail != false)
377 		atf_tc_fail_nonfatal("ENETRESET not defined");
378 
379 	fail = true;
380 
381 #ifdef ENETUNREACH
382 	fail = false;
383 #endif
384 
385 	if (fail != false)
386 		atf_tc_fail_nonfatal("ENETUNREACH not defined");
387 
388 	fail = true;
389 
390 #ifdef ENFILE
391 	fail = false;
392 #endif
393 
394 	if (fail != false)
395 		atf_tc_fail_nonfatal("ENFILE not defined");
396 
397 	fail = true;
398 
399 #ifdef ENOBUFS
400 	fail = false;
401 #endif
402 
403 	if (fail != false)
404 		atf_tc_fail_nonfatal("ENOBUFS not defined");
405 
406 	fail = true;
407 
408 #ifdef ENODATA
409 	fail = false;
410 #endif
411 
412 	if (fail != false)
413 		atf_tc_fail_nonfatal("ENODATA not defined");
414 
415 	fail = true;
416 
417 #ifdef ENODEV
418 	fail = false;
419 #endif
420 
421 	if (fail != false)
422 		atf_tc_fail_nonfatal("ENODEV not defined");
423 
424 	fail = true;
425 
426 #ifdef ENOENT
427 	fail = false;
428 #endif
429 
430 	if (fail != false)
431 		atf_tc_fail_nonfatal("ENOENT not defined");
432 
433 	fail = true;
434 
435 #ifdef ENOEXEC
436 	fail = false;
437 #endif
438 
439 	if (fail != false)
440 		atf_tc_fail_nonfatal("ENOEXEC not defined");
441 
442 	fail = true;
443 
444 #ifdef ENOLCK
445 	fail = false;
446 #endif
447 
448 	if (fail != false)
449 		atf_tc_fail_nonfatal("ENOLCK not defined");
450 
451 	fail = true;
452 
453 #ifdef ENOLINK
454 	fail = false;
455 #endif
456 
457 	if (fail != false)
458 		atf_tc_fail_nonfatal("ENOLINK not defined");
459 
460 	fail = true;
461 
462 #ifdef ENOMEM
463 	fail = false;
464 #endif
465 
466 	if (fail != false)
467 		atf_tc_fail_nonfatal("ENOMEM not defined");
468 
469 	fail = true;
470 
471 #ifdef ENOMSG
472 	fail = false;
473 #endif
474 
475 	if (fail != false)
476 		atf_tc_fail_nonfatal("ENOMSG not defined");
477 
478 	fail = true;
479 
480 #ifdef ENOPROTOOPT
481 	fail = false;
482 #endif
483 
484 	if (fail != false)
485 		atf_tc_fail_nonfatal("ENOPROTOOPT not defined");
486 
487 	fail = true;
488 
489 #ifdef ENOSPC
490 	fail = false;
491 #endif
492 
493 	if (fail != false)
494 		atf_tc_fail_nonfatal("ENOSPC not defined");
495 
496 	fail = true;
497 
498 #ifdef ENOSR
499 	fail = false;
500 #endif
501 
502 	if (fail != false)
503 		atf_tc_fail_nonfatal("ENOSR not defined");
504 
505 	fail = true;
506 
507 #ifdef ENOSTR
508 	fail = false;
509 #endif
510 
511 	if (fail != false)
512 		atf_tc_fail_nonfatal("ENOSTR not defined");
513 
514 	fail = true;
515 
516 #ifdef ENOSYS
517 	fail = false;
518 #endif
519 
520 	if (fail != false)
521 		atf_tc_fail_nonfatal("ENOSYS not defined");
522 
523 	fail = true;
524 
525 #ifdef ENOTCONN
526 	fail = false;
527 #endif
528 
529 	if (fail != false)
530 		atf_tc_fail_nonfatal("ENOTCONN not defined");
531 
532 	fail = true;
533 
534 #ifdef ENOTDIR
535 	fail = false;
536 #endif
537 
538 	if (fail != false)
539 		atf_tc_fail_nonfatal("ENOTDIR not defined");
540 
541 	fail = true;
542 
543 #ifdef ENOTEMPTY
544 	fail = false;
545 #endif
546 
547 	if (fail != false)
548 		atf_tc_fail_nonfatal("ENOTEMPTY not defined");
549 
550 	fail = true;
551 
552 #ifdef ENOTRECOVERABLE
553 	fail = false;
554 #endif
555 
556 	if (fail != false)
557 		atf_tc_fail_nonfatal("ENOTRECOVERABLE not defined");
558 
559 	fail = true;
560 
561 #ifdef ENOTSOCK
562 	fail = false;
563 #endif
564 
565 	if (fail != false)
566 		atf_tc_fail_nonfatal("ENOTSOCK not defined");
567 
568 	fail = true;
569 
570 #ifdef ENOTSUP
571 	fail = false;
572 #endif
573 
574 	if (fail != false)
575 		atf_tc_fail_nonfatal("ENOTSUP not defined");
576 
577 	fail = true;
578 
579 #ifdef ENOTTY
580 	fail = false;
581 #endif
582 
583 	if (fail != false)
584 		atf_tc_fail_nonfatal("ENOTTY not defined");
585 
586 	fail = true;
587 
588 #ifdef ENXIO
589 	fail = false;
590 #endif
591 
592 	if (fail != false)
593 		atf_tc_fail_nonfatal("ENXIO not defined");
594 
595 	fail = true;
596 
597 #ifdef EOPNOTSUPP
598 	fail = false;
599 #endif
600 
601 	if (fail != false)
602 		atf_tc_fail_nonfatal("EOPNOTSUPP not defined");
603 
604 	fail = true;
605 
606 #ifdef EOVERFLOW
607 	fail = false;
608 #endif
609 
610 	if (fail != false)
611 		atf_tc_fail_nonfatal("EOVERFLOW not defined");
612 
613 	fail = true;
614 
615 #ifdef EOWNERDEAD
616 	fail = false;
617 #endif
618 
619 	if (fail != false)
620 		atf_tc_fail_nonfatal("EOWNERDEAD not defined");
621 
622 	fail = true;
623 
624 #ifdef EPERM
625 	fail = false;
626 #endif
627 
628 	if (fail != false)
629 		atf_tc_fail_nonfatal("EPERM not defined");
630 
631 	fail = true;
632 
633 #ifdef EPIPE
634 	fail = false;
635 #endif
636 
637 	if (fail != false)
638 		atf_tc_fail_nonfatal("EPIPE not defined");
639 
640 	fail = true;
641 
642 #ifdef EPROTO
643 	fail = false;
644 #endif
645 
646 	if (fail != false)
647 		atf_tc_fail_nonfatal("EPROTO not defined");
648 
649 	fail = true;
650 
651 #ifdef EPROTONOSUPPORT
652 	fail = false;
653 #endif
654 
655 	if (fail != false)
656 		atf_tc_fail_nonfatal("EPROTONOSUPPORT not defined");
657 
658 	fail = true;
659 
660 #ifdef EPROTOTYPE
661 	fail = false;
662 #endif
663 
664 	if (fail != false)
665 		atf_tc_fail_nonfatal("EPROTOTYPE not defined");
666 
667 	fail = true;
668 
669 #ifdef ERANGE
670 	fail = false;
671 #endif
672 
673 	if (fail != false)
674 		atf_tc_fail_nonfatal("ERANGE not defined");
675 
676 	fail = true;
677 
678 #ifdef EROFS
679 	fail = false;
680 #endif
681 
682 	if (fail != false)
683 		atf_tc_fail_nonfatal("EROFS not defined");
684 
685 	fail = true;
686 
687 #ifdef ESPIPE
688 	fail = false;
689 #endif
690 
691 	if (fail != false)
692 		atf_tc_fail_nonfatal("ESPIPE not defined");
693 
694 	fail = true;
695 
696 #ifdef ESRCH
697 	fail = false;
698 #endif
699 
700 	if (fail != false)
701 		atf_tc_fail_nonfatal("ESRCH not defined");
702 
703 	fail = true;
704 
705 #ifdef ESTALE
706 	fail = false;
707 #endif
708 
709 	if (fail != false)
710 		atf_tc_fail_nonfatal("ESTALE not defined");
711 
712 	fail = true;
713 
714 #ifdef ETIME
715 	fail = false;
716 #endif
717 
718 	if (fail != false)
719 		atf_tc_fail_nonfatal("ETIME not defined");
720 
721 	fail = true;
722 
723 #ifdef ETIMEDOUT
724 	fail = false;
725 #endif
726 
727 	if (fail != false)
728 		atf_tc_fail_nonfatal("ETIMEDOUT not defined");
729 
730 	fail = true;
731 
732 #ifdef ETXTBSY
733 	fail = false;
734 #endif
735 
736 	if (fail != false)
737 		atf_tc_fail_nonfatal("ETXTBSY not defined");
738 
739 	fail = true;
740 
741 #ifdef EWOULDBLOCK
742 	fail = false;
743 #endif
744 
745 	if (fail != false)
746 		atf_tc_fail_nonfatal("EWOULDBLOCK not defined");
747 
748 	fail = true;
749 
750 #ifdef EXDEV
751 	fail = false;
752 #endif
753 
754 	if (fail != false)
755 		atf_tc_fail_nonfatal("EXDEV not defined");
756 }
757 
ATF_TP_ADD_TCS(tp)758 ATF_TP_ADD_TCS(tp)
759 {
760 
761 	ATF_TP_ADD_TC(tp, errno_constants);
762 
763 	return atf_no_error();
764 }
765