Blob


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