예제 #1
0
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);
	}
예제 #2
0
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);
	}
// ---------------------------------------------------------------------------
// Removes all requests belonging to a terminated client.
// ---------------------------------------------------------------------------
//
void CPolicyClientRequestHandler::RemoveDeadClients()
	{
	// Lint seems to have some trouble identifying the TThreadId class.
	// Due to this, Lint will report several errors here that are incorrect.
	// These errors are disabled.
	/*lint -e10 -e1013 -e1055 -e746 -e747 */
	RThread client;
	for( TInt i = iControlPolicyClients.Count() - 1; i >= 0; i--)
		{
		TInt err = client.Open(iControlPolicyClients[i]->iClientId.Id());
		if(err == KErrNone)
			{
			if(client.ExitType() != EExitPending)
				{
				//Client is dead, remove from list.
				iControlPolicyClients[i]->iMessage = RMessage2(); //Null message so destructor wont try to complete.
				delete iControlPolicyClients[i];
				iControlPolicyClients.Remove(i);
				}
		    client.Close();
			}
		else
			{
			//Could not open client, client handle was invalid.
			//So clean it up from list too.
			iControlPolicyClients[i]->iMessage = RMessage2(); //Null message so destructor wont try to complete.
			delete iControlPolicyClients[i];
			iControlPolicyClients.Remove(i);
			}
		}
	/*lint +e10 +e1013 +e1055 +e746 +e747 */
	}
// ----------------------------------------------------------------------------
// CSIPClientResolver::CreateWorkerThreadL
// ----------------------------------------------------------------------------
//   
void CSIPClientResolver::CreateWorkerThreadL()
    {
    TName threadName(KWorkerThreadName);
    // Append a random number to make the name unique
    const TInt KThreadIdWidth = 10;
    threadName.AppendNumFixedWidthUC(Math::Random(), EHex, KThreadIdWidth);
    RThread thread;
    TInt err = thread.Create(threadName,
                             WorkerThreadFunction,
                             KDefaultStackSize,
                             NULL, // Use the same heap as the main thread
                             this);
    User::LeaveIfError(err);
    TRequestStatus status;
    thread.Logon(status);
    thread.Resume();
    User::WaitForRequest(status);
    TExitType exitType = thread.ExitType();
    thread.Close();
    if (exitType == EExitPanic)
        {
        User::Leave(KErrGeneral);
        }
    User::LeaveIfError(status.Int());
    }
예제 #5
0
// main loop
//
GLDEF_C TInt E32Main()
    {  
	__UHEAP_MARK;  
	CTrapCleanup* theCleanup = CTrapCleanup::New(); // Install exception handler  
	
	// Create a new thread for running tests in
	RThread testThread;
	TInt err = testThread.Create(KTestThreadName, TestEntryPoint, KDefaultStackSize,  
							 KMinHeapSize, KMaxHeapSize, NULL);
	if(err == KErrNone)
		{
		testThread.Resume();	
		}
	else
		{
		return err;
		}
	
	// Kick off test thread and wait for it to exit
	TRequestStatus tStat;
	testThread.Logon(tStat);
	User::WaitForRequest(tStat);
	
	// Log if paniced
	if(testThread.ExitType() == EExitPanic)
		{
		TRAP_IGNORE(LogOnPanicL(testThread));	
		}
	
	testThread.Close();
	delete theCleanup;		
	__UHEAP_MARKEND;		
	return KErrNone;
	}
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;
}
예제 #7
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");
	}
예제 #8
0
TInt RConsoleProxy::DoConnect(TServerParams* aParams, const TDesC& aThreadNameBase, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize, RServer2& aServer, RThread& aServerThread)
	{
	TName threadName;
	RThread server;
	TInt threadId = 0;
	_LIT(KThreadIdFmt, "%08x");
	TInt err;
	do
		{
		threadName = aThreadNameBase.Left(threadName.MaxLength()-8);
		threadName.AppendFormat(KThreadIdFmt, threadId);
		err = server.Create(threadName, &ServerThreadFunction, aStackSize, aHeapMinSize, aHeapMaxSize, aParams);
		++threadId;
		} while (err==KErrAlreadyExists);
	if (err!=KErrNone) return err;
	
	TRequestStatus rendezvous;
	server.Rendezvous(rendezvous);
	if (rendezvous == KRequestPending)
		{
		server.Resume();
		}
	User::WaitForRequest(rendezvous);
	err = rendezvous.Int();
	if (server.ExitType() != EExitPending && err >= 0) err = KErrDied;
	if (err==KErrNone)
		{
		err = Connect(aParams->iServer);
		}
	aServer = aParams->iServer;
	aServerThread = server;
	return err;
	}
