示例#1
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);
}
// ----------------------------------------------------------------------------
// 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());
    }
示例#3
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();
	}
示例#4
0
/**
	@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;
	}
示例#5
0
void CTestAppUi::TestWaitOnAppStartL()
	{
	RDebug::Print(_L("TVIEW1 : Test Wait On App Start"));

	RThread appThread;
	TRequestStatus status;
	TThreadId threadId;

	RApaLsSession ls;
	CleanupClosePushL(ls);
	User::LeaveIfError(ls.Connect());
	TApaAppInfo info;
	User::LeaveIfError(ls.GetAppInfo(info,KUidViewAppTwo));
	CleanupStack::PopAndDestroy();	// ls 

	CApaCommandLine* cmdLine=CApaCommandLine::NewLC();	
	cmdLine->SetExecutableNameL(info.iFullName);
	cmdLine->SetCommandL(EApaCommandViewActivate);
	TFileName fName=_L("c:\\Documents\\");
	TParsePtrC parse(info.iFullName);
	fName.Append(parse.Name());
	cmdLine->SetDocumentNameL(fName);

	RApaLsSession lsSession;
  	User::LeaveIfError(lsSession.Connect());
  	CleanupClosePushL(lsSession);
  	threadId=User::LeaveIfError(lsSession.StartApp(*cmdLine, threadId));
  	CleanupStack::PopAndDestroy(&lsSession);
	CleanupStack::PopAndDestroy(); // cmdLine
	User::LeaveIfError(appThread.Open(threadId));
	appThread.Logon(status);
	User::WaitForRequest(status);
	}
示例#6
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;
	}
/**
@SYMTestCaseID          PDS-EFM-CT-4058
@SYMTestCaseDesc        Querying and modifying a feature during restore operation. 
                        Verify that a response is returned from the server during restore.
@SYMTestPriority        High
@SYMTestActions         Start simulating restore operation
                        Create a thread that will:
                        Modify a feature and verify that a response (KErrServerBusy) is received 
                        Query a feature and verify that a response is received (doesn't matter what the result is)
                        The thread should finished in less than 2 seconds.
                        Otherwise the test fail.          
@SYMTestExpectedResults Test must not fail
@SYMREQ                 
*/  
void TestRestoreResponseL()
    {
        _LIT(KThreadName, "RstTh");
        featMgrIsResponsive = EFalse;
        
        CFeatMgrBURSim* simulate = CFeatMgrBURSim::NewLC();
        RThread testThread;
        TRequestStatus testStatus;
        CleanupClosePushL( testThread );
        
        //Needs to ensure server is started before simulating backup operation
        RFeatureControl rfc;
        TTEST2( rfc.Connect(), KErrNone ); //This will start the server if not already started
        rfc.Close();
        
        simulate->Simulate_CheckRegFileL();
        
        // Simulate a restore
        RDebug::Print(_L("Simulating Restore of FeatMgr\r\n"));
        simulate->Simulate_StartRestoreL();

        TEST2( testThread.Create(KThreadName, &TestThreadL, 0x2000, 0x1000, 0x10000, NULL, EOwnerProcess), KErrNone );
        testThread.Logon(testStatus);
        TEST2( testStatus.Int(), KRequestPending );
        testThread.Resume();
        // Wait for 1.5 second for the query thread to finish. 
        RDebug::Print(_L("+++:MainThread: Wait for query and modification completion...\r\n"));
        MainThreadCrS.Wait(threadTimeout);
        // If query is responsive within the 1.5 second frame the following check should pass.
        TEST (featMgrIsResponsive);
        simulate->Simulate_EndRestoreL();
        
        CleanupStack::PopAndDestroy(&testThread);
        CleanupStack::PopAndDestroy(simulate);
    }
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;
	}
示例#9
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();

	}
