| @@ -1,380 +1,378 @@ | | | @@ -1,380 +1,378 @@ |
1 | /* $NetBSD: t_rpc.c,v 1.6 2015/11/08 19:38:04 christos Exp $ */ | | 1 | /* $NetBSD: t_rpc.c,v 1.7 2015/11/08 19:40:06 christos Exp $ */ |
2 | | | 2 | |
3 | #include <sys/cdefs.h> | | 3 | #include <sys/cdefs.h> |
4 | __RCSID("$NetBSD: t_rpc.c,v 1.6 2015/11/08 19:38:04 christos Exp $"); | | 4 | __RCSID("$NetBSD: t_rpc.c,v 1.7 2015/11/08 19:40:06 christos Exp $"); |
5 | | | 5 | |
6 | #include <sys/types.h> | | 6 | #include <sys/types.h> |
7 | #include <sys/socket.h> | | 7 | #include <sys/socket.h> |
8 | #include <rpc/rpc.h> | | 8 | #include <rpc/rpc.h> |
9 | #include <stdlib.h> | | 9 | #include <stdlib.h> |
10 | #include <string.h> | | 10 | #include <string.h> |
11 | #include <err.h> | | 11 | #include <err.h> |
12 | #include <netdb.h> | | 12 | #include <netdb.h> |
13 | #include <stdio.h> | | 13 | #include <stdio.h> |
14 | #include <errno.h> | | 14 | #include <errno.h> |
15 | #include <unistd.h> | | 15 | #include <unistd.h> |
16 | | | 16 | |
17 | #define DEBUG | | | |
18 | #define TEST | | | |
19 | #ifndef TEST | | 17 | #ifndef TEST |
20 | #include <atf-c.h> | | 18 | #include <atf-c.h> |
21 | | | 19 | |
22 | #define ERRX(ev, msg, ...) ATF_REQUIRE_MSG(0, msg, __VA_ARGS__) | | 20 | #define ERRX(ev, msg, ...) ATF_REQUIRE_MSG(0, msg, __VA_ARGS__) |
23 | | | 21 | |
24 | #define SKIPX(ev, msg, ...) do { \ | | 22 | #define SKIPX(ev, msg, ...) do { \ |
25 | atf_tc_skip(msg, __VA_ARGS__); \ | | 23 | atf_tc_skip(msg, __VA_ARGS__); \ |
26 | return; \ | | 24 | return; \ |
27 | } while(/*CONSTCOND*/0) | | 25 | } while(/*CONSTCOND*/0) |
28 | | | 26 | |
29 | #else | | 27 | #else |
30 | #define ERRX(ev, msg, ...) errx(ev, msg, __VA_ARGS__) | | 28 | #define ERRX(ev, msg, ...) errx(ev, msg, __VA_ARGS__) |
31 | #define SKIPX(ev, msg, ...) errx(ev, msg, __VA_ARGS__) | | 29 | #define SKIPX(ev, msg, ...) errx(ev, msg, __VA_ARGS__) |
32 | #endif | | 30 | #endif |
33 | | | 31 | |
34 | #ifdef DEBUG | | 32 | #ifdef DEBUG |
35 | #define DPRINTF(...) printf(__VA_ARGS__) | | 33 | #define DPRINTF(...) printf(__VA_ARGS__) |
36 | #else | | 34 | #else |
37 | #define DPRINTF(...) | | 35 | #define DPRINTF(...) |
38 | #endif | | 36 | #endif |
39 | | | 37 | |
40 | | | 38 | |
41 | #define RPCBPROC_NULL 0 | | 39 | #define RPCBPROC_NULL 0 |
42 | | | 40 | |
43 | static int | | 41 | static int |
44 | reply(caddr_t replyp, struct netbuf * raddrp, struct netconfig * nconf) | | 42 | reply(caddr_t replyp, struct netbuf * raddrp, struct netconfig * nconf) |
45 | { | | 43 | { |
46 | char host[NI_MAXHOST]; | | 44 | char host[NI_MAXHOST]; |
47 | struct sockaddr *sock = raddrp->buf; | | 45 | struct sockaddr *sock = raddrp->buf; |
48 | int error; | | 46 | int error; |
49 | | | 47 | |
50 | | | 48 | |
51 | error = getnameinfo(sock, sock->sa_len, host, sizeof(host), NULL, 0, 0); | | 49 | error = getnameinfo(sock, sock->sa_len, host, sizeof(host), NULL, 0, 0); |
52 | if (error) | | 50 | if (error) |
53 | warnx("Cannot resolve address (%s)", gai_strerror(error)); | | 51 | warnx("Cannot resolve address (%s)", gai_strerror(error)); |
54 | else | | 52 | else |
55 | printf("response from: %s\n", host); | | 53 | printf("response from: %s\n", host); |
56 | return 0; | | 54 | return 0; |
57 | } | | 55 | } |
58 | | | 56 | |
59 | extern bool_t __rpc_control(int, void *); | | 57 | extern bool_t __rpc_control(int, void *); |
60 | | | 58 | |
61 | static void | | 59 | static void |
62 | onehost(const char *host, const char *transp) | | 60 | onehost(const char *host, const char *transp) |
63 | { | | 61 | { |
64 | CLIENT *clnt; | | 62 | CLIENT *clnt; |
65 | struct netbuf addr; | | 63 | struct netbuf addr; |
66 | struct timeval tv; | | 64 | struct timeval tv; |
67 | | | 65 | |
68 | /* | | 66 | /* |
69 | * Magic! | | 67 | * Magic! |
70 | */ | | 68 | */ |
71 | tv.tv_sec = 0; | | 69 | tv.tv_sec = 0; |
72 | tv.tv_usec = 500000; | | 70 | tv.tv_usec = 500000; |
73 | #define CLCR_SET_RPCB_TIMEOUT 2 | | 71 | #define CLCR_SET_RPCB_TIMEOUT 2 |
74 | __rpc_control(CLCR_SET_RPCB_TIMEOUT, &tv); | | 72 | __rpc_control(CLCR_SET_RPCB_TIMEOUT, &tv); |
75 | | | 73 | |
76 | if ((clnt = clnt_create(host, RPCBPROG, RPCBVERS, transp)) == NULL) | | 74 | if ((clnt = clnt_create(host, RPCBPROG, RPCBVERS, transp)) == NULL) |
77 | SKIPX(EXIT_FAILURE, "clnt_create (%s)", clnt_spcreateerror("")); | | 75 | SKIPX(EXIT_FAILURE, "clnt_create (%s)", clnt_spcreateerror("")); |
78 | | | 76 | |
79 | tv.tv_sec = 1; | | 77 | tv.tv_sec = 1; |
80 | tv.tv_usec = 0; | | 78 | tv.tv_usec = 0; |
81 | if (clnt_call(clnt, RPCBPROC_NULL, xdr_void, NULL, xdr_void, NULL, tv) | | 79 | if (clnt_call(clnt, RPCBPROC_NULL, xdr_void, NULL, xdr_void, NULL, tv) |
82 | != RPC_SUCCESS) | | 80 | != RPC_SUCCESS) |
83 | ERRX(EXIT_FAILURE, "clnt_call (%s)", clnt_sperror(clnt, "")); | | 81 | ERRX(EXIT_FAILURE, "clnt_call (%s)", clnt_sperror(clnt, "")); |
84 | clnt_control(clnt, CLGET_SVC_ADDR, (char *) &addr); | | 82 | clnt_control(clnt, CLGET_SVC_ADDR, (char *) &addr); |
85 | reply(NULL, &addr, NULL); | | 83 | reply(NULL, &addr, NULL); |
86 | } | | 84 | } |
87 | | | 85 | |
88 | #define PROGNUM 0x81 | | 86 | #define PROGNUM 0x81 |
89 | #define VERSNUM 0x01 | | 87 | #define VERSNUM 0x01 |
90 | #define PLUSONE 1 | | 88 | #define PLUSONE 1 |
91 | #define DESTROY 2 | | 89 | #define DESTROY 2 |
92 | | | 90 | |
93 | static struct timeval tout = {1, 0}; | | 91 | static struct timeval tout = {1, 0}; |
94 | | | 92 | |
95 | static void | | 93 | static void |
96 | server(struct svc_req *rqstp, SVCXPRT *transp) | | 94 | server(struct svc_req *rqstp, SVCXPRT *transp) |
97 | { | | 95 | { |
98 | int num; | | 96 | int num; |
99 | | | 97 | |
100 | DPRINTF("Starting server\n"); | | 98 | DPRINTF("Starting server\n"); |
101 | | | 99 | |
102 | switch (rqstp->rq_proc) { | | 100 | switch (rqstp->rq_proc) { |
103 | case NULLPROC: | | 101 | case NULLPROC: |
104 | if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) | | 102 | if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) |
105 | ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0); | | 103 | ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0); |
106 | return; | | 104 | return; |
107 | case PLUSONE: | | 105 | case PLUSONE: |
108 | break; | | 106 | break; |
109 | case DESTROY: | | 107 | case DESTROY: |
110 | if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) | | 108 | if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) |
111 | ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0); | | 109 | ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0); |
112 | svc_destroy(transp); | | 110 | svc_destroy(transp); |
113 | exit(0); | | 111 | exit(0); |
114 | default: | | 112 | default: |
115 | svcerr_noproc(transp); | | 113 | svcerr_noproc(transp); |
116 | return; | | 114 | return; |
117 | } | | 115 | } |
118 | | | 116 | |
119 | if (!svc_getargs(transp, (xdrproc_t)xdr_int, (void *)&num)) { | | 117 | if (!svc_getargs(transp, (xdrproc_t)xdr_int, (void *)&num)) { |
120 | svcerr_decode(transp); | | 118 | svcerr_decode(transp); |
121 | return; | | 119 | return; |
122 | } | | 120 | } |
123 | DPRINTF("About to increment\n"); | | 121 | DPRINTF("About to increment\n"); |
124 | num++; | | 122 | num++; |
125 | if (!svc_sendreply(transp, (xdrproc_t)xdr_int, (void *)&num)) | | 123 | if (!svc_sendreply(transp, (xdrproc_t)xdr_int, (void *)&num)) |
126 | ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 1); | | 124 | ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 1); |
127 | DPRINTF("Leaving server procedure.\n"); | | 125 | DPRINTF("Leaving server procedure.\n"); |
128 | } | | 126 | } |
129 | | | 127 | |
130 | static int | | 128 | static int |
131 | rawtest(const char *arg) | | 129 | rawtest(const char *arg) |
132 | { | | 130 | { |
133 | CLIENT *clnt; | | 131 | CLIENT *clnt; |
134 | SVCXPRT *svc; | | 132 | SVCXPRT *svc; |
135 | int num, resp; | | 133 | int num, resp; |
136 | enum clnt_stat rv; | | 134 | enum clnt_stat rv; |
137 | | | 135 | |
138 | if (arg) | | 136 | if (arg) |
139 | num = atoi(arg); | | 137 | num = atoi(arg); |
140 | else | | 138 | else |
141 | num = 0; | | 139 | num = 0; |
142 | | | 140 | |
143 | svc = svc_raw_create(); | | 141 | svc = svc_raw_create(); |
144 | if (svc == NULL) | | 142 | if (svc == NULL) |
145 | ERRX(EXIT_FAILURE, "Can't not create server %d", num); | | 143 | ERRX(EXIT_FAILURE, "Can't not create server %d", num); |
146 | if (!svc_reg(svc, PROGNUM, VERSNUM, server, NULL)) | | 144 | if (!svc_reg(svc, PROGNUM, VERSNUM, server, NULL)) |
147 | ERRX(EXIT_FAILURE, "Can't not register server %d", num); | | 145 | ERRX(EXIT_FAILURE, "Can't not register server %d", num); |
148 | | | 146 | |
149 | clnt = clnt_raw_create(PROGNUM, VERSNUM); | | 147 | clnt = clnt_raw_create(PROGNUM, VERSNUM); |
150 | if (clnt == NULL) | | 148 | if (clnt == NULL) |
151 | ERRX(EXIT_FAILURE, "%s", | | 149 | ERRX(EXIT_FAILURE, "%s", |
152 | clnt_spcreateerror("clnt_raw_create")); | | 150 | clnt_spcreateerror("clnt_raw_create")); |
153 | rv = clnt_call(clnt, PLUSONE, (xdrproc_t)xdr_int, (void *)&num, | | 151 | rv = clnt_call(clnt, PLUSONE, (xdrproc_t)xdr_int, (void *)&num, |
154 | (xdrproc_t)xdr_int, (void *)&resp, tout); | | 152 | (xdrproc_t)xdr_int, (void *)&resp, tout); |
155 | if (rv != RPC_SUCCESS) | | 153 | if (rv != RPC_SUCCESS) |
156 | ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); | | 154 | ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); |
157 | DPRINTF("Got %d\n", resp); | | 155 | DPRINTF("Got %d\n", resp); |
158 | clnt_destroy(clnt); | | 156 | clnt_destroy(clnt); |
159 | svc_destroy(svc); | | 157 | svc_destroy(svc); |
160 | if (++num != resp) | | 158 | if (++num != resp) |
161 | ERRX(EXIT_FAILURE, "expected %d got %d", num, resp); | | 159 | ERRX(EXIT_FAILURE, "expected %d got %d", num, resp); |
162 | | | 160 | |
163 | return EXIT_SUCCESS; | | 161 | return EXIT_SUCCESS; |
164 | } | | 162 | } |
165 | | | 163 | |
166 | static int | | 164 | static int |
167 | regtest(const char *hostname, const char *transp, const char *arg, int p) | | 165 | regtest(const char *hostname, const char *transp, const char *arg, int p) |
168 | { | | 166 | { |
169 | CLIENT *clnt; | | 167 | CLIENT *clnt; |
170 | int num, resp; | | 168 | int num, resp; |
171 | enum clnt_stat rv; | | 169 | enum clnt_stat rv; |
172 | pid_t pid; | | 170 | pid_t pid; |
173 | | | 171 | |
174 | if (arg) | | 172 | if (arg) |
175 | num = atoi(arg); | | 173 | num = atoi(arg); |
176 | else | | 174 | else |
177 | num = 0; | | 175 | num = 0; |
178 | | | 176 | |
179 | svc_fdset_init(p ? SVC_FDSET_POLL : 0); | | 177 | svc_fdset_init(p ? SVC_FDSET_POLL : 0); |
180 | if (!svc_create(server, PROGNUM, VERSNUM, transp)) | | 178 | if (!svc_create(server, PROGNUM, VERSNUM, transp)) |
181 | ERRX(EXIT_FAILURE, "Can't not create server %d", num); | | 179 | ERRX(EXIT_FAILURE, "Can't not create server %d", num); |
182 | | | 180 | |
183 | switch ((pid = fork())) { | | 181 | switch ((pid = fork())) { |
184 | case 0: | | 182 | case 0: |
185 | DPRINTF("Calling svc_run\n"); | | 183 | DPRINTF("Calling svc_run\n"); |
186 | svc_run(); | | 184 | svc_run(); |
187 | case -1: | | 185 | case -1: |
188 | ERRX(EXIT_FAILURE, "Fork failed (%s)", strerror(errno)); | | 186 | ERRX(EXIT_FAILURE, "Fork failed (%s)", strerror(errno)); |
189 | default: | | 187 | default: |
190 | sleep(1); | | 188 | sleep(1); |
191 | break; | | 189 | break; |
192 | } | | 190 | } |
193 | | | 191 | |
194 | DPRINTF("Initializing client\n"); | | 192 | DPRINTF("Initializing client\n"); |
195 | clnt = clnt_create(hostname, PROGNUM, VERSNUM, transp); | | 193 | clnt = clnt_create(hostname, PROGNUM, VERSNUM, transp); |
196 | if (clnt == NULL) | | 194 | if (clnt == NULL) |
197 | ERRX(EXIT_FAILURE, "%s", | | 195 | ERRX(EXIT_FAILURE, "%s", |
198 | clnt_spcreateerror("clnt_raw_create")); | | 196 | clnt_spcreateerror("clnt_raw_create")); |
199 | rv = clnt_call(clnt, PLUSONE, (xdrproc_t)xdr_int, (void *)&num, | | 197 | rv = clnt_call(clnt, PLUSONE, (xdrproc_t)xdr_int, (void *)&num, |
200 | (xdrproc_t)xdr_int, (void *)&resp, tout); | | 198 | (xdrproc_t)xdr_int, (void *)&resp, tout); |
201 | if (rv != RPC_SUCCESS) | | 199 | if (rv != RPC_SUCCESS) |
202 | ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); | | 200 | ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); |
203 | DPRINTF("Got %d\n", resp); | | 201 | DPRINTF("Got %d\n", resp); |
204 | if (++num != resp) | | 202 | if (++num != resp) |
205 | ERRX(EXIT_FAILURE, "expected %d got %d", num, resp); | | 203 | ERRX(EXIT_FAILURE, "expected %d got %d", num, resp); |
206 | rv = clnt_call(clnt, DESTROY, (xdrproc_t)xdr_void, NULL, | | 204 | rv = clnt_call(clnt, DESTROY, (xdrproc_t)xdr_void, NULL, |
207 | (xdrproc_t)xdr_void, NULL, tout); | | 205 | (xdrproc_t)xdr_void, NULL, tout); |
208 | if (rv != RPC_SUCCESS) | | 206 | if (rv != RPC_SUCCESS) |
209 | ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); | | 207 | ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); |
210 | clnt_destroy(clnt); | | 208 | clnt_destroy(clnt); |
211 | | | 209 | |
212 | return EXIT_SUCCESS; | | 210 | return EXIT_SUCCESS; |
213 | } | | 211 | } |
214 | | | 212 | |
215 | | | 213 | |
216 | #ifdef TEST | | 214 | #ifdef TEST |
217 | static void | | 215 | static void |
218 | allhosts(const char *transp) | | 216 | allhosts(const char *transp) |
219 | { | | 217 | { |
220 | enum clnt_stat clnt_stat; | | 218 | enum clnt_stat clnt_stat; |
221 | | | 219 | |
222 | clnt_stat = rpc_broadcast(RPCBPROG, RPCBVERS, RPCBPROC_NULL, | | 220 | clnt_stat = rpc_broadcast(RPCBPROG, RPCBVERS, RPCBPROC_NULL, |
223 | (xdrproc_t)xdr_void, NULL, (xdrproc_t)xdr_void, | | 221 | (xdrproc_t)xdr_void, NULL, (xdrproc_t)xdr_void, |
224 | NULL, (resultproc_t)reply, transp); | | 222 | NULL, (resultproc_t)reply, transp); |
225 | if (clnt_stat != RPC_SUCCESS && clnt_stat != RPC_TIMEDOUT) | | 223 | if (clnt_stat != RPC_SUCCESS && clnt_stat != RPC_TIMEDOUT) |
226 | ERRX(EXIT_FAILURE, "%s", clnt_sperrno(clnt_stat)); | | 224 | ERRX(EXIT_FAILURE, "%s", clnt_sperrno(clnt_stat)); |
227 | } | | 225 | } |
228 | | | 226 | |
229 | int | | 227 | int |
230 | main(int argc, char *argv[]) | | 228 | main(int argc, char *argv[]) |
231 | { | | 229 | { |
232 | int ch; | | 230 | int ch; |
233 | int s, p; | | 231 | int s, p; |
234 | const char *transp = "udp"; | | 232 | const char *transp = "udp"; |
235 | | | 233 | |
236 | p = s = 0; | | 234 | p = s = 0; |
237 | while ((ch = getopt(argc, argv, "prstu")) != -1) | | 235 | while ((ch = getopt(argc, argv, "prstu")) != -1) |
238 | switch (ch) { | | 236 | switch (ch) { |
239 | case 'p': | | 237 | case 'p': |
240 | p = 1; | | 238 | p = 1; |
241 | break; | | 239 | break; |
242 | case 's': | | 240 | case 's': |
243 | s = 1; | | 241 | s = 1; |
244 | break; | | 242 | break; |
245 | case 't': | | 243 | case 't': |
246 | transp = "tcp"; | | 244 | transp = "tcp"; |
247 | break; | | 245 | break; |
248 | case 'u': | | 246 | case 'u': |
249 | transp = "udp"; | | 247 | transp = "udp"; |
250 | break; | | 248 | break; |
251 | case 'r': | | 249 | case 'r': |
252 | transp = NULL; | | 250 | transp = NULL; |
253 | break; | | 251 | break; |
254 | default: | | 252 | default: |
255 | fprintf(stderr, | | 253 | fprintf(stderr, |
256 | "Usage: %s -[r|s|t|u] [<hostname>...]\n", | | 254 | "Usage: %s -[r|s|t|u] [<hostname>...]\n", |
257 | getprogname()); | | 255 | getprogname()); |
258 | return EXIT_FAILURE; | | 256 | return EXIT_FAILURE; |
259 | } | | 257 | } |
260 | | | 258 | |
261 | if (argc == optind) { | | 259 | if (argc == optind) { |
262 | if (transp) | | 260 | if (transp) |
263 | allhosts(transp); | | 261 | allhosts(transp); |
264 | else | | 262 | else |
265 | rawtest(NULL); | | 263 | rawtest(NULL); |
266 | } else { | | 264 | } else { |
267 | for (; optind < argc; optind++) { | | 265 | for (; optind < argc; optind++) { |
268 | if (transp) | | 266 | if (transp) |
269 | s == 0 ? | | 267 | s == 0 ? |
270 | onehost(argv[optind], transp) : | | 268 | onehost(argv[optind], transp) : |
271 | regtest(argv[optind], transp, "1", p); | | 269 | regtest(argv[optind], transp, "1", p); |
272 | else | | 270 | else |
273 | rawtest(argv[optind]); | | 271 | rawtest(argv[optind]); |
274 | } | | 272 | } |
275 | } | | 273 | } |
276 | | | 274 | |
277 | return EXIT_SUCCESS; | | 275 | return EXIT_SUCCESS; |
278 | } | | 276 | } |
279 | | | 277 | |
280 | #else | | 278 | #else |
281 | | | 279 | |
282 | ATF_TC(get_svc_addr_tcp); | | 280 | ATF_TC(get_svc_addr_tcp); |
283 | ATF_TC_HEAD(get_svc_addr_tcp, tc) | | 281 | ATF_TC_HEAD(get_svc_addr_tcp, tc) |
284 | { | | 282 | { |
285 | atf_tc_set_md_var(tc, "descr", "Checks CLGET_SVC_ADDR for tcp"); | | 283 | atf_tc_set_md_var(tc, "descr", "Checks CLGET_SVC_ADDR for tcp"); |
286 | | | 284 | |
287 | } | | 285 | } |
288 | | | 286 | |
289 | ATF_TC_BODY(get_svc_addr_tcp, tc) | | 287 | ATF_TC_BODY(get_svc_addr_tcp, tc) |
290 | { | | 288 | { |
291 | onehost("localhost", "tcp"); | | 289 | onehost("localhost", "tcp"); |
292 | | | 290 | |
293 | } | | 291 | } |
294 | | | 292 | |
295 | ATF_TC(get_svc_addr_udp); | | 293 | ATF_TC(get_svc_addr_udp); |
296 | ATF_TC_HEAD(get_svc_addr_udp, tc) | | 294 | ATF_TC_HEAD(get_svc_addr_udp, tc) |
297 | { | | 295 | { |
298 | atf_tc_set_md_var(tc, "descr", "Checks CLGET_SVC_ADDR for udp"); | | 296 | atf_tc_set_md_var(tc, "descr", "Checks CLGET_SVC_ADDR for udp"); |
299 | } | | 297 | } |
300 | | | 298 | |
301 | ATF_TC_BODY(get_svc_addr_udp, tc) | | 299 | ATF_TC_BODY(get_svc_addr_udp, tc) |
302 | { | | 300 | { |
303 | onehost("localhost", "udp"); | | 301 | onehost("localhost", "udp"); |
304 | | | 302 | |
305 | } | | 303 | } |
306 | | | 304 | |
307 | ATF_TC(raw); | | 305 | ATF_TC(raw); |
308 | ATF_TC_HEAD(raw, tc) | | 306 | ATF_TC_HEAD(raw, tc) |
309 | { | | 307 | { |
310 | atf_tc_set_md_var(tc, "descr", "Checks svc raw"); | | 308 | atf_tc_set_md_var(tc, "descr", "Checks svc raw"); |
311 | } | | 309 | } |
312 | | | 310 | |
313 | ATF_TC_BODY(raw, tc) | | 311 | ATF_TC_BODY(raw, tc) |
314 | { | | 312 | { |
315 | rawtest(NULL); | | 313 | rawtest(NULL); |
316 | | | 314 | |
317 | } | | 315 | } |
318 | | | 316 | |
319 | ATF_TC(tcp); | | 317 | ATF_TC(tcp); |
320 | ATF_TC_HEAD(tcp, tc) | | 318 | ATF_TC_HEAD(tcp, tc) |
321 | { | | 319 | { |
322 | atf_tc_set_md_var(tc, "descr", "Checks svc tcp (select)"); | | 320 | atf_tc_set_md_var(tc, "descr", "Checks svc tcp (select)"); |
323 | } | | 321 | } |
324 | | | 322 | |
325 | ATF_TC_BODY(tcp, tc) | | 323 | ATF_TC_BODY(tcp, tc) |
326 | { | | 324 | { |
327 | regtest("localhost", "tcp", 1, 0); | | 325 | regtest("localhost", "tcp", "1", 0); |
328 | | | 326 | |
329 | } | | 327 | } |
330 | | | 328 | |
331 | ATF_TC(udp); | | 329 | ATF_TC(udp); |
332 | ATF_TC_HEAD(udp, tc) | | 330 | ATF_TC_HEAD(udp, tc) |
333 | { | | 331 | { |
334 | atf_tc_set_md_var(tc, "descr", "Checks svc udp (select)"); | | 332 | atf_tc_set_md_var(tc, "descr", "Checks svc udp (select)"); |
335 | } | | 333 | } |
336 | | | 334 | |
337 | ATF_TC_BODY(udp, tc) | | 335 | ATF_TC_BODY(udp, tc) |
338 | { | | 336 | { |
339 | regtest("localhost", "udp", 1, 0); | | 337 | regtest("localhost", "udp", "1", 0); |
340 | | | 338 | |
341 | } | | 339 | } |
342 | | | 340 | |
343 | ATF_TC(tcp_poll); | | 341 | ATF_TC(tcp_poll); |
344 | ATF_TC_HEAD(tcp_poll, tc) | | 342 | ATF_TC_HEAD(tcp_poll, tc) |
345 | { | | 343 | { |
346 | atf_tc_set_md_var(tc, "descr", "Checks svc tcp (poll)"); | | 344 | atf_tc_set_md_var(tc, "descr", "Checks svc tcp (poll)"); |
347 | } | | 345 | } |
348 | | | 346 | |
349 | ATF_TC_BODY(tcp_poll, tc) | | 347 | ATF_TC_BODY(tcp_poll, tc) |
350 | { | | 348 | { |
351 | regtest("localhost", "tcp", 1, 1); | | 349 | regtest("localhost", "tcp", "1", 1); |
352 | | | 350 | |
353 | } | | 351 | } |
354 | | | 352 | |
355 | ATF_TC(udp_poll); | | 353 | ATF_TC(udp_poll); |
356 | ATF_TC_HEAD(udp_poll, tc) | | 354 | ATF_TC_HEAD(udp_poll, tc) |
357 | { | | 355 | { |
358 | atf_tc_set_md_var(tc, "descr", "Checks svc udp (poll)"); | | 356 | atf_tc_set_md_var(tc, "descr", "Checks svc udp (poll)"); |
359 | } | | 357 | } |
360 | | | 358 | |
361 | ATF_TC_BODY(udp_poll, tc) | | 359 | ATF_TC_BODY(udp_poll, tc) |
362 | { | | 360 | { |
363 | regtest("localhost", "udp", 1, 1); | | 361 | regtest("localhost", "udp", "1", 1); |
364 | | | 362 | |
365 | } | | 363 | } |
366 | | | 364 | |
367 | ATF_TP_ADD_TCS(tp) | | 365 | ATF_TP_ADD_TCS(tp) |
368 | { | | 366 | { |
369 | ATF_TP_ADD_TC(tp, get_svc_addr_udp); | | 367 | ATF_TP_ADD_TC(tp, get_svc_addr_udp); |
370 | ATF_TP_ADD_TC(tp, get_svc_addr_tcp); | | 368 | ATF_TP_ADD_TC(tp, get_svc_addr_tcp); |
371 | ATF_TP_ADD_TC(tp, raw); | | 369 | ATF_TP_ADD_TC(tp, raw); |
372 | ATF_TP_ADD_TC(tp, tcp); | | 370 | ATF_TP_ADD_TC(tp, tcp); |
373 | ATF_TP_ADD_TC(tp, udp); | | 371 | ATF_TP_ADD_TC(tp, udp); |
374 | ATF_TP_ADD_TC(tp, tcp_poll); | | 372 | ATF_TP_ADD_TC(tp, tcp_poll); |
375 | ATF_TP_ADD_TC(tp, udp_poll); | | 373 | ATF_TP_ADD_TC(tp, udp_poll); |
376 | | | 374 | |
377 | return atf_no_error(); | | 375 | return atf_no_error(); |
378 | } | | 376 | } |
379 | | | 377 | |
380 | #endif | | 378 | #endif |