Blob


1 #if TEST__MMD
2 int
3 main(void)
4 {
5 return 0;
6 }
7 #endif /* TEST_NOOP */
8 #if TEST___PROGNAME
9 int
10 main(void)
11 {
12 extern char *__progname;
14 return !__progname;
15 }
16 #endif /* TEST___PROGNAME */
17 #if TEST_ARC4RANDOM
18 #include <stdlib.h>
20 int
21 main(void)
22 {
23 return (arc4random() + 1) ? 0 : 1;
24 }
25 #endif /* TEST_ARC4RANDOM */
26 #if TEST_B64_NTOP
27 #include <netinet/in.h>
28 #include <resolv.h>
30 int
31 main(void)
32 {
33 const char *src = "hello world";
34 char output[1024];
36 return b64_ntop((const unsigned char *)src, 11, output, sizeof(output)) > 0 ? 0 : 1;
37 }
38 #endif /* TEST_B64_NTOP */
39 #if TEST_CAPSICUM
40 #include <sys/capsicum.h>
42 int
43 main(void)
44 {
45 cap_enter();
46 return(0);
47 }
48 #endif /* TEST_CAPSICUM */
49 #if TEST_CRYPT
50 #if defined(__linux__)
51 # define _GNU_SOURCE /* old glibc */
52 # define _DEFAULT_SOURCE /* new glibc */
53 #endif
54 #if defined(__sun)
55 # ifndef _XOPEN_SOURCE /* SunOS already defines */
56 # define _XOPEN_SOURCE /* XPGx */
57 # endif
58 # define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
59 # ifndef __EXTENSIONS__ /* SunOS already defines */
60 # define __EXTENSIONS__ /* reallocarray, etc. */
61 # endif
62 #endif
63 #include <unistd.h>
65 int main(void)
66 {
67 char *v;
69 v = crypt("this_is_a_key", "123455");
70 return v == NULL;
71 }
72 #endif /* TEST_CRYPT */
73 #if TEST_CRYPT_NEWHASH
74 #include <pwd.h> /* _PASSWORD_LEN */
75 #include <unistd.h>
77 int
78 main(void)
79 {
80 const char *v = "password";
81 char hash[_PASSWORD_LEN];
83 if (crypt_newhash(v, "bcrypt,a", hash, sizeof(hash)) == -1)
84 return 1;
85 if (crypt_checkpass(v, hash) == -1)
86 return 1;
88 return 0;
89 }
90 #endif /* TEST_CRYPT_NEWHASH */
91 #if TEST_ENDIAN_H
92 #ifdef __linux__
93 # define _DEFAULT_SOURCE
94 #endif
95 #include <endian.h>
97 int
98 main(void)
99 {
100 return !htole32(23);
102 #endif /* TEST_ENDIAN_H */
103 #if TEST_ERR
104 /*
105 * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
107 * Permission to use, copy, modify, and distribute this software for any
108 * purpose with or without fee is hereby granted, provided that the above
109 * copyright notice and this permission notice appear in all copies.
111 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
112 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
113 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
114 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
115 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
116 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
117 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
118 */
120 #include <err.h>
121 #include <errno.h>
123 int
124 main(void)
126 warnx("%d. warnx", 1);
127 warnc(ENOENT, "%d. warn", ENOENT);
128 warn("%d. warn", 2);
129 err(0, "%d. err", 3);
130 errx(0, "%d. err", 3);
131 errc(0, ENOENT, "%d. err", 3);
132 /* NOTREACHED */
133 return 1;
135 #endif /* TEST_ERR */
136 #if TEST_EXPLICIT_BZERO
137 #include <string.h>
139 int
140 main(void)
142 char foo[10];
144 explicit_bzero(foo, sizeof(foo));
145 return(0);
147 #endif /* TEST_EXPLICIT_BZERO */
148 #if TEST_FLOCK
149 #include <fcntl.h>
151 int
152 main(void)
154 flock(0, LOCK_SH|LOCK_NB);
155 return 0;
157 #endif /* TEST_FLOCK */
158 #if TEST_FREEZERO
159 #include <stdlib.h>
161 int
162 main(void)
164 freezero(NULL, 0);
165 return 0;
167 #endif /* TEST_FREEZERO */
168 #if TEST_FTS
169 #include <stddef.h>
170 #include <sys/types.h>
171 #include <sys/stat.h>
172 #include <fts.h>
174 int
175 main(void)
177 const char *argv[2];
178 FTS *ftsp;
179 FTSENT *entry;
181 argv[0] = ".";
182 argv[1] = (char *)NULL;
184 ftsp = fts_open((char * const *)argv,
185 FTS_PHYSICAL | FTS_NOCHDIR, NULL);
187 if (ftsp == NULL)
188 return 1;
190 entry = fts_read(ftsp);
192 if (entry == NULL)
193 return 1;
195 if (fts_set(ftsp, entry, FTS_SKIP) != 0)
196 return 1;
198 if (fts_close(ftsp) != 0)
199 return 1;
201 return 0;
203 #endif /* TEST_FTS */
204 #if TEST_GETDTABLECOUNT
205 #include <unistd.h>
207 int
208 main(void)
210 return getdtablecount();
212 #endif /* TEST_GETDTABLECOUNT */
213 #if TEST_GETDTABLESIZE
214 #include <unistd.h>
216 int
217 main(void)
219 return getdtablesize();
221 #endif /* TEST_GETDTABLESIZE */
222 #if TEST_GETEXECNAME
223 #include <stdlib.h>
225 int
226 main(void)
228 const char * progname;
230 progname = getexecname();
231 return progname == NULL;
233 #endif /* TEST_GETEXECNAME */
234 #if TEST_GETPROGNAME
235 #include <stdlib.h>
237 int
238 main(void)
240 const char * progname;
242 progname = getprogname();
243 return progname == NULL;
245 #endif /* TEST_GETPROGNAME */
246 #if TEST_LIB_IMSG
247 #include <sys/types.h>
248 #include <sys/queue.h>
249 #include <sys/uio.h>
250 #include <stdint.h>
251 #include <imsg.h>
253 int
254 main(void)
256 struct imsgbuf ibuf;
258 imsg_init(&ibuf, 3);
259 imsg_clear(&ibuf);
260 return 0;
262 #endif /* TEST_LIB_IMSG */
263 #if TEST_INFTIM
264 /*
265 * Linux doesn't (always?) have this.
266 */
268 #include <poll.h>
269 #include <stdio.h>
271 int
272 main(void)
274 printf("INFTIM is defined to be %ld\n", (long)INFTIM);
275 return 0;
277 #endif /* TEST_INFTIM */
278 #if TEST_LANDLOCK
279 #include <linux/landlock.h>
280 #include <stdlib.h>
281 #include <sys/prctl.h>
282 #include <sys/syscall.h>
283 #include <unistd.h>
284 #include <stdint.h>
286 #ifndef landlock_create_ruleset
287 static inline int landlock_create_ruleset(const struct landlock_ruleset_attr *const attr,
288 const size_t size, const __u32 flags)
290 return syscall(__NR_landlock_create_ruleset, attr, size, flags);
292 #endif
294 #ifndef landlock_restrict_self
295 static inline int landlock_restrict_self(const int ruleset_fd,
296 const __u32 flags)
298 return syscall(__NR_landlock_restrict_self, ruleset_fd, flags);
300 #endif
302 int
303 main(void)
305 uint64_t mask = LANDLOCK_ACCESS_FS_READ_FILE | LANDLOCK_ACCESS_FS_WRITE_FILE;
306 struct landlock_ruleset_attr rules = {
307 .handled_access_fs = mask
308 };
309 int fd = landlock_create_ruleset(&rules, sizeof(rules), 0);
311 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0))
312 return 1;
313 return landlock_restrict_self(fd, 0) ? 1 : 0;
315 #endif /* TEST_LANDLOCK */
316 #if TEST_LIB_SOCKET
317 #include <sys/socket.h>
319 int
320 main(void)
322 int fds[2], c;
324 c = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
325 return c == -1;
327 #endif /* TEST_LIB_SOCKET */
328 #if TEST_MD5
329 #include <sys/types.h>
330 #include <md5.h>
332 int main(void)
334 MD5_CTX ctx;
335 char result[MD5_DIGEST_STRING_LENGTH];
337 MD5Init(&ctx);
338 MD5Update(&ctx, (const unsigned char *)"abcd", 4);
339 MD5End(&ctx, result);
341 return 0;
343 #endif /* TEST_MD5 */
344 #if TEST_MEMMEM
345 #define _GNU_SOURCE
346 #include <string.h>
348 int
349 main(void)
351 char *a = memmem("hello, world", strlen("hello, world"), "world", strlen("world"));
352 return(NULL == a);
354 #endif /* TEST_MEMMEM */
355 #if TEST_MEMRCHR
356 #if defined(__linux__) || defined(__MINT__)
357 #define _GNU_SOURCE /* See test-*.c what needs this. */
358 #endif
359 #include <string.h>
361 int
362 main(void)
364 const char *buf = "abcdef";
365 void *res;
367 res = memrchr(buf, 'a', strlen(buf));
368 return(NULL == res ? 1 : 0);
370 #endif /* TEST_MEMRCHR */
371 #if TEST_MEMSET_S
372 #include <string.h>
374 int main(void)
376 char buf[10];
377 memset_s(buf, 0, 'c', sizeof(buf));
378 return 0;
380 #endif /* TEST_MEMSET_S */
381 #if TEST_MKFIFOAT
382 #include <sys/stat.h>
383 #include <fcntl.h>
385 int main(void) {
386 mkfifoat(AT_FDCWD, "this/path/should/not/exist", 0600);
387 return 0;
389 #endif /* TEST_MKFIFOAT */
390 #if TEST_MKNODAT
391 #include <sys/stat.h>
392 #include <fcntl.h>
394 int main(void) {
395 mknodat(AT_FDCWD, "this/path/should/not/exist", S_IFIFO | 0600, 0);
396 return 0;
398 #endif /* TEST_MKNODAT */
399 #if TEST_OPTRESET
400 #include <unistd.h>
402 int
403 main(int argc, char **argv)
405 optreset = 1;
406 getopt(argc, argv, "");
407 return 0;
409 #endif /* TEST_OPTRESET */
410 #if TEST_OSBYTEORDER_H
411 #include <libkern/OSByteOrder.h>
413 int
414 main(void)
416 return !OSSwapHostToLittleInt32(23);
418 #endif /* TEST_OSBYTEORDER_H */
419 #if TEST_PATH_MAX
420 /*
421 * POSIX allows PATH_MAX to not be defined, see
422 * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html;
423 * the GNU Hurd is an example of a system not having it.
425 * Arguably, it would be better to test sysconf(_SC_PATH_MAX),
426 * but since the individual *.c files include "config.h" before
427 * <limits.h>, overriding an excessive value of PATH_MAX from
428 * "config.h" is impossible anyway, so for now, the simplest
429 * fix is to provide a value only on systems not having any.
430 * So far, we encountered no system defining PATH_MAX to an
431 * impractically large value, even though POSIX explicitly
432 * allows that.
434 * The real fix would be to replace all static buffers of size
435 * PATH_MAX by dynamically allocated buffers. But that is
436 * somewhat intrusive because it touches several files and
437 * because it requires changing struct mlink in mandocdb.c.
438 * So i'm postponing that for now.
439 */
441 #include <limits.h>
442 #include <stdio.h>
444 int
445 main(void)
447 printf("PATH_MAX is defined to be %ld\n", (long)PATH_MAX);
448 return 0;
450 #endif /* TEST_PATH_MAX */
451 #if TEST_PLEDGE
452 #include <unistd.h>
454 int
455 main(void)
457 return !!pledge("stdio", NULL);
459 #endif /* TEST_PLEDGE */
460 #if TEST_PROGRAM_INVOCATION_SHORT_NAME
461 #define _GNU_SOURCE /* See feature_test_macros(7) */
462 #include <errno.h>
464 int
465 main(void)
468 return !program_invocation_short_name;
470 #endif /* TEST_PROGRAM_INVOCATION_SHORT_NAME */
471 #if TEST_PR_SET_NAME
472 #include <sys/prctl.h>
474 int
475 main(void)
477 prctl(PR_SET_NAME, "foo");
478 return 0;
480 #endif /* TEST_PR_SET_NAME */
481 #if TEST_READPASSPHRASE
482 #include <stddef.h>
483 #include <readpassphrase.h>
485 int
486 main(void)
488 return !!readpassphrase("prompt: ", NULL, 0, 0);
490 #endif /* TEST_READPASSPHRASE */
491 #if TEST_REALLOCARRAY
492 #ifdef __NetBSD__
493 # define _OPENBSD_SOURCE
494 #endif
495 #include <stdlib.h>
497 int
498 main(void)
500 return !reallocarray(NULL, 2, 2);
502 #endif /* TEST_REALLOCARRAY */
503 #if TEST_RECALLOCARRAY
504 #include <stdlib.h>
506 int
507 main(void)
509 return !recallocarray(NULL, 0, 2, 2);
511 #endif /* TEST_RECALLOCARRAY */
512 #if TEST_SANDBOX_INIT
513 #include <sandbox.h>
515 int
516 main(void)
518 char *ep;
519 int rc;
521 rc = sandbox_init(kSBXProfileNoInternet, SANDBOX_NAMED, &ep);
522 if (-1 == rc)
523 sandbox_free_error(ep);
524 return(-1 == rc);
526 #endif /* TEST_SANDBOX_INIT */
527 #if TEST_SETPROCTITLE
528 #include <stdlib.h>
530 int
531 main(void)
533 setproctitle("#%d test program", 7);
534 return 0;
536 #endif
537 #if TEST_SIO_FLUSH
538 #include <sndio.h>
540 int
541 main(void)
543 struct sio_hdl *hdl;
544 hdl = sio_open(SIO_DEVANY, SIO_PLAY, 1);
545 sio_flush(hdl);
546 sio_close(hdl);
547 return 0;
549 #endif /* TEST_SIO_FLUSH */
550 #if TEST_SCAN_SCALED
551 #include <util.h>
553 int
554 main(void)
556 char *cinput = (char *)"1.5K", buf[FMT_SCALED_STRSIZE];
557 long long ninput = 10483892, result;
558 return scan_scaled(cinput, &result) == 0;
560 #endif /* TEST_SCAN_SCALED */
561 #if TEST_SECCOMP_FILTER
562 #include <sys/prctl.h>
563 #include <linux/seccomp.h>
564 #include <errno.h>
566 int
567 main(void)
570 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, 0);
571 return(EFAULT == errno ? 0 : 1);
573 #endif /* TEST_SECCOMP_FILTER */
574 #if TEST_SETRESGID
575 #define _GNU_SOURCE /* linux */
576 #include <sys/types.h>
577 #include <unistd.h>
579 int
580 main(void)
582 return setresgid(-1, -1, -1) == -1;
584 #endif /* TEST_SETRESGID */
585 #if TEST_SETRESUID
586 #define _GNU_SOURCE /* linux */
587 #include <sys/types.h>
588 #include <unistd.h>
590 int
591 main(void)
593 return setresuid(-1, -1, -1) == -1;
595 #endif /* TEST_SETRESUID */
596 #if TEST_SHA2
597 #include <sys/types.h>
598 #include <sha2.h>
600 int main(void)
602 SHA2_CTX ctx;
603 char result[SHA256_DIGEST_STRING_LENGTH];
605 SHA256Init(&ctx);
606 SHA256Update(&ctx, (const unsigned char *)"abcd", 4);
607 SHA256End(&ctx, result);
609 return 0;
611 #endif /* TEST_SHA2 */
612 #if TEST_SOCK_NONBLOCK
613 /*
614 * Linux doesn't (always?) have this.
615 */
617 #include <sys/socket.h>
619 int
620 main(void)
622 int fd[2];
623 socketpair(AF_UNIX, SOCK_STREAM|SOCK_NONBLOCK, 0, fd);
624 return 0;
626 #endif /* TEST_SOCK_NONBLOCK */
627 #if TEST_STATIC
628 int
629 main(void)
631 return 0; /* not meant to do anything */
633 #endif /* TEST_STATIC */
634 #if TEST_STRLCAT
635 #include <string.h>
637 int
638 main(void)
640 char buf[3] = "a";
641 return ! (strlcat(buf, "b", sizeof(buf)) == 2 &&
642 buf[0] == 'a' && buf[1] == 'b' && buf[2] == '\0');
644 #endif /* TEST_STRLCAT */
645 #if TEST_STRLCPY
646 #include <string.h>
648 int
649 main(void)
651 char buf[2] = "";
652 return ! (strlcpy(buf, "a", sizeof(buf)) == 1 &&
653 buf[0] == 'a' && buf[1] == '\0');
655 #endif /* TEST_STRLCPY */
656 #if TEST_STRNDUP
657 #include <string.h>
659 int
660 main(void)
662 const char *foo = "bar";
663 char *baz;
665 baz = strndup(foo, 1);
666 return(0 != strcmp(baz, "b"));
668 #endif /* TEST_STRNDUP */
669 #if TEST_STRNLEN
670 #include <string.h>
672 int
673 main(void)
675 const char *foo = "bar";
676 size_t sz;
678 sz = strnlen(foo, 1);
679 return(1 != sz);
681 #endif /* TEST_STRNLEN */
682 #if TEST_STRTONUM
683 /*
684 * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
686 * Permission to use, copy, modify, and distribute this software for any
687 * purpose with or without fee is hereby granted, provided that the above
688 * copyright notice and this permission notice appear in all copies.
690 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
691 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
692 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
693 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
694 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
695 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
696 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
697 */
698 #ifdef __NetBSD__
699 # define _OPENBSD_SOURCE
700 #endif
701 #include <stdlib.h>
703 int
704 main(void)
706 const char *errstr;
708 if (strtonum("1", 0, 2, &errstr) != 1)
709 return 1;
710 if (errstr != NULL)
711 return 2;
712 if (strtonum("1x", 0, 2, &errstr) != 0)
713 return 3;
714 if (errstr == NULL)
715 return 4;
716 if (strtonum("2", 0, 1, &errstr) != 0)
717 return 5;
718 if (errstr == NULL)
719 return 6;
720 if (strtonum("0", 1, 2, &errstr) != 0)
721 return 7;
722 if (errstr == NULL)
723 return 8;
724 return 0;
726 #endif /* TEST_STRTONUM */
727 #if TEST_SYS_BYTEORDER_H
728 #include <sys/byteorder.h>
730 int
731 main(void)
733 return !LE_32(23);
735 #endif /* TEST_SYS_BYTEORDER_H */
736 #if TEST_SYS_ENDIAN_H
737 #include <sys/endian.h>
739 int
740 main(void)
742 return !htole32(23);
744 #endif /* TEST_SYS_ENDIAN_H */
745 #if TEST_SYS_MKDEV_H
746 #include <sys/types.h>
747 #include <sys/mkdev.h>
749 int
750 main(void)
752 return !minor(0);
754 #endif /* TEST_SYS_MKDEV_H */
755 #if TEST_SYS_FILE
756 #include <sys/file.h>
758 int
759 main(void)
761 flock(0, LOCK_SH|LOCK_NB);
762 return 0;
764 #endif /* TEST_SYS_FILE */
765 #if TEST_SYS_QUEUE
766 #include <sys/queue.h>
767 #include <stddef.h>
769 struct foo {
770 int bar;
771 TAILQ_ENTRY(foo) entries;
772 };
774 TAILQ_HEAD(fooq, foo);
776 int
777 main(void)
779 struct fooq foo_q, bar_q;
780 struct foo *p, *tmp;
781 int i = 0;
783 TAILQ_INIT(&foo_q);
784 TAILQ_INIT(&bar_q);
786 /*
787 * Use TAILQ_FOREACH_SAFE because some systems (e.g., Linux)
788 * have TAILQ_FOREACH but not the safe variant.
789 */
791 TAILQ_FOREACH_SAFE(p, &foo_q, entries, tmp)
792 p->bar = i++;
794 /* Test for newer macros as well. */
796 TAILQ_CONCAT(&foo_q, &bar_q, entries);
797 return 0;
799 #endif /* TEST_SYS_QUEUE */
800 #if TEST_SYS_SYSMACROS_H
801 #include <sys/sysmacros.h>
803 int
804 main(void)
806 return !minor(0);
808 #endif /* TEST_SYS_SYSMACROS_H */
809 #if TEST_SYS_TREE
810 #include <sys/tree.h>
811 #include <stdlib.h>
813 struct node {
814 RB_ENTRY(node) entry;
815 int i;
816 };
818 static int
819 intcmp(struct node *e1, struct node *e2)
821 return (e1->i < e2->i ? -1 : e1->i > e2->i);
824 RB_HEAD(inttree, node) head = RB_INITIALIZER(&head);
825 RB_PROTOTYPE(inttree, node, entry, intcmp)
826 RB_GENERATE(inttree, node, entry, intcmp)
828 int testdata[] = {
829 20, 16, 17, 13, 3, 6, 1, 8, 2, 4
830 };
832 int
833 main(void)
835 size_t i;
836 struct node *n;
838 for (i = 0; i < sizeof(testdata) / sizeof(testdata[0]); i++) {
839 if ((n = malloc(sizeof(struct node))) == NULL)
840 return 1;
841 n->i = testdata[i];
842 RB_INSERT(inttree, &head, n);
845 return 0;
848 #endif /* TEST_SYS_TREE */
849 #if TEST_TIMESPECSUB
850 #include <sys/time.h>
852 int
853 main(void)
855 struct timespec a = {0, 0}, b = {0, 0}, c;
857 timespecsub(&a, &b, &c);
858 return c.tv_sec;
860 #endif /* TEST_TIMESPECSUB */
861 #if TEST_UNVEIL
862 #include <unistd.h>
864 int
865 main(void)
867 return -1 != unveil(NULL, NULL);
869 #endif /* TEST_UNVEIL */
870 #if TEST_WAIT_ANY
871 #include <sys/wait.h>
873 int
874 main(void)
876 int st;
878 return waitpid(WAIT_ANY, &st, WNOHANG) != -1;
880 #endif /* TEST_WAIT_ANY */
881 #if TEST_LIB_FLAC
882 #include <FLAC/stream_decoder.h>
884 int
885 main(void)
887 FLAC__StreamDecoder *decoder = NULL;
888 FLAC__StreamDecoderInitStatus init_status;
890 decoder = FLAC__stream_decoder_new();
891 FLAC__stream_decoder_delete(decoder);
892 return 0;
894 #endif /* TEST_LIB_FLAC */
895 #if TEST_LIB_MPG123
896 #include <mpg123.h>
898 int
899 main(void)
901 mpg123_handle *mh;
903 mh = mpg123_new(NULL, NULL);
904 mpg123_delete(mh);
905 return 0;
907 #endif/* TEST_LIB_MPG123 */
908 #if TEST_LIB_PTHREAD
909 #include <stdlib.h>
910 #include <pthread.h>
912 int
913 main(void)
915 pthread_mutex_t mutex;
917 return (pthread_mutex_init(&mutex, NULL));
919 #endif/* TEST_LIB_PTHREAD */
920 #if TEST_LIB_OPUSFILE
921 #include <stdio.h>
922 #include <opusfile.h>
924 int
925 main(void)
927 FILE *f;
928 OggOpusFile *of;
929 OpusFileCallbacks cb = {NULL, NULL, NULL, NULL};
930 int r;
932 f = op_fdopen(&cb, 0, "r");
933 of = op_open_callbacks(f, &cb, NULL, 0, &r);
934 op_free(of);
935 return 0;
937 #endif /* TEST_LIB_OPUSFILE */
938 #if TEST_LIB_VORBISFILE
939 #include <stdio.h>
940 #include <vorbis/vorbisfile.h>
942 int
943 main(void)
945 OggVorbis_File vf;
947 ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE);
948 ov_clear(&vf);
949 return 0;
951 #endif /* TEST_LIB_VORBISFILE */
952 #if TEST_LIB_AO
953 #include <stdio.h>
954 #include <string.h>
955 #include <ao/ao.h>
957 int
958 main(void)
960 ao_initialize();
961 return (0);
963 #endif /* TEST_LIB_AO */
964 #if TEST_LIB_ASOUND
965 #include <alsa/asoundlib.h>
967 int
968 main(void)
970 snd_pcm_t *pcm;
971 int err;
973 err = snd_pcm_open(&pcm, "default", SND_PCM_STREAM_PLAYBACK,
974 SND_PCM_NONBLOCK);
975 return err;
977 #endif /* TEST_LIB_ASOUND */
978 #if TEST_LIB_SNDIO
979 #include <sndio.h>
981 int
982 main(void)
984 struct sio_hdl *hdl;
985 hdl = sio_open(SIO_DEVANY, SIO_PLAY, 1);
986 sio_close(hdl);
987 return 0;
989 #endif /* TEST_LIB_SNDIO */
990 #if TEST_LIB_MD
991 #include <sys/types.h>
992 #include <sha1.h>
994 int
995 main(void)
997 SHA1_CTX ctx;
998 char result[SHA1_DIGEST_STRING_LENGTH];
1000 SHA1Init(&ctx);
1001 SHA1Update(&ctx, (const unsigned char *)"abcd", 4);
1002 SHA1End(&ctx, result);
1004 return 0;
1006 #endif /* TEST_LIB_MD */