1168754Sbushman/*-
2168754Sbushman * Copyright (c) 2006 Michael Bushkov <bushman@freebsd.org>
3251867Seadler * All rights reserved.
4168754Sbushman *
5168754Sbushman * Redistribution and use in source and binary forms, with or without
6168754Sbushman * modification, are permitted provided that the following conditions
7168754Sbushman * are met:
8168754Sbushman * 1. Redistributions of source code must retain the above copyright
9168754Sbushman *    notice, this list of conditions and the following disclaimer.
10168754Sbushman * 2. Redistributions in binary form must reproduce the above copyright
11168754Sbushman *    notice, this list of conditions and the following disclaimer in the
12168754Sbushman *    documentation and/or other materials provided with the distribution.
13168754Sbushman *
14168754Sbushman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15168754Sbushman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16168754Sbushman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17168754Sbushman * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18168754Sbushman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19168754Sbushman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20168754Sbushman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21168754Sbushman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22168754Sbushman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23168754Sbushman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24168754Sbushman * SUCH DAMAGE.
25168754Sbushman *
26168754Sbushman */
27168754Sbushman
28168754Sbushman#include <sys/cdefs.h>
29168754Sbushman__FBSDID("$FreeBSD: releng/10.3/lib/libc/tests/nss/getrpc_test.c 292323 2015-12-16 08:09:03Z ngie $");
30168754Sbushman
31168754Sbushman#include <arpa/inet.h>
32168754Sbushman#include <rpc/rpc.h>
33168754Sbushman#include <errno.h>
34168754Sbushman#include <stdio.h>
35168754Sbushman#include <stdlib.h>
36168754Sbushman#include <string.h>
37168754Sbushman#include <stringlist.h>
38168754Sbushman#include <unistd.h>
39292323Sngie
40292323Sngie#include <atf-c.h>
41292323Sngie
42168754Sbushman#include "testutil.h"
43168754Sbushman
44168754Sbushmanenum test_methods {
45168754Sbushman	TEST_GETRPCENT,
46168754Sbushman	TEST_GETRPCBYNAME,
47168754Sbushman	TEST_GETRPCBYNUMBER,
48168754Sbushman	TEST_GETRPCENT_2PASS,
49168754Sbushman	TEST_BUILD_SNAPSHOT
50168754Sbushman};
51168754Sbushman
52168754SbushmanDECLARE_TEST_DATA(rpcent)
53168754SbushmanDECLARE_TEST_FILE_SNAPSHOT(rpcent)
54168754SbushmanDECLARE_1PASS_TEST(rpcent)
55168754SbushmanDECLARE_2PASS_TEST(rpcent)
56168754Sbushman
57168754Sbushmanstatic void clone_rpcent(struct rpcent *, struct rpcent const *);
58168754Sbushmanstatic int compare_rpcent(struct rpcent *, struct rpcent *, void *);
59168754Sbushmanstatic void dump_rpcent(struct rpcent *);
60168754Sbushmanstatic void free_rpcent(struct rpcent *);
61168754Sbushman
62168754Sbushmanstatic void sdump_rpcent(struct rpcent *, char *, size_t);
63168754Sbushmanstatic int rpcent_read_snapshot_func(struct rpcent *, char *);
64168754Sbushman
65291363Sngiestatic int rpcent_check_ambiguity(struct rpcent_test_data *,
66168754Sbushman	struct rpcent *);
67168754Sbushmanstatic int rpcent_fill_test_data(struct rpcent_test_data *);
68168754Sbushmanstatic int rpcent_test_correctness(struct rpcent *, void *);
69168754Sbushmanstatic int rpcent_test_getrpcbyname(struct rpcent *, void *);
70168754Sbushmanstatic int rpcent_test_getrpcbynumber(struct rpcent *, void *);
71168754Sbushmanstatic int rpcent_test_getrpcent(struct rpcent *, void *);
72291363Sngie
73168754Sbushmanstatic void usage(void)  __attribute__((__noreturn__));
74168754Sbushman
75168754SbushmanIMPLEMENT_TEST_DATA(rpcent)
76168754SbushmanIMPLEMENT_TEST_FILE_SNAPSHOT(rpcent)
77168754SbushmanIMPLEMENT_1PASS_TEST(rpcent)
78168754SbushmanIMPLEMENT_2PASS_TEST(rpcent)
79168754Sbushman
80168754Sbushmanstatic void
81168754Sbushmanclone_rpcent(struct rpcent *dest, struct rpcent const *src)
82168754Sbushman{
83292323Sngie	ATF_REQUIRE(dest != NULL);
84292323Sngie	ATF_REQUIRE(src != NULL);
85291363Sngie
86168754Sbushman	char **cp;
87168754Sbushman	int aliases_num;
88291363Sngie
89168754Sbushman	memset(dest, 0, sizeof(struct rpcent));
90291363Sngie
91168754Sbushman	if (src->r_name != NULL) {
92168754Sbushman		dest->r_name = strdup(src->r_name);
93292323Sngie		ATF_REQUIRE(dest->r_name != NULL);
94168754Sbushman	}
95291363Sngie
96168754Sbushman	dest->r_number = src->r_number;
97291363Sngie
98168754Sbushman	if (src->r_aliases != NULL) {
99168754Sbushman		aliases_num = 0;
100168754Sbushman		for (cp = src->r_aliases; *cp; ++cp)
101168754Sbushman			++aliases_num;
102291363Sngie
103292323Sngie		dest->r_aliases = calloc(1, (aliases_num + 1) * sizeof(char *));
104292323Sngie		ATF_REQUIRE(dest->r_aliases != NULL);
105291363Sngie
106168754Sbushman		for (cp = src->r_aliases; *cp; ++cp) {
107168754Sbushman			dest->r_aliases[cp - src->r_aliases] = strdup(*cp);
108292323Sngie			ATF_REQUIRE(dest->r_aliases[cp - src->r_aliases] != NULL);
109168754Sbushman		}
110168754Sbushman	}
111168754Sbushman}
112168754Sbushman
113291363Sngiestatic void
114168754Sbushmanfree_rpcent(struct rpcent *rpc)
115168754Sbushman{
116168754Sbushman	char **cp;
117291363Sngie
118292323Sngie	ATF_REQUIRE(rpc != NULL);
119291363Sngie
120168754Sbushman	free(rpc->r_name);
121291363Sngie
122168754Sbushman	for (cp = rpc->r_aliases; *cp; ++cp)
123168754Sbushman		free(*cp);
124168754Sbushman	free(rpc->r_aliases);
125168754Sbushman}
126168754Sbushman
127291363Sngiestatic  int
128168754Sbushmancompare_rpcent(struct rpcent *rpc1, struct rpcent *rpc2, void *mdata)
129168754Sbushman{
130168754Sbushman	char **c1, **c2;
131291363Sngie
132168754Sbushman	if (rpc1 == rpc2)
133168754Sbushman		return 0;
134291363Sngie
135168754Sbushman	if ((rpc1 == NULL) || (rpc2 == NULL))
136168754Sbushman		goto errfin;
137291363Sngie
138168754Sbushman	if ((strcmp(rpc1->r_name, rpc2->r_name) != 0) ||
139168754Sbushman		(rpc1->r_number != rpc2->r_number))
140168754Sbushman			goto errfin;
141291363Sngie
142168754Sbushman	c1 = rpc1->r_aliases;
143168754Sbushman	c2 = rpc2->r_aliases;
144291363Sngie
145168754Sbushman	if ((rpc1->r_aliases == NULL) || (rpc2->r_aliases == NULL))
146168754Sbushman		goto errfin;
147291363Sngie
148168754Sbushman	for (;*c1 && *c2; ++c1, ++c2)
149168754Sbushman		if (strcmp(*c1, *c2) != 0)
150168754Sbushman			goto errfin;
151291363Sngie
152168754Sbushman	if ((*c1 != '\0') || (*c2 != '\0'))
153168754Sbushman		goto errfin;
154291363Sngie
155168754Sbushman	return 0;
156291363Sngie
157168754Sbushmanerrfin:
158292323Sngie	if (mdata == NULL) {
159168754Sbushman		printf("following structures are not equal:\n");
160168754Sbushman		dump_rpcent(rpc1);
161168754Sbushman		dump_rpcent(rpc2);
162168754Sbushman	}
163168754Sbushman
164168754Sbushman	return (-1);
165168754Sbushman}
166168754Sbushman
167168754Sbushmanstatic void
168168754Sbushmansdump_rpcent(struct rpcent *rpc, char *buffer, size_t buflen)
169168754Sbushman{
170168754Sbushman	char **cp;
171168754Sbushman	int written;
172291363Sngie
173168754Sbushman	written = snprintf(buffer, buflen, "%s %d",
174291363Sngie		rpc->r_name, rpc->r_number);
175168754Sbushman	buffer += written;
176168754Sbushman	if (written > buflen)
177168754Sbushman		return;
178168754Sbushman	buflen -= written;
179291363Sngie
180168754Sbushman	if (rpc->r_aliases != NULL) {
181168754Sbushman		if (*(rpc->r_aliases) != '\0') {
182168754Sbushman			for (cp = rpc->r_aliases; *cp; ++cp) {
183168754Sbushman				written = snprintf(buffer, buflen, " %s",*cp);
184168754Sbushman				buffer += written;
185168754Sbushman				if (written > buflen)
186168754Sbushman					return;
187168754Sbushman				buflen -= written;
188291363Sngie
189168754Sbushman				if (buflen == 0)
190291363Sngie					return;
191168754Sbushman			}
192168754Sbushman		} else
193168754Sbushman			snprintf(buffer, buflen, " noaliases");
194168754Sbushman	} else
195168754Sbushman		snprintf(buffer, buflen, " (null)");
196168754Sbushman}
197168754Sbushman
198168754Sbushmanstatic int
199168754Sbushmanrpcent_read_snapshot_func(struct rpcent *rpc, char *line)
200168754Sbushman{
201168754Sbushman	StringList *sl;
202168754Sbushman	char *s, *ps, *ts;
203168754Sbushman	int i;
204168754Sbushman
205292323Sngie	printf("1 line read from snapshot:\n%s\n", line);
206291363Sngie
207168754Sbushman	i = 0;
208168754Sbushman	sl = NULL;
209168754Sbushman	ps = line;
210168754Sbushman	memset(rpc, 0, sizeof(struct rpcent));
211292323Sngie	while ((s = strsep(&ps, " ")) != NULL) {
212168754Sbushman		switch (i) {
213292323Sngie		case 0:
214168754Sbushman				rpc->r_name = strdup(s);
215292323Sngie				ATF_REQUIRE(rpc->r_name != NULL);
216168754Sbushman			break;
217168754Sbushman
218292323Sngie		case 1:
219292323Sngie			rpc->r_number = (int)strtol(s, &ts, 10);
220292323Sngie			if (*ts != '\0') {
221292323Sngie				free(rpc->r_name);
222292323Sngie				return (-1);
223292323Sngie			}
224168754Sbushman			break;
225168754Sbushman
226292323Sngie		default:
227292323Sngie			if (sl == NULL) {
228292323Sngie				if (strcmp(s, "(null)") == 0)
229292323Sngie					return (0);
230291363Sngie
231292323Sngie				sl = sl_init();
232292323Sngie				ATF_REQUIRE(sl != NULL);
233291363Sngie
234292323Sngie				if (strcmp(s, "noaliases") != 0) {
235168754Sbushman					ts = strdup(s);
236292323Sngie					ATF_REQUIRE(ts != NULL);
237168754Sbushman					sl_add(sl, ts);
238168754Sbushman				}
239292323Sngie			} else {
240292323Sngie				ts = strdup(s);
241292323Sngie				ATF_REQUIRE(ts != NULL);
242292323Sngie				sl_add(sl, ts);
243292323Sngie			}
244291363Sngie			break;
245292323Sngie		}
246292323Sngie		i++;
247168754Sbushman	}
248168754Sbushman
249168754Sbushman	if (i < 3) {
250168754Sbushman		free(rpc->r_name);
251168754Sbushman		memset(rpc, 0, sizeof(struct rpcent));
252168754Sbushman		return (-1);
253168754Sbushman	}
254291363Sngie
255168754Sbushman	sl_add(sl, NULL);
256168754Sbushman	rpc->r_aliases = sl->sl_str;
257168754Sbushman
258168754Sbushman	/* NOTE: is it a dirty hack or not? */
259291363Sngie	free(sl);
260168754Sbushman	return (0);
261168754Sbushman}
262168754Sbushman
263291363Sngiestatic void
264168754Sbushmandump_rpcent(struct rpcent *result)
265168754Sbushman{
266168754Sbushman	if (result != NULL) {
267168754Sbushman		char buffer[1024];
268168754Sbushman		sdump_rpcent(result, buffer, sizeof(buffer));
269168754Sbushman		printf("%s\n", buffer);
270168754Sbushman	} else
271168754Sbushman		printf("(null)\n");
272168754Sbushman}
273168754Sbushman
274168754Sbushmanstatic int
275168754Sbushmanrpcent_fill_test_data(struct rpcent_test_data *td)
276168754Sbushman{
277168754Sbushman	struct rpcent *rpc;
278291363Sngie
279168754Sbushman	setrpcent(1);
280168754Sbushman	while ((rpc = getrpcent()) != NULL) {
281168754Sbushman		if (rpcent_test_correctness(rpc, NULL) == 0)
282168754Sbushman			TEST_DATA_APPEND(rpcent, td, rpc);
283168754Sbushman		else
284168754Sbushman			return (-1);
285168754Sbushman	}
286168754Sbushman	endrpcent();
287291363Sngie
288168754Sbushman	return (0);
289168754Sbushman}
290168754Sbushman
291168754Sbushmanstatic int
292168754Sbushmanrpcent_test_correctness(struct rpcent *rpc, void *mdata)
293168754Sbushman{
294291363Sngie
295292323Sngie	printf("testing correctness with the following data:\n");
296292323Sngie	dump_rpcent(rpc);
297292323Sngie
298168754Sbushman	if (rpc == NULL)
299168754Sbushman		goto errfin;
300291363Sngie
301168754Sbushman	if (rpc->r_name == NULL)
302168754Sbushman		goto errfin;
303291363Sngie
304168754Sbushman	if (rpc->r_number < 0)
305168754Sbushman		goto errfin;
306291363Sngie
307168754Sbushman	if (rpc->r_aliases == NULL)
308168754Sbushman		goto errfin;
309291363Sngie
310292323Sngie	printf("correct\n");
311291363Sngie
312291363Sngie	return (0);
313168754Sbushmanerrfin:
314292323Sngie	printf("incorrect\n");
315291363Sngie
316168754Sbushman	return (-1);
317168754Sbushman}
318168754Sbushman
319168754Sbushman/* rpcent_check_ambiguity() is needed when one port+rpc is associated with
320168754Sbushman * more than one peice (these cases are usually marked as PROBLEM in
321291363Sngie * /etc/peices. This functions is needed also when one peice+rpc is
322168754Sbushman * associated with several ports. We have to check all the rpcent structures
323168754Sbushman * to make sure that rpc really exists and correct */
324168754Sbushmanstatic int
325168754Sbushmanrpcent_check_ambiguity(struct rpcent_test_data *td, struct rpcent *rpc)
326168754Sbushman{
327291363Sngie
328168754Sbushman	return (TEST_DATA_FIND(rpcent, td, rpc, compare_rpcent,
329168754Sbushman		NULL) != NULL ? 0 : -1);
330168754Sbushman}
331168754Sbushman
332168754Sbushmanstatic int
333168754Sbushmanrpcent_test_getrpcbyname(struct rpcent *rpc_model, void *mdata)
334168754Sbushman{
335168754Sbushman	char **alias;
336168754Sbushman	struct rpcent *rpc;
337291363Sngie
338292323Sngie	printf("testing getrpcbyname() with the following data:\n");
339292323Sngie	dump_rpcent(rpc_model);
340168754Sbushman
341168754Sbushman	rpc = getrpcbyname(rpc_model->r_name);
342168754Sbushman	if (rpcent_test_correctness(rpc, NULL) != 0)
343168754Sbushman		goto errfin;
344291363Sngie
345168754Sbushman	if ((compare_rpcent(rpc, rpc_model, NULL) != 0) &&
346291363Sngie	    (rpcent_check_ambiguity((struct rpcent_test_data *)mdata, rpc)
347168754Sbushman	    !=0))
348168754Sbushman	    goto errfin;
349291363Sngie
350168754Sbushman	for (alias = rpc_model->r_aliases; *alias; ++alias) {
351168754Sbushman		rpc = getrpcbyname(*alias);
352291363Sngie
353168754Sbushman		if (rpcent_test_correctness(rpc, NULL) != 0)
354168754Sbushman			goto errfin;
355291363Sngie
356168754Sbushman		if ((compare_rpcent(rpc, rpc_model, NULL) != 0) &&
357168754Sbushman		    (rpcent_check_ambiguity(
358168754Sbushman		    (struct rpcent_test_data *)mdata, rpc) != 0))
359168754Sbushman		    goto errfin;
360168754Sbushman	}
361291363Sngie
362292323Sngie	printf("ok\n");
363168754Sbushman	return (0);
364291363Sngie
365168754Sbushmanerrfin:
366292323Sngie	printf("not ok\n");
367291363Sngie
368168754Sbushman	return (-1);
369168754Sbushman}
370168754Sbushman
371168754Sbushmanstatic int
372168754Sbushmanrpcent_test_getrpcbynumber(struct rpcent *rpc_model, void *mdata)
373168754Sbushman{
374168754Sbushman	struct rpcent *rpc;
375291363Sngie
376292323Sngie	printf("testing getrpcbyport() with the following data...\n");
377292323Sngie	dump_rpcent(rpc_model);
378291363Sngie
379168754Sbushman	rpc = getrpcbynumber(rpc_model->r_number);
380292323Sngie	if (rpcent_test_correctness(rpc, NULL) != 0 ||
381292323Sngie	    (compare_rpcent(rpc, rpc_model, NULL) != 0 &&
382292323Sngie	     rpcent_check_ambiguity((struct rpcent_test_data *)mdata, rpc)
383292323Sngie	    != 0)) {
384168754Sbushman		printf("not ok\n");
385292323Sngie		return (-1);
386168754Sbushman	} else {
387168754Sbushman		printf("ok\n");
388292323Sngie		return (0);
389168754Sbushman	}
390168754Sbushman}
391168754Sbushman
392291363Sngiestatic int
393168754Sbushmanrpcent_test_getrpcent(struct rpcent *rpc, void *mdata)
394168754Sbushman{
395292323Sngie
396292323Sngie	/*
397292323Sngie	 * Only correctness can be checked when doing 1-pass test for
398292323Sngie	 * getrpcent().
399292323Sngie	 */
400168754Sbushman	return (rpcent_test_correctness(rpc, NULL));
401168754Sbushman}
402168754Sbushman
403168754Sbushmanint
404292323Sngierun_tests(const char *snapshot_file, enum test_methods method)
405168754Sbushman{
406168754Sbushman	struct rpcent_test_data td, td_snap, td_2pass;
407168754Sbushman	int rv;
408291363Sngie
409168754Sbushman	TEST_DATA_INIT(rpcent, &td, clone_rpcent, free_rpcent);
410168754Sbushman	TEST_DATA_INIT(rpcent, &td_snap, clone_rpcent, free_rpcent);
411168754Sbushman	if (snapshot_file != NULL) {
412291363Sngie		if (access(snapshot_file, W_OK | R_OK) != 0) {
413168754Sbushman			if (errno == ENOENT)
414168754Sbushman				method = TEST_BUILD_SNAPSHOT;
415168754Sbushman			else {
416292323Sngie				printf("can't access the file %s\n",
417292323Sngie				    snapshot_file);
418291363Sngie
419168754Sbushman				rv = -1;
420168754Sbushman				goto fin;
421168754Sbushman			}
422168754Sbushman		} else {
423168754Sbushman			if (method == TEST_BUILD_SNAPSHOT) {
424168754Sbushman				rv = 0;
425168754Sbushman				goto fin;
426168754Sbushman			}
427291363Sngie
428168754Sbushman			TEST_SNAPSHOT_FILE_READ(rpcent, snapshot_file,
429168754Sbushman				&td_snap, rpcent_read_snapshot_func);
430168754Sbushman		}
431168754Sbushman	}
432291363Sngie
433168754Sbushman	rv = rpcent_fill_test_data(&td);
434168754Sbushman	if (rv == -1)
435168754Sbushman		return (-1);
436168754Sbushman	switch (method) {
437168754Sbushman	case TEST_GETRPCBYNAME:
438168754Sbushman		if (snapshot_file == NULL)
439168754Sbushman			rv = DO_1PASS_TEST(rpcent, &td,
440168754Sbushman				rpcent_test_getrpcbyname, (void *)&td);
441168754Sbushman		else
442291363Sngie			rv = DO_1PASS_TEST(rpcent, &td_snap,
443168754Sbushman				rpcent_test_getrpcbyname, (void *)&td_snap);
444168754Sbushman		break;
445168754Sbushman	case TEST_GETRPCBYNUMBER:
446168754Sbushman		if (snapshot_file == NULL)
447168754Sbushman			rv = DO_1PASS_TEST(rpcent, &td,
448168754Sbushman				rpcent_test_getrpcbynumber, (void *)&td);
449168754Sbushman		else
450291363Sngie			rv = DO_1PASS_TEST(rpcent, &td_snap,
451168754Sbushman				rpcent_test_getrpcbynumber, (void *)&td_snap);
452168754Sbushman		break;
453168754Sbushman	case TEST_GETRPCENT:
454168754Sbushman		if (snapshot_file == NULL)
455168754Sbushman			rv = DO_1PASS_TEST(rpcent, &td, rpcent_test_getrpcent,
456168754Sbushman				(void *)&td);
457168754Sbushman		else
458168754Sbushman			rv = DO_2PASS_TEST(rpcent, &td, &td_snap,
459168754Sbushman				compare_rpcent, NULL);
460168754Sbushman		break;
461168754Sbushman	case TEST_GETRPCENT_2PASS:
462168754Sbushman			TEST_DATA_INIT(rpcent, &td_2pass, clone_rpcent, free_rpcent);
463291363Sngie			rv = rpcent_fill_test_data(&td_2pass);
464168754Sbushman			if (rv != -1)
465168754Sbushman				rv = DO_2PASS_TEST(rpcent, &td, &td_2pass,
466168754Sbushman					compare_rpcent, NULL);
467168754Sbushman			TEST_DATA_DESTROY(rpcent, &td_2pass);
468168754Sbushman		break;
469168754Sbushman	case TEST_BUILD_SNAPSHOT:
470168754Sbushman		if (snapshot_file != NULL)
471291363Sngie		    rv = TEST_SNAPSHOT_FILE_WRITE(rpcent, snapshot_file, &td,
472168754Sbushman			sdump_rpcent);
473168754Sbushman		break;
474168754Sbushman	default:
475168754Sbushman		rv = 0;
476168754Sbushman		break;
477292323Sngie	}
478168754Sbushman
479168754Sbushmanfin:
480168754Sbushman	TEST_DATA_DESTROY(rpcent, &td_snap);
481168754Sbushman	TEST_DATA_DESTROY(rpcent, &td);
482292323Sngie
483168754Sbushman	return (rv);
484168754Sbushman}
485292323Sngie
486292323Sngie#define	SNAPSHOT_FILE	"snapshot_rpc"
487292323Sngie
488292323SngieATF_TC_WITHOUT_HEAD(build_snapshot);
489292323SngieATF_TC_BODY(build_snapshot, tc)
490292323Sngie{
491292323Sngie
492292323Sngie	ATF_REQUIRE(run_tests(SNAPSHOT_FILE, TEST_BUILD_SNAPSHOT) == 0);
493292323Sngie}
494292323Sngie
495292323SngieATF_TC_WITHOUT_HEAD(getrpcbyname);
496292323SngieATF_TC_BODY(getrpcbyname, tc)
497292323Sngie{
498292323Sngie
499292323Sngie	ATF_REQUIRE(run_tests(NULL, TEST_GETRPCBYNAME) == 0);
500292323Sngie}
501292323Sngie
502292323SngieATF_TC_WITHOUT_HEAD(getrpcbyname_with_snapshot);
503292323SngieATF_TC_BODY(getrpcbyname_with_snapshot, tc)
504292323Sngie{
505292323Sngie
506292323Sngie	ATF_REQUIRE(run_tests(SNAPSHOT_FILE, TEST_BUILD_SNAPSHOT) == 0);
507292323Sngie	ATF_REQUIRE(run_tests(SNAPSHOT_FILE, TEST_GETRPCBYNAME) == 0);
508292323Sngie}
509292323Sngie
510292323SngieATF_TC_WITHOUT_HEAD(getrpcbynumber);
511292323SngieATF_TC_BODY(getrpcbynumber, tc)
512292323Sngie{
513292323Sngie
514292323Sngie	ATF_REQUIRE(run_tests(NULL, TEST_GETRPCBYNUMBER) == 0);
515292323Sngie}
516292323Sngie
517292323SngieATF_TC_WITHOUT_HEAD(getrpcbynumber_with_snapshot);
518292323SngieATF_TC_BODY(getrpcbynumber_with_snapshot, tc)
519292323Sngie{
520292323Sngie
521292323Sngie	ATF_REQUIRE(run_tests(SNAPSHOT_FILE, TEST_BUILD_SNAPSHOT) == 0);
522292323Sngie	ATF_REQUIRE(run_tests(SNAPSHOT_FILE, TEST_GETRPCBYNUMBER) == 0);
523292323Sngie}
524292323Sngie
525292323SngieATF_TC_WITHOUT_HEAD(getrpcbyent);
526292323SngieATF_TC_BODY(getrpcbyent, tc)
527292323Sngie{
528292323Sngie
529292323Sngie	ATF_REQUIRE(run_tests(NULL, TEST_GETRPCENT) == 0);
530292323Sngie}
531292323Sngie
532292323SngieATF_TC_WITHOUT_HEAD(getrpcbyent_with_snapshot);
533292323SngieATF_TC_BODY(getrpcbyent_with_snapshot, tc)
534292323Sngie{
535292323Sngie
536292323Sngie	ATF_REQUIRE(run_tests(SNAPSHOT_FILE, TEST_BUILD_SNAPSHOT) == 0);
537292323Sngie	ATF_REQUIRE(run_tests(SNAPSHOT_FILE, TEST_GETRPCENT) == 0);
538292323Sngie}
539292323Sngie
540292323SngieATF_TC_WITHOUT_HEAD(getrpcbyent_with_two_pass);
541292323SngieATF_TC_BODY(getrpcbyent_with_two_pass, tc)
542292323Sngie{
543292323Sngie
544292323Sngie	ATF_REQUIRE(run_tests(NULL, TEST_GETRPCENT_2PASS) == 0);
545292323Sngie}
546292323Sngie
547292323SngieATF_TP_ADD_TCS(tp)
548292323Sngie{
549292323Sngie
550292323Sngie	ATF_TP_ADD_TC(tp, build_snapshot);
551292323Sngie	ATF_TP_ADD_TC(tp, getrpcbyname);
552292323Sngie	ATF_TP_ADD_TC(tp, getrpcbyname_with_snapshot);
553292323Sngie	ATF_TP_ADD_TC(tp, getrpcbynumber);
554292323Sngie	ATF_TP_ADD_TC(tp, getrpcbynumber_with_snapshot);
555292323Sngie	ATF_TP_ADD_TC(tp, getrpcbyent);
556292323Sngie	ATF_TP_ADD_TC(tp, getrpcbyent_with_snapshot);
557292323Sngie	ATF_TP_ADD_TC(tp, getrpcbyent_with_two_pass);
558292323Sngie
559292323Sngie	return (atf_no_error());
560292323Sngie}
561