Esempio n. 1
0
TInt E32Main()
	{
	test.Title();

	// Turn off evil lazy dll unloading
	RLoader l;
	test(l.Connect()==KErrNone);
	test(l.CancelLazyDllUnload()==KErrNone);
	l.Close();

	test.Start(_L("Preload t_oedll1.dll"));
	RLibrary library;
	test(library.Load(_L("t_oedll1.dll")) == KErrNone);

	test.Next(_L("Run T_OEEXPORT.EXE..."));
	RProcess p;
	TInt r=p.Create(_L("T_OEEXPORT.EXE"), _L("2"));
	test(r==KErrNone);
	TRequestStatus s;
	p.Logon(s);
	p.Resume();
	User::WaitForRequest(s);
	TExitCategoryName aExitCategory = p.ExitCategory();
	test.Printf(_L("Second test exits with: %d,%d,%S\n"),p.ExitType(),p.ExitReason(),&aExitCategory);
	test(p.ExitType()==EExitKill);
	test(p.ExitReason()==0);
	p.Close();

	library.Close();

	test.End();
	return KErrNone;
	}
Esempio n. 2
0
/**
 @SYMTestCaseID APPFWK-APPARC-0018

 @SYMPREQ PREQ1123

 @SYMTestCaseDesc The Test determines that a process is launched and terminated without any problem.\n

 @SYMTestPriority Low

 @SYMTestStatus Implemented

 @SYMTestActions. Creates and launches a process. No Child is created. Parent should launch properly, and on termination should die.
 API Calls:\n
 RProcess::Create(const TDesC &aFileName, const TDesC &aCommand, TOwnerType aType=EOwnerProcess);\n
 RProcess::Resume();
 RProcess::ExitType() const;
 RProcess::ExitReason() const;
 RProcess::Id() const;
 RProcess::Terminate(TInt aReason);
 
 @SYMTestExpectedResults Proper creation and termination.\n

 */
void CT_ProcStep::testParentWithoutAChildL(void)
	{
	TInt ret(0)	;

	//process
	RProcess parentProc;
	ret = parentProc.Create(KParentExe,KNullDesC);
	TEST(ret == KErrNone);
	User::LeaveIfError(ret);
	CleanupClosePushL(parentProc);
	INFO_PRINTF2(_L("	Create Parent Process returned : %d"),ret);

	TUint64 parentProcId=parentProc.Id();
	INFO_PRINTF2(_L("	Process Id = 0x%lx "),parentProcId);

	INFO_PRINTF1(_L("	Run the Process "));
	parentProc.Resume();
	//Time for the parent process to launch itself
	User::After(5000000);

	TExitType exitType = parentProc.ExitType();
	TEST(exitType == EExitKill||exitType == EExitPending);
	if(exitType==EExitPending)
		{
		INFO_PRINTF1(_L("	Process running normally "));
		parentProc.Terminate(KTProcTerminatingParent);
		exitType = parentProc.ExitType();
		TEST(exitType==EExitTerminate);
		TInt exitReason = parentProc.ExitReason();
		TEST(exitReason == KTProcTerminatingParent);
		INFO_PRINTF1(_L("	Terminating the process "));
		}
	CleanupStack::PopAndDestroy(&parentProc);
	}
/**
Creates a second process, runs the requested test and ensures that
the specified panic occurs.

@param aExecutableName The name of the new process
@param aTestInfo The specification for this test
@param aPanicCategory Descriptor containing the start of the expected panic string e.g. for "ALLOC:xxxxxxxx" this would be "ALLOC"
@leave One of the system wide error codes
*/
void CTGraphicsResourceInternalBase::CreateSecondProcessAndCheckAllocPanicL(const TDesC &aExecutableName, TSgResIntTestInfo& aTestInfo, const TDesC &aPanicCategory)
	{
	// Create a second process
	RProcess process;
	TInt err = process.Create(aExecutableName, KNullDesC);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(process);

	// Specify the id passed to the second process
	TPckg<TSgResIntTestInfo> ptr(aTestInfo);
	err = process.SetParameter(KSecondProcessParametersSlot, ptr);
	TESTEL(KErrNone == err, err);

	// Kick off the second process and wait for it to complete
	// The actual testing is done in the second process
	TRequestStatus status;
	process.Logon(status);
	process.Resume();
	User::WaitForRequest(status);

	if(EExitPanic != process.ExitType())
		{
		ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, process.ExitType());
		TEST(EFalse);
		}

	TExitCategoryName secondProcessExitCategory = process.ExitCategory();
	if(0 != secondProcessExitCategory.Match(aPanicCategory))
		{
		ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aPanicCategory, &secondProcessExitCategory);
		TEST(EFalse);
		}
	
	CleanupStack::PopAndDestroy();
	}
