Exemplo n.º 1
0
void AgentThread::processCMDCLEAN_REQUEST(int socketHandle)
{
  try {
	ConsoleServer::debugMsg(1,"Processing CMDCLEAN_REQUEST\n");
	// read the serialized TestObject which we will stop
	TestObject test;
	
	test.readTestObject(socketHandle);
	// now send a signal indicating we are processing the request
	Utils::sendSignal(socketHandle,RESPONSE_PROCESSING);
		
	//clean the files now
	for (int i = 0; i < getProcessCount(); i++) {
	  // check for any instance of test running with the same id
	  TestObject *curr = getProcess(i)->getTestObject();		  
	  if (curr->getTestID().compare(test.getTestID())==0) {
		// clean up the trace files
		ConsoleServer::debugMsg(1,
								"Cleaning environment file :%s\n",
								curr->getEnvFileName().c_str());
		if (Utils::delete_file(curr->getEnvFileName())!=0)
		  ConsoleServer::debugMsg(1,"No environment file was found :%s\n",
								  curr->getEnvFileName().c_str());
		ConsoleServer::debugMsg(1,"Cleaning stdout file :%s\n",
								curr->getStdOutFileName().c_str());
		if (Utils::delete_file(curr->getStdOutFileName())!=0)
		  ConsoleServer::debugMsg(1,"No stdout file was found :%s\n",
								  curr->getStdOutFileName().c_str());
		ConsoleServer::debugMsg(1,"Cleaning stderr file :%s\n",
								curr->getStdErrFileName().c_str());
		if (Utils::delete_file(curr->getStdErrFileName())!=0)
		  ConsoleServer::debugMsg(1,"No stderr file was found :%s\n",
								  curr->getStdErrFileName().c_str());
		
		// remove from our list of test objects
		ConsoleServer::debugMsg(1,"Removing process from process pool\n");
		
		delProcess(i);						
		
		break;
	  }
	}
		
	// now send a signal indicating we have finished
	Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK);
  }
  catch (char * message) {
	ConsoleServer::debugMsg(1,"Error processing CMDCLEAN_REQUEST request:%s\n",message);
	Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR);
  }
};	
Exemplo n.º 2
0
void AgentThread::processGETTRACEPATHS_REQUEST(int socketHandle) 
{
  try {
	ConsoleServer::debugMsg(1,"Processing GETTRACEPATHS_REQUEST\n");
	// read the serialized TestObject which we want the exit code of
	TestObject test;
	
	test.readTestObject(socketHandle);
	// now send a signal indicating we are processing the request
	Utils::sendSignal(socketHandle,RESPONSE_PROCESSING);
	int wasRun = FALSE;			
	for (int i = 0; i < getProcessCount(); i++) {
	  // check for any instance of test running with the same id
	  TestObject *curr = getProcess(i)->getTestObject();		  
	  if (curr->getTestID().compare(test.getTestID())==0) {
		wasRun = true;
		Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK);
		ConsoleServer::debugMsg(9,"Sending trace file paths\n");
		ConsoleServer::debugMsg(9,"Env file    :%s\n",curr->getEnvFileName().c_str());		
		ConsoleServer::debugMsg(9,"StdOut file :%s\n",curr->getStdOutFileName().c_str());		
		ConsoleServer::debugMsg(9,"StdErr file :%s\n",curr->getStdErrFileName().c_str());
		
		// ---- send the env, stdout and stderr files --------------------
		Utils::writeString(socketHandle,curr->getEnvFileName());
		Utils::writeString(socketHandle,curr->getStdOutFileName());
		Utils::writeString(socketHandle,curr->getStdErrFileName());	
		// ----------------------------------
		break;
	  }
	}
	
	if (!wasRun) {
	  // the process was never started, so assume it failed
	  ConsoleServer::debugMsg(1,"Process was never started :%s\n",test.getTestID().c_str());			
	  Utils::writeInt(socketHandle,RESPONSE_FINISHED_ERROR);
	}
	else {
	  // now send a signal indicating we have finished
	  Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK);
	}
	
  }
  catch (char *message) {
	ConsoleServer::debugMsg(1,"Error processing GETTRACEPATHS_REQUEST request:%s\n",message);
	Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR);
  }  
}