TInt ChildThread(TAny* aArg) { TInt testType = (TInt)aArg; RThread mainThread; TInt r = mainThread.Open(MainThreadId); if (r != KErrNone) return r; // Open handle on dynamic DLL in this thread RLibrary library; test_KErrNone(library.Load(KDynamicDll)); RThread().Rendezvous(KErrNone); TRequestStatus status; mainThread.Logon(status); User::WaitForRequest(status); if (mainThread.ExitType() != EExitKill) return KErrGeneral; if (mainThread.ExitReason() != KErrNone) return mainThread.ExitReason(); mainThread.Close(); if (testType != ETestRecursive) { RMsgQueue<TMessage> messageQueue; r = messageQueue.OpenGlobal(KMessageQueueName); if (r != KErrNone) return r; r = messageQueue.Send(EMessagePreDestruct); if (r != KErrNone) return r; } return testType; }
void UnfragmentMemory(TBool aDiscard, TBool aTouchMemory, TBool aFragThread) { test_Value(aTouchMemory, !aTouchMemory || !aFragThread); if (aTouchMemory && !ManualTest) { TouchDataStop = ETrue; User::WaitForRequest(TouchStatus); test_Equal(EExitKill, TouchThread.ExitType()); test_KErrNone(TouchThread.ExitReason()); CLOSE_AND_WAIT(TouchThread); } if (aFragThread) { FragThreadStop = ETrue; User::WaitForRequest(FragStatus); test_Equal(EExitKill, FragThread.ExitType()); test_KErrNone(FragThread.ExitReason()); CLOSE_AND_WAIT(FragThread); } else UnfragmentMemoryFunc(); if (CacheSizeAdjustable) test_KErrNone(DPTest::SetCacheSize(OrigMinCacheSize, OrigMaxCacheSize)); CLOSE_AND_WAIT(Chunk); }
/** Intended Usage : Capture the PANIC that occurs in the thread. @param : aName The name to be assigned to this thread. @param : aFunction The function which causes the panic. */ LOCAL_C void ThreadPanicTest(const TDesC& aName,TThreadFunction aFunction) { TheTest.Next(aName); TRequestStatus threadStatus; RThread thread; TBool jit; jit=User::JustInTime(); User::SetJustInTime(EFalse); for (TInt i = EIterFunctionDriveUnit; i <= EIterFunctionIsRemovable; i++) { TIteratorFunctionToTest func = static_cast<TIteratorFunctionToTest>(i); TInt err=thread.Create(aName,aFunction,KDefaultStackSize,KMinHeapSize,KMinHeapSize, &func); TESTL(err==KErrNone); thread.Logon(threadStatus); thread.Resume(); User::WaitForRequest(threadStatus); //Now check why the thread Exit TExitType exitType = thread.ExitType(); TInt exitReason = thread.ExitReason(); TheTest.Printf(_L("PanicTest: exitType %d, reason %d\n"), exitType, exitReason); TESTL(exitType == EExitPanic); TESTL(exitReason == KPanicIndexOutOfBound); thread.Close(); } User::SetJustInTime(jit); }
LOCAL_D void TestSelfSuspend(TOwnerType anOwnerType) // // Test running a thread that suspends itself. This activity has // deadlocked the Emulator in the past // { RThread suspendThread; TInt r; TRequestStatus s; TInt jit=User::JustInTime(); test.Start(_L("Test running a thread which suspends itself")); test.Next(_L("Create the thread")); r=suspendThread.Create(KNullDesC,SuspendThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)NULL,anOwnerType); test(r==KErrNone); suspendThread.Logon(s); suspendThread.Resume(); test.Next(_L("Wait a second")); User::After(1000000); User::SetJustInTime(EFalse); suspendThread.Panic(_L("FEDCBA9876543210fedcba"),999); User::WaitForRequest(s); User::SetJustInTime(jit); test(suspendThread.ExitType()==EExitPanic); test(suspendThread.ExitReason()==999); test(suspendThread.ExitCategory()==_L("FEDCBA9876543210")); CLOSE_AND_WAIT(suspendThread); test.End(); }
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"); }
/* * Creates a Thread that modifies its code in a tight loop while the main * thread moves the functions page around */ LOCAL_C TInt TestCodeModificationAsync(RPageMove& pagemove) { TInt ret; RThread CodeThread; TRequestStatus s; /* Create the Thread to modify the code segment */ test_KErrNone(CodeThread.Create(_L("TestCodeAsync"), TestCodeAsync, KDefaultStackSize, NULL, NULL)); CodeThread.Logon(s); CodeThread.SetPriority(EPriorityMore); CodeThread.Resume(); TestCodeSetupDrive(CodeThread); /* Loop trying to move the code page while the thread (CodeThread) modifies it */ for (TInt i=0; i<Repitions; i++) { test_KErrNone(pagemove.TryMovingUserPage((TAny*)TestCodeModFunc)); } CodeThread.Kill(KErrNone); User::WaitForRequest(s); test_Equal(EExitKill, CodeThread.ExitType()); test_KErrNone(CodeThread.ExitReason()); CodeThread.Close(); ret = TestCodeModFunc(); test(ret == 1 || ret == 2); return KErrNone; }
void TestServerApi(TInt aFunctionNumber, TInt aTestType,TInt aArgCount, TExitDetails& aExitDetails) { TTestInfo testInfo; testInfo.iFunction = aFunctionNumber; testInfo.iType = aTestType; testInfo.iArgCount = aArgCount; RThread thread; _LIT(KThreadName,"FuzzerThread" ); TInt err = thread.Create(KThreadName,&FuzzServerL, KDefaultStackSize, NULL,&testInfo); TEST2(err, KErrNone); TRequestStatus threadStat; thread.Logon(threadStat); TBool jit = User::JustInTime(); User::SetJustInTime(EFalse); thread.Resume(); User::WaitForRequest(threadStat); User::SetJustInTime(jit); aExitDetails.iCategory = thread.ExitCategory(); aExitDetails.iReason = thread.ExitReason(); aExitDetails.iExitType = thread.ExitType(); thread.Close(); }
/** Test framework to check for panic scenarios It requires to create a separate thread so we can check the panic category and code. */ TInt StartSwpInvalidListInThreadL(CSsmValidSwpListTest* aSsmValidSwpListTest) { RThread thread; // Give each thread a unique name to avoid KErrAlreadyExists error on thread creation _LIT(KThreadNamePrefix, "SsmTestThread"); RBuf threadName; CleanupClosePushL(threadName); threadName.CreateL(KThreadNamePrefix().Length() + 6); // 6 digit thread number threadName = KThreadNamePrefix; threadName.AppendNumFixedWidth(aSsmValidSwpListTest->Function(), EDecimal, 6); const TInt KMinHeapSize = 0xc800; // 50k - NOTE just an arbitrary value, please feel free to change it const TInt KMaxHeapSize = 0x19000; // 100k - NOTE just an arbitrary value, please feel free to change it User::LeaveIfError(thread.Create(threadName, ThreadStartSwpInvalidListFn, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, aSsmValidSwpListTest)); CleanupStack::PopAndDestroy(&threadName); TRequestStatus status; thread.Logon(status); TBool jit = User::JustInTime(); User::SetJustInTime(EFalse); thread.Resume(); User::WaitForRequest(status); // always expecting a state transition engine panic TExitCategoryName category = thread.ExitCategory(); if (category.Compare(KPanicSysStateMgr) != 0) { User::Leave(KTestInvalidPanicCategory); } const TInt exitReason = thread.ExitReason(); thread.Close(); User::SetJustInTime(jit); // return the exit reason for the caller to verify the expected panic value return exitReason; }
/** @SYMTestCaseID GRAPHICS-FBSERV-0593 @SYMTestCaseDesc Tests the cleaning when a thead is panicing. @SYMTestActions Creates a bitmap. Checks the resource count. Creates a thread with high priority. Unlocks the heap and locks it back again. Disables just-in-time debugging. Waits for he thead to complete its execution. The created thread creates its own cleanup stack and connects to a FbsSession. It creates three bitmaps and duplicates one of them to the other. A FbsTypefaceStore object is created on the heap an GetNearestFontToDesignHeightInPixel is called on it. Disconnect from the FbsSession. The thread is paniced and terminated. The function that created the thread now continues its execution by checking the exit reason for the thread. Closes the thead. Enables just-in-time again. Locks the heap and unlocks it again. Checks the resource count. Deletes scan line buffer. The heap is checked for memory leaks. @SYMTestExpectedResults Test should pass */ void CTClean::DeadThread() { __UHEAP_MARK; CFbsBitmapEx bmp; TInt ret=bmp.Create(TSize(100,100),EGray16); TEST(ret==KErrNone); TInt rc=iFbs->ResourceCount(); TEST(rc==1); RThread thrd; TRequestStatus stat; thrd.Create(_L("ctt"),CleanupTestThread,KDefaultStackSize,0x8000,0x8000,this); thrd.SetPriority(EPriorityMuchMore); thrd.Logon(stat); User::SetJustInTime(EFalse); bmp.LockHeap(); bmp.UnlockHeap(); thrd.Resume(); User::WaitForRequest(stat); ret = thrd.ExitReason(); thrd.Close(); User::SetJustInTime(ETrue); TEST(ret == KErrNone); INFO_PRINTF1(_L("About to lock heap\r\n")); bmp.LockHeap(); bmp.UnlockHeap(); rc=iFbs->ResourceCount(); TEST(rc==1); DeleteScanLineBuffer(); __UHEAP_MARKEND; }
void C_thread::SuspendThreadSelf(){ if(imp){ RThread *thrd = (RThread*)imp; if(!thrd->ExitReason()) thrd->Suspend(); } }
TExitDetails LaunchTestThread(const TDesC& aThreadName, TestFunction aFunction) { RThread thread; thread.Create(aThreadName, &TestFunctionLauncher, KDefaultStackSize, NULL, (TAny*)aFunction); TRequestStatus threadStat; thread.Logon(threadStat); TBool jit = User::JustInTime(); User::SetJustInTime(EFalse); thread.Resume(); User::WaitForRequest(threadStat); User::SetJustInTime(jit); TExitDetails exitDetails; exitDetails.iCategory = thread.ExitCategory(); exitDetails.iReason = thread.ExitReason(); exitDetails.iExitType = thread.ExitType(); thread.Close(); return exitDetails; }
void TestCommitDecommit(RPageMove& pagemove, RChunk& aChunk) { test.Printf(_L("Attempt to move a page while it is being committed and decommited\n")); RThread thread; TRequestStatus s; test_KErrNone(thread.Create(_L("CommitDecommit"), &CommitDecommit, KDefaultStackSize, NULL, (TAny*)&aChunk)); thread.Logon(s); thread.SetPriority(EPriorityMore); thread.Resume(); TUint8* firstpage=(TUint8*)_ALIGN_DOWN((TLinAddr)aChunk.Base(), PageSize); for (TInt i=0; i < Repitions; i++) { TInt r = pagemove.TryMovingUserPage(firstpage, ETrue); // Allow all valid return codes as we are only testing that this doesn't // crash the kernel and the page could be commited, paged out or decommited // at any one time. test_Value(r, r <= KErrNone); } thread.Kill(KErrNone); User::WaitForRequest(s); test_Equal(EExitKill,thread.ExitType()); test_KErrNone(thread.ExitReason()); thread.Close(); }
/** @SYMTestCaseID SYSLIB-ECOM-CT-3163 @SYMTestCaseDesc Verify the startup behaviour of the ECOM server under OOM conditions @SYMTestPriority High @SYMTestActions Generate an OOM condition. Create a new thread which will launch the ECOM server. Wait for the thread to exit and check the thread exit type and reason to verify behaviour. @SYMTestExpectedResults The test must not fail. @SYMDEF DEF094675 */ void StartServer_OOMTest() { _LIT(KStartThreadName,"Server Start Thread"); //Create a new thread to launch the ECOM server RThread testThread; testThread.Create(KStartThreadName, ServerStartThreadEntryL, KDefaultStackSize,KMinHeapSize,KMinHeapSize,NULL); TRequestStatus status; testThread.Logon(status); testThread.Resume(); //Wait for the thread to exit User::WaitForRequest(status); //Obtain exit type and reason for test thread TExitType exitType = testThread.ExitType(); TInt exitReason = testThread.ExitReason(); //close the thread handle testThread.Close(); //Verify the exit reason and exit code //Exit type is TExitType::EExitKill when E32Main() exit normally TEST(exitType == EExitKill); TEST(exitReason == KErrNoMemory); }
void C_thread::ResumeThread(){ suspend_request = false; if(imp){ RThread *thrd = (RThread*)imp; if(!thrd->ExitReason()) thrd->Resume(); } }
void DoTestThreadCpuTime3(TAny* aParam, TExitType aExpectedExitType, TInt aExpectedExitReason) { RThread thread; FailIfError(thread.Create(_L("TestThread"), ThreadFunction2, 1024, NULL, aParam)); thread.Resume(); TRequestStatus status; thread.Logon(status); User::WaitForRequest(status); TExitCategoryName exitCat = thread.ExitCategory(); test.Printf(_L("Thread exit with type == %d, reason == %d, cat == %S\n"), thread.ExitType(), thread.ExitReason(), &exitCat); test(thread.ExitType() == aExpectedExitType); test(thread.ExitReason() == aExpectedExitReason); CLOSE_AND_WAIT(thread); }
void CheckExit(TInt aThreadNum, RThread aThread) { TInt exitType=aThread.ExitType(); TInt exitReason=aThread.ExitReason(); TBuf<32> exitCat=aThread.ExitCategory(); test.Printf(_L("Thread %d: %d,%d,%S\n"),aThreadNum,exitType,exitReason,&exitCat); test(exitType==EExitKill); test(exitReason==KErrNone); }
bool_t ThreadJoin(void* Handle,uintptr_t *ExitCode) { RThread Thread; Thread.SetHandle((TInt)Handle); //!!! todo // This is only supported in Symbian 9.2, but it's the only clean way // Thread.Rendezvous(0); if (ExitCode) *ExitCode = Thread.ExitReason(); Thread.Close(); return 1; }
void CTestExecutor::KillAllTestThreads() { RThread killer; killer.Create(_L("KillerThread"), KillerThread, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, NULL); killer.Resume(); TRequestStatus status; killer.Logon(status); User::WaitForRequest(status); TInt err = killer.ExitReason(); test(err == KErrNone); }
void C_thread::KillThread(){ if(imp){ RThread *thrd = (RThread*)imp; if(!thrd->ExitReason()){ thrd->Terminate(1); thrd->Close(); } delete thrd; imp = NULL; } status = STATUS_UNINITIALIZED; }
// ----------------------------------------------------------------------------- // MceServerStarter::CreateServerProcess // ----------------------------------------------------------------------------- // TInt MceServerStarter::CreateServerProcess (RSemaphore& aSemaphore) { const TUidType serverUid (KNullUid, KNullUid, KServerUid3); #if ((defined (__WINS__) || defined(__WINSCW__)) && !defined (EKA2)) RLibrary lib; RETURN_IF_ERROR (lib.Load(KMceServerFilename,serverUid)) // Get the WinsMain function TLibraryFunction functionWinsMain = lib.Lookup (1); // Call it and cast the result to a thread function TThreadFunction serverThreadFunction = reinterpret_cast<TThreadFunction> (functionWinsMain()); TName threadName (KSipServerName); // Append a random number to make it unique threadName.AppendNum (Math::Random(), EHex); RThread server; TInt err = server.Create (threadName, serverThreadFunction, // thread's main function KDefaultStackSize, NULL, &lib, NULL, KServerMinHeapSize, KServerMaxHeapSize, EOwnerProcess ); lib.Close (); // if successful, server thread has handle to library now RETURN_IF_ERROR (err) server.SetPriority (EPriorityMore); #else // HW build RProcess server; RETURN_IF_ERROR (server.Create( KMceServerName, KNullDesC, serverUid ) ) #endif server.Resume (); aSemaphore.Wait(); TInt exitReason = server.ExitReason(); server.Close (); return exitReason; }
LOCAL_C void RunTestThreadL() { __UHEAP_MARK; CopyPluginsL(); _LIT(KThreadName, "RoguePluginTest"); TBool jit = User::JustInTime(); User::SetJustInTime(EFalse); TheTest.Start(KTestTitle); // Save the console because the created thread must use its own // console. CConsoleBase* savedConsole = TheTest.Console(); RThread tt; TInt err = tt.Create(KThreadName, &ThreadFunc, KDefaultStackSize, KMinHeapSize, 0x100000, 0); User::LeaveIfError(err); TRequestStatus status; tt.Logon(status); tt.Resume(); User::WaitForRequest(status); // restore console TheTest.SetConsole(savedConsole); TExitCategoryName exitcategory = tt.ExitCategory(); TExitType exittype = tt.ExitType(); TInt exitReason = tt.ExitReason(); tt.Close(); TheTest.Printf(_L("Thread exit type %d, reason %d, category %S"), exittype, exitReason, &exitcategory); User::SetJustInTime(jit); DeleteTestPlugin(); // Check if tt thread passes this checkpoint TheTest(correctTypeCastPassed); // Check if tt thread die of KERN-EXEC. _LIT(KKernExec, "KERN-EXEC"); TheTest(exitcategory.CompareF(KKernExec) == 0); TheTest.End(); TheTest.Close(); __UHEAP_MARKEND; }
TInt ThreadFunc(TAny* anArgument) { CSharedData* mySharedData = reinterpret_cast<CSharedData*> (anArgument); RUndertaker u; u.Create(); TRequestStatus status; TInt deadThread; TBool clientWaiting = ETrue; FOREVER { status = KRequestPending; u.Logon(status,deadThread); // wait for the next thread to die. if (clientWaiting) { // rendezvous with the client so that they know we're ready. // This guarantees that we will catch at least the first panic to // occur (as long as we aren't closed before kernel tells us. RThread::Rendezvous(KErrNone); clientWaiting = EFalse; } User::WaitForRequest(status); // until we get back around to the top we are missing notifications now. // being high priority helps us, but still... // deal with this QUICKLY // get handle to the dead thread (this has already been marked for us in // the kernel) RThread t; t.SetHandle(deadThread); if (t.ExitType() == EExitPanic) { // the other ways threads can die are uninteresting TTime now; now.UniversalTime(); TThreadPanicDetails* tpd = new TThreadPanicDetails (t.Name(), t.ExitReason(),t.ExitCategory(),now); mySharedData->iPanicDetails.AppendL(tpd); } t.Close(); } }
void CSystemTestBase::HandleThreadExitL(RThread& aThread) { TExitType exitType=aThread.ExitType(); if (exitType==EExitPanic) { CActiveScheduler::Stop(); iExitReason = aThread.ExitReason(); iExitCategory = aThread.ExitCategory(); TBuf<100> iName(aThread.FullName()); iLogger.WriteFormat(KPanicText, &iName, iExitReason, &iExitCategory); User::Panic(iExitCategory,iExitReason); } }
void RunTestInThread(TThreadFunction aFn, TAny* aParameter, const TDesC* aPanicCat, TInt aExitCode) { RThread t; TInt r=t.Create(KNullDesC(),aFn,0x2000,NULL,aParameter); test(r==KErrNone); TRequestStatus s; t.Logon(s); t.Resume(); User::WaitForRequest(s); if (aPanicCat) { test(t.ExitType()==EExitPanic); test(t.ExitCategory()==*aPanicCat); test(t.ExitReason()==aExitCode); } else { test(t.ExitType()==EExitKill); test(t.ExitReason()==aExitCode); } CLOSE_AND_WAIT(t); }
void CCmdUndertaker::ProcessHandle(TInt aDeadThreadHandle) { RThread deadThread; deadThread.SetHandle(aDeadThreadHandle); TFullName name(deadThread.FullName()); TExitType type = deadThread.ExitType(); if (type != EExitKill || deadThread.ExitReason() != 0 || iAll) { Write(_L("Thread ")); Write(name); Printf(_L(" (tid=%d) "), (TUint)deadThread.Id()); } if (type == EExitPanic) { TExitCategoryName cat = deadThread.ExitCategory(); Printf(_L("panicked with %S %d\r\n"), &cat, deadThread.ExitReason()); } else if (type == EExitTerminate) { Printf(_L("terminated with reason %d\r\n"), deadThread.ExitReason()); } else if (deadThread.ExitReason() != 0) { // We'll consider a kill with non-zero exit code as counting as abnormal Printf(_L("killed with reason %d\r\n"), deadThread.ExitReason()); } else if (iAll) { Printf(_L("exited cleanly\r\n")); } if (!iLeakThreads) { deadThread.Close(); } }
/** @SYMTestCaseID APPFWK-APPARC-0071 @SYMDEF PDEF100072 -- CApaWindowGroupName::SetAppUid() and FindByAppUid panic @SYMTestCaseDesc Test Launching of an application with unprotected application UID @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions Prepare command line information to start an application using CApaCommandLine Apis.Call RApaLsSession::StartApp() to start an application defined by the command line information.\n Test the launching of application for following scenario:\n When Application specified by command line has unprotected application UID(negative uid).\n API Calls:\n RApaLsSession::StartApp(const CApaCommandLine &aCommandLine, TThreadId &aThreadId);\n @SYMTestExpectedResults The test checks whether the thread has terminated with the exit reason KTUnProtectedAppTestPassed */ void CT_StartAppTestStep::TestStartApp8L() { INFO_PRINTF1(_L("Checking launching of an application which has unprotected UID")); CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); TFileName filename; _LIT(KAppFileName, "z:\\sys\\bin\\UnProctectedUidApp.exe"); TFullName exePath(KAppFileName); filename = SearchAndReturnCompleteFileName(exePath); cmdLine->SetExecutableNameL(filename); TThreadId appThreadId(0U); TInt ret = iApaLsSession.StartApp(*cmdLine, appThreadId); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupStack::PopAndDestroy(cmdLine); // cmdLine RThread appThread; User::LeaveIfError(appThread.Open(appThreadId)); TRequestStatus logonRequestStatus; appThread.Logon(logonRequestStatus); // wait for UnProctectedUidApp.exe to terminate INFO_PRINTF1(_L("Waiting for application to terminate...")); User::WaitForRequest(logonRequestStatus); const TExitType exitType = appThread.ExitType(); const TInt exitReason = appThread.ExitReason(); TExitCategoryName categoryName = appThread.ExitCategory(); appThread.Close(); TBuf<50> msg; if (exitType == EExitPanic) { _LIT(KAppPanicInfo, "Application panic: %S %d"); msg.Format(KAppPanicInfo, &categoryName, exitReason); } else { _LIT(KAppExitInfo, "Application exited with code %d"); msg.Format(KAppExitInfo, exitReason); } INFO_PRINTF1(msg); TEST(logonRequestStatus == KTUnProtectedAppTestPassed); TEST(exitType == EExitKill); TEST(exitReason == KTUnProtectedAppTestPassed); INFO_PRINTF1(KCompleted); }
/** * Creates a second thread to run the test. * * @param aFunctionIndex The drawing function command to be executed. All commands are defined in TestFunctionIndex. */ void CTW32CmdBuf::CreateSecondThreadAndDoTestL(TTestFunctionIndex aFunctionIndex) { RThread thread; TBuf<30> threadName(KTW32CmdBufSecondThread); static TInt threadSerialNumber = 0; threadName.AppendNum(++threadSerialNumber); User::LeaveIfError(thread.Create(threadName, TestCmdBufFunction, KDefaultStackSize, KMinHeapSize, 0x4000, &aFunctionIndex)); TRequestStatus status; thread.Logon(status); thread.Resume(); User::WaitForRequest(status); TEST(thread.ExitType()==EExitKill); TEST(thread.ExitReason() == KErrNone); thread.Close(); }
static void ConfirmPanicReason(RThread aThread, TInt aExpectedReason) /** Confirm that the supplied thread was panicked with KKmsClientPanicCat category and the supplied reason. @param aThread Thread whcih should have been panicked with the supplied reason. @param aExpectedReason Reason with which thread should have been panicked. */ { TExitCategoryName exitCat = aThread.ExitCategory(); test.Printf(_L("thread exit with type=%d, cat=\"%S\", reason=%d\n"), aThread.ExitType(), &exitCat, aThread.ExitReason()); test(aThread.ExitType() == EExitPanic); test(exitCat == KKmsClientPanicCat); test(aThread.ExitReason() == aExpectedReason); }
void LogOnPanicL(RThread& aTestThread) { CTestScheduler* as = new(ELeave) CTestScheduler; CleanupStack::PushL(as); if (!as) { User::Panic(_L("Failed to create active scheduler"),KErrNoMemory); } CActiveScheduler::Install(as); // Install active scheduler // Initialise Comms, required in a minimal console environment CHTTPTestUtils::InitCommsL(); // Force a connection to be held open keep NT RAS connected... CHTTPTestUtils::HoldOpenConnectionL(); // Create the test engine CHttpTestEngine* engine=NULL; TRAPD(err,engine = CHttpTestEngine::NewL(KHttpTestTitle(), EFalse)); if (err != KErrNone) { User::Panic(_L("T_HTTP_ENG"), err); } CleanupStack::PushL(engine); // Create log message TExitCategoryName panicName = aTestThread.ExitCategory(); TInt panicNumber = aTestThread.ExitReason(); HBufC* logMessage = HBufC::NewLC(KRtestFailureLabel().Length() + panicName.Length() + KMaxIntDesLen); TPtr logMessagePtr = logMessage->Des(); logMessagePtr.Format(KRtestFailureLabel, &panicName, panicNumber); engine->Utils().LogIt(logMessagePtr); // Panic here so that nothing else is written to the log file User::Panic(panicName, panicNumber); // The code below provided for completenes, but should never be reached // Release the held open connection CHTTPTestUtils::ReleaseConnectionL(); CleanupStack::PopAndDestroy(3, as); //as, engine, logMessage }
// --------------------------------------------------------------------------- // CPeninputServerObserver::RunL // --------------------------------------------------------------------------- // void CPeninputServerObserver::RunL() { //iHandler is always there. No need to check it TInt ret = EFalse; if(iStatus.Int() < 0) { //check server status RThread srvThread; TInt err = srvThread.Open(iSrvThreadId); TInt exitReason = 0; if(err == KErrNone) //thread is just closed { exitReason = srvThread.ExitReason(); srvThread.Close(); iPeninputServer->OnServerReady(-1000); } if(err != KErrNone || exitReason != 0) //server has exited { iServerExit = ETrue; iPeninputServer->HandleServerExit(); iHandler->HandleServerEventL(ESignalServerExit); return; } } if(iStatus.Int() == ESignalServerReady) //server has started { iPeninputServer->OnServerReady(); return; } //if there is also iUiActivationHandler, handle it first if(iUiActivationHandler) ret = iUiActivationHandler->HandleServerEventL(iStatus.Int()); if(!ret) ret = iHandler->HandleServerEventL(iStatus.Int()); // re-issue request if request if(ret) { iPeninputServer->RequestMessageNotification(iStatus); SetActive(); } }