TInt MainL()
	{
	CSysMonTestHelper* helper = CSysMonTestHelper::NewLC();
	
	TRecoveryMethod recoveryMethod = EIgnoreOnFailure;
	TInt recoveryMode = 0;
	helper->GetRecoveryMethodArgsL(recoveryMethod, recoveryMode);

	TBuf<KMaxTestIdLength> testId;
	helper->GetTestId(testId);
	
	TBuf<KMaxTestIdLength + 5> args;
	args.Append(testId);
	args.Append(_L(" "));
	args.Append(_L("500")); //The length of time, in milliseconds, for the process to wait before deregistering
	
	RProcess slave;
	CleanupClosePushL(slave);
	TInt err = slave.Create(KFilenameDeregTimeout, args);
	// If we fail to create the process, pass the error code out to the test step and then leave
	helper->TestErrorcodeL(err); 
	slave.Resume();

	CStartupProperties* props = CStartupProperties::NewLC(KFilenameDeregTimeout, KNullDesC);
	props->SetMonitored(ETrue);
	props->SetStartupType(EStartProcess);
	props->SetStartMethod(EWaitForStart);
	props->SetNoOfRetries(1);
	props->SetTimeout(1000);
	props->SetRecoveryParams(recoveryMethod, recoveryMode);
	
	RSysMonSession sysmon;
	CleanupClosePushL(sysmon);
	
	TRAP(err, sysmon.OpenL());
	// If we fail to connect, pass the error code out to the test step and then re-leave
	helper->TestErrorcodeL(err); 

	// Register with SysMon
	TRAP(err, sysmon.MonitorL(*props, slave));

	CleanupStack::PopAndDestroy(2,props);	
	
	helper->WriteResultL(err);

	for (int i = 0; slave.ExitType() == EExitPending && i < 100; i++ )
	// Wait for the process to end, or up to 1 second
		{
		User::After(10000);
		}
	
	if (slave.ExitType() == EExitPending)
		{
		slave.Terminate(KErrGeneral);
		}

	CleanupStack::PopAndDestroy(2, helper);
	return KErrNone;
	}
Esempio n. 5
0
TBool IsProcessRunning(const TDesC& aProcessName)
	{
	TFullName name;
	TBool IsProcessRunning(EFalse);
	TBuf<64> pattern(aProcessName);
	TInt length = pattern.Length();
	pattern += _L("*");
	TFindProcess procFinder(pattern);

	while(procFinder.Next(name) == KErrNone)
		{
		if(name.Length() > length)
			{//If found name is a string containing aProcessName string.
			TChar c(name[length]);
			if(c.IsAlphaDigit() || c == TChar('_') || c == TChar('-'))
				{//If the found name is other valid application name starting with aProcessName string.
				RDebug::Print(_L(":: Process name: \"%S\".\n"), &name);
				continue;
				}
			}
		RProcess proc;
		if(proc.Open(name) == KErrNone)
			{
			if (EExitKill == proc.ExitType())
			    {
			    RDebug::Print(_L("\"%S\" process killed.\n"), &name);
			    proc.Close();
			    IsProcessRunning = EFalse;
			    }
			 else
			    {
			    IsProcessRunning = ETrue;
			    RDebug::Print(_L("\"%S\" process is running.\n"), &name);
			    }

			if(IsProcessRunning)
				{
				RDebug::Print(_L("Waiting additional time...\n"), &name);

				User::After(1000000);

				if (EExitKill == proc.ExitType())
					{
					RDebug::Print(_L("\"%S\" process now killed.\n"), &name);
			    	IsProcessRunning = EFalse;
					}

				proc.Close();
				}
			}


		}
	return IsProcessRunning;
	}
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;	
	}
