Exemplo n.º 1
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP -> not used for this test
	//					   argc[2] : Server Program Number
	//					   other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 1; //Default test result set to FAILED
	int progNum = atoi(argc[2]);
	enum clnt_stat rslt;
    char nettype[16] = "visible";
    int sndVar = 0;
    int recVar = -1;

	if (run_mode == 1)
	{
		printf("Server # %d\n", progNum);
	}

	rslt = rpc_broadcast(progNum, VERSNUM, PROCNUM,
						  (xdrproc_t)xdr_int, (char *)&sndVar,
						  (xdrproc_t)xdr_int, (char *)&recVar,
						  (resultproc_t)eachresult, nettype);

	test_status = (rslt == RPC_SUCCESS) ? 0 : 1;

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);

	return test_status;
}
Exemplo n.º 2
0
/*
 * Broadcasts on UDP transport. Obsoleted by rpc_broadcast().
 */
enum clnt_stat
clnt_broadcast(u_long prog, u_long vers, u_long proc, xdrproc_t xargs,
    void *argsp, xdrproc_t xresults, void *resultsp, resultproc_t eachresult)
/*
 *	u_long		prog;		// program number
 *	u_long		vers;		// version number
 *	u_long		proc;		// procedure number
 *	xdrproc_t	xargs;		// xdr routine for args
 *	void	       *argsp;		// pointer to args
 *	xdrproc_t	xresults;	// xdr routine for results
 *	void	       *resultsp;	// pointer to results
 *	resultproc_t	eachresult;	// call with each result obtained
 */
{

	if (thr_main())
		clnt_broadcast_result_main = eachresult;
	else {
		thr_once(&clnt_broadcast_once, clnt_broadcast_key_init);
		thr_setspecific(clnt_broadcast_key, (void *) eachresult);
	}
	return rpc_broadcast((rpcprog_t)prog, (rpcvers_t)vers,
	    (rpcproc_t)proc, xargs, argsp, xresults, resultsp,
	    (resultproc_t) rpc_wrap_bcast, "udp");
}
Exemplo n.º 3
0
/*
 * Broadcasts on UDP transport. Obsoleted by rpc_broadcast().
 */
enum clnt_stat
clnt_broadcast(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, xdrproc_t xargs,
	caddr_t argsp, xdrproc_t xresults,
	caddr_t resultsp, resultproc_t eachresult)
{
	if (thr_main()) {
		clnt_broadcast_result_main = eachresult;
	} else {
		(void) pthread_key_create_once_np(&clnt_broadcast_key, NULL);
		(void) pthread_setspecific(clnt_broadcast_key,
							(void *)eachresult);
	}
	return (rpc_broadcast(prog, vers, proc, xargs, argsp, xresults,
				resultsp, (resultproc_t)rpc_wrap_bcast, "udp"));
}
Exemplo n.º 4
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//					   argc[2] : Server Program Number
	//					   argc[3] : Number of host ready to answer to broadcast
	//					   other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 1; //Default test result set to FAILED
	int progNum = atoi(argc[2]);
	enum clnt_stat cs;
	char nettype[16] = "visible";
	int varSnd = 0;
	int varRec;

	bool_t eachResult (char *out, struct sockaddr_in *addr);
	maxAnswer = atoi(argc[3]);
	currentAnswer = 0;

	//Show information in debug mode...
	if (run_mode == 1)
	{
		printf("progNum : %d\n", progNum);
		printf("Max SVC : %d\n", maxAnswer);
	}

	//Call broadcast routine
	cs = rpc_broadcast(progNum, VERSNUM, PINGPROC,
						  (xdrproc_t)xdr_int, (char *)&varSnd,
						  (xdrproc_t)xdr_int, (char *)&varRec,
						  (resultproc_t) eachResult, nettype);

	if (currentAnswer == maxAnswer)
		test_status = 0;

	if (cs != RPC_SUCCESS)
		clnt_perrno(cs);

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);

	return test_status;
}
Exemplo n.º 5
0
void *my_thread_process(void *arg)
{
	int i;
	int sndVar = 0;
	int recVar;

	if (run_mode == 1) {
		fprintf(stderr, "Thread %d\n", atoi(arg));
	}

	for (i = 0; i < callNb; i++) {
		rpc_broadcast(progNum, VERSNUM, PROCNUM,
			      (xdrproc_t) xdr_int, (char *)&sndVar,
			      (xdrproc_t) xdr_int, (char *)&recVar,
			      (resultproc_t) eachresult, nettype);
	}

	pthread_exit(0);
}
Exemplo n.º 6
0
/*
 * Broadcasts on UDP transport. Obsoleted by rpc_broadcast().
 */
