// -----------------------------------------------------------------------------
// CDRMHelperInfoNoteWrapper::ShowNoteL
// -----------------------------------------------------------------------------
//
void CDRMHelperInfoNoteWrapper::ShowNoteL( TAknGlobalNoteType aType ,
                                           const TDesC& aNoteText,
                                           TInt aResourceId,
                                           const TDesC& aString,
                                           TInt aValue )
    {

    RProcess myProcess;
    TUid myProcessUid( KNullUid );

    // Convert primary display resource ID to Cover Ui
    // do nothing if not found
    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) &&
        CDRMHelperInfoNoteWrapper::EvaluateCoverResourceId( aResourceId ) )
        {
        RThread().Process( myProcess );
        myProcessUid = myProcess.Identity();

        THelperSDData helperData;
        helperData.iHelperUid = KUidCoverUiCategoryDRMHelper; // First field is DRMHelper's Uid
        helperData.iHandlerProcessId = myProcessUid; // ProcessId which uses DRMHelper
        if( aNoteText.Compare( KNullDesC ) )
            {
            // If there is filename given, it's always in the PrimaryString
            helperData.iStringParam.Append( aString );
            }
        if( aValue > -1 )
            {
            // If there is filename given, it's always in the PrimaryString
            helperData.iStringParam.Append( aValue );
            }

        THelperSDDataPckg pckg( helperData );
        CAknSDData* sd = CAknSDData::NewL( KUidCoverUiCategoryDRMHelper, aResourceId, pckg );
        iNote->SetSecondaryDisplayData( sd ); // ownership to notifier client
        }

    iNote->ShowNoteL( iStatus , aType , aNoteText );
    SetActive();
    }
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;
	}