Esempio n. 7
0
// Gets the state and priority of process aproc. Writes state into buffer
//pointed to by aprocstate and returns priority as an integer
	int getProcessState(RProcess& aproc,TDes& aprocstate)
		{
		TExitType exittype;
		TProcessPriority prio;
		exittype = aproc.ExitType();
		prio = aproc.Priority();
		switch(exittype)
			{
				case EExitPending:
					aprocstate.Append(_L("R"));
					break;
				case EExitPanic:
					aprocstate.Append(_L("P"));
					break;
				case EExitKill:
				case EExitTerminate:
					aprocstate.Append(_L("X"));
					return -1;
			}
			
		switch(prio)	
			{
			case EPriorityLow:
 			case EPriorityBackground:
			case EPriorityForeground:
				aprocstate.Append(_L("N"));
				break;
 
 			default:
 				// All other cases
				aprocstate.Append(_L("<"));
				break;
		}
		return prio;
		}
// ----------------------------------------------------
// CPresenceCacheClient::StartServer
//
// ----------------------------------------------------
//
TInt CPresenceCacheClient::StartServer()
    {
    TInt result;
    TRequestStatus status = KRequestPending; 

    TFindServer findCacheServer( NName::KSymbianServer );
    TFullName name;

    result = findCacheServer.Next( name );
    if ( result == KErrNone )
        {
        // Server already running
        return KErrNone;
        }

    RProcess server;
    result = server.Create( NName::KExecutable, KNullDesC );       
    if( result != KErrNone )
        return result;     
    server.Rendezvous( status );    	
    status != KRequestPending ? server.Kill( 0 ) : server.Resume();
    //Wait for start or death 
    User::WaitForRequest( status );	
    result = server.ExitType() == EExitPanic ? KErrGeneral : status.Int();
    server.Close();
    
    return result;	    
    }
Esempio n. 9
0
// -----------------------------------------------------------------------------
// CHtiFramework::IsHtiRunning
// Checks whether HTI Framework process is already running.
// -----------------------------------------------------------------------------
TBool CHtiFramework::IsHtiRunning()
    {
    HTI_LOG_FUNC_IN( "CHtiFramework::IsHtiRunning" );
    TInt htiInstanceCount = 0;
    TBool isRunning = EFalse;
    TFullName processName;
    TFindProcess finder( KHtiFrameworkMatchPattern );
    TInt err = finder.Next( processName );
    while ( err == KErrNone && processName.Length() > 0 )
        {
        HTI_LOG_FORMAT( "Found process %S", &processName );
        RProcess process;
        err = process.Open( finder );
        if ( err == KErrNone )
            {
            if ( process.ExitType() == EExitPending )
                {
                HTI_LOG_TEXT( "Process is running" );
                htiInstanceCount++;
                }
            process.Close();
            }
        err = finder.Next( processName );
        }
    if ( htiInstanceCount > 1 )
        {
        isRunning = ETrue;
        }
    HTI_LOG_FUNC_OUT( "CHtiFramework::IsHtiRunning" );
    return isRunning;
    }
// -----------------------------------------------------------------------------
// CreateServerProcess
// Static function to create the server process.
// -----------------------------------------------------------------------------
//
static TInt CreateServerProcess()
    {
    TInt err( KErrNone );
    RProcess server;
    err = server.Create( KSnsrDispCtrlSrvName, KNullDesC, EOwnerThread );
    if ( !err )
        {
        TRequestStatus status;
        server.Rendezvous( status );
        if ( status != KRequestPending )
            {
            server.Kill( 0 ); // Abort startup.
            }
        else
            {
            server.Resume(); // Logon OK - start the server.
            }
        User::WaitForRequest( status ); // Wait for start or death.
        // We can't use the 'exit reason' if the server panicked as this
        // is the panic 'reason' and may be '0' which cannot be distinguished
        // from KErrNone.
        err = ( server.ExitType() == EExitPanic ) ? KErrGeneral
                : status.Int();
        server.Close();
        }
    return err;
    }
