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 imsgbuf;
257 struct imsg imsg;
259 imsg_init(&imsgbuf, 3);
260 imsg_clear(&imsgbuf);
261 imsg_get_fd(&imsg);
262 return 0;
264 #endif /* TEST_LIB_IMSG */
265 #if TEST_INFTIM
266 /*
267 * Linux doesn't (always?) have this.
268 */
270 #include <poll.h>
271 #include <stdio.h>
273 int
274 main(void)
276 printf("INFTIM is defined to be %ld\n", (long)INFTIM);
277 return 0;
279 #endif /* TEST_INFTIM */
280 #if TEST_LANDLOCK
281 #include <linux/landlock.h>
282 #include <stdlib.h>
283 #include <sys/prctl.h>
284 #include <sys/syscall.h>
285 #include <unistd.h>
286 #include <stdint.h>
288 #ifndef landlock_create_ruleset
289 static inline int landlock_create_ruleset(const struct landlock_ruleset_attr *const attr,
290 const size_t size, const __u32 flags)
292 return syscall(__NR_landlock_create_ruleset, attr, size, flags);
294 #endif
296 #ifndef landlock_restrict_self
297 static inline int landlock_restrict_self(const int ruleset_fd,
298 const __u32 flags)
300 return syscall(__NR_landlock_restrict_self, ruleset_fd, flags);
302 #endif
304 int
305 main(void)
307 uint64_t mask = LANDLOCK_ACCESS_FS_READ_FILE | LANDLOCK_ACCESS_FS_WRITE_FILE;
308 struct landlock_ruleset_attr rules = {
309 .handled_access_fs = mask
310 };
311 int fd = landlock_create_ruleset(&rules, sizeof(rules), 0);
313 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0))
314 return 1;
315 return landlock_restrict_self(fd, 0) ? 1 : 0;
317 #endif /* TEST_LANDLOCK */
318 #if TEST_LIB_SOCKET
319 #include <sys/socket.h>
321 int
322 main(void)
324 int fds[2], c;
326 c = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
327 return c == -1;
329 #endif /* TEST_LIB_SOCKET */
330 #if TEST_MD5
331 #include <sys/types.h>
332 #include <md5.h>
334 int main(void)
336 MD5_CTX ctx;
337 char result[MD5_DIGEST_STRING_LENGTH];
339 MD5Init(&ctx);
340 MD5Update(&ctx, (const unsigned char *)"abcd", 4);
341 MD5End(&ctx, result);
343 return 0;
345 #endif /* TEST_MD5 */
346 #if TEST_MEMMEM
347 #define _GNU_SOURCE
348 #include <string.h>
350 int
351 main(void)
353 char *a = memmem("hello, world", strlen("hello, world"), "world", strlen("world"));
354 return(NULL == a);
356 #endif /* TEST_MEMMEM */
357 #if TEST_MEMRCHR
358 #if defined(__linux__) || defined(__MINT__)
359 #define _GNU_SOURCE /* See test-*.c what needs this. */
360 #endif
361 #include <string.h>
363 int
364 main(void)
366 const char *buf = "abcdef";
367 void *res;
369 res = memrchr(buf, 'a', strlen(buf));
370 return(NULL == res ? 1 : 0);
372 #endif /* TEST_MEMRCHR */
373 #if TEST_MEMSET_S
374 #include <string.h>
376 int main(void)
378 char buf[10];
379 memset_s(buf, 0, 'c', sizeof(buf));
380 return 0;
382 #endif /* TEST_MEMSET_S */
383 #if TEST_MKFIFOAT
384 #include <sys/stat.h>
385 #include <fcntl.h>
387 int main(void) {
388 mkfifoat(AT_FDCWD, "this/path/should/not/exist", 0600);
389 return 0;
391 #endif /* TEST_MKFIFOAT */
392 #if TEST_MKNODAT
393 #include <sys/stat.h>
394 #include <fcntl.h>
396 int main(void) {
397 mknodat(AT_FDCWD, "this/path/should/not/exist", S_IFIFO | 0600, 0);
398 return 0;
400 #endif /* TEST_MKNODAT */
401 #if TEST_OPTRESET
402 #include <unistd.h>
404 int
405 main(int argc, char **argv)
407 optreset = 1;
408 getopt(argc, argv, "");
409 return 0;
411 #endif /* TEST_OPTRESET */
412 #if TEST_OSBYTEORDER_H
413 #include <libkern/OSByteOrder.h>
415 int
416 main(void)
418 return !OSSwapHostToLittleInt32(23);
420 #endif /* TEST_OSBYTEORDER_H */
421 #if TEST_PATH_MAX
422 /*
423 * POSIX allows PATH_MAX to not be defined, see
424 * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html;
425 * the GNU Hurd is an example of a system not having it.
427 * Arguably, it would be better to test sysconf(_SC_PATH_MAX),
428 * but since the individual *.c files include "config.h" before
429 * <limits.h>, overriding an excessive value of PATH_MAX from
430 * "config.h" is impossible anyway, so for now, the simplest
431 * fix is to provide a value only on systems not having any.
432 * So far, we encountered no system defining PATH_MAX to an
433 * impractically large value, even though POSIX explicitly
434 * allows that.
436 * The real fix would be to replace all static buffers of size
437 * PATH_MAX by dynamically allocated buffers. But that is
438 * somewhat intrusive because it touches several files and
439 * because it requires changing struct mlink in mandocdb.c.
440 * So i'm postponing that for now.
441 */
443 #include <limits.h>
444 #include <stdio.h>
446 int
447 main(void)
449 printf("PATH_MAX is defined to be %ld\n", (long)PATH_MAX);
450 return 0;
452 #endif /* TEST_PATH_MAX */
453 #if TEST_PLEDGE
454 #include <unistd.h>
456 int
457 main(void)
459 return !!pledge("stdio", NULL);
461 #endif /* TEST_PLEDGE */
462 #if TEST_PROGRAM_INVOCATION_SHORT_NAME
463 #define _GNU_SOURCE /* See feature_test_macros(7) */
464 #include <errno.h>
466 int
467 main(void)
470 return !program_invocation_short_name;
472 #endif /* TEST_PROGRAM_INVOCATION_SHORT_NAME */
473 #if TEST_PR_SET_NAME
474 #include <sys/prctl.h>
476 int
477 main(void)
479 prctl(PR_SET_NAME, "foo");
480 return 0;
482 #endif /* TEST_PR_SET_NAME */
483 #if TEST_READPASSPHRASE
484 #include <stddef.h>
485 #include <readpassphrase.h>
487 int
488 main(void)
490 return !!readpassphrase("prompt: ", NULL, 0, 0);
492 #endif /* TEST_READPASSPHRASE */
493 #if TEST_REALLOCARRAY
494 #ifdef __NetBSD__
495 # define _OPENBSD_SOURCE
496 #endif
497 #include <stdlib.h>
499 int
500 main(void)
502 return !reallocarray(NULL, 2, 2);
504 #endif /* TEST_REALLOCARRAY */
505 #if TEST_RECALLOCARRAY
506 #include <stdlib.h>
508 int
509 main(void)
511 return !recallocarray(NULL, 0, 2, 2);
513 #endif /* TEST_RECALLOCARRAY */
514 #if TEST_SANDBOX_INIT
515 #include <sandbox.h>
517 int
518 main(void)
520 char *ep;
521 int rc;
523 rc = sandbox_init(kSBXProfileNoInternet, SANDBOX_NAMED, &ep);
524 if (-1 == rc)
525 sandbox_free_error(ep);
526 return(-1 == rc);
528 #endif /* TEST_SANDBOX_INIT */
529 #if TEST_SETPROCTITLE
530 #include <stdlib.h>
532 int
533 main(void)
535 setproctitle("#%d test program", 7);
536 return 0;
538 #endif
539 #if TEST_SIO_FLUSH
540 #include <sndio.h>
542 int
543 main(void)
545 struct sio_hdl *hdl;
546 hdl = sio_open(SIO_DEVANY, SIO_PLAY, 1);
547 sio_flush(hdl);
548 sio_close(hdl);
549 return 0;
551 #endif /* TEST_SIO_FLUSH */
552 #if TEST_SCAN_SCALED
553 #include <util.h>
555 int
556 main(void)
558 char *cinput = (char *)"1.5K", buf[FMT_SCALED_STRSIZE];
559 long long ninput = 10483892, result;
560 return scan_scaled(cinput, &result) == 0;
562 #endif /* TEST_SCAN_SCALED */
563 #if TEST_SECCOMP_FILTER
564 #include <sys/prctl.h>
565 #include <linux/seccomp.h>
566 #include <errno.h>
568 int
569 main(void)
572 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, 0);
573 return(EFAULT == errno ? 0 : 1);
575 #endif /* TEST_SECCOMP_FILTER */
576 #if TEST_SETRESGID
577 #define _GNU_SOURCE /* linux */
578 #include <sys/types.h>
579 #include <unistd.h>
581 int
582 main(void)
584 return setresgid(-1, -1, -1) == -1;
586 #endif /* TEST_SETRESGID */
587 #if TEST_SETRESUID
588 #define _GNU_SOURCE /* linux */
589 #include <sys/types.h>
590 #include <unistd.h>
592 int
593 main(void)
595 return setresuid(-1, -1, -1) == -1;
597 #endif /* TEST_SETRESUID */
598 #if TEST_SHA2
599 #include <sys/types.h>
600 #include <sha2.h>
602 int main(void)
604 SHA2_CTX ctx;
605 char result[SHA256_DIGEST_STRING_LENGTH];
607 SHA256Init(&ctx);
608 SHA256Update(&ctx, (const unsigned char *)"abcd", 4);
609 SHA256End(&ctx, result);
611 return 0;
613 #endif /* TEST_SHA2 */
614 #if TEST_SOCK_NONBLOCK
615 /*
616 * Linux doesn't (always?) have this.
617 */
619 #include <sys/socket.h>
621 int
622 main(void)
624 int fd[2];
625 socketpair(AF_UNIX, SOCK_STREAM|SOCK_NONBLOCK, 0, fd);
626 return 0;
628 #endif /* TEST_SOCK_NONBLOCK */
629 #if TEST_STATIC
630 int
631 main(void)
633 return 0; /* not meant to do anything */
635 #endif /* TEST_STATIC */
636 #if TEST_STRLCAT
637 #include <string.h>
639 int
640 main(void)
642 char buf[3] = "a";
643 return ! (strlcat(buf, "b", sizeof(buf)) == 2 &&
644 buf[0] == 'a' && buf[1] == 'b' && buf[2] == '\0');
646 #endif /* TEST_STRLCAT */
647 #if TEST_STRLCPY
648 #include <string.h>
650 int
651 main(void)
653 char buf[2] = "";
654 return ! (strlcpy(buf, "a", sizeof(buf)) == 1 &&
655 buf[0] == 'a' && buf[1] == '\0');
657 #endif /* TEST_STRLCPY */
658 #if TEST_STRNDUP
659 #include <string.h>
661 int
662 main(void)
664 const char *foo = "bar";
665 char *baz;
667 baz = strndup(foo, 1);
668 return(0 != strcmp(baz, "b"));
670 #endif /* TEST_STRNDUP */
671 #if TEST_STRNLEN
672 #include <string.h>
674 int
675 main(void)
677 const char *foo = "bar";
678 size_t sz;
680 sz = strnlen(foo, 1);
681 return(1 != sz);
683 #endif /* TEST_STRNLEN */
684 #if TEST_STRTONUM
685 /*
686 * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
688 * Permission to use, copy, modify, and distribute this software for any
689 * purpose with or without fee is hereby granted, provided that the above
690 * copyright notice and this permission notice appear in all copies.
692 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
693 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
694 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
695 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
696 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
697 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
698 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
699 */
700 #ifdef __NetBSD__
701 # define _OPENBSD_SOURCE
702 #endif
703 #include <stdlib.h>
705 int
706 main(void)
708 const char *errstr;
710 if (strtonum("1", 0, 2, &errstr) != 1)
711 return 1;
712 if (errstr != NULL)
713 return 2;
714 if (strtonum("1x", 0, 2, &errstr) != 0)
715 return 3;
716 if (errstr == NULL)
717 return 4;
718 if (strtonum("2", 0, 1, &errstr) != 0)
719 return 5;
720 if (errstr == NULL)
721 return 6;
722 if (strtonum("0", 1, 2, &errstr) != 0)
723 return 7;
724 if (errstr == NULL)
725 return 8;
726 return 0;
728 #endif /* TEST_STRTONUM */
729 #if TEST_SYS_BYTEORDER_H
730 #include <sys/byteorder.h>
732 int
733 main(void)
735 return !LE_32(23);
737 #endif /* TEST_SYS_BYTEORDER_H */
738 #if TEST_SYS_ENDIAN_H
739 #include <sys/endian.h>
741 int
742 main(void)
744 return !htole32(23);
746 #endif /* TEST_SYS_ENDIAN_H */
747 #if TEST_SYS_MKDEV_H
748 #include <sys/types.h>
749 #include <sys/mkdev.h>
751 int
752 main(void)
754 return !minor(0);
756 #endif /* TEST_SYS_MKDEV_H */
757 #if TEST_SYS_FILE
758 #include <sys/file.h>
760 int
761 main(void)
763 flock(0, LOCK_SH|LOCK_NB);
764 return 0;
766 #endif /* TEST_SYS_FILE */
767 #if TEST_SYS_QUEUE
768 #include <sys/queue.h>
769 #include <stddef.h>
771 struct foo {
772 int bar;
773 TAILQ_ENTRY(foo) entries;
774 };
776 TAILQ_HEAD(fooq, foo);
778 int
779 main(void)
781 struct fooq foo_q, bar_q;
782 struct foo *p, *tmp;
783 int i = 0;
785 TAILQ_INIT(&foo_q);
786 TAILQ_INIT(&bar_q);
788 /*
789 * Use TAILQ_FOREACH_SAFE because some systems (e.g., Linux)
790 * have TAILQ_FOREACH but not the safe variant.
791 */
793 TAILQ_FOREACH_SAFE(p, &foo_q, entries, tmp)
794 p->bar = i++;
796 /* Test for newer macros as well. */
798 TAILQ_CONCAT(&foo_q, &bar_q, entries);
799 return 0;
801 #endif /* TEST_SYS_QUEUE */
802 #if TEST_SYS_SYSMACROS_H
803 #include <sys/sysmacros.h>
805 int
806 main(void)
808 return !minor(0);
810 #endif /* TEST_SYS_SYSMACROS_H */
811 #if TEST_SYS_TREE
812 #include <sys/tree.h>
813 #include <stdlib.h>
815 struct node {
816 RB_ENTRY(node) entry;
817 int i;
818 };
820 static int
821 intcmp(struct node *e1, struct node *e2)
823 return (e1->i < e2->i ? -1 : e1->i > e2->i);
826 RB_HEAD(inttree, node) head = RB_INITIALIZER(&head);
827 RB_PROTOTYPE(inttree, node, entry, intcmp)
828 RB_GENERATE(inttree, node, entry, intcmp)
830 int testdata[] = {
831 20, 16, 17, 13, 3, 6, 1, 8, 2, 4
832 };
834 int
835 main(void)
837 size_t i;
838 struct node *n;
840 for (i = 0; i < sizeof(testdata) / sizeof(testdata[0]); i++) {
841 if ((n = malloc(sizeof(struct node))) == NULL)
842 return 1;
843 n->i = testdata[i];
844 RB_INSERT(inttree, &head, n);
847 return 0;
850 #endif /* TEST_SYS_TREE */
851 #if TEST_TIMESPECSUB
852 #include <sys/time.h>
854 int
855 main(void)
857 struct timespec a = {0, 0}, b = {0, 0}, c;
859 timespecsub(&a, &b, &c);
860 return c.tv_sec;
862 #endif /* TEST_TIMESPECSUB */
863 #if TEST_UNVEIL
864 #include <unistd.h>
866 int
867 main(void)
869 return -1 != unveil(NULL, NULL);
871 #endif /* TEST_UNVEIL */
872 #if TEST_WAIT_ANY
873 #include <sys/wait.h>
875 int
876 main(void)
878 int st;
880 return waitpid(WAIT_ANY, &st, WNOHANG) != -1;
882 #endif /* TEST_WAIT_ANY */
883 #if TEST_LIB_FLAC
884 #include <FLAC/stream_decoder.h>
886 int
887 main(void)
889 FLAC__StreamDecoder *decoder = NULL;
890 FLAC__StreamDecoderInitStatus init_status;
892 decoder = FLAC__stream_decoder_new();
893 FLAC__stream_decoder_delete(decoder);
894 return 0;
896 #endif /* TEST_LIB_FLAC */
897 #if TEST_LIB_MPG123
898 #include <mpg123.h>
900 int
901 main(void)
903 mpg123_handle *mh;
905 mh = mpg123_new(NULL, NULL);
906 mpg123_delete(mh);
907 return 0;
909 #endif/* TEST_LIB_MPG123 */
910 #if TEST_LIB_PTHREAD
911 #include <stdlib.h>
912 #include <pthread.h>
914 int
915 main(void)
917 pthread_mutex_t mutex;
919 return (pthread_mutex_init(&mutex, NULL));
921 #endif/* TEST_LIB_PTHREAD */
922 #if TEST_LIB_OPUSFILE
923 #include <stdio.h>
924 #include <opusfile.h>
926 int
927 main(void)
929 FILE *f;
930 OggOpusFile *of;
931 OpusFileCallbacks cb = {NULL, NULL, NULL, NULL};
932 int r;
934 f = op_fdopen(&cb, 0, "r");
935 of = op_open_callbacks(f, &cb, NULL, 0, &r);
936 op_free(of);
937 return 0;
939 #endif /* TEST_LIB_OPUSFILE */
940 #if TEST_LIB_VORBISFILE
941 #include <stdio.h>
942 #include <vorbis/vorbisfile.h>
944 int
945 main(void)
947 OggVorbis_File vf;
949 ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE);
950 ov_clear(&vf);
951 return 0;
953 #endif /* TEST_LIB_VORBISFILE */
954 #if TEST_LIB_AO
955 #include <stdio.h>
956 #include <string.h>
957 #include <ao/ao.h>
959 int
960 main(void)
962 ao_initialize();
963 return (0);
965 #endif /* TEST_LIB_AO */
966 #if TEST_LIB_ASOUND
967 #include <alsa/asoundlib.h>
969 int
970 main(void)
972 snd_pcm_t *pcm;
973 int err;
975 err = snd_pcm_open(&pcm, "default", SND_PCM_STREAM_PLAYBACK,
976 SND_PCM_NONBLOCK);
977 return err;
979 #endif /* TEST_LIB_ASOUND */
980 #if TEST_LIB_SNDIO
981 #include <sndio.h>
983 int
984 main(void)
986 struct sio_hdl *hdl;
987 hdl = sio_open(SIO_DEVANY, SIO_PLAY, 1);
988 sio_close(hdl);
989 return 0;
991 #endif /* TEST_LIB_SNDIO */
992 #if TEST_LIB_MD
993 #include <sys/types.h>
994 #include <sha1.h>
996 int
997 main(void)
999 SHA1_CTX ctx;
1000 char result[SHA1_DIGEST_STRING_LENGTH];
1002 SHA1Init(&ctx);
1003 SHA1Update(&ctx, (const unsigned char *)"abcd", 4);
1004 SHA1End(&ctx, result);
1006 return 0;
1008 #endif /* TEST_LIB_MD */