enum clnt_stat
clnt_broadcast(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, xdrproc_t xargs,
	caddr_t argsp, xdrproc_t xresults,
	caddr_t resultsp, resultproc_t eachresult)
{
	extern mutex_t tsd_lock;

	if (thr_main()) {
		clnt_broadcast_result_main = eachresult;
	} else {
		if (clnt_broadcast_key == 0) {
			(void) mutex_lock(&tsd_lock);
			if (clnt_broadcast_key == 0)
				(void) pthread_key_create(&clnt_broadcast_key,
									NULL);
			(void) mutex_unlock(&tsd_lock);
		}
		(void) pthread_setspecific(clnt_broadcast_key,
							(void *)eachresult);
	}
	return (rpc_broadcast(prog, vers, proc, xargs, argsp, xresults,
				resultsp, (resultproc_t)rpc_wrap_bcast, "udp"));
}
Exemplo n.º 7
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//					   argc[2] : Server Program Number
	//					   argc[3] : Number of test call
	//					   other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 0; //Default test result set to FAILED
	int i;
	double *resultTbl;
	struct timeval tv1,tv2;
    struct timezone tz;
    long long diff;
    double rslt;
	int progNum = atoi(argc[2]);
	enum clnt_stat cs;
    char nettype[16] = "visible";
    int sndVar = 0;
    int recVar = -1;

	//Test initialisation
    maxIter = atoi(argc[3]);
    resultTbl = (double *)malloc(maxIter * sizeof(double));

	//Call tested function several times
	for (i = 0; i < maxIter; i++)
	{
		//Tic
		gettimeofday(&tv1, &tz);

		//Call function
		cs = rpc_broadcast(progNum, VERSNUM, PROCNUM,
						  	 (xdrproc_t)xdr_int, (char *)&sndVar,
						  	 (xdrproc_t)xdr_int, (char *)&recVar,
						  	 (resultproc_t) eachresult, nettype);

		//Toc
		gettimeofday(&tv2, &tz);

		//Add function execution time (toc-tic)
		diff = (tv2.tv_sec-tv1.tv_sec) * 1000000L + (tv2.tv_usec-tv1.tv_usec);
		rslt = (double)diff / 1000;

    	if (cs == RPC_SUCCESS)
    	{
    		resultTbl[i] = rslt;
    	}
    	else
    	{
    		test_status = 1;
    		break;
    	}

    	if (run_mode)
    	{
    		fprintf(stderr, "lf time  = %lf usecn\n", resultTbl[i]);
    	}
	}

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);
	printf("%lf %d\n", average(resultTbl), maxIter);
	printf("%lf\n", mini(resultTbl));
	printf("%lf\n", maxi(resultTbl));

	return test_status;
}
Exemplo n.º 8
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//					   argc[2] : Server Program Number
	//					   other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 0; //Default test result set to FAILED
	int progNum = atoi(argc[2]);
    char nettype[16] = "visible";
	//Sent variables
	int intSnd;
	double dblSnd;
	long lngSnd;
	char *strSnd;
	//Received variables
	int intRec;
	double dblRec;
	long lngRec;
	char *strRec;

	//Test initialization

	//Call tested procedure several times
	//Int test : call INTPROCNUM RPC
	intSnd = -65536;

	rpc_broadcast(progNum, VERSNUM, INTPROCNUM,
						  (xdrproc_t)xdr_int, (char *)&intSnd,
						  (xdrproc_t)xdr_int, (char *)&intRec,
						  (resultproc_t)eachresult, nettype);

	if (intSnd != intRec)
		test_status = 1;
	if (run_mode == 1)
		printf("Send (int) : %d, Received : %d\n", intSnd, intRec);

	//Test positive number
	intSnd = 16777216;

	rpc_broadcast(progNum, VERSNUM, INTPROCNUM,
						  (xdrproc_t)xdr_int, (char *)&intSnd,
						  (xdrproc_t)xdr_int, (char *)&intRec,
						  (resultproc_t)eachresult, nettype);

	if (intSnd != intRec)
		test_status = 1;
	if (run_mode == 1)
		printf("Send (int) : %d, Received : %d\n", intSnd, intRec);

	//Long test : call LNGPROCNUM RPC
	lngSnd = -430000;

	rpc_broadcast(progNum, VERSNUM, LNGPROCNUM,
						  (xdrproc_t)xdr_long, (char *)&lngSnd,
						  (xdrproc_t)xdr_long, (char *)&lngRec,
						  (resultproc_t)eachresult, nettype);

	if (lngSnd != lngRec)
		test_status = 1;
	if (run_mode == 1)
		printf("Send (long) : %ld, Received : %ld\n", lngSnd, lngRec);

	//Double test : call DBLPROCNUM RPC
	dblSnd = -1735.63000f;

	rpc_broadcast(progNum, VERSNUM, DBLPROCNUM,
						  (xdrproc_t)xdr_double, (char *)&dblSnd,
						  (xdrproc_t)xdr_double, (char *)&dblRec,
						  (resultproc_t)eachresult, nettype);

	if (dblSnd != dblRec)
		test_status = 1;
	if (run_mode == 1)
		printf("Send (double) : %lf, Received : %lf\n", dblSnd, dblRec);

	//String test : call STRPROCNUM RPC
	strSnd = "text to send.";
	strRec = (char *)malloc(64 * sizeof(char));

	rpc_broadcast(progNum, VERSNUM, DBLPROCNUM,
						  (xdrproc_t)xdr_wrapstring, (char *)&strSnd,
						  (xdrproc_t)xdr_wrapstring, (char *)&strRec,
						  (resultproc_t)eachresult, nettype);

	if (strcmp(strSnd, strRec))
		test_status = 1;
	if (run_mode == 1)
		printf("Send (string) : %s, Received : %s\n", strSnd, strRec);

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);

	return test_status;
}