Esempio n. 11
0
// ---------------------------------------------------------------------------
// start btnotif server from client.
// ---------------------------------------------------------------------------
//
TInt StartBTNotifSrv()
    {
    const TUidType serverUid( KNullUid, KNullUid, KBTNotifServerUid3 );
        // Create a new server process. Simultaneous launching of two processes 
        // should be detected when the second one attempts to create the server 
        // object, failing with KErrAlreadyExists.
    RProcess server;
    TInt err = server.Create( KBTNotifServerName, KNullDesC, serverUid );
    if( err != KErrNone )
        {
        return err;
        }
    TRequestStatus status;
    server.Rendezvous( status );
    if( status != KRequestPending )
        {
        server.Kill( KErrCancel );  // Abort startup
        }
    else
        {
        server.Resume();
        }
    User::WaitForRequest( status ); // Wait for start or death
    err = status.Int();
    if( server.ExitType() == EExitPanic )
        {
        // The server actually panicked; inform the client.
        err = KErrDied;
        }
    server.Close();
    return err;
    }
/**
 * Function used by RClassControllerClient::Connect member function.
 * It exists to create a new process which contains the server side code.
 *
 * @return Value of error code created
 */
static TInt StartServer()
	{
	const TUidType serverUid(KNullUid, KNullUid, KObexCCUid);
	RProcess server;
	TInt err = server.Create(KServerExe, KNullDesC, serverUid);
	if ( err != KErrNone )
		{
		return err;
		}

	TRequestStatus stat;
	server.Rendezvous(stat);

	if ( stat != KRequestPending )
		{
		server.Kill(0); 	// abort startup
		}
	else
		{
		server.Resume();	// logon OK - start the server
		}

	User::WaitForRequest(stat); 	// wait for start or death

	// we can't use the 'exit reason' if the server paniced as this
	// is the panic 'reason' and may be '0' which cannot be distinguished
	// from KErrNone
	err = (server.ExitType() == EExitPanic) ? KErrServerTerminated : stat.Int();
	
	server.Close();

	return err;
	}
static TInt StartDummyServer()
	{
	const TUidType serverUid(KNullUid, TUid::Uid(KSendAsServerExeUid));
	TRequestStatus started( KRequestPending );
	RProcess server;
	TInt err = server.Create(KDummyServerExe, KNullDesC(), serverUid);

	if( err != KErrNone )
		{
		return err;
		}
	
	TRequestStatus status;
	server.Rendezvous(status);
	if( status != KRequestPending )
		{
		server.Kill(0); // abort start-up
		}
	else
		{
		server.Resume();	// wait for server start-up.
		}
	User::WaitForRequest(status);
	err = (server.ExitType() == EExitPanic ) ? KErrGeneral : status.Int();
	server.Close();
	return err;	
	}
Esempio n. 14
0
TInt StartServer()
    {
        TRACE_STATIC_FUNC
    const TUid KKBTHIDSrvUid3 =
        {
        BTHID_SRV_UID
        };
    const TUidType serverUid(KNullUid,KNullUid, KKBTHIDSrvUid3);
    RProcess server;
    TInt r = server.Create(KBTHidServerFilename, KNullDesC, serverUid);
    if (r != KErrNone)
        return r;
    server.SetPriority(EPriorityHigh);

    TRequestStatus stat;
    server.Rendezvous(stat);
    if (stat != KRequestPending)
        {
        server.Kill(0);
        }
    else
        {
        server.Resume();
        }

    User::WaitForRequest(stat);
        TRACE_INFO((_L("[BTHID] Server started, code %d"), stat.Int()))
    r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
    server.Close();
    return r;
    }
//
// Starts the IntegrityServices Server in a new process
//
static TInt StartIntegrityServicesServer()
	{
	const TUidType serverUid(KExecutableImageUid, KNullUid, KIntegrityServicesServerUid3);
	RProcess server;
	TInt err = server.Create(KIntegrityServicesServerImage, KNullDesC);

	if (err != KErrNone)
		{
		return err;
		}

	TRequestStatus stat;
	server.Rendezvous(stat);

	if (stat != KRequestPending)
		{
		server.Kill(0); // abort startup
		}
	else
		{
		server.Resume(); // logon OK, start the server
		}

	User::WaitForRequest(stat); // wait for start or death
	// We can't use the 'exit reason' if the server panicked as this is the
	// panic 'reason' and may be 0 which cannot be distinguished from KErrNone.
	err = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
	server.Close();
	return err;
	}