示例#10
0
TInt CTimesliceTestThread::Construct(TUint32 aId, TInt aCpu, TInt aSlice, CircBuf* aBuf)
	{
	iId = aId;
	iCpu = aCpu;
	iSlice = aSlice;
	iBuf = aBuf;

	TInt r = HAL::Get(HAL::EFastCounterFrequency, (TInt&)iFreq);
	if (r!=KErrNone)
		return r;
	iThresh = iFreq / 3000;
	if (iThresh < 10)
		iThresh = 10;
	iThresh2 = iFreq;
	TBuf<16> name = _L("TSThrd");
	name.AppendNum(iId);
	r = iThread.Create(name, &ThreadFunc, 0x1000, NULL, this);
	if (r!=KErrNone)
		return r;
	iThread.Logon(iExitStatus);
	if (iExitStatus != KRequestPending)
		{
		iThread.Kill(0);
		iThread.Close();
		iThread.SetHandle(0);
		return iExitStatus.Int();
		}
	return KErrNone;
	}
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();
 	}
/**
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;
	}
示例#13
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;
	}
示例#14
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();
	}
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;
}
EXPORT_C void CloseTestUpdateReceiver(CTContentUpdateReceiver* aReceiver)
	{
	if(!aReceiver)
		return;

	TBuf<64> contentUpdateReceiverThreadName;
	contentUpdateReceiverThreadName.Format(KMaskBackend, aReceiver->Screen());
	TBuf<64> contentUpdateReceiverThreadMask;
	contentUpdateReceiverThreadMask = contentUpdateReceiverThreadName;
	contentUpdateReceiverThreadMask.Insert(0, _L("*"));
	contentUpdateReceiverThreadMask.Append('*');
	TFindThread findThread(contentUpdateReceiverThreadMask);
	TFullName name;
	RThread thread;
	if((findThread.Next(name)!=KErrNone) ||
		(thread.Open(findThread) != KErrNone))
		{
		thread.Close();
		return;
		}
	TRequestStatus status; 
	thread.Logon(status);
	if(aReceiver)
		aReceiver->Stop();
	User::WaitForRequest(status);
	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);

	}
示例#18
0
LOCAL_C void RunTest(TInt aSize)
	{
	const TInt KTestRunUs = KTestRunSeconds * 1000000;

	RThread t;
	TInt r=t.Create(KNullDesC,TestThread,0x1000,NULL,(TAny*)aSize);
	test(r==KErrNone);
	t.SetPriority(EPriorityLess);
	TRequestStatus s;
	t.Logon(s);
	t.Resume();
	ServerSem.Wait();
	test(Server.Handle() != KNullHandle);

	RMySession sess;
	TRequestStatus stat;
	test(sess.Connect(Server,stat) == KErrNone);
	User::WaitForRequest(stat);	// connected

	Count=0;
	TPtr8 des((TUint8*)Dest, 0, aSize);
	sess.Test(des);
	User::After(KTestRunUs);
	t.Kill(0);
	User::WaitForRequest(s);
	sess.Close();
	Server.Close();
	CLOSE_AND_WAIT(t);

	TInt us=10*KTestRunUs/Count;
	test.Printf(_L("%5d byte writes: %8d/%ds %4d.%01dus\n"),aSize,Count,KTestRunSeconds,us/10,us%10);
	}
示例#19
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");
	}
/**
 * 
 * Multithread test - Initializes and opens from two threads
 *
 */
TVerdict CTestStep_MMF_A2DPBLUETOOTH_SVR_U_0020::DoTestStepL( void )
	{
	TVerdict verdict = EPass;
	iError = KErrCompletion; //we'll start with an error
	CAsyncTestStepNotifier* asyncRequestHandler = CAsyncTestStepNotifier::NewL(this);
	TRequestStatus* status = &(asyncRequestHandler->RequestStatus());
	iA2dpBTHeadsetAudioInterface.Initialize(*iBTheadsetAddress, *status);
	asyncRequestHandler->HandleAsyncRequest();
	if (iError != KErrNone)
		{
		INFO_PRINTF2(_L("Initialization error %d" ), iError);
		verdict = EFail;
		}

	if (verdict == EPass)
		{
		_LIT(KThreadName, "TSU_MMF_A2DPBLUETOOTH_SVR_TestThread");
		RThread newThread;
		
		//create a second thread
		iError = newThread.Create(KThreadName, NewThread, KDefaultStackSize, NULL, this, EOwnerProcess);
		
		if (iError != KErrNone)
			{
			INFO_PRINTF2(_L("Error creating second thread %d" ), iError);
			verdict = EInconclusive;
			}
		else
			{	
			*status = KRequestPending;
			newThread.Logon(*status);
			newThread.Resume();
			User::WaitForRequest(*status);
		
			if (iError != KErrNone)
				{
				INFO_PRINTF2(_L("Error in second thread %d" ), iError);
				verdict = EFail;
				}
			}
			
		if (verdict == EPass)
			{
			//try configuring
			iA2dpBTHeadsetAudioInterface.SetSampleRate(KDefaultTestSampleRate);
			iA2dpBTHeadsetAudioInterface.OpenDevice(*status);
			asyncRequestHandler->HandleAsyncRequest();
	
			if (iError != KErrNone)
				{
				INFO_PRINTF2(_L("Open error %d" ), iError);
				verdict = EFail;
				}
			}
		}
	
	delete asyncRequestHandler;
	return verdict ;
	}
