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(); }
/** 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; }
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); } }
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 }