/**
Helper function to find and kill the specified process
*/
TInt CCmdTestSsmCommand::FindAndKill(const TDesC& aProcessName)
	{
	TFullName searchTerm(aProcessName);
	StripExtension( searchTerm );	
	searchTerm += _L("*");
	TFindProcess find(searchTerm);
	TFullName name;
	TInt instancesFound = 0;
	while(find.Next(name) == KErrNone)
		{
		RProcess process;
		const TInt err = process.Open(find);

		if (KErrNone == err)
			{
			if (process.ExitType() == EExitPending)
				{
				instancesFound++;
				process.Kill(KErrCancel);
				process.Close();
				INFO_PRINTF2(_L("Process %S found and killed"), &aProcessName);
				}
			process.Close();
			}
		}
	return instancesFound;
	}
Esempio n. 17
0
/**
   @SYMTestCaseID UIF-UIKON-0008
  
   @SYMREQ 7736

   @SYMTestCaseDependencies	Following steps should be done before running this test: 
   		1. Uncomment the call to this manual test
   		2. Error codes must be updated. Following files need replacing with those in uikon/test/terror/terrortextwithtitleapp/data.
   			a) //EPOC/master/common/generic/tools/s60_header_compat/commonengineresources/data/errorres.rss
			b) //EPOC/master/common/generic/tools/s60_header_compat/commonengineresources/inc/errorres.loc
		3. Reallyclean and re-compile the following folders:
			a) //EPOC/master/common/generic/tools/s60_header_compat/group95/bld.inf (or later)
			b) Uiktest code (\uikon\test\group\bld.inf), so the test code links against the new rsc files.
  
   @SYMTestCaseDesc Test
  
   @SYMTestPriority High
  
   @SYMTestStatus Implemented
   
   @SYMTestActions This Method invokes terrortextwithtitleapp.exe, which tests the newly added error codes.
     
   @SYMTestExpectedResults terrortextwithtitleapp.exe should terminate with KErrNone, meaning that all its internal
   						   checks inside the app were ok, and hence error message correctly resolved.
 */
void CAppTest::TestErrorWithTitleManuallyL()
	{
	iAppUi->INFO_PRINTF1(_L("Manual Testing for new test error codes added to errorres.rss file"));
	_LIT(KErrorTextWithTitleAppFileName,"z:\\sys\\bin\\terrortextwithtitleapp.exe");
	RProcess errorContextProc;
	TRequestStatus appState;
	TBool jit = User::JustInTime();
	User::SetJustInTime(EFalse);
	TInt ret = errorContextProc.Create(KErrorTextWithTitleAppFileName,KNullDesC);
	iAppUi->TEST(ret == KErrNone);
	User::LeaveIfError(ret);
	CleanupClosePushL(errorContextProc);

	//Launching the application
	iAppUi->INFO_PRINTF1(_L("Start terrortextwithtitleapp.exe to test the new test error codes"));
	errorContextProc.Logon(appState);
	errorContextProc.Resume();
	User::WaitForRequest(appState);
	iAppUi->TEST(errorContextProc.ExitReason() == KErrNone);
	iAppUi->TEST(errorContextProc.ExitType() == EExitKill);

	CleanupStack::PopAndDestroy(&errorContextProc);
	User::SetJustInTime(jit);
	iAppUi->INFO_PRINTF1(_L("Manual test completed"));
    }