示例#21
0
void FragmentMemory(TUint aSize, TUint aFrequency, TBool aDiscard, TBool aTouchMemory, TBool aFragThread)
	{
	test_Value(aTouchMemory, !aTouchMemory || !aFragThread);
	test_Value(aSize, aSize < aFrequency);
	FragData.iSize = aSize;
	FragData.iFrequency = aFrequency;
	FragData.iDiscard = aDiscard;
	FragData.iFragThread = aFragThread;

	TChunkCreateInfo chunkInfo;
	chunkInfo.SetDisconnected(0, 0, TotalRam);
	chunkInfo.SetPaging(TChunkCreateInfo::EUnpaged);
	chunkInfo.SetClearByte(0x19);
	test_KErrNone(Chunk.Create(chunkInfo));

	if (aFragThread)
		{
		TInt r = FragThread.Create(_L("FragThread"), FragmentMemoryThreadFunc, KDefaultStackSize, PageSize, PageSize, NULL);
		test_KErrNone(r);
		FragThread.Logon(FragStatus);
		FragThreadStop = EFalse;
		TRequestStatus threadInitialised;
		FragThread.Rendezvous(threadInitialised);
		FragThread.Resume();
		User::WaitForRequest(threadInitialised);
		test_KErrNone(threadInitialised.Int());
		}
	else
		{
		FragmentMemoryFunc();
		}
	if (aTouchMemory && !ManualTest)
		{
		TouchData.iSize = aSize;
		TouchData.iFrequency = aFrequency;
		TInt r = TouchThread.Create(_L("TouchThread"), TouchMemory, KDefaultStackSize, PageSize, PageSize, NULL);
		test_KErrNone(r);
		TouchThread.Logon(TouchStatus);
		TouchDataStop = EFalse;
		TRequestStatus threadInitialised;
		TouchThread.Rendezvous(threadInitialised);
		TouchThread.Resume();
		User::WaitForRequest(threadInitialised);
		test_KErrNone(threadInitialised.Int());
		}
	}
