int InstallOperation::startJavaInstaller() { JELOG2(EDebugApi); std::string args = java::runtime::JAVA_INSTALLER_STARTER_DLL; args += " poll -address=debugapi"; std::auto_ptr<HBufC> cmdLine(stringToDes(args.c_str())); std::auto_ptr<HBufC> exe(stringToDes(java::runtime::JAVA_PROCESS)); RProcess process; int rc = process.Create(exe->Des(), cmdLine->Des()); if (KErrNone == rc) { // wait for JavaInstaller exit TRequestStatus status; process.Logon(status); process.Resume(); User::WaitForRequest(status); rc = status.Int(); process.Close(); } LOG1(EDebugApi, EInfo,"javainstaller exit code: %d", rc); return rc; }
/** @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")); }
/** 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; }
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"); }
/** Uses a test executable to define or delete a test version of the theme server rotation RProperty */ void CTRenderOrientation::ThemeServerProperty(const TDesC& aCmd) { /* This Process called with the argument KThemeServerPropertyDefineCmdDefine defines the theme server RProperty, or with KThemeServerPropertyDefineCmdDelete, deletes the theme server RProperty. This is because an RProperty with this catagory UID can only be defined and deleted from within a process with the same UID3 as the RProperty catogory you are trying to define/delete */ RProcess themeServerPropertyDefine; TInt err = themeServerPropertyDefine.Create(KThemeServerPropertyDefine, aCmd); if (KErrNone != err) { _LIT(KLog, "themeServerPropertyDefine.Create() failed with error: %d"); INFO_PRINTF2(KLog, err); TEST(EFalse); } // wait for themeServerPropertyDefine process to terminate TRequestStatus themeServerPropertyDefineLogonStatus; themeServerPropertyDefine.Logon(themeServerPropertyDefineLogonStatus); themeServerPropertyDefine.Resume(); User::WaitForRequest(themeServerPropertyDefineLogonStatus); if (themeServerPropertyDefineLogonStatus != KErrNone) { _LIT(KLog, "themeServerPropertyDefine.Logon() failed with error: %d"); INFO_PRINTF2(KLog, themeServerPropertyDefineLogonStatus); TEST(EFalse); } themeServerPropertyDefine.Close(); }
/** Starts test step @internalComponent @return TVerdict pass / fail @pre N/A @post N/A */ enum TVerdict CT_WServCapCheckStepTSizeMode::runTestCaseL(const TDesC& aExecutable, const TInt& aExitReason) { __UHEAP_MARK; // mark the heap state //Launch window server client process read fron ini file RProcess process; User::LeaveIfError(process.Create(aExecutable, KNullDesC)); process.SetPriority(EPriorityHigh); TEST(process.Priority() == EPriorityHigh); INFO_PRINTF3(_L("Process Priority: Actual: %d, Expected: %d"), process.Priority(), EPriorityHigh); //Wait for the client process to terminate TRequestStatus status; process.Logon(status); process.Resume(); User::WaitForRequest(status); //Check the window server client exit reason INFO_PRINTF3(_L("Process Check: Actual: %d, Expected: %d"), process.ExitReason(), aExitReason); TEST(process.ExitReason() == aExitReason); __UHEAP_MARKEND; // check for no memory leak return TestStepResult(); }
/** 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 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; }
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(); }
void CTestCalInterimApiSuiteStepBase::WaitForAgendaServerShutdown() { // the name of the agenda server process includes its uid like this [10003a5b] _LIT(KAgendaServerUIDMatch, "*[10003a5b]*"); TFindProcess findProcess(KAgendaServerUIDMatch); TFullName fullName; TInt findProcessResult(KErrNone); findProcessResult = findProcess.Next(fullName); if (findProcessResult == KErrNone) { // find the latest agenda server process while (findProcessResult == KErrNone) { findProcessResult = findProcess.Next(fullName); } // The agenda server process is running so wait RProcess process; if (process.Open(fullName) == KErrNone) { TRequestStatus processStatus; process.Logon(processStatus); // ask for a callback when the process ends // Don't wait for the server to close for longer than 7 seconds RTimer timeOutTimer; timeOutTimer.CreateLocal(); TRequestStatus timeOutStatus; timeOutTimer.After(timeOutStatus, 7000000); // Wait for either the agenda server to close // or the time out timer to time out. User::WaitForRequest(processStatus, timeOutStatus); if (timeOutStatus.Int() == KRequestPending) { timeOutTimer.Cancel(); User::WaitForRequest(timeOutStatus); } else { if (timeOutStatus.Int() == KErrNone) { // Agenda server shutdown request has timed out ERR_PRINTF1(KErrAgendaServerShutdownTimedOut); SetTestStepResult(EFail); } } timeOutTimer.Close(); process.LogonCancel(processStatus); process.Close(); } } }
// This function can be used to compare the performance with the old (e.g. attachExe) and new // (e.g. attachAll) APIs depending depending on the parameters passed in when running this test. void CRunModeAgent::TestDriverPerformance() { LOG_ENTRY(); test.Start(_L("TestDriverPerformance")); RProcess process; test(KErrNone == DebugDriver().Connect(securityServerVersion)); LOG_MSG("iParams.iNumOfTestRuns = %d", iParams.iNumOfTestRuns); for ( TUint i = 0; i < iParams.iNumOfTestRuns; i++ ) { ilaunchCompleted = EFalse; Attach(); SetEventAction(); test(KErrNone == LaunchProcessL(process, KRMDebugTestApplication(), KTargetOptions)); LOG_MSG("CRunModeAgent::TestDriverPerformance - process.Logon"); while ( !ilaunchCompleted ) { LOG_MSG("CRunModeAgent::TestDriverPerformance - DebugDriver().GetEvent"); GetEvent(); LOG_MSG("CRunModeAgent::TestDriverPerformance - User::WaitForRequest"); User::WaitForRequest(iStatus); LOG_MSG( "iStatus.Int() = %d " , iStatus.Int() ); LOG_MSG("CRunModeAgent::TestDriverPerformance - HandleEvent"); HandleEvent(iSEventInfo.iEventInfo); } process.Logon(iStatus); LOG_MSG("CRunModeAgent::TestDriverPerformance - process.Logon, User::WaitForRequest"); User::WaitForRequest(iStatus); LOG_MSG( "iStatus.Int() = %d " , iStatus.Int() ); // Stop timer on logon request completion as in benchmark performance test iParams.iCountEnd = GetTimeInMs(); // prefetch abort should raise a KERN-EXEC 3 test(3 == iStatus.Int()); Detach(); process.Close(); GetStartTime(); // NTickCount shouldn't overflow, so no reason why this assertion should fail test(iParams.iCountEnd > iParams.iCountStart); iTimeDifs.Append( iParams.iCountEnd - iParams.iCountStart ); } LOG_EXIT(); }
TInt Wait(RProcess& aProcess) #endif { aProcess.Logon(iStatus); aProcess.Resume(); SetActive(); CActiveScheduler::Start(); return iStatus.Int(); }
void CApaParentProcessMonitor::ConstructL() { User::LeaveIfError(iProcess.Open(iProcessId)); iProcess.Logon(iStatus); if(iStatus==KErrNoMemory) { User::WaitForRequest(iStatus); User::Leave(KErrNoMemory); } CActiveScheduler::Add(this); SetActive(); }
LOCAL_C void LaunchAndWaitL(const TDesC& file) { RProcess p; test(p.Create(file, KNullDesC) == KErrNone); TRequestStatus status = KRequestPending; p.Logon(status); p.Resume(); User::WaitForRequest(status); p.Close(); WaitForServerClose(); }
// 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); }
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); }
void LaunchProcessL(const TDesC& aProcessName, const TDesC& aCmdLine) { TRequestStatus stat; RProcess p; User::LeaveIfError(p.Create(aProcessName, aCmdLine)); // Asynchronous logon: completes when process terminates with process // exit code p.Logon(stat); p.Resume(); User::WaitForRequest(stat); TExitType exitType = p.ExitType(); TInt exitReason = p.ExitReason(); p.Close(); User::LeaveIfError(exitReason); }
// This function allows us to provide a benchmark when comparing the performance with the // old and new APIs using the TestDriverPerformance function below. The two possible // configurations are as follows: // 1. Run t_rmdebug_app with a prefetch abort configuration and measure the time from the // point of crash to the logon request completion. // 2. Load the debug-system and then run the above configuration. void CRunModeAgent::RunBenchMarkTest() { LOG_ENTRY(); test.Start(_L("RunBenchMarkTest")); RProcess process; TRequestStatus status; if (iParams.iDriver) { RDebug::Printf("RunBenchMarkTest() - DebugDriver().Connect()"); test(KErrNone == DebugDriver().Connect(securityServerVersion)); } LOG_MSG("iParams.iNumOfTestRuns = %d", iParams.iNumOfTestRuns); for ( TUint i = 0; i < iParams.iNumOfTestRuns; i++ ) { // Start test application test( KErrNone == LaunchProcessL(process, KRMDebugTestApplication(), KTargetOptions()) ); process.Logon(status); User::WaitForRequest(status); // Stop timer on logon request completion iParams.iCountEnd = GetTimeInMs(); LOG_MSG("iParams.iCountEnd = %d", iParams.iCountEnd); LOG_MSG( "status.Int() = %d " , status.Int() ); // prefetch abort should raise a KERN-EXEC 3 test(3 == status.Int()); process.Close(); GetStartTime(); // NTickCount shouldn't overflow, so no reason why this assertion should fail test(iParams.iCountEnd > iParams.iCountStart); iTimeDifs.Append( iParams.iCountEnd - iParams.iCountStart ); } LOG_EXIT(); }
void CPerformanceFunctionalityBase::CloseProcessL(const TDesC& aProcessName, const TInt aIteration) { _LIT(KillString, "Kill"); if ( aProcessName != KNullDesC ) { _LIT(KServerRunning,"*** The CntSrv process is running ***"); _LIT(KServerIteration, "Found server process on iteration: %d"); INFO_PRINTF1(KServerRunning); INFO_PRINTF2(KServerIteration, aIteration); // the CntSrv process is running so wait RProcess process; const TInt OpenError = process.Open(aProcessName); if ( OpenError == KErrNone) { TRequestStatus status; process.Logon(status); // ask for a callback when the process ends User::WaitForRequest(status); const TInt serverError = process.ExitReason(); TExitCategoryName category = process.ExitCategory(); _LIT(KServerClosed,"*** The CntSrv process has ended with error type: %S, and error value: %d ***"); INFO_PRINTF3(KServerClosed, &category, serverError); process.Close(); if( ( category != KillString ) || ( serverError != KErrNone ) ) { _LIT(KServerError,"*** The server caused an error while closing ***"); ERR_PRINTF1(KServerError); TEST1( EFalse, ETrue); } } else { _LIT(KProcessFailure,"*** Failed to open process, error: %d ***"); ERR_PRINTF2(KProcessFailure, OpenError); TEST1(EFalse, ETrue); } } else { _LIT(KNoProcess,"*** The CntSrv process is NOT running ***"); ERR_PRINTF1(KNoProcess); TEST1(EFalse, ETrue); } }
/* 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; }
void CAppfwkAmaStarterTestStepStandalone::LaunchExe(const TDesC& aFilename, const TDesC& aArguments, TInt aExitReason) { RProcess process; TInt ret = process.Create(aFilename, aArguments, EOwnerThread); TEST(ret == KErrNone); TRequestStatus status; process.Logon(status); User::SetJustInTime(EFalse); process.Resume(); User::WaitForRequest(status); User::SetJustInTime(ETrue); TInt exitReason = process.ExitReason(); process.Close(); // Check the process ended with the expected exit reason INFO_PRINTF3(_L("Process finished with ExitReason '%d' (expected was '%d')"), exitReason, aExitReason); TEST(exitReason == aExitReason); }
TInt RMemSpySession::StartServer() { RProcess server; _LIT(KCommand, "start"); const TUid KServerUid3 = {0xE5883BC2}; TInt error = server.Create(KMemSpyServerName, KCommand);//, KServerUid3); if (error != KErrNone) return error; TRequestStatus startStatus, stopStatus; server.Logon(stopStatus); if (stopStatus != KRequestPending) { User::WaitForRequest(stopStatus); server.Kill(0); server.Close(); return stopStatus.Int(); } server.Rendezvous(startStatus); server.Resume(); User::WaitForRequest(startStatus, stopStatus); if (startStatus == KRequestPending) { // not started yet, i.e. stopStatus was signaled server.Close(); return stopStatus.Int(); } // Rendezvous was called - the server is ready // We first need to cancel Logon server.LogonCancel(stopStatus); // We don't need this anymore server.Close(); // Wait for LogonCancel to complete User::WaitForRequest(stopStatus); // Everything went OK return KErrNone; }
//This function is used in the test code to kill backupSrv or the backuplauncher process. // It creates a separate process to do this as killing a process requires // PwrMgmt capability which we don't want to grant to all test exes. TInt KillProcess(const TDesC& aProcessName) { _LIT(KProcessKiller, "t_processkiller"); TRequestStatus stat; RProcess p; TInt result = p.Create(KProcessKiller, aProcessName); if(result == KErrNone) { // Asynchronous logon: completes when process terminates with process exit code p.Logon(stat); p.Resume(); User::WaitForRequest(stat); result = p.ExitReason(); p.Close(); } return result; }
int epoc_spawn( char *cmd, char *cmdline) { RProcess p; TRequestStatus status; TInt rc; rc = p.Create( _L( cmd), _L( cmdline)); if (rc != KErrNone) { return -1; } p.Resume(); p.Logon( status); User::WaitForRequest( status); p.Kill( 0); if (status!=KErrNone) { return -1; } return 0; }
/** Function : ExecuteActionL Description : Launches the schsendexe.exe and verifies the result of process completion with that of the expected result. @internalTechnology @param : none @return : void @pre @post : none */ void CMtfTestActionLaunchSchSendExe::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionLaunchSchSendExe); // Expected result TInt expectedResult = KErrPermissionDenied; TBuf<20> cmdString; // Return KErrNotSupported in case of Wins TInt returnValue = KErrNotSupported; TRequestStatus status = KRequestPending; RProcess process; User::LeaveIfError(process.Create(KMsvSchSendExe, cmdString, TUidType(KNullUid, KNullUid, KMsvSchSendExeUid))); TestCase().INFO_PRINTF2(_L("RProcess::Create() is successful %S "), &KTestActionLaunchSchSendExe); // Make the process eligible for execution process.Logon(status); process.Resume(); // Wait for the process completion User::WaitForRequest(status); // Check the exit reason of the process.If Panic occurs the return value is set to KErrGeneral as the // focus of test action is to check if KErrPermissionDenied is returned. returnValue = (process.ExitType() == EExitPanic)? KErrGeneral: status.Int(); process.Close(); TestCase().INFO_PRINTF4(_L("Test Action %S completed with %d, while expected %d "), &KTestActionLaunchSchSendExe,returnValue, expectedResult ); if(returnValue != expectedResult ) { TestCase().SetTestStepResult(EFail); } TestCase().ActionCompletedL(*this); }
// This function launches the TPropertyDefine process which // has WriteDeviceData Capabilities enabling it to create the P&S // variables used by this test. static void LaunchHelperL(TUid aCategory, TInt aKey, TInt aAttr) { _LIT(KConditionHelper, "TPropertyDefine"); TRequestStatus stat; RProcess p; TBuf<32> args; args.AppendNum(aCategory.iUid); args.Append(KSeparator); args.AppendNum(aKey); args.Append(KSeparator); args.AppendNum(aAttr); User::LeaveIfError(p.Create(KConditionHelper, args,EOwnerProcess)); // Asynchronous logon: completes when process terminates with process exit code p.Logon(stat); p.Resume(); User::WaitForRequest(stat); TInt exitReason = p.ExitReason(); p.Close(); User::LeaveIfError(exitReason); }
void DoExecuteL(const TDesC& aCmd) { CActiveScheduler* activeSch = new (ELeave) CActiveScheduler(); CleanupStack::PushL(activeSch); CActiveScheduler::Install(activeSch); RProcess process; User::LeaveIfError(process.Create(KMsvAutoSendExe, aCmd, TUidType(KNullUid, KNullUid, KMsvAutoSendExeUid))); TRequestStatus status = KRequestPending; process.Logon(status); process.Resume(); User::WaitForRequest(status); //Check the process completion status TInt err = (process.ExitType() == EExitPanic) ? KErrGeneral: status.Int(); process.Close(); User::LeaveIfError(err); CleanupStack::PopAndDestroy(activeSch); }
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(); }
/** @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); }
EXPORT_C int spawnv(int mode,const char * path,const char **argv) { TText16 iPath16[KMaxFileName]; char replacePath[KMaxFileName]; /* replace / with // */ strcpy(replacePath,path); char *temp = strchr(replacePath,'/'); while (temp) { *temp = '\\'; temp = strchr(replacePath,'/'); } // end while // convert narrow char to wide char if(mbstowcs((wchar_t *)iPath16, replacePath, strlen(replacePath)+1) == (size_t)(-1)) { return -1; } TBuf16<KMaxFileName> iCmdName16; iCmdName16.FillZ(KMaxFileName); iCmdName16.Copy(iPath16); TInt i; TInt iVal = 0; while(argv[iVal]) { iVal++; } //end while TBuf16<MAX_COMMAND_LINE_LENGTH> iArgv16; iArgv16.FillZ(MAX_COMMAND_LINE_LENGTH); iArgv16.SetLength(0); for(i = 0; i < iVal ; i++) { TText16 temp[MAX_COMMAND_LINE_LENGTH]; if(mbstowcs((wchar_t *)temp, argv[i], strlen(argv[i])+1) == (size_t)(-1)) { return -1; } TPtrC16 iTemp(temp,strlen(argv[i])); iArgv16.Append(iTemp); if(i != iVal-1) iArgv16.Append(L' '); } // end for RProcess iProcess; TRequestStatus iStatus; TInt iRetVal = iProcess.Create(iCmdName16,iArgv16); if(iRetVal != KErrNone) { switch(iRetVal) { case KErrNotFound : errno = ENOENT; break; case KErrNoMemory : errno = ENOMEM ; break; case KErrNotSupported : errno = ENOEXEC; break; case KErrBadName : errno = ENAMETOOLONG; break; default: break; } return -1; } if(mode == P_WAIT) { iProcess.Logon(iStatus); iProcess.Resume(); User::WaitForRequest(iStatus); iProcess.Close(); return iStatus.Int(); } else { iProcess.Resume(); return iProcess.Id(); } }