Exemplo n.º 1
0
TBool IsAlreadyRunning()
{
	RDebug::Print(_L("TrkLauncher::IsAlreadyRunning()"));

	_LIT(KTrkConsoleSearchPattern, "*TRKPROCESS*");
	_LIT(KTrkConsoleProcessPattern, "*");
	
	TFindProcess finder;
	TFullName fullName;
	TBool found = EFalse;
	finder.Find(KTrkConsoleProcessPattern);

	while (!found && finder.Next(fullName) == KErrNone)
	{
		fullName.UpperCase();
		
		if (fullName.Match(KTrkConsoleSearchPattern) != KErrNotFound)
		{
			found = ETrue;
			RDebug::Print(_L("process found Inside while"));
			break;
		}
	}

	if (found)
	{
		RDebug::Print(_L("TrkLauncher - Process found outside while"));
	}
	else
	{
		RDebug::Print(_L("TrkLauncher - Process was never found"));
	}
		
	return found;
}
TBool CLbsRootApiTest22Step::CheckProcessIsRunning(const TDesC& aProcessNamePattern)
	{
	TInt err = KErrNone;
	RProcess process;
	TFullName fullName;
	TFindProcess findProcess;
	TBool runningInstanceFound = EFalse;
	
	findProcess.Find(aProcessNamePattern);
	while (err = findProcess.Next(fullName), err == KErrNone)
		{
		TInt processOpenErr = process.Open(findProcess);
		if (processOpenErr == KErrNone)
			{
			TExitType exitType = process.ExitType();
			if (exitType == EExitPending)
				{
				// found a running instance of the process,
				// so assume everything is ok; return ETrue
				runningInstanceFound = ETrue;
				process.Close();
				break;
				}
			}
			process.Close();
		}
	
	return runningInstanceFound;	
	}
/* Forces the shutdown of the LbsNetGateway executable.
*/
TInt CTe_LbsNetworkPrivacySuiteStepBase::StopNetGateway()
	{
	// Shutdown the network gateway via the process 
	// supervisor api that LbsRoot uses.
	TRAPD(err, iProcessSupervisor.OpenL(KDummyNetworkGatewayUid));
	if (err == KErrNone)
		{
		// Find the network gateway manager process
		RProcess process;
		TFullName fullName;
		TFindProcess findProcess;
		_LIT(KGatewayProcessPattern, "te_dummynetgateway.exe*");
		TBool runningInstanceFound = EFalse;
		
		findProcess.Find(KGatewayProcessPattern);
		while (err = findProcess.Next(fullName), err == KErrNone)
			{
			TInt processOpenErr = process.Open(findProcess);
			if (processOpenErr == KErrNone)
				{
				TExitType exitType = process.ExitType();
				if (exitType == EExitPending)
					{
					// found a running instance of the process,
					// so assume everything is ok;
					runningInstanceFound = ETrue;
					break;
					}
				}
				process.Close();
			}
		
		if (runningInstanceFound)
			{
			TRequestStatus status;
			process.Logon(status);
			iProcessSupervisor.CloseDownProcess();
			User::WaitForRequest(status);
			process.Close();
			iProcessSupervisor.Close();
			}
		}
	return err;
	}
// ==============================================================
// ============ DoKillProcessL()                    =============
// ==============================================================
void DoKillProcessL( const TDesC& aProcessName )
    {
    TFullName psName;
    psName.Append( _L("*") );
    psName.Append( aProcessName );
    psName.Append( _L("*") );

    TFindProcess psFinder;
    psFinder.Find( psName );

    TInt killCount( 0 );
    while( psFinder.Next( psName ) != KErrNotFound )
        {
        RProcess ps;
        User::LeaveIfError( ps.Open( psFinder ) );
        ps.Kill( -666 );
        ps.Close();
        killCount++;
        }

    User::Leave( killCount );
    }
