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);
}
Exemple #2
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);
	}
}