1 0efd7c9a 2022-07-30 op #if TEST_GETEXECNAME
2 0efd7c9a 2022-07-30 op #include <stdlib.h>
7 0efd7c9a 2022-07-30 op const char * progname;
9 0efd7c9a 2022-07-30 op progname = getexecname();
10 0efd7c9a 2022-07-30 op return progname == NULL;
12 0efd7c9a 2022-07-30 op #endif /* TEST_GETEXECNAME */
13 0efd7c9a 2022-07-30 op #if TEST_GETPROGNAME
14 0efd7c9a 2022-07-30 op #include <stdlib.h>
19 0efd7c9a 2022-07-30 op const char * progname;
21 0efd7c9a 2022-07-30 op progname = getprogname();
22 0efd7c9a 2022-07-30 op return progname == NULL;
24 0efd7c9a 2022-07-30 op #endif /* TEST_GETPROGNAME */
25 0efd7c9a 2022-07-30 op #if TEST_LIBEVENT
26 0efd7c9a 2022-07-30 op #include <event.h>
31 0efd7c9a 2022-07-30 op struct event ev;
33 0efd7c9a 2022-07-30 op event_set(&ev, 0, EV_READ, NULL, NULL);
34 0efd7c9a 2022-07-30 op event_add(&ev, NULL);
35 0efd7c9a 2022-07-30 op event_del(&ev);
38 0efd7c9a 2022-07-30 op #endif /* TEST_LIBEVENT */
39 0efd7c9a 2022-07-30 op #if TEST_LIBEVENT2
40 0efd7c9a 2022-07-30 op #include <event2/event.h>
41 0efd7c9a 2022-07-30 op #include <event2/event_compat.h>
42 0efd7c9a 2022-07-30 op #include <event2/event_struct.h>
43 0efd7c9a 2022-07-30 op #include <event2/buffer.h>
44 0efd7c9a 2022-07-30 op #include <event2/buffer_compat.h>
45 0efd7c9a 2022-07-30 op #include <event2/bufferevent.h>
46 0efd7c9a 2022-07-30 op #include <event2/bufferevent_struct.h>
47 0efd7c9a 2022-07-30 op #include <event2/bufferevent_compat.h>
52 0efd7c9a 2022-07-30 op struct event ev;
54 0efd7c9a 2022-07-30 op event_set(&ev, 0, EV_READ, NULL, NULL);
55 0efd7c9a 2022-07-30 op event_add(&ev, NULL);
56 0efd7c9a 2022-07-30 op event_del(&ev);
59 0efd7c9a 2022-07-30 op #endif /* TEST_LIBEVENT2 */
60 0efd7c9a 2022-07-30 op #if TEST_LIB_SOCKET
61 0efd7c9a 2022-07-30 op #include <sys/socket.h>
66 0efd7c9a 2022-07-30 op int fds[2], c;
68 0efd7c9a 2022-07-30 op c = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
69 0efd7c9a 2022-07-30 op return c == -1;
71 0efd7c9a 2022-07-30 op #endif /* TEST_LIB_SOCKET */
72 0efd7c9a 2022-07-30 op #if TEST_PLEDGE
73 0efd7c9a 2022-07-30 op #include <unistd.h>
78 0efd7c9a 2022-07-30 op return !!pledge("stdio", NULL);
80 0efd7c9a 2022-07-30 op #endif /* TEST_PLEDGE */
81 0efd7c9a 2022-07-30 op #if TEST_PROGRAM_INVOCATION_SHORT_NAME
82 0efd7c9a 2022-07-30 op #define _GNU_SOURCE /* See feature_test_macros(7) */
83 0efd7c9a 2022-07-30 op #include <errno.h>
89 0efd7c9a 2022-07-30 op return !program_invocation_short_name;
91 0efd7c9a 2022-07-30 op #endif /* TEST_PROGRAM_INVOCATION_SHORT_NAME */
92 0efd7c9a 2022-07-30 op #if TEST_PR_SET_NAME
93 0efd7c9a 2022-07-30 op #include <sys/prctl.h>
98 0efd7c9a 2022-07-30 op prctl(PR_SET_NAME, "foo");
101 0efd7c9a 2022-07-30 op #endif /* TEST_PR_SET_NAME */
102 cfe57149 2022-07-30 op #if TEST_SO_SPLICE
103 cfe57149 2022-07-30 op #include <sys/socket.h>
108 cfe57149 2022-07-30 op int src = 0, dst = 1;
111 cfe57149 2022-07-30 op * invalid usage, i'm only interested in checking if it
114 cfe57149 2022-07-30 op setsockopt(src, SOL_SOCKET, SO_SPLICE, &dst, sizeof(int));
117 cfe57149 2022-07-30 op #endif /* TEST_SO_SPLICE */
118 0efd7c9a 2022-07-30 op #if TEST_STATIC
122 0efd7c9a 2022-07-30 op return 0; /* not meant to do anything */
124 0efd7c9a 2022-07-30 op #endif /* TEST_STATIC */
125 0efd7c9a 2022-07-30 op #if TEST_STRLCAT
126 0efd7c9a 2022-07-30 op #include <string.h>
131 0efd7c9a 2022-07-30 op char buf[3] = "a";
132 0efd7c9a 2022-07-30 op return ! (strlcat(buf, "b", sizeof(buf)) == 2 &&
133 0efd7c9a 2022-07-30 op buf[0] == 'a' && buf[1] == 'b' && buf[2] == '\0');
135 0efd7c9a 2022-07-30 op #endif /* TEST_STRLCAT */
136 0efd7c9a 2022-07-30 op #if TEST_STRLCPY
137 0efd7c9a 2022-07-30 op #include <string.h>
142 0efd7c9a 2022-07-30 op char buf[2] = "";
143 0efd7c9a 2022-07-30 op return ! (strlcpy(buf, "a", sizeof(buf)) == 1 &&
144 0efd7c9a 2022-07-30 op buf[0] == 'a' && buf[1] == '\0');
146 0efd7c9a 2022-07-30 op #endif /* TEST_STRLCPY */
147 0efd7c9a 2022-07-30 op #if TEST_STRTONUM
149 0efd7c9a 2022-07-30 op * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
151 0efd7c9a 2022-07-30 op * Permission to use, copy, modify, and distribute this software for any
152 0efd7c9a 2022-07-30 op * purpose with or without fee is hereby granted, provided that the above
153 0efd7c9a 2022-07-30 op * copyright notice and this permission notice appear in all copies.
155 0efd7c9a 2022-07-30 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
156 0efd7c9a 2022-07-30 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
157 0efd7c9a 2022-07-30 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
158 0efd7c9a 2022-07-30 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
159 0efd7c9a 2022-07-30 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
160 0efd7c9a 2022-07-30 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
161 0efd7c9a 2022-07-30 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
163 0efd7c9a 2022-07-30 op #ifdef __NetBSD__
164 0efd7c9a 2022-07-30 op # define _OPENBSD_SOURCE
166 0efd7c9a 2022-07-30 op #include <stdlib.h>
171 0efd7c9a 2022-07-30 op const char *errstr;
173 0efd7c9a 2022-07-30 op if (strtonum("1", 0, 2, &errstr) != 1)
175 0efd7c9a 2022-07-30 op if (errstr != NULL)
177 0efd7c9a 2022-07-30 op if (strtonum("1x", 0, 2, &errstr) != 0)
179 0efd7c9a 2022-07-30 op if (errstr == NULL)
181 0efd7c9a 2022-07-30 op if (strtonum("2", 0, 1, &errstr) != 0)
183 0efd7c9a 2022-07-30 op if (errstr == NULL)
185 0efd7c9a 2022-07-30 op if (strtonum("0", 1, 2, &errstr) != 0)
187 0efd7c9a 2022-07-30 op if (errstr == NULL)
191 0efd7c9a 2022-07-30 op #endif /* TEST_STRTONUM */
192 0efd7c9a 2022-07-30 op #if TEST_UNVEIL
193 0efd7c9a 2022-07-30 op #include <unistd.h>
198 0efd7c9a 2022-07-30 op return -1 != unveil(NULL, NULL);
200 0efd7c9a 2022-07-30 op #endif /* TEST_UNVEIL */
201 0efd7c9a 2022-07-30 op #if TEST__MMD
207 0efd7c9a 2022-07-30 op #endif /* TEST_NOOP */
208 0efd7c9a 2022-07-30 op #if TEST___PROGNAME
212 0efd7c9a 2022-07-30 op extern char *__progname;
214 0efd7c9a 2022-07-30 op return !__progname;
216 0efd7c9a 2022-07-30 op #endif /* TEST___PROGNAME */