Exemplo n.º 5
0
TVerdict Cman6Step::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Our implementation only gets called if the base class doTestStepPreambleL() did
 * not leave. That being the case, the current test result value will be EPass.
 */
	{
	  if (TestStepResult()==EPass)
		{
		TTime time;
		time.UniversalTime();
		RDebug::Printf("%02d:%02d:%02d:%06d  [%Ld] xxxxx Cman6Step::doTestStepL start",
			time.DateTime().Hour(), time.DateTime().Minute(), time.DateTime().Second(),time.DateTime().MicroSecond(),
			RProcess().Id().Id());
		
		//This should be run as the last test in the te_man suite.  This test uses the Root API
		// CLbsCloseDownRequestDetector to simulate the Root telling the AGPS Manager to shutdown.
		// The Manager should send a CancelLocationRequest message and a CloseDown power message
		// to the integration module.  The Manager should then wait until the module makes the 
		// Shutdown() call before beginning the shut down process.
		

		//Setup the test AGPS Module Channel
		RAgpsModuleTestChannel moduleInt;
		moduleInt.OpenL();
		CleanupClosePushL(moduleInt);
		
		//Setup the root process ShutDown
		RLbsProcessSupervisor shutDownProcess;
		TUid managerModuleId = TUid::Uid(0x10281D44);	//KLbsGpsLocManagerUidValue
		shutDownProcess.OpenL(managerModuleId);
		CleanupClosePushL(shutDownProcess);

		//Open up the test AGPS Manager Process
		RProcess proc;
		_LIT(KMatchName,"testlbsgpslocmanager*");
		TFindProcess procName;
		TFullName procFullName;
		procName.Find(KMatchName);
		procName.Next(procFullName);
		
		//Check to see whether the manager process is still up and running
		TInt rc = proc.Open(procFullName);
		if(rc != KErrNone)
			{
			//Error, process has already closed down before receiving the shutdown from the module
			INFO_PRINTF1(_L("Error - cannot find the GPS Location Manager Process, failing test"));
			SetTestStepResult(EFail);
			}
		else
			{
			//Send the Shut Down to the Manager
			shutDownProcess.CloseDownProcess();
				
			//The test integration module will wait 5 seconds before sending the shutdown message to
			// the manager.  So the AGPS Manager should still be open.  The test should wait here
			// until the AGPS Manager process is closed down.  If the test times out, it is likely that
			// the AGPS Manager process was never closed, so the test cannot progress past this part
			TRequestStatus procStatus;
			proc.Logon(procStatus);
			
			time.UniversalTime();
			RDebug::Printf("%02d:%02d:%02d:%06d  [%Ld] xxxxx Cman6Step::doTestStepL after logon",
				time.DateTime().Hour(), time.DateTime().Minute(), time.DateTime().Second(),time.DateTime().MicroSecond(),
				RProcess().Id().Id());
					
			User::WaitForRequest(procStatus);
			
			time.UniversalTime();
			RDebug::Printf("%02d:%02d:%02d:%06d  [%Ld] xxxxx Cman6Step::doTestStepL after wait",
				time.DateTime().Hour(), time.DateTime().Minute(), time.DateTime().Second(),time.DateTime().MicroSecond(),
				RProcess().Id().Id());
						
			
			//When the Integration Module sends the shutdown message to the manager it updates the test
			// channel (so this message should also take 5 seconds before appearing on the channel and should
			// only appear when the manager has been given permission to close down).  Check the channel
			// to make sure the right message is present (ShutdownEvent)
			RAgpsModuleTestChannel::TTestMsgType messageType = RAgpsModuleTestChannel::ETestMsgUnknown;
			moduleInt.GetMsg(messageType);
			if(messageType == RAgpsModuleTestChannel::ETestMsgShutdownEvent)
				{
				INFO_PRINTF1(_L("Module correctly waited for Shutdown call from Module to shutdown and then shutdown the manager process."));
				SetTestStepResult(EPass);
				}
			else
				{
				INFO_PRINTF1(_L("Error - AGPS Manager has already been shutdown before receiving Shutdown() from Module"));
				SetTestStepResult(EFail);
				}
			}
		proc.Close();
		
		CleanupStack::Pop(2, &moduleInt);	//moduleInt, shutDownProcess
		}
	  return TestStepResult();
	}