Esempio n. 18
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CTraceContainer::IsServerOn()
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
	  	if(ph.SecureId() == (TUint32)KUidTraceServerUID.iUid)
	 	{
	 		TExitType Exxit =ph.ExitType();
	 		if(Exxit == EExitPending)
	 		{
		  		Ret = ETrue;
		  		break;
	 		}
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Esempio n. 19
0
//______________________________________________________________________________
//						RConsoleProxy
static TInt StartServer(const TDesC& aServerName, const TDesC& aServerArgs)
	{
	TPtrC processName(aServerName);
	if (processName.Length() && processName[0] == '!')
		{
		processName.Set(processName.Mid(1));
		}
	RProcess server;
	TInt r = server.Create(processName, aServerArgs);
	if (r!=KErrNone) return r;
	TRequestStatus stat;
	server.Rendezvous(stat);
	if (stat != KRequestPending)
		{
		server.Kill(0);
		}
	else
		{
		server.Resume();
		}
	User::WaitForRequest(stat);		// wait for start or death
	r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
	server.Close();
	return r;
	}
/**
Creates a second process and do some tests in it.
@param aExecutableName The name of the new process
@param aTestInfo The information for the tests
@leave Gets system wide error code
*/
TInt CTGraphicsResourceInternalBase::CreateSecondProcessAndDoTestL(const TDesC &aExecutableName, TSgResIntTestInfo& aTestInfo)
	{
	// Create a second process
    RProcess process;
    User::LeaveIfError(process.Create(aExecutableName, KNullDesC));
	CleanupClosePushL(process);

	// Specify the id passed to the second process
	TPckg<TSgResIntTestInfo> ptr(aTestInfo);
	TInt err = process.SetParameter(KSecondProcessParametersSlot, ptr);
	TESTEL(KErrNone == err, err);

	// Kick off the second process and wait for it to complete
	// The actual testing is done in the second process
	TRequestStatus status;
	process.Logon(status);
	process.Resume();
	User::WaitForRequest(status);

	//ExitReason() returns the test result
	TInt exitreason = process.ExitReason();
	
	TEST(process.ExitType() == EExitKill);
	
	CleanupStack::PopAndDestroy();
	
	return exitreason;
	}
Esempio n. 21
0
static void RunHelper(const TDesC& aFileToDelete, TInt aExpectedError)
/**
	Invoke the helper executable, tell it to delete the supplied file.
	
	@param	aFileToDelete	Name of file which helper executable should delete
							with RLoader::Delete.
	@param	aExpectedError	The expected return code from RLoader::Delete.
 */
	{
	TInt r;
	
	// run the helper exe, which will try to delete the file with RLoader::Delete
	RProcess ph;
	r = ph.Create(_L("tld_helper_caps.exe"), aFileToDelete);
	test(r == KErrNone);

	TRequestStatus rsh;
	ph.Logon(rsh);
	test(rsh == KRequestPending);
	ph.Resume();
	User::WaitForRequest(rsh);

	// process has died so check the panic category and reason match the expected values
	test(ph.ExitType() == EExitPanic);
	test(ph.ExitCategory() == KTldPanicCat);
	test(ph.ExitReason() == aExpectedError);

	ph.Close();
	}
Esempio n. 22
0
void TestServerPanic()
	{
	TRequestStatus status;
	
	test_KErrNone(TheSemaphore.CreateLocal(0));
	
	RDebug::Printf("Main: start server");
	RThread serverThread;
	test_KErrNone(serverThread.Create(_L("server"), ServerThread, 4096, NULL, NULL));
	serverThread.Rendezvous(status);
	serverThread.Resume();
	User::WaitForRequest(status);
	test_KErrNone(status.Int());

	RDebug::Printf("Main: start client");
	RProcess clientProcess;
	test_KErrNone(clientProcess.Create(KMyName, _L("client")));
	clientProcess.Resume();
	clientProcess.Logon(status);
	User::WaitForRequest(status);
	test_KErrNone(clientProcess.ExitReason());
	test_Equal(EExitKill, clientProcess.ExitType());

	RDebug::Printf("Main: kick server");
	TheSemaphore.Signal();
	
	RDebug::Printf("Main: wait for server to exit");
	serverThread.Logon(status);
	User::WaitForRequest(status);
	test_KErrNone(serverThread.ExitReason());
	test_Equal(EExitKill, serverThread.ExitType());

	User::After(1);
	RDebug::Printf("Main: exit");
	}
// -----------------------------------------------------------------------------
// StartServer
// Static function to start the server process thread.
// Start the server process/thread which lives in an EPOCEXE object.
// Returns: TInt: KErrNone (0) if no error
// -----------------------------------------------------------------------------
//
static TInt StartServer()
    {
    const TUidType serverUid(KNullUid, KNullUid, KVoIPServerUid3);

    // Only one instance of the server is allowed. Attempt of launching
    // second instance of the server will fail with KErrAlreadyExists.
    RProcess server;
    TInt r = server.Create(KVoIPServerName, KNullDesC, serverUid);

    if (r != KErrNone)
        {
        return r;
        }

    TRequestStatus stat;
    server.Rendezvous(stat);

    if (stat != KRequestPending)
        {
        server.Kill(0); // abort startup
        }
    else
        {
        server.Resume(); // logon OK - start the server
        }

    User::WaitForRequest(stat); // wait for start or death

    // Panic reason cannot be '0' as it would conflict with KErrNone
    r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
    server.Close();
    return r;
    }
Esempio n. 24
0
// -----------------------------------------------------------------------------
// StartServer
// Static method to start the server.
// Start the server process. Simultaneous launching
// of two such processes should be detected when the second one attempts to
// create the server object, failing with KErrAlreadyExists.
// -----------------------------------------------------------------------------
//
static TInt StartServer( TUid aUid3, const TDesC& aFileName )
    {
    const TUidType serverUid( KNullUid, KNullUid, aUid3 );
    RProcess server;
    TInt r = server.Create( aFileName, KNullDesC, serverUid );
    if ( r != KErrNone )
        {
        return r;
        }
    TRequestStatus stat;
    server.Rendezvous( stat );
    if ( stat != KRequestPending )
        {
        server.Kill( 0 ); // abort startup
        }
    else
        {
        server.Resume(); // logon OK - start the server
        }
    User::WaitForRequest( stat ); // wait for start or death
    // we can't use the 'exit reason' if the server panicked as this
    // is the panic 'reason' and may be '0' which cannot be distinguished
    // from KErrNone
    r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
    server.Close();
    return r;
    }
Esempio n. 25
0
// -----------------------------------------------------------------------------
// RPsmServer::StartServer
// Starts server.
// -----------------------------------------------------------------------------
//
TInt RPsmServer::StartServer() const
    {
    COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::StartServer()" ) ) );

    RProcess server;
    const TUidType serverUid( KNullUid, KPsmServerUid2, KNullUid );
    TInt err = server.Create( ServerLocation(), // psmserver.exe
                              KNullDesC, // A descriptor containing data passed as 
                                         // an argument to the thread function of 
                                         // the new process's main thread, when it 
                                         // is first scheduled.
                              serverUid, // PSM server UID
                              EOwnerProcess ); // Ownership of this process handle 

    // Return error code if we couldn't create a process
    if ( err == KErrNone )
        {
        // Rendezvous is used to detect server start
        TRequestStatus stat;
        server.Rendezvous( stat );

        if ( stat != KRequestPending )
            {
            ERROR_TRACE( ( _L( "PSM Client - RPsmServer::StartServer - ERROR: Rendezvous failure: %d" ), stat.Int() ) );
            server.Kill( 0 ); // Abort startup
            }
        else
            {
            server.Resume();  // Logon OK - start the server
            }

        COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::StartServer - Waiting server startup" ) ) );

        User::WaitForRequest( stat ); // Wait for start or death

        COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::StartServer - Server startup wait finished" ) ) );
        
        // We can't use the 'exit reason' if the server paniced as this
        // is the panic 'reason' and may be '0' which cannot be distinguished
        // from KErrNone
        if ( server.ExitType() == EExitPanic ) 
            {
            ERROR_TRACE( ( _L( "PSM Client - RPsmServer::StartServer - ERROR: Server paniced at startup" ) ) );
            err = KErrGeneral;
            }
        else
            {
            err = stat.Int();
            }

        // We can close the handle now
        server.Close();        
        }

    COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::StartServer - return %d" ), err ) );

    return err;
    }
Esempio n. 26
0
// resume the exe and if compatibility mode is available, check that the
// expected outcome of the test loop was observed (check 2)
// delete it afterward.
void DoStopExe(RProcess& p, TInt aExpectedUnsafe)
{
    TRequestStatus s;
    p.Logon(s);
    p.Resume();
    User::WaitForRequest(s);
    if (CompatMode)
        test_Equal(aExpectedUnsafe ? 1 : 0, s.Int());
    test_Equal(EExitKill, p.ExitType());
    p.NotifyDestruction(s);
    p.Close();
    User::WaitForRequest(s);
}
TInt RLbsLocMonitorSession::StartServer()
	{
	TRequestStatus started;
	started = KRequestPending;

#ifdef _DEBUG
	RDebug::Print(_L("EPos: LocMonitor API: Starting <Test> Location Monitor Server..."));
#endif
	
	//const TUid KLocMonServerUid2 = { 0x1000009B };
	const TUidType serverUid(KNullUid, KNullUid, KLocMonServerUid3);

	// Simultaneous launching of two such processes should be detected 
	// when the second one attempts to create the server object, 
	// failing with KErrAlreadyExists.
	//
	RProcess server;
	TInt ret = server.Create(KLocMonServerName, KNullDesC, serverUid);
	
	if (ret != KErrNone)
		{
#ifdef _DEBUG
		RDebug::Print(_L("EPos: LocMonitor API:  server start failed %d"), ret);
#endif
		return ret;
		}

	TRequestStatus died;
	server.Rendezvous(died);

	if (died != KRequestPending)
		{
		// logon failed - server is not yet running, so cannot have terminated
		User::WaitForRequest(died);             // eat signal
		server.Kill(0);                         // abort startup
		}
	else
		{
		server.Resume();
		User::WaitForRequest(died);             // wait for start or death
		}

	// we can't use the 'exit reason' if the server panicked as this
	// is the panic 'reason' and may be '0' which cannot be distinguished
	// from KErrNone
	ret = (server.ExitType() == EExitPanic) ? KErrGeneral : died.Int();
	server.Close();
	return ret;

	}
Esempio n. 28
0
void ExecSlave(TUint aArg)
	{
	RProcess proc;
	TInt r = proc.Create(KSecuritySlavePath, TPtrC((TUint16*) &aArg, sizeof(aArg)/sizeof(TUint16)));
	test(r == KErrNone);
	TRequestStatus status;
	proc.Logon(status);
	proc.Resume();
	User::WaitForRequest(status);
	// The slave must panic
	test_Equal(EExitPanic, proc.ExitType());
	test_Equal(EPlatformSecurityTrap, proc.ExitReason());
	CLOSE_AND_WAIT(proc);
	}
// -----------------------------------------------------------------------------
// RHssInterface::StartServer()
// Starts the server if it is not already running
// -----------------------------------------------------------------------------
//
TInt RHssInterface::StartServer()
    {
    TInt res( KErrNone );
    // create server - if one of this name does not already exist
    TFindServer findServer( KHotSpotDataServerName );
    TFullName name;

    if ( findServer.Next( name ) != KErrNone ) // we don't exist already
        {
        RProcess server;
        // Create the server process
        res = server.Create( KHotSpotServerExe, KNullDesC );

        if ( res != KErrNone ) // thread created ok - now start it going
            {
            return res;
            }

        // Rendezvous is used to detect server start
        TRequestStatus status;
        server.Rendezvous( status );                                                 
                                                                                   
        if ( status != KRequestPending )                                             
            {
            DEBUG1( "StartServer Rendezvous ERROR: %d", status.Int() );
            server.Kill( 0 );    // abort startup                                 
            }                                                                      
        else                                                                       
            {                                                                      
            server.Resume();    // logon OK - start the server                     
            }                                                                      
        
        DEBUG( "StartServer wait for start" );
        User::WaitForRequest( status ); // wait for start or death

        // We can't use the 'exit reason' if the server paniced as this                                                          
        // is the panic 'reason' and may be '0' which cannot be distinguished                                        
        // from KErrNone                                                                                             
        res = ( server.ExitType() == EExitPanic ) ? KErrGeneral : status.Int();
        
        // we're no longer interested in the other process
        server.Close(); 
        }
        
    return res;

    }
Esempio n. 30
0
// ---------------------------------------------------------------------------
// Starts runtime security manager server
//
// ---------------------------------------------------------------------------
//
TInt RSecMgrSession::StartSecManagerServer() const
	{
	RTSecMgrTraceFunction("RSecMgrSession::StartSecManagerServer()") ;
	RProcess server;
	const TUidType serverUid( KNullUid, KSecMgrServerUid2, KNullUid);
	TInt err = server.Create ( ServerLocation (), 
			KNullDesC, 
			serverUid, 
			EOwnerProcess);

	// Return error code if we the process couldn't be created
	if ( KErrNone == err)
		{
		// Rendezvous is used to detect server start
		TRequestStatus status;
		server.Rendezvous ( status);
		if ( status != KRequestPending)
			{
			// Log Abort Error
#ifdef _DEBUG
			RDebug::Print(KServerStartFailed);
#endif			
			server.Kill ( 0); // Abort startup
			}
		else
			{
			server.Resume (); // Logon OK - start the server
			}
		User::WaitForRequest (status); // Wait for start or death

		if ( server.ExitType ()== EExitPanic)
			{
#ifdef _DEBUG
			RDebug::Print(KServerStartFailed);
#endif
			err = KErrGeneral;
			}
		else
			{
			err = status.Int ();
			}

		// We can close the handle now
		server.Close ();
		}
	return err;
	}