示例#22
0
void CTestList::SelectedL(TInt aIndex)
{
#if USE_PROCESS
    TThreadParams params;
    params.iIndex=aIndex;
    TName name;
    name.Format(_L("TimeTest-%x"),iCount++);
    params.iGroupId=Client()->iGroup->GroupWin()->Identifier();
    User::LeaveIfError(iTimeTest.Create(name,TimeThread,KDefaultStackSize*2,KHeapSize,KHeapSize,&params,EOwnerThread));
    TRequestStatus status;
    iTimeTest.Logon(status);
    __PROFILE_RESET(8);
    iTimeTest.Resume();
    User::WaitForRequest(status);
#else
    TThreadParams params;
    params.iIndex=aIndex;
    TimeThread(&params);
#endif
    TBuf<64> buf;
    TBuf<64> buf2;
    TBuf<64> buf3;
    CResultDialog *dialog=new(ELeave) CResultDialog(Client()->iGroup, iGc);
    dialog->ConstructLD();
#if USE_PROCESS
    if (status.Int()==KErrNone)
    {
#endif
#if !defined(__PROFILING__)
        buf=_L("Profiling information not available");
#else
        TProfile profile[6];
        __PROFILE_DISPLAY(6);
        for (TInt index=1; index<6; index++)
            AppendProfileNum(buf2,profile[index].iTime);
        for (TInt index2=1; index2<6; index2++)
            AppendProfileCount(buf3,profile[index2].iCount);
        buf.Format(_L("Time=%d.%2d"),profile[0].iTime/1000000,(profile[0].iTime%1000000)/10000);
#endif
        dialog->SetTitle(buf);
#if USE_PROCESS
    }
    else
    {
        dialog->SetTitle(_L("Error in test"));
        buf.Format(_L("Error=%d"),status.Int());
        buf2=iTimeTest.ExitCategory();
    }
#endif
    dialog->SetLine1(buf2);
    dialog->SetLine2(buf3);
    dialog->SetNumButtons(1);
    dialog->SetButtonText(0,_L("Okay"));
    if (dialog->Display()!=0)
        Panic(0);
}
示例#23
0
void CThreadWatcher::ConstructL()
{
	CActiveScheduler::Add(this);
	RThread thread;
	if(thread.Open(iName) == KErrNone) {
		thread.Logon(iStatus);
		thread.Close();
		SetActive();
	}
}
示例#24
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;
	}
示例#25
0
SilcBool silc_thread_wait(SilcThread thread, void **exit_value)
{
#ifdef SILC_THREADS
  TRequestStatus req;
  RThread *t = (RThread *)thread;
  t->Logon(req);
  User::WaitForAnyRequest();
  return TRUE;
#else
  return FALSE;
#endif
}
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);
    }
示例#27
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);
    }
/** Start a thread. */
LOCAL_D void StartThreadL(RThread& aThread, TThreadData& aData, TInt aIteration, TInt aThreadNum, TRequestStatus& aStatus)
	{
	aData.InitialiseL(aIteration, aThreadNum);

	TBuf<32> threadName;
	threadName.Format(_L("iteration%02d_thread%d"), aIteration, aThreadNum);
	
	RHeap* heap = User::ChunkHeap(NULL, KMinHeapSize, 0x100000);
	User::LeaveIfNull(heap);
	User::LeaveIfError(aThread.Create(threadName, ThreadEntryPoint, KDefaultStackSize, heap, (TAny*)&aData));	
	aStatus = KRequestPending;
	aThread.Logon(aStatus);
	aThread.Resume();
	}
示例#29
0
/**
 Test access from a different thread
 @pre	TestLoadDriver() called
 */    
void TestExDriver::TestMultipleThreadAccess()
	{
	TInt r;
	RThread thrd;		    
    TRequestStatus tS;
	_LIT(KTestThreadName,"TestThread");
	
	iTest.Printf(_L("Test multiple thread access\n"));
	
	// Create the iTimer that is relative to the thread 
 	r = iTimer.CreateLocal();
 	iTest(r==KErrNone);
 	
 	// Open the channel 	  
	r=iLdd.Open(KUnit1);
	iTest(r==KErrNone);
	  
	// Create a new thread, where we can test access to the driver
    iTest (thrd.Create(KTestThreadName,&ThreadFunc,KDefaultStackSize,NULL,&iLdd)==KErrNone);
    
    // Logon() will request asynchronous notification on thread termination
    thrd.Logon(tS);
    
    // Trigger iTimer expiry after KTimeOut. The status should be pending
	iTimer.After(iTimeStatus,KTimeOut);
	iTest(iTimeStatus==KRequestPending);
	
	// Resume() schedules the thread created
    thrd.Resume();
    
    // Wait for the thread termination notification
    //User::WaitForRequest(tS,iTimeStatus);
    User::WaitForRequest(tS);
    
    // Incase thread is not scheduled and timeout occurs
    if ((iTimeStatus==KErrNone))
    	{
    	iTest.Printf(_L("Timeout for TestThread schedule and exit\n"));
    	}
    
    // Cancel the timer and close	
    iTimer.Cancel();	
    iTimer.Close();
    
    // Close the thread created	
    thrd.Close(); 
    // Close the channel opened   
    iLdd.Close(); 
	}
示例#30
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);
	}