static int rpcent_test_getrpcent(struct rpcent *rpc, void *mdata) { /* Only correctness can be checked when doing 1-pass test for * getrpcent(). */ return (rpcent_test_correctness(rpc, NULL)); }
static int rpcent_test_getrpcbyname(struct rpcent *rpc_model, void *mdata) { char **alias; struct rpcent *rpc; if (debug) { printf("testing getrpcbyname() with the following data:\n"); dump_rpcent(rpc_model); } rpc = getrpcbyname(rpc_model->r_name); if (rpcent_test_correctness(rpc, NULL) != 0) goto errfin; if ((compare_rpcent(rpc, rpc_model, NULL) != 0) && (rpcent_check_ambiguity((struct rpcent_test_data *)mdata, rpc) !=0)) goto errfin; for (alias = rpc_model->r_aliases; *alias; ++alias) { rpc = getrpcbyname(*alias); if (rpcent_test_correctness(rpc, NULL) != 0) goto errfin; if ((compare_rpcent(rpc, rpc_model, NULL) != 0) && (rpcent_check_ambiguity( (struct rpcent_test_data *)mdata, rpc) != 0)) goto errfin; } if (debug) printf("ok\n"); return (0); errfin: if (debug) printf("not ok\n"); return (-1); }
static int rpcent_fill_test_data(struct rpcent_test_data *td) { struct rpcent *rpc; setrpcent(1); while ((rpc = getrpcent()) != NULL) { if (rpcent_test_correctness(rpc, NULL) == 0) TEST_DATA_APPEND(rpcent, td, rpc); else return (-1); } endrpcent(); return (0); }
static int rpcent_test_getrpcbynumber(struct rpcent *rpc_model, void *mdata) { struct rpcent *rpc; printf("testing getrpcbyport() with the following data...\n"); dump_rpcent(rpc_model); rpc = getrpcbynumber(rpc_model->r_number); if (rpcent_test_correctness(rpc, NULL) != 0 || (compare_rpcent(rpc, rpc_model, NULL) != 0 && rpcent_check_ambiguity((struct rpcent_test_data *)mdata, rpc) != 0)) { printf("not ok\n"); return (-1); } else { printf("ok\n"); return (0); } }