Lines Matching +full:rpc +full:- +full:if
1 /*-
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <rpc/rpc.h>
37 #include <atf-c.h>
86 if (src->r_name != NULL) { in IMPLEMENT_TEST_FILE_SNAPSHOT()
87 dest->r_name = strdup(src->r_name); in IMPLEMENT_TEST_FILE_SNAPSHOT()
88 ATF_REQUIRE(dest->r_name != NULL); in IMPLEMENT_TEST_FILE_SNAPSHOT()
91 dest->r_number = src->r_number; in IMPLEMENT_TEST_FILE_SNAPSHOT()
93 if (src->r_aliases != NULL) { in IMPLEMENT_TEST_FILE_SNAPSHOT()
95 for (cp = src->r_aliases; *cp; ++cp) in IMPLEMENT_TEST_FILE_SNAPSHOT()
98 dest->r_aliases = calloc(aliases_num + 1, sizeof(char *)); in IMPLEMENT_TEST_FILE_SNAPSHOT()
99 ATF_REQUIRE(dest->r_aliases != NULL); in IMPLEMENT_TEST_FILE_SNAPSHOT()
101 for (cp = src->r_aliases; *cp; ++cp) { in IMPLEMENT_TEST_FILE_SNAPSHOT()
102 dest->r_aliases[cp - src->r_aliases] = strdup(*cp); in IMPLEMENT_TEST_FILE_SNAPSHOT()
103 ATF_REQUIRE(dest->r_aliases[cp - src->r_aliases] != NULL); in IMPLEMENT_TEST_FILE_SNAPSHOT()
109 free_rpcent(struct rpcent *rpc) in free_rpcent() argument
113 ATF_REQUIRE(rpc != NULL); in free_rpcent()
115 free(rpc->r_name); in free_rpcent()
117 for (cp = rpc->r_aliases; *cp; ++cp) in free_rpcent()
119 free(rpc->r_aliases); in free_rpcent()
127 if (rpc1 == rpc2) in compare_rpcent()
130 if ((rpc1 == NULL) || (rpc2 == NULL)) in compare_rpcent()
133 if ((strcmp(rpc1->r_name, rpc2->r_name) != 0) || in compare_rpcent()
134 (rpc1->r_number != rpc2->r_number)) in compare_rpcent()
137 c1 = rpc1->r_aliases; in compare_rpcent()
138 c2 = rpc2->r_aliases; in compare_rpcent()
140 if ((rpc1->r_aliases == NULL) || (rpc2->r_aliases == NULL)) in compare_rpcent()
144 if (strcmp(*c1, *c2) != 0) in compare_rpcent()
147 if ((*c1 != NULL) || (*c2 != NULL)) in compare_rpcent()
153 if (mdata == NULL) { in compare_rpcent()
159 return (-1); in compare_rpcent()
163 sdump_rpcent(struct rpcent *rpc, char *buffer, size_t buflen) in sdump_rpcent() argument
169 rpc->r_name, rpc->r_number); in sdump_rpcent()
171 if (written > (int)buflen) in sdump_rpcent()
173 buflen -= written; in sdump_rpcent()
175 if (rpc->r_aliases != NULL) { in sdump_rpcent()
176 if (*(rpc->r_aliases) != NULL) { in sdump_rpcent()
177 for (cp = rpc->r_aliases; *cp; ++cp) { in sdump_rpcent()
180 if (written > (int)buflen) in sdump_rpcent()
182 buflen -= written; in sdump_rpcent()
184 if (buflen == 0) in sdump_rpcent()
194 rpcent_read_snapshot_func(struct rpcent *rpc, char *line) in rpcent_read_snapshot_func() argument
205 memset(rpc, 0, sizeof(struct rpcent)); in rpcent_read_snapshot_func()
209 rpc->r_name = strdup(s); in rpcent_read_snapshot_func()
210 ATF_REQUIRE(rpc->r_name != NULL); in rpcent_read_snapshot_func()
214 rpc->r_number = (int)strtol(s, &ts, 10); in rpcent_read_snapshot_func()
215 if (*ts != '\0') { in rpcent_read_snapshot_func()
216 free(rpc->r_name); in rpcent_read_snapshot_func()
217 return (-1); in rpcent_read_snapshot_func()
222 if (sl == NULL) { in rpcent_read_snapshot_func()
223 if (strcmp(s, "(null)") == 0) in rpcent_read_snapshot_func()
229 if (strcmp(s, "noaliases") != 0) { in rpcent_read_snapshot_func()
244 if (i < 3) { in rpcent_read_snapshot_func()
245 free(rpc->r_name); in rpcent_read_snapshot_func()
246 memset(rpc, 0, sizeof(struct rpcent)); in rpcent_read_snapshot_func()
247 return (-1); in rpcent_read_snapshot_func()
251 rpc->r_aliases = sl->sl_str; in rpcent_read_snapshot_func()
261 if (result != NULL) { in dump_rpcent()
272 struct rpcent *rpc; in rpcent_fill_test_data() local
275 while ((rpc = getrpcent()) != NULL) { in rpcent_fill_test_data()
276 if (rpcent_test_correctness(rpc, NULL) == 0) in rpcent_fill_test_data()
277 TEST_DATA_APPEND(rpcent, td, rpc); in rpcent_fill_test_data()
279 return (-1); in rpcent_fill_test_data()
287 rpcent_test_correctness(struct rpcent *rpc, void *mdata __unused) in rpcent_test_correctness() argument
291 dump_rpcent(rpc); in rpcent_test_correctness()
293 if (rpc == NULL) in rpcent_test_correctness()
296 if (rpc->r_name == NULL) in rpcent_test_correctness()
299 if (rpc->r_number < 0) in rpcent_test_correctness()
302 if (rpc->r_aliases == NULL) in rpcent_test_correctness()
311 return (-1); in rpcent_test_correctness()
314 /* rpcent_check_ambiguity() is needed when one port+rpc is associated with
316 * /etc/peices. This functions is needed also when one piece+rpc is
318 * to make sure that rpc really exists and correct */
320 rpcent_check_ambiguity(struct rpcent_test_data *td, struct rpcent *rpc) in rpcent_check_ambiguity() argument
323 return (TEST_DATA_FIND(rpcent, td, rpc, compare_rpcent, in rpcent_check_ambiguity()
324 NULL) != NULL ? 0 : -1); in rpcent_check_ambiguity()
331 struct rpcent *rpc; in rpcent_test_getrpcbyname() local
336 rpc = getrpcbyname(rpc_model->r_name); in rpcent_test_getrpcbyname()
337 if (rpcent_test_correctness(rpc, NULL) != 0) in rpcent_test_getrpcbyname()
340 if ((compare_rpcent(rpc, rpc_model, NULL) != 0) && in rpcent_test_getrpcbyname()
341 (rpcent_check_ambiguity((struct rpcent_test_data *)mdata, rpc) in rpcent_test_getrpcbyname()
345 for (alias = rpc_model->r_aliases; *alias; ++alias) { in rpcent_test_getrpcbyname()
346 rpc = getrpcbyname(*alias); in rpcent_test_getrpcbyname()
348 if (rpcent_test_correctness(rpc, NULL) != 0) in rpcent_test_getrpcbyname()
351 if ((compare_rpcent(rpc, rpc_model, NULL) != 0) && in rpcent_test_getrpcbyname()
353 (struct rpcent_test_data *)mdata, rpc) != 0)) in rpcent_test_getrpcbyname()
363 return (-1); in rpcent_test_getrpcbyname()
369 struct rpcent *rpc; in rpcent_test_getrpcbynumber() local
374 rpc = getrpcbynumber(rpc_model->r_number); in rpcent_test_getrpcbynumber()
375 if (rpcent_test_correctness(rpc, NULL) != 0 || in rpcent_test_getrpcbynumber()
376 (compare_rpcent(rpc, rpc_model, NULL) != 0 && in rpcent_test_getrpcbynumber()
377 rpcent_check_ambiguity((struct rpcent_test_data *)mdata, rpc) in rpcent_test_getrpcbynumber()
380 return (-1); in rpcent_test_getrpcbynumber()
388 rpcent_test_getrpcent(struct rpcent *rpc, void *mdata __unused) in rpcent_test_getrpcent() argument
392 * Only correctness can be checked when doing 1-pass test for in rpcent_test_getrpcent()
395 return (rpcent_test_correctness(rpc, NULL)); in rpcent_test_getrpcent()
406 if (snapshot_file != NULL) { in run_tests()
407 if (access(snapshot_file, W_OK | R_OK) != 0) { in run_tests()
408 if (errno == ENOENT) in run_tests()
414 rv = -1; in run_tests()
418 if (method == TEST_BUILD_SNAPSHOT) { in run_tests()
429 if (rv == -1) in run_tests()
430 return (-1); in run_tests()
433 if (snapshot_file == NULL) in run_tests()
441 if (snapshot_file == NULL) in run_tests()
449 if (snapshot_file == NULL) in run_tests()
459 if (rv != -1) in run_tests()
465 if (snapshot_file != NULL) in run_tests()