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 0efd7c9a 2022-07-30 op #if TEST_STATIC
106 0efd7c9a 2022-07-30 op return 0; /* not meant to do anything */
108 0efd7c9a 2022-07-30 op #endif /* TEST_STATIC */
109 0efd7c9a 2022-07-30 op #if TEST_STRLCAT
110 0efd7c9a 2022-07-30 op #include <string.h>
115 0efd7c9a 2022-07-30 op char buf[3] = "a";
116 0efd7c9a 2022-07-30 op return ! (strlcat(buf, "b", sizeof(buf)) == 2 &&
117 0efd7c9a 2022-07-30 op buf[0] == 'a' && buf[1] == 'b' && buf[2] == '\0');
119 0efd7c9a 2022-07-30 op #endif /* TEST_STRLCAT */
120 0efd7c9a 2022-07-30 op #if TEST_STRLCPY
121 0efd7c9a 2022-07-30 op #include <string.h>
126 0efd7c9a 2022-07-30 op char buf[2] = "";
127 0efd7c9a 2022-07-30 op return ! (strlcpy(buf, "a", sizeof(buf)) == 1 &&
128 0efd7c9a 2022-07-30 op buf[0] == 'a' && buf[1] == '\0');
130 0efd7c9a 2022-07-30 op #endif /* TEST_STRLCPY */
131 0efd7c9a 2022-07-30 op #if TEST_STRTONUM
133 0efd7c9a 2022-07-30 op * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
135 0efd7c9a 2022-07-30 op * Permission to use, copy, modify, and distribute this software for any
136 0efd7c9a 2022-07-30 op * purpose with or without fee is hereby granted, provided that the above
137 0efd7c9a 2022-07-30 op * copyright notice and this permission notice appear in all copies.
139 0efd7c9a 2022-07-30 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
140 0efd7c9a 2022-07-30 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
141 0efd7c9a 2022-07-30 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
142 0efd7c9a 2022-07-30 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
143 0efd7c9a 2022-07-30 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
144 0efd7c9a 2022-07-30 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
145 0efd7c9a 2022-07-30 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
147 0efd7c9a 2022-07-30 op #ifdef __NetBSD__
148 0efd7c9a 2022-07-30 op # define _OPENBSD_SOURCE
150 0efd7c9a 2022-07-30 op #include <stdlib.h>
155 0efd7c9a 2022-07-30 op const char *errstr;
157 0efd7c9a 2022-07-30 op if (strtonum("1", 0, 2, &errstr) != 1)
159 0efd7c9a 2022-07-30 op if (errstr != NULL)
161 0efd7c9a 2022-07-30 op if (strtonum("1x", 0, 2, &errstr) != 0)
163 0efd7c9a 2022-07-30 op if (errstr == NULL)
165 0efd7c9a 2022-07-30 op if (strtonum("2", 0, 1, &errstr) != 0)
167 0efd7c9a 2022-07-30 op if (errstr == NULL)
169 0efd7c9a 2022-07-30 op if (strtonum("0", 1, 2, &errstr) != 0)
171 0efd7c9a 2022-07-30 op if (errstr == NULL)
175 0efd7c9a 2022-07-30 op #endif /* TEST_STRTONUM */
176 0efd7c9a 2022-07-30 op #if TEST_UNVEIL
177 0efd7c9a 2022-07-30 op #include <unistd.h>
182 0efd7c9a 2022-07-30 op return -1 != unveil(NULL, NULL);
184 0efd7c9a 2022-07-30 op #endif /* TEST_UNVEIL */
185 0efd7c9a 2022-07-30 op #if TEST__MMD
191 0efd7c9a 2022-07-30 op #endif /* TEST_NOOP */
192 0efd7c9a 2022-07-30 op #if TEST___PROGNAME
196 0efd7c9a 2022-07-30 op extern char *__progname;
198 0efd7c9a 2022-07-30 op return !__progname;
200 0efd7c9a 2022-07-30 op #endif /* TEST___PROGNAME */