예제 #9
0
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();
	}
enum TVerdict CTestMemRelinquish::doTestStepL()
   	{
   	INFO_PRINTF1(_L("Test Call Relinquish Case 2"));
 
 	User::SetJustInTime(EFalse);	// switches off the WINS threadbreakpoints
 
 	RThread t;
 	TInt res=t.Create(_L("RelinquishCall"),RelinquishCall,KDefaultStackSize,KDefaultHeapSize,KDefaultHeapSize,NULL);
 	TESTCHECK(res, KErrNone);
 
 	TRequestStatus stat = KRequestPending;
 	t.Logon(stat);
 	t.Resume();
 	User::WaitForRequest(stat);
 
 	TESTCHECK(t.ExitType(), EExitKill);
 	//TESTCHECK(t.ExitCategory()==_L("Etel Client Faul"));
 	//TESTCHECK(t.ExitReason()==11);	// EEtelPanicHandleNotClosed is 11
 	//TESTCHECK(t.ExitType()==EExitPanic);
 	t.Close();
 
 	User::SetJustInTime(ETrue);
 	User::After(KETelThreadShutdownGuardPeriod);
 
 	return TestStepResult();
 	}
예제 #11
0
/**
@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);

	}
예제 #12
0
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;
	}
TInt CTSISHelperStepBase::startSisHelper(Swi::TSisHelperStartParams& aParams)
	{
	// To deal with the unique thread (+semaphore!) naming in Symbian OS, and
	// that we may be trying to restart a server that has just exited we 
	// attempt to create a unique thread name for the server
	TName name(Swi::KSisHelperServerName);
	name.AppendNum(Math::Random(), EHex);
	RThread server;
	const TInt KSisHelperServerStackSize=0x2000;
	const TInt KSisHelperServerInitHeapSize=0x1000;
	const TInt KSisHelperServerMaxHeapSize=0x1000000;
	TInt err=server.Create(name, sisHelperThreadFunction, 
		KSisHelperServerStackSize, KSisHelperServerInitHeapSize, 
		KSisHelperServerMaxHeapSize, static_cast<TAny*>(&aParams), 
		EOwnerProcess);
	if (err!=KErrNone)
		return err;
	
	// The following code is the same whether the server runs in a new thread 
	// or process
	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;
	}
예제 #14
0
/* 
 * 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;
	}
예제 #15
0
/**
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);
}
예제 #16
0
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();
	}
예제 #17
0
GLDEF_C TInt E32Main()
{
    test.Title();
    test.Start(_L("Waiting..."));

    RUndertaker u;
    TInt r=u.Create();
    test(r==KErrNone);
    //to avoid RVCT4 warning of unreachable statement.
    volatile TInt forever = 0;
    while(forever)
    {
        TInt h;
        TRequestStatus s;
        r=u.Logon(s,h);
        test(r==KErrNone);
        User::WaitForRequest(s);
        RThread t;
        t.SetHandle(h);
        TBuf8<128> b;
        t.Context(b);
        TInt *pR=(TInt*)b.Ptr();
        TFullName tFullName = t.FullName();
        TExitCategoryName tExitCategory = t.ExitCategory();
        test.Printf(_L("Thread %S Exit %d %S %d\n"),&tFullName,t.ExitType(),&tExitCategory,t.ExitReason());
        test.Printf(_L("r0 =%08x r1 =%08x r2 =%08x r3 =%08x\n"),pR[0],pR[1],pR[2],pR[3]);
        test.Printf(_L("r4 =%08x r5 =%08x r6 =%08x r7 =%08x\n"),pR[4],pR[5],pR[6],pR[7]);
        test.Printf(_L("r8 =%08x r9 =%08x r10=%08x r11=%08x\n"),pR[8],pR[9],pR[10],pR[11]);
        test.Printf(_L("r12=%08x r13=%08x r14=%08x r15=%08x\n"),pR[12],pR[13],pR[14],pR[15]);
        test.Printf(_L("cps=%08x dac=%08x\n"),pR[16],pR[17]);
        t.Close();
    }
    return 0;
}
예제 #18
0
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();

	}
예제 #19
0
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);
	}
예제 #20
0
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);
	}
예제 #21
0
static TInt StartServer()
//
// Start the server process or thread
//
	{
	const TUidType serverUid(KNullUid,KNullUid,KServerUid3);

#ifdef __CDLSERVER_NO_PROCESSES__
	//
	// In EKA1 WINS the server is a DLL, the exported entrypoint returns a TInt
	// which represents the real entry-point for the server thread
	//
	RLibrary lib;
	TInt r=lib.Load(KCdlServerDllImg,serverUid);
	if (r!=KErrNone)
		return r;
	TLibraryFunction ordinal1=lib.Lookup(1);
	TThreadFunction serverFunc=reinterpret_cast<TThreadFunction>(ordinal1());
	//
	// To deal with the unique thread (+semaphore!) naming in EPOC, and that we may
	// be trying to restart a server that has just exited we attempt to create a
	// unique thread name for the server.
	// This uses Math::Random() to generate a 32-bit random number for the name
	//
	TName name(KCdlServerName);
	name.AppendNum(Math::Random(),EHex);
	RThread server;
	r=server.Create(name,serverFunc,
					KCdlServerStackSize,
					NULL,&lib,NULL,
					KCdlServerInitHeapSize,KCdlServerMaxHeapSize,EOwnerProcess);
	lib.Close();	// if successful, server thread has handle to library now
#else
	//
	// EPOC and EKA2 is easy, we just create a new server process. 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 r=server.Create(KCdlServerExeImg,KNullDesC,serverUid);
#endif
	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;
	}
예제 #22
0
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;
	}
예제 #23
0
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();
		}
	}
예제 #24
0
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);
	}
예제 #25
0
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);
		}
	}
예제 #26
0
void SDL_SYS_WaitThread(SDL_Thread *thread)
    {
    SDL_TRACE1("Close thread", thread);
    RThread t;
    const TInt err = t.Open(thread->threadid);
    if(err == KErrNone && t.ExitType() == EExitPending)
        {
        TRequestStatus status;
        t.Logon(status);
        User::WaitForRequest(status);
        }
    t.Close();
    SDL_TRACE1("Closed thread", thread);
    }
예제 #27
0
/**
   @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);
	}
예제 #28
0
/**
* 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();	
	}
예제 #29
0
void CCmdKill::DoKillThreadL(TUint aId)
	{
#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
	LoadMemoryAccessL();

	RThread thread;
	LeaveIfErr(iMemAccess.RThreadForceOpen(thread, aId), _L("Unable to open thread"));
	TName name(thread.FullName());
	if (thread.ExitType() != EExitPending)
		{
		Printf(_L("%S (id=%u) has already exited"), &name, aId);
		thread.Close();
		return;
		}

	CleanupClosePushL(thread);
	TExitType type = EExitKill;
	if (iTerminate)
		{
		type = EExitTerminate;
		}
	else if (iPanicCategory)
		{
		type = EExitPanic;
		}
	TInt err = iMemAccess.ObjectDie(EThread, aId, NULL, type, iReason, iPanicCategory ? *iPanicCategory : KNullDesC());
	LeaveIfErr(err, _L("Couldn't kill thread id %u"), aId);

	if (iTerminate)
		{
		Printf(_L("Terminated %S (id=%u) with %d\r\n"), &name, aId, iReason);
		}
	else if (iPanicCategory)
		{
		Printf(_L("Panicked %S (id=%u) with %S %d\r\n"), &name, aId, iPanicCategory, iReason);
		}
	else
		{
		Printf(_L("Killed %S (id=%u) with %d\r\n"), &name, aId, iReason);
		}
	CleanupStack::PopAndDestroy(&thread);

#else
	DoKillByHandleL<RThread>(aId);
#endif
	}
예제 #30
0
//DEF057265 - Panics when uninstalling a java midlet while it is running.
//The test will run one thread. Inside the thread's function the test will create
//DBMS session and reserve some disk space. Then the test will panic the thread
//(without freeing the reserved disk space).
//If DBMS server panics in _DEBUG mode - the defect is not fixed.
void DEF057265()
	{
	_LIT(KSessThreadName,"SessThrd");
	RThread sessThread;
	TEST2(sessThread.Create(KSessThreadName, &ThreadFunc, 0x2000, 0, 0), KErrNone);

	TRequestStatus sessThreadStatus;
	sessThread.Logon(sessThreadStatus);
	TEST2(sessThreadStatus.Int(), KRequestPending);

	sessThread.Resume();
	User::WaitForRequest(sessThreadStatus);
	TEST2(sessThread.ExitType(), EExitPanic);

	User::SetJustInTime(EFalse);	// disable debugger panic handling
	sessThread.Close();//This Close() operation will force DBMS server to close
					   //created in ThreadFunc() DBMS session.
	}