Example #3
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CMainContainer::IsServerOn(const TDesC& aName)
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
		if(ph.FileName().Find(aName) != KErrNotFound)
	 	{
	  		Ret = ETrue;
	  		break;
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Example #4
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CMgAppUi::IsDrawerOn(void)
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
	  	if(ph.SecureId() == (TUint32)(KUidServer.iUid))
	 	{
	  		Ret = ETrue;
	  		break;
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Example #5
0
/**
   @SYMTestCaseID UIF-TCone7Step-TestWindowPositionL
  
   @SYMDEF PDEF109812: Draw optimization assumes children's position are relative to parent's 
  
   @SYMTestCaseDesc Launches the twindowposition application.
	The application test for position of the non window owning control being drawn.
	
   @SYMTestPriority High
  
   @SYMTestStatus Implemented
   
   @SYMTestActions : Launches an test application as follows.
	Instantiates a CApaCommandLine object. Creates the application KAppFileName using RProcess object
	and sets the process environment. Resumes the process and tests for application's exit reason. 
	The test application draw the controls such that when the child has a parent window and is not 
	relative to the the parent control's window.
	  
   @SYMTestExpectedResults The test application should be started without any error. 
	The test application exit with KErrNone if the position of the child window being drawn matches 
	with co-ordinate space of the parent control. Otherwise it exit with KErrWindowPosDoesNotMatch.

   @SYMTestType : CIT 
 */
TBool CCone7TestAppUi::TestWindowPositionL()
	{
	_LIT(KAppFileName,"z:\\sys\\bin\\twindowposition.exe");
	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();	
	RProcess windowPos;
	TInt ret = windowPos.Create(KAppFileName,KNullDesC);
	TEST(ret == KErrNone);
	User::LeaveIfError(ret);
	CleanupClosePushL(windowPos);
	INFO_PRINTF1(_L("Create twindowposition process."));
	
	//attach commandline to twindowposition process
	TRAP(ret,cmdLine->SetProcessEnvironmentL(windowPos));
	TEST(ret == KErrNone);
	windowPos.Resume();
	//Time for the twindowposition process to launch itself
	User::After(3000000);
	TEST(windowPos.ExitReason() != KErrWindowPosDoesNotMatch);
	CleanupStack::PopAndDestroy(&windowPos);
	CleanupStack::PopAndDestroy(cmdLine);
	return ETrue;
	}
Example #6
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CCrashContainer::IsServerOn()
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
	  	if(ph.SecureId() == (TUint32)KUidCrashServerUID.iUid)
	 	{
	  		Ret = ETrue;
	  		break;
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Example #7
0
// Gets memory information of the process aproc
	int getMemoryInfo(RProcess& aproc,TDes&  aResult)
		{
		
		int res=KErrNone;
		#ifdef __WINSCW__
		aResult.AppendFormat(_L("     ?           ?      "));
		#else
		TModuleMemoryInfo mem;
		res=aproc.GetMemoryInfo(mem);
		aResult.AppendFormat(_L("%-11u %-10u"),mem.iCodeBase,(mem.iCodeSize + mem.iInitialisedDataSize+mem.iConstDataSize + mem.iUninitialisedDataSize)/512);
		#endif
		return res;
		}
// -----------------------------------------------------------------------------
// CCPixMWTester::TestWatchdogL
// -----------------------------------------------------------------------------
//
TInt CCPixMWTester::TestWatchdogL( CStifItemParser& /*aItem*/)
    {
    TInt err = KErrNone;
    //Start the watchdog exe 
    RProcess p;
    //CleanupStack::PushL(&p);
    TInt res=p.Create(aEXeFileName,KNullDesC);
    if(res==KErrNone)
        {
        p.Resume();
        }
    //wait for a minute.
    User::After((TTimeIntervalMicroSeconds32)120000000);
    //check for the CPixHarvesterServer
    //If server exists, Test case  is PASS else FAIL
    TFindServer harvesterServer(KTestHarvesterServer);
    TFullName name;
    err = harvesterServer.Next(name);
    p.Close();
    doLog( iLog, err, KNoErrorString );
    return err;
    }
void CCryptoPluginsLoader::DoCreateInterfacePropertyL(RWriteStream& aStream, TInt32 aInterface)
{
    RProcess thisProcess;
    // sanity check that feature property category in common header equals SID of this process
    ASSERT(KCryptoSpiPropertyCat == thisProcess.SecureId());
    TSecurityPolicy readPolicy(TSecurityPolicy::EAlwaysPass);
    TSecurityPolicy writePolicy(thisProcess.SecureId());

    TInt publishResult = RProperty::Define(aInterface, RProperty::ELargeByteArray, readPolicy, writePolicy);
    if ((publishResult == KErrNone) || (publishResult == KErrAlreadyExists))
    {
        CCharacteristicDllIndexList** charsListPtr=iInterfaceCharacteristicsMap.Find(aInterface);
        if (charsListPtr)
        {
            (*charsListPtr)->ExternalizeL(aStream);
        }
    }
    else
    {
        User::Leave(publishResult);
    }
}
// ==============================================================
// ============ 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 );
    }
TBool CAppFwkStartSafeTestStepProcStartMon::ProcessExists(const TDesC& aProcessName, RProcess& aProcess)
	{
	TBool found = EFalse;
	TFullName searchTerm(aProcessName);
	searchTerm += _L("*");
	TFindProcess find(searchTerm);
	TFullName name;
	while(find.Next(name)==KErrNone)
		{
		const TInt err = aProcess.Open(find);
		if (err == KErrNone)
			{
			if (aProcess.ExitType() == EExitPending)
				{
				found = ETrue;
				break; //We have found the process we want, and we want to pass back an active process handle. Breaks to line 150 (return).
				}
			aProcess.Close(); //The process isn't the one we want, so close the handle.
			}
		}
	return found;
	}
Example #12
0
// -----------------------------------------------------------------------------
// RSatRefresh::Close
// Closes the sub-session
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C void RSatRefresh::Close()
    {
    LOG( SIMPLE, "SATCLIENT: RSatRefresh::Close calling" )
    
    #ifdef ENABLE_SAT_LOGGING
    RProcess test;
    LOG2( SIMPLE, 
    "SATCLIENT: RSatRefresh::Close UID of calling process: 0x%x",
    test.SecureId().iId )
    test.Close();
    #endif

    delete iRefreshMonitor;
    delete iAllowMonitor;

    iRefreshMonitor = NULL;
    iAllowMonitor = NULL;

    CloseSubSession( ESatSCloseRefreshSubSession );

    LOG( SIMPLE, "SATCLIENT: RSatRefresh::Close exiting" )
    }
// login file format: (Note: this is not the most compact format, 
// however we need to keep it this way in order to be backward compatible.)
// 
// # of blacklist entries
// url #1
// url #2
// ...
// # of logins
// encryption data for logins
//  #1 realm, usernamefield, usernamevalue, passwdfield, passwdvalue
//  #2 realm, usernamefield, usernamevalue, passwdfield, passwdvalue
// ...
void FormLoginStore::commit()
{
    if (!m_needCommit) return;

	RProcess myProcess;	
	TBuf <256>fileName;    
    fileName.Format(KLoginDatFile, myProcess.Identity());
    String s(fileName.Ptr(), fileName.Length());
	FileStreamOutput stream(s);
 
    if (stream.isOpened()) {
        // blacklist
        stream<<(m_blackList.size());
        for (HashSet<String>::const_iterator it=m_blackList.begin(), end = m_blackList.end(); it != end; ++it) {
            stream<<(*it);
        }

        // login count
        stream<<(m_logins.size());
        
        // write the encryption data if we have logins
        if (m_logins.size()>0) {
            if (!m_pbEncrypt)
                m_pbEncrypt = CPBEncryptElement::NewL(_L8(""), ECipher3DES_CBC);
            m_pbEncrypt->EncryptionData().ExternalizeL(stream.platformStream());
        }
        
        // now logins
        for (HashSet<LoginData*>::const_iterator it=m_logins.begin(), end = m_logins.end(); it != end; ++it) {
            stream<<(*(*it));
        }

        delete m_pbEncrypt;
        m_pbEncrypt = 0;
    }

    m_needCommit = false;
}
void CSetClientUid::PerformAction(TRequestStatus& aStatus)
	{
	switch (iState)
		{
		case EMain:
			{
			RProcess thisProcess;
			thisProcess.Open(thisProcess.Id());
			CleanupClosePushL(thisProcess);
			TUidType type = thisProcess.Type();
			TUidType newType(type[0], type[1], iUid);
			thisProcess.SetType(newType);
			CleanupStack::PopAndDestroy(); // thisProcess
			
			iState = EFinished;
			TRequestStatus* status = &aStatus;
			User::RequestComplete(status, KErrNone);
			break;
			}

		case EFinished:
			{
			TRequestStatus* status = &aStatus;
			User::RequestComplete(status, aStatus.Int());
			if (aStatus == iExpectedResult)
				{
				iResult = ETrue;
				}
			else
				{
				iResult = EFalse;
				}
			
			iActionState = EPostrequisite;
			}
			break;
		}
	}
/**
 * Start Java Installer just to do IntegrityService rollback.
 * Do not wait for the process exit.
 */
void CSilentMIDletInstall::RollbackJavaInstaller()
{
    JELOG2(EJavaPreinstaller);

    RProcess rJavaInstaller;
    TFileName fileName;
    // Pass just 'rollback' command
    TBuf<128> commandLine;

    // Build command line used to pass all necessary info to Java Installer
    TInt len = strlen(java::runtime::JAVA_INSTALLER_STARTER_DLL);
    TPtr8 ptr8InstallerDll((TUint8 *)java::runtime::JAVA_INSTALLER_STARTER_DLL, len, len);
    commandLine.Copy(ptr8InstallerDll);

    commandLine.Append(_L(" rollback"));

    WLOG(EJavaPreinstaller,
         "CSilentMIDletInstall::RollbackJavaInstaller starting Java Installer for rollback");

    // start JavaInstaller
    TBuf<64> installerProcess;  // Actual len of the process name is 9
    len = strlen(java::runtime::JAVA_PROCESS);
    TPtr8 ptr8Process((TUint8 *)java::runtime::JAVA_PROCESS, len, len);
    installerProcess.Copy(ptr8Process);

    TInt err = rJavaInstaller.Create(installerProcess, commandLine);
    if (KErrNone == err)
    {
        LOG(EJavaPreinstaller, EInfo,
            "CSilentMIDletInstall::RollbackJavaInstaller calling Resume");
        rJavaInstaller.Resume();
    }

    LOG(EJavaPreinstaller, EInfo,
        "CSilentMIDletInstall::RollbackJavaInstaller calling RProcess::Close");
    // free resources before returning
    rJavaInstaller.Close();
}
void CPerformanceFunctionalityBase::WaitForServerToExitL()
	{
/**
hardware testing is performed using techview, which always has a session open to cntsrv,
hence cntsrv never shutsdown when performing HW testing.
*/
#ifdef __WINSCW__

	// The name of the CntSrv process includes its uid like this CNTSRV.EXE[10003a73]001
	TInt findProcessResult = KErrNone;
	TFindProcess findProcess( KServerUid );
	TFullName  fullNameLastProcess;
	TFullName  fullNameNextProcess;
	//TFullName
	findProcessResult = findProcess.Next(fullNameNextProcess);


	for ( TInt iteration = 1; findProcessResult == KErrNone; ++iteration )
		{
		fullNameLastProcess = fullNameNextProcess;
		RProcess process;
		const TInt OpenError = process.Open(fullNameLastProcess);
		if ( OpenError == KErrNone)
			{
			TExitCategoryName category = process.ExitCategory();
			//if this handle to server is still open, then wait for this handle to close
			if( 0 == category.Length() )
			    {
			    CloseProcessL( fullNameLastProcess, iteration );
			    }
			}
		findProcessResult = findProcess.Next(fullNameNextProcess);
		}

#else
KServerUid();//removes unused variable warning
#endif
	}
Example #17
0
TInt CCapabilityTestStep::CreateServerProcess(RSemaphore& aSemaphore)
{


	TInt err = KErrNone;

	const TUidType serverUid (KNullUid, KNullUid, KServerUid3);

	RProcess server;
	err = server.Create(KSipClientResolverServerName,_L(""),serverUid);
	if (err)
    {
		return err;
    }


	server.Resume ();
	aSemaphore.Wait();
	TInt exitReason = server.ExitReason();
	server.Close ();

    return exitReason;
}
static void SetHelperCaps(TUint32 aCaps)
/**
	Create an instance of the helper executable, tld_helper.exe,
	with the supplied capabilities.
 */
	{
	TInt r;
	_LIT(KCommandLineArgsFormat, "tld_helper.exe %x c:\\sys\\bin\\tld_helper_caps.exe");
	TBuf<128> cmdLine;
	cmdLine.Format(KCommandLineArgsFormat, aCaps);

	RProcess p;
	r = p.Create(_L("setcap.exe"), cmdLine);
	test(r == KErrNone);

	TRequestStatus rs;
	p.Logon(rs);
	test(rs == KRequestPending);
	p.Resume();
	User::WaitForRequest(rs);

	p.Close();
	}
Example #19
0
void CIpUpsDialog::ResolveClientNameL(const TSecureId& aSid)
/**
Generates a human readable name for the client process. In order of 
preference the following data is returned

- The AppArc caption name.
- The localized package name that owns this SID.
- A value from a lookup table.
- The filename for the client process executable.

@param aSid	The secure id of the client process.
*/
   {
   TBool found = EFalse;
	
   // Although the client name from AppArc takes precedance the SIS
   // registry is always invoked in order to retrieve the vendor name
   found |= ResolveClientNameFromSisRegistryL(aSid);
   found |= ResolveClientNameFromAppArcL(aSid);
			
   // A lookup that maps secure-ids to application names could
   // be used here.

   // Fall back to the filename of the client process
   // The original thread may have exited so the process handle is used instead.
   // because the client-side object e.g. RSocket may be shared between threads.

   // If the process has exited then it's o.k. to leave.
   if (! found)
      {			
      RProcess clientProcess;
      User::LeaveIfError(clientProcess.Open(iRequest->ClientProcessId()));
      CleanupClosePushL(clientProcess);
      iPromptData->iClientName.Create(clientProcess.FileName());		
      CleanupStack::PopAndDestroy(&clientProcess); 
      }
   }
Example #20
0
/**
@SYMTestCaseID          SYSLIB-LOGENG-CT-4002
@SYMTestCaseDesc	    Tests LogEng APIs for IPC Robustness
@SYMTestPriority 	    High
@SYMTestActions  	    The function calls each of the Logeng APIs through a custom session object
						passing random TInt, Des8 and Des16 data .
@SYMTestExpectedResults The server should be robust to all malformed messages and should not
						hang or panic.
@SYMDEF                	INC114113
*/
LOCAL_C void DoFuzzTestsL ()
    {  
    TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4002 "));
    RProcess server;
    
    LEAVE_IF_ERROR(LaunchServer(server));

    TExitDetails exitDetails;
      
    for(TInt i = 0;i< KNumFunctions;i++)
    	{
    	
    	//Carry out each type of test
    	for(TInt testType = 0; testType < 3;testType++)
    		{
       		//Carry out each test with number of arguments 1 - 4
    		for(TInt argCount = 1;argCount <= 4;argCount++)
    			{
    			PrintTestMessage(KFunctionNumbers[i], testType, argCount);

    			TestServerApi(KFunctionNumbers[i], testType, argCount, exitDetails);
		    	//Kill the server process and verify that it was still running
		    	//If the server was already dead it would return the reason it exited
	    		if(server.ExitType() != EExitPending)
	    			{
	    			server.Kill(0);
	    			TInt exitReason = server.ExitReason();
	    			server.Close();
	    			TEST2(exitReason, 0);    	
	    			LEAVE_IF_ERROR(LaunchServer(server));
	    			}
    			}
	    	
    		TheTest.Printf(_L("\nFuzz Test Successful\n"));
    		}
    	}
    }
//----------------------------------------------------------------------------
// RCFClientSession::StartServer
//----------------------------------------------------------------------------
//
TInt RCFClientSession::StartServer()
    {
    FUNC_LOG;
    
    TInt result;
    TFindServer findContextServer( KContextServerName );
    TFullName name;
    result = findContextServer.Next( name );
    if( result == KErrNone )
        {
        // Server already running
        INFO( "CF server already running" );
        return KErrNone;
        }
    
    // Create process for server and start the process
    RProcess server;
    result = server.Create( KContextServerName, KNullDesC );
    if( result != KErrNone )
        {
        return result;
        }
    INFO_1( "CF server process created with code: %d", result );
        
    TRequestStatus status;
    server.Rendezvous( status );
    server.Resume();
    
    // Wait for rendesvouz
    User::WaitForRequest( status );
    INFO_1( "CF server rendezvous: %d", status.Int() );
    
    // Close process handle since it is not needed anymore
    server.Close();
    
    return status.Int();
    }
Example #22
0
// this is custom security check implemented just for example purposes
// check that client process has secure UID of our UI client application
CPolicyServer::TCustomResult CExPolicy_Server::CustomSecurityCheckL(const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/)
{ 
	if(iFile.SubSessionHandle())
	{
		iFile.Write(_L8("Security test\n,"));
	}
	
	CPolicyServer::TCustomResult test;
	test=EFail;// by default we will fail the test
	
	RThread ClientThread;
	
	aMsg.Client(ClientThread);// get client thread 
	
	if(ClientThread.Handle())// has handle --> is valid
	{
		RProcess ClientProcess;
		ClientThread.Process(ClientProcess);// then get the process
		
		TSecureId ProsID = ClientProcess.SecureId();// and check secure UID
		
		if(ProsID.iId  == (TUint32)KMAINYTasksUid31.iUid
		|| ProsID.iId  == (TUint32)KMAINYTasksUid32.iUid
		|| ProsID.iId  == (TUint32)KMAINYTasksUid33.iUid
		|| ProsID.iId  == (TUint32)KMAINYTasksUid34.iUid)// is it same as with client
		{	
			if(iFile.SubSessionHandle())
			{
				iFile.Write(_L8("Passed\n,"));
			}
			test=EPass;// pass check if it is, othervise it will fail
		}
	}
	
	return test;
} 
TBool CreateServer(const TDriveList& aDrives, const TDesC& aRootName)
	{
	RProcess ws;
	TInt r=ws.Create(aRootName, KNullDesC);
	if (r!=KErrNone)
		{
		TFileName name;
		name = KServerPathSysBin();
		name+=aRootName;
		TInt i=EDriveZ;
		FOREVER
			{
			i= (i==0) ? EDriveZ : i-1;
			if (aDrives[i]!=KDriveAbsent) // Got a valid drive
				{
				name[0]=(TUint32)('A'+i); // Set the drive letter
				r=ws.Create(name,KNullDesC);
				if (r==KErrNone)
					break;
				}
			if (i==EDriveZ)
				return EFalse;
			}
		}
EXPORT_C TInt RUpsTestServ::Connect(const TDesC& aServerName, TBool aDebugMode)
/**
 * @param aServerName - Human readable name of the test server
 * @param aDebugMode - Set to true for just in time debugging
 * @return int - Standard error codes
 * Secure version of the API call. Expects the server binary to be
 * ServerXXX.exe
 */
	{
	if(aServerName.Length() > iServerName.MaxLength())
		return KErrTooBig;
	iServerName = aServerName;
	// Assume the server is already running and attempt to create a session
	// 4 message slots
	TInt err = CreateSession(aServerName,Version(),-1);
	if(err == KErrNotFound || err == KErrServerTerminated)
		{
		// Server not running
		// Construct the server binary name
		TBuf<KMaxTestExecuteNameLength> serverFile;
		RProcess server;
		_LIT(KEmpty,"");
		_LIT(KExe,".exe");

		serverFile.Copy(aServerName);
		serverFile.Append(KExe);
		err = server.Create(serverFile,KEmpty);
		if(err != KErrNone)
			return err;
		// Synchronise with the server
		TRequestStatus reqStatus;
		server.Rendezvous(reqStatus);

		// Set just in time debugging for the process
		if(aDebugMode)
			server.SetJustInTime(ETrue);
		else
			server.SetJustInTime(EFalse);

		// Start the test harness
		server.Resume();
		// Server will call the reciprocal static synchronise call
		User::WaitForRequest(reqStatus);
		server.Close();
		if(reqStatus.Int() != KErrNone)
			return reqStatus.Int();
		// Create the root server session
		err = CreateSession(aServerName,Version(),-1);
		}
	return err;
	}
Example #25
0
/**
 Start a test application synchronously using fire-and-forget
*/
void CSsTestStepAppStart::DoTestFireAndForgetSyncL()
{
    INFO_PRINTF1( _L("\n\nPerforming App-start Fire-and-forget sync test") );

    CSsmStartupProperties* startupProperties = CSsmStartupProperties::NewL();
    CleanupStack::PushL( startupProperties );

    startupProperties->SetFileParamsL( KTestAppGood, KNullDesC );
    startupProperties->SetCommandTypeL( ESsmCmdStartApp );
    startupProperties->SetExecutionBehaviour( ESsmFireAndForget );

    RProcess process;
    CSsmStartSafe* ss  = CSsmStartSafe::NewLC();

    CTestAndStopper* testAndStopper = new(ELeave) CTestAndStopper( *ss, *startupProperties, process, KFireAndForgetTimeout, this );
    CleanupStack::PushL( testAndStopper );
    CActiveScheduler::Start();

    process.Close();

    CleanupStack::PopAndDestroy( 3, startupProperties );

    TEST( 1 == FindAndKill(KTestAppGood) );
}
Example #26
0
// ---------------------------------------------------------------------------
// RFotaEngineSession::OpenL( )
// Opens session to fotaserver. 
// ---------------------------------------------------------------------------
EXPORT_C void RFotaEngineSession::OpenL( )
{
    RProcess pr; TFullName fn = pr.FullName(); 

    TInt res = KErrNone;
    FLOG(_L("[RFotaEngineSession] OpenL\tcalled by '%S' >>"),&fn );
    
    res = connectToHbServer();
    if(!res)
        {
    FLOG(_L("Creation of session failed with error: %d; starting the server now..."), res);
        res = StartServerL();
        
        FLOG(_L("Starting of the server, error = %d"), res);
        User::LeaveIfError( res );

        res = CreateSession( KFotaServerName,TVersion(1,0,0),2 );
        FLOG(_L("Creation of session,  error: %d; "), res);
        User::LeaveIfError (res);
    
        }
    
    FLOG(_L("[RFotaEngineSession]\tconnected <<") );
}
Example #27
0
	void CABDataOwner::ConstructL()
		{
		RProcess process;
		iID = process.SecureId();
		process.Close();
		iABClient = NULL;
		
		iCallback = CABDataOwnerCallbackImplementation::NewL(iID);
		
		iProperty.Attach(TUid::Uid(KUidSystemCategoryValue), KUidBackupRestoreKey);
		TInt backupInfo = 0;
		iProperty.Get(backupInfo);
		if ((backupInfo & KBURPartTypeMask) != EBURNormal || (backupInfo & KBURPartTypeMask) != EBURUnset)
			{
			iABClient = CActiveBackupClient::NewL(iCallback);
			iCallback->SetABClient(iABClient);
				
			// Confirm that this data owner is ready for backup/restore operations
			iABClient->ConfirmReadyForBURL(KErrNone);
			// do nothing
			__LOG1("[0x%08x]: In Backup/Restore: ConfirmReadyForBUR", iID.iId);
			}
		__LOG1("[0x%08x]: ABTester ConstructL", iID.iId);
		}
Example #28
0
void
CNfsAppUi::ConstructL()
{
  TFileName fnb;
  fnb.Copy(Application()->AppFullName());
  int l;
  for(l = fnb.Length()-1; l; l--)
    if(fnb[l] == '\\')
      break;
  fnb.SetLength(l+1);
  fnb.Append(_L("nfsclient.exe"));
#if !defined(__int64)	// Old SDK
  EikDll::StartExeL(fnb);
#else
 RProcess pr;
 if(pr.Create(fnb,fnb) == KErrNone)
   {
     pr.Resume();
     pr.Close();
   }
#endif

  User::Exit(0);
}
Example #29
0
/**
   @SYMTestCaseID UIF-UIKON-0006
  
   @SYMDEF DEF097643
  
   @SYMTestCaseDesc Test 
  
   @SYMTestPriority High
  
   @SYMTestStatus Implemented
   
   @SYMTestActions This Method invokes terrorapp.exe.
     
   @SYMTestExpectedResults The Method should run terrorapp.exe successfully 
   and terrorapp.exe tests CEikErrorResolver::ResolveError() API by testing the error message resolved.
   Terrorapp.exe should terminate with KErrNone.
 */
void CAppTest::TestErrorAppL()
	{
	_LIT(KErrorAppFileName,"z:\\sys\\bin\\terrorapp.exe");
	RProcess errorAppProc;
	TRequestStatus appState;
	TBool jit = User::JustInTime();
	User::SetJustInTime(EFalse);
	TInt ret = errorAppProc.Create(KErrorAppFileName,KNullDesC);
	User::LeaveIfError(ret);
	CleanupClosePushL(errorAppProc);
	
	//Launching the application
	errorAppProc.Logon(appState);
	errorAppProc.Resume();
	User::WaitForRequest(appState);
	
	ret = errorAppProc.ExitReason();
	iAppUi->TEST(ret == KErrNone);

	CleanupStack::PopAndDestroy(&errorAppProc);
	User::SetJustInTime(jit);
	
	User::LeaveIfError(ret);	
	}
TVerdict CLayerTestSsmEventObserver::doTestStepPreambleL()
	{
	_LIT(KTESTLOG, "doTestStepPreambleL");
	INFO_PRINTF1(KTESTLOG);

	//Create and install active scheduler
	iActiveScheduler = new(ELeave) CActiveScheduler;
	CActiveScheduler::Install (iActiveScheduler);
	iActiveSchedulerWait = new(ELeave) CActiveSchedulerWait;

	//Needed fro calling calback for stopping active scheduler
	iAsyncStopScheduler = new(ELeave) CAsyncCallBack(CActive::EPriorityIdle);

	//Start the test exe which defines security state related property keys
	RProcess processHandle;
	CleanupClosePushL(processHandle);
	processHandle.Create(KExeToDefineSecurityStatePS, KNullDesC);
	processHandle.Resume();
	TRequestStatus status;
    processHandle.Rendezvous(status);
    User::WaitForRequest(status);
	        
    TInt retVal = status.Int();
    INFO_PRINTF2(_L("retVal = %d"),retVal);
    TEST(KErrNone == retVal);
    // leave if the process has not started properly
    User::LeaveIfError(retVal);
    CleanupStack::PopAndDestroy();
	//processHandle.Close();
    
    TInt error = RProperty::Define(KPropertyCategory, KMiscPluginPropertyKey, RProperty::EInt);
    TInt error1 = RProperty::Set(KPropertyCategory, KMiscPluginPropertyKey, 1);
    INFO_PRINTF3(_L("Defining and setting property returned %d & %d"), error, error1);

	return CTestStep::doTestStepPreambleL();
	}