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_GETEXECNAME
205 #include <stdlib.h>
207 int
208 main(void)
210 const char * progname;
212 progname = getexecname();
213 return progname == NULL;
215 #endif /* TEST_GETEXECNAME */
216 #if TEST_GETPROGNAME
217 #include <stdlib.h>
219 int
220 main(void)
222 const char * progname;
224 progname = getprogname();
225 return progname == NULL;
227 #endif /* TEST_GETPROGNAME */
228 #if TEST_IMSG
229 #include <sys/types.h>
230 #include <sys/queue.h>
231 #include <sys/uio.h>
232 #include <stdint.h>
233 #include <imsg.h>
235 int
236 main(void)
238 struct imsgbuf ibuf;
240 imsg_init(&ibuf, 3);
241 imsg_clear(&ibuf);
242 return 0;
244 #endif /* TEST_IMSG */
245 #if TEST_INFTIM
246 /*
247 * Linux doesn't (always?) have this.
248 */
250 #include <poll.h>
251 #include <stdio.h>
253 int
254 main(void)
256 printf("INFTIM is defined to be %ld\n", (long)INFTIM);
257 return 0;
259 #endif /* TEST_INFTIM */
260 #if TEST_LANDLOCK
261 #include <linux/landlock.h>
262 #include <stdlib.h>
263 #include <sys/prctl.h>
264 #include <sys/syscall.h>
265 #include <unistd.h>
266 #include <stdint.h>
268 #ifndef landlock_create_ruleset
269 static inline int landlock_create_ruleset(const struct landlock_ruleset_attr *const attr,
270 const size_t size, const __u32 flags)
272 return syscall(__NR_landlock_create_ruleset, attr, size, flags);
274 #endif
276 #ifndef landlock_restrict_self
277 static inline int landlock_restrict_self(const int ruleset_fd,
278 const __u32 flags)
280 return syscall(__NR_landlock_restrict_self, ruleset_fd, flags);
282 #endif
284 int
285 main(void)
287 uint64_t mask = LANDLOCK_ACCESS_FS_READ_FILE | LANDLOCK_ACCESS_FS_WRITE_FILE;
288 struct landlock_ruleset_attr rules = {
289 .handled_access_fs = mask
290 };
291 int fd = landlock_create_ruleset(&rules, sizeof(rules), 0);
293 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0))
294 return 1;
295 return landlock_restrict_self(fd, 0) ? 1 : 0;
297 #endif /* TEST_LANDLOCK */
298 #if TEST_LIB_SOCKET
299 #include <sys/socket.h>
301 int
302 main(void)
304 int fds[2], c;
306 c = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
307 return c == -1;
309 #endif /* TEST_LIB_SOCKET */
310 #if TEST_MD5
311 #include <sys/types.h>
312 #include <md5.h>
314 int main(void)
316 MD5_CTX ctx;
317 char result[MD5_DIGEST_STRING_LENGTH];
319 MD5Init(&ctx);
320 MD5Update(&ctx, (const unsigned char *)"abcd", 4);
321 MD5End(&ctx, result);
323 return 0;
325 #endif /* TEST_MD5 */
326 #if TEST_MEMMEM
327 #define _GNU_SOURCE
328 #include <string.h>
330 int
331 main(void)
333 char *a = memmem("hello, world", strlen("hello, world"), "world", strlen("world"));
334 return(NULL == a);
336 #endif /* TEST_MEMMEM */
337 #if TEST_MEMRCHR
338 #if defined(__linux__) || defined(__MINT__)
339 #define _GNU_SOURCE /* See test-*.c what needs this. */
340 #endif
341 #include <string.h>
343 int
344 main(void)
346 const char *buf = "abcdef";
347 void *res;
349 res = memrchr(buf, 'a', strlen(buf));
350 return(NULL == res ? 1 : 0);
352 #endif /* TEST_MEMRCHR */
353 #if TEST_MEMSET_S
354 #include <string.h>
356 int main(void)
358 char buf[10];
359 memset_s(buf, 0, 'c', sizeof(buf));
360 return 0;
362 #endif /* TEST_MEMSET_S */
363 #if TEST_MKFIFOAT
364 #include <sys/stat.h>
365 #include <fcntl.h>
367 int main(void) {
368 mkfifoat(AT_FDCWD, "this/path/should/not/exist", 0600);
369 return 0;
371 #endif /* TEST_MKFIFOAT */
372 #if TEST_MKNODAT
373 #include <sys/stat.h>
374 #include <fcntl.h>
376 int main(void) {
377 mknodat(AT_FDCWD, "this/path/should/not/exist", S_IFIFO | 0600, 0);
378 return 0;
380 #endif /* TEST_MKNODAT */
381 #if TEST_OPTRESET
382 #include <unistd.h>
384 int
385 main(int argc, char **argv)
387 optreset = 1;
388 getopt(argc, argv, "");
389 return 0;
391 #endif /* TEST_OPTRESET */
392 #if TEST_OSBYTEORDER_H
393 #include <libkern/OSByteOrder.h>
395 int
396 main(void)
398 return !OSSwapHostToLittleInt32(23);
400 #endif /* TEST_OSBYTEORDER_H */
401 #if TEST_PATH_MAX
402 /*
403 * POSIX allows PATH_MAX to not be defined, see
404 * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html;
405 * the GNU Hurd is an example of a system not having it.
407 * Arguably, it would be better to test sysconf(_SC_PATH_MAX),
408 * but since the individual *.c files include "config.h" before
409 * <limits.h>, overriding an excessive value of PATH_MAX from
410 * "config.h" is impossible anyway, so for now, the simplest
411 * fix is to provide a value only on systems not having any.
412 * So far, we encountered no system defining PATH_MAX to an
413 * impractically large value, even though POSIX explicitly
414 * allows that.
416 * The real fix would be to replace all static buffers of size
417 * PATH_MAX by dynamically allocated buffers. But that is
418 * somewhat intrusive because it touches several files and
419 * because it requires changing struct mlink in mandocdb.c.
420 * So i'm postponing that for now.
421 */
423 #include <limits.h>
424 #include <stdio.h>
426 int
427 main(void)
429 printf("PATH_MAX is defined to be %ld\n", (long)PATH_MAX);
430 return 0;
432 #endif /* TEST_PATH_MAX */
433 #if TEST_PLEDGE
434 #include <unistd.h>
436 int
437 main(void)
439 return !!pledge("stdio", NULL);
441 #endif /* TEST_PLEDGE */
442 #if TEST_PROGRAM_INVOCATION_SHORT_NAME
443 #define _GNU_SOURCE /* See feature_test_macros(7) */
444 #include <errno.h>
446 int
447 main(void)
450 return !program_invocation_short_name;
452 #endif /* TEST_PROGRAM_INVOCATION_SHORT_NAME */
453 #if TEST_PR_SET_NAME
454 #include <sys/prctl.h>
456 int
457 main(void)
459 prctl(PR_SET_NAME, "foo");
460 return 0;
462 #endif /* TEST_PR_SET_NAME */
463 #if TEST_READPASSPHRASE
464 #include <stddef.h>
465 #include <readpassphrase.h>
467 int
468 main(void)
470 return !!readpassphrase("prompt: ", NULL, 0, 0);
472 #endif /* TEST_READPASSPHRASE */
473 #if TEST_REALLOCARRAY
474 #ifdef __NetBSD__
475 # define _OPENBSD_SOURCE
476 #endif
477 #include <stdlib.h>
479 int
480 main(void)
482 return !reallocarray(NULL, 2, 2);
484 #endif /* TEST_REALLOCARRAY */
485 #if TEST_RECALLOCARRAY
486 #include <stdlib.h>
488 int
489 main(void)
491 return !recallocarray(NULL, 0, 2, 2);
493 #endif /* TEST_RECALLOCARRAY */
494 #if TEST_SANDBOX_INIT
495 #include <sandbox.h>
497 int
498 main(void)
500 char *ep;
501 int rc;
503 rc = sandbox_init(kSBXProfileNoInternet, SANDBOX_NAMED, &ep);
504 if (-1 == rc)
505 sandbox_free_error(ep);
506 return(-1 == rc);
508 #endif /* TEST_SANDBOX_INIT */
509 #if TEST_SETPROCTITLE
510 #include <stdlib.h>
512 int
513 main(void)
515 setproctitle("#%d test program", 7);
516 return 0;
518 #endif
519 #if TEST_SIO_FLUSH
520 #include <sndio.h>
522 int
523 main(void)
525 struct sio_hdl *hdl;
526 hdl = sio_open(SIO_DEVANY, SIO_PLAY, 1);
527 sio_flush(hdl);
528 sio_close(hdl);
529 return 0;
531 #endif /* TEST_SIO_FLUSH */
532 #if TEST_SCAN_SCALED
533 #include <util.h>
535 int
536 main(void)
538 char *cinput = (char *)"1.5K", buf[FMT_SCALED_STRSIZE];
539 long long ninput = 10483892, result;
540 return scan_scaled(cinput, &result) == 0;
542 #endif /* TEST_SCAN_SCALED */
543 #if TEST_SECCOMP_FILTER
544 #include <sys/prctl.h>
545 #include <linux/seccomp.h>
546 #include <errno.h>
548 int
549 main(void)
552 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, 0);
553 return(EFAULT == errno ? 0 : 1);
555 #endif /* TEST_SECCOMP_FILTER */
556 #if TEST_SETRESGID
557 #define _GNU_SOURCE /* linux */
558 #include <sys/types.h>
559 #include <unistd.h>
561 int
562 main(void)
564 return setresgid(-1, -1, -1) == -1;
566 #endif /* TEST_SETRESGID */
567 #if TEST_SETRESUID
568 #define _GNU_SOURCE /* linux */
569 #include <sys/types.h>
570 #include <unistd.h>
572 int
573 main(void)
575 return setresuid(-1, -1, -1) == -1;
577 #endif /* TEST_SETRESUID */
578 #if TEST_SHA2
579 #include <sys/types.h>
580 #include <sha2.h>
582 int main(void)
584 SHA2_CTX ctx;
585 char result[SHA256_DIGEST_STRING_LENGTH];
587 SHA256Init(&ctx);
588 SHA256Update(&ctx, (const unsigned char *)"abcd", 4);
589 SHA256End(&ctx, result);
591 return 0;
593 #endif /* TEST_SHA2 */
594 #if TEST_SOCK_NONBLOCK
595 /*
596 * Linux doesn't (always?) have this.
597 */
599 #include <sys/socket.h>
601 int
602 main(void)
604 int fd[2];
605 socketpair(AF_UNIX, SOCK_STREAM|SOCK_NONBLOCK, 0, fd);
606 return 0;
608 #endif /* TEST_SOCK_NONBLOCK */
609 #if TEST_STATIC
610 int
611 main(void)
613 return 0; /* not meant to do anything */
615 #endif /* TEST_STATIC */
616 #if TEST_STRLCAT
617 #include <string.h>
619 int
620 main(void)
622 char buf[3] = "a";
623 return ! (strlcat(buf, "b", sizeof(buf)) == 2 &&
624 buf[0] == 'a' && buf[1] == 'b' && buf[2] == '\0');
626 #endif /* TEST_STRLCAT */
627 #if TEST_STRLCPY
628 #include <string.h>
630 int
631 main(void)
633 char buf[2] = "";
634 return ! (strlcpy(buf, "a", sizeof(buf)) == 1 &&
635 buf[0] == 'a' && buf[1] == '\0');
637 #endif /* TEST_STRLCPY */
638 #if TEST_STRNDUP
639 #include <string.h>
641 int
642 main(void)
644 const char *foo = "bar";
645 char *baz;
647 baz = strndup(foo, 1);
648 return(0 != strcmp(baz, "b"));
650 #endif /* TEST_STRNDUP */
651 #if TEST_STRNLEN
652 #include <string.h>
654 int
655 main(void)
657 const char *foo = "bar";
658 size_t sz;
660 sz = strnlen(foo, 1);
661 return(1 != sz);
663 #endif /* TEST_STRNLEN */
664 #if TEST_STRTONUM
665 /*
666 * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
668 * Permission to use, copy, modify, and distribute this software for any
669 * purpose with or without fee is hereby granted, provided that the above
670 * copyright notice and this permission notice appear in all copies.
672 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
673 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
674 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
675 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
676 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
677 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
678 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
679 */
680 #ifdef __NetBSD__
681 # define _OPENBSD_SOURCE
682 #endif
683 #include <stdlib.h>
685 int
686 main(void)
688 const char *errstr;
690 if (strtonum("1", 0, 2, &errstr) != 1)
691 return 1;
692 if (errstr != NULL)
693 return 2;
694 if (strtonum("1x", 0, 2, &errstr) != 0)
695 return 3;
696 if (errstr == NULL)
697 return 4;
698 if (strtonum("2", 0, 1, &errstr) != 0)
699 return 5;
700 if (errstr == NULL)
701 return 6;
702 if (strtonum("0", 1, 2, &errstr) != 0)
703 return 7;
704 if (errstr == NULL)
705 return 8;
706 return 0;
708 #endif /* TEST_STRTONUM */
709 #if TEST_SYS_BYTEORDER_H
710 #include <sys/byteorder.h>
712 int
713 main(void)
715 return !LE_32(23);
717 #endif /* TEST_SYS_BYTEORDER_H */
718 #if TEST_SYS_ENDIAN_H
719 #include <sys/endian.h>
721 int
722 main(void)
724 return !htole32(23);
726 #endif /* TEST_SYS_ENDIAN_H */
727 #if TEST_SYS_MKDEV_H
728 #include <sys/types.h>
729 #include <sys/mkdev.h>
731 int
732 main(void)
734 return !minor(0);
736 #endif /* TEST_SYS_MKDEV_H */
737 #if TEST_SYS_FILE
738 #include <sys/file.h>
740 int
741 main(void)
743 flock(0, LOCK_SH|LOCK_NB);
744 return 0;
746 #endif /* TEST_SYS_FILE */
747 #if TEST_SYS_QUEUE
748 #include <sys/queue.h>
749 #include <stddef.h>
751 struct foo {
752 int bar;
753 TAILQ_ENTRY(foo) entries;
754 };
756 TAILQ_HEAD(fooq, foo);
758 int
759 main(void)
761 struct fooq foo_q, bar_q;
762 struct foo *p, *tmp;
763 int i = 0;
765 TAILQ_INIT(&foo_q);
766 TAILQ_INIT(&bar_q);
768 /*
769 * Use TAILQ_FOREACH_SAFE because some systems (e.g., Linux)
770 * have TAILQ_FOREACH but not the safe variant.
771 */
773 TAILQ_FOREACH_SAFE(p, &foo_q, entries, tmp)
774 p->bar = i++;
776 /* Test for newer macros as well. */
778 TAILQ_CONCAT(&foo_q, &bar_q, entries);
779 return 0;
781 #endif /* TEST_SYS_QUEUE */
782 #if TEST_SYS_SYSMACROS_H
783 #include <sys/sysmacros.h>
785 int
786 main(void)
788 return !minor(0);
790 #endif /* TEST_SYS_SYSMACROS_H */
791 #if TEST_SYS_TREE
792 #include <sys/tree.h>
793 #include <stdlib.h>
795 struct node {
796 RB_ENTRY(node) entry;
797 int i;
798 };
800 static int
801 intcmp(struct node *e1, struct node *e2)
803 return (e1->i < e2->i ? -1 : e1->i > e2->i);
806 RB_HEAD(inttree, node) head = RB_INITIALIZER(&head);
807 RB_PROTOTYPE(inttree, node, entry, intcmp)
808 RB_GENERATE(inttree, node, entry, intcmp)
810 int testdata[] = {
811 20, 16, 17, 13, 3, 6, 1, 8, 2, 4
812 };
814 int
815 main(void)
817 size_t i;
818 struct node *n;
820 for (i = 0; i < sizeof(testdata) / sizeof(testdata[0]); i++) {
821 if ((n = malloc(sizeof(struct node))) == NULL)
822 return 1;
823 n->i = testdata[i];
824 RB_INSERT(inttree, &head, n);
827 return 0;
830 #endif /* TEST_SYS_TREE */
831 #if TEST_UNVEIL
832 #include <unistd.h>
834 int
835 main(void)
837 return -1 != unveil(NULL, NULL);
839 #endif /* TEST_UNVEIL */
840 #if TEST_WAIT_ANY
841 #include <sys/wait.h>
843 int
844 main(void)
846 int st;
848 return waitpid(WAIT_ANY, &st, WNOHANG) != -1;
850 #endif /* TEST_WAIT_ANY */
851 #if TEST_LIBEVENT
852 #include <event.h>
854 int
855 main(void)
857 struct event ev;
859 event_set(&ev, 0, EV_READ, NULL, NULL);
860 event_add(&ev, NULL);
861 event_del(&ev);
862 return 0;
864 #endif /* TEST_LIBEVENT */
865 #if TEST_LIBEVENT2
866 #include <event2/event.h>
867 #include <event2/event_compat.h>
868 #include <event2/event_struct.h>
869 #include <event2/buffer.h>
870 #include <event2/buffer_compat.h>
871 #include <event2/bufferevent.h>
872 #include <event2/bufferevent_struct.h>
873 #include <event2/bufferevent_compat.h>
875 int
876 main(void)
878 struct event ev;
880 event_set(&ev, 0, EV_READ, NULL, NULL);
881 event_add(&ev, NULL);
882 event_del(&ev);
883 return 0;
885 #endif /* TEST_LIBEVENT2 */
886 #if TEST_LIB_FLAC
887 #include <FLAC/stream_decoder.h>
889 int
890 main(void)
892 FLAC__StreamDecoder *decoder = NULL;
893 FLAC__StreamDecoderInitStatus init_status;
895 decoder = FLAC__stream_decoder_new();
896 FLAC__stream_decoder_delete(decoder);
897 return 0;
899 #endif /* TEST_LIB_FLAC */
900 #if TEST_LIB_MPG123
901 #include <mpg123.h>
903 int
904 main(void)
906 mpg123_handle *mh;
908 mh = mpg123_new(NULL, NULL);
909 mpg123_delete(mh);
910 return 0;
912 #endif/* TEST_LIB_MPG123 */
913 #if TEST_LIB_OPUSFILE
914 #include <stdio.h>
915 #include <opusfile.h>
917 int
918 main(void)
920 FILE *f;
921 OggOpusFile *of;
922 OpusFileCallbacks cb = {NULL, NULL, NULL, NULL};
923 int r;
925 f = op_fdopen(&cb, 0, "r");
926 of = op_open_callbacks(f, &cb, NULL, 0, &r);
927 op_free(of);
928 return 0;
930 #endif /* TEST_LIB_OPUSFILE */
931 #if TEST_LIB_VORBISFILE
932 #include <stdio.h>
933 #include <vorbis/vorbisfile.h>
935 int
936 main(void)
938 OggVorbis_File vf;
940 ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE);
941 ov_clear(&vf);
942 return 0;
944 #endif /* TEST_LIB_VORBISFILE */
945 #if TEST_LIB_ASOUND
946 #include <alsa/asoundlib.h>
948 int
949 main(void)
951 snd_pcm_t *pcm;
952 int err;
954 err = snd_pcm_open(&pcm, "default", SND_PCM_STREAM_PLAYBACK,
955 SND_PCM_NONBLOCK);
956 return err;
958 #endif /* TEST_LIB_ASOUND */
959 #if TEST_LIB_SNDIO
960 #include <sndio.h>
962 int
963 main(void)
965 struct sio_hdl *hdl;
966 hdl = sio_open(SIO_DEVANY, SIO_PLAY, 1);
967 sio_close(hdl);
968 return 0;
970 #endif /* TEST_LIB_SNDIO */