Example #1
0
void *my_thread_process(void *arg)
{
	enum clnt_stat rslt;
	int recVar;
	int i;

	int iTimeOut = 1;
	int mTimeOut = 1;

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

	for (i = 0; i < callNb; i++) {
		rslt = rpc_broadcast_exp(progNum, VERSNUM, PROCNUM,
					 (xdrproc_t) xdr_int, (char *)&recVar,
					 (xdrproc_t) xdr_int, (char *)&recVar,
					 (resultproc_t) eachresult, iTimeOut,
					 mTimeOut, nettype);

		thread_array_result[atoi(arg)] += (rslt == RPC_SUCCESS);
	}

	pthread_exit(0);
}
Example #2
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 PASS
	enum clnt_stat rslt;
    char nettype[16] = "visible";
    int sndVar = 0;
    int recVar = -1;
	int i;
	int progNum = atoi(argc[2]);
	params paramList[NBCASE];

	//Test initialization
	paramList[0].init_tout = 1;
	paramList[0].next_tout = 1;
	paramList[1].init_tout = 10;
	paramList[1].next_tout = 10;
	paramList[2].init_tout = 1000;
	paramList[2].next_tout = 1000;

	//Call tested function using all tests cases
	for (i = 0; i < NBCASE; i++)
	{
		//Debug mode prints
		if (run_mode == 1)
		{
			printf("Test using values : %d ", paramList[i].init_tout);
			printf("%d", paramList[i].next_tout);
			printf("\n");
		}

		//Call function
		rslt = rpc_broadcast_exp(progNum, VERSNUM, PROCNUM,
						  		 (xdrproc_t)xdr_int, (char *)&sndVar,
						  		 (xdrproc_t)xdr_int, (char *)&recVar,
						  		 (resultproc_t)eachresult, paramList[i].init_tout, paramList[i].next_tout, nettype);

		//Check result
		if (rslt != RPC_TIMEDOUT)
		{
			//test has failed
			test_status = 1;
			break;
		}/**/
	}

	//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;
}
Example #3
0
/*
 * rpc_broadcast()
 *
 * prog       - program number 
 * vers       - version number 
 * proc       - procedure number 
 * xargs      - xdr routine for args 
 * argsp      - pointer to args 
 * xresults   - xdr routine for results 
 * resultsp   - pointer to results 
 * eachresult - call with each result obtained 
 * nettype    - transport type 
 */
enum clnt_stat
rpc_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, const char *nettype)
{
	enum clnt_stat	dummy;

	dummy = rpc_broadcast_exp(prog, vers, proc, xargs, argsp,
		xresults, resultsp, eachresult,
		INITTIME, WAITTIME, nettype);
	return (dummy);
}
Example #4
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
	//					   argc[3] : Init. timeout
	//					   argc[4] : Reply timeout
	//					   argc[5] : Number of testes function calls

	//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;
    int nbCall = atoi(argc[5]);
	int nbOk = 0;
	int i;

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

	for (i = 0; i < nbCall; i++)
	{
		rslt = rpc_broadcast_exp(progNum, VERSNUM, PROCNUM,
							  (xdrproc_t)xdr_int, (char *)&sndVar,
							  (xdrproc_t)xdr_int, (char *)&recVar,
							  (resultproc_t)eachresult, atoi(argc[3]), atoi(argc[4]), nettype);
		if (rslt == RPC_SUCCESS)
			nbOk++;
	}

	if (run_mode == 1)
	{
		printf("Aimed : %d\n", nbCall);
		printf("Got : %d\n", nbOk);
	}

	test_status = (nbOk == nbCall) ? 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;
}
Example #5
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_exp (progNum, VERSNUM, PINGPROC,
						  	(xdrproc_t)xdr_int, (char *)&varSnd,
						  	(xdrproc_t)xdr_int, (char *)&varRec,
						  	(resultproc_t)eachResult, 0, 100, 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;
}
Example #6
0
enum clnt_stat
rpc_broadcast(rpcprog_t prog,  /* program number */
              rpcvers_t vers,  /* version number */
              rpcproc_t proc,  /* procedure number */
              xdrproc_t xargs,  /* xdr routine for args */
              caddr_t   argsp,  /* pointer to args */
              xdrproc_t xresults, /* xdr routine for results */
              caddr_t resultsp, /* pointer to results */
              resultproc_t eachresult, /* call with each result obtained */
              const char *nettype /* transport type */)
{
    enum clnt_stat dummy;

    dummy = rpc_broadcast_exp(prog, vers, proc, xargs, argsp,
                              xresults, resultsp, eachresult,
                              INITTIME, WAITTIME, nettype);
    return (dummy);
}
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_exp(progNum, VERSNUM, PROCNUM,
				  (xdrproc_t) xdr_int, (char *)&sndVar,
				  (xdrproc_t) xdr_int, (char *)&recVar,
				  (resultproc_t) eachresult, 1, 1, nettype);
	}

	pthread_exit(0);
}