示例#1
0
/** Kills the concurrent session

*/
LOCAL_C void DoTestKill()
	{
	gKillMe = ETrue;
	User::After(10000000);
	
	gSpeedy.Kill(KErrNone);
	gSpeedy.Close();	
	
	gSpeedyII.Kill(KErrNone);
	gSpeedyII.Close();	
	}
示例#2
0
/** Kills the concurrent session

*/
LOCAL_C void DoTestKill()
	{
	TInt r = 0;
	
	gSpeedy.Kill(KErrNone);
	FailIfError(r);
	gSpeedy.Close();	
	
	gSpeedyII.Kill(KErrNone);
	FailIfError(r);
	gSpeedyII.Close();	
	}
	EXPORT_C void KillApplicationL(RWsSession& aWs, TUid aUid, TInt aRetryInterval )
	{
		TTime wait_until; wait_until.HomeTime();
		wait_until+=TTimeIntervalSeconds(15);
	
		TApaTaskList taskList( aWs );

		for(;;) {
			TApaTask task = taskList.FindApp(aUid);
			if(! task.Exists()) {
				break;
			}
			TTime now; now.HomeTime();
			if (now < wait_until) {
				task.EndTask();
				//DebugMsg(_L("waiting..."), aDebugLog);
				User::After(TTimeIntervalMicroSeconds32(aRetryInterval*1000) );
			} else {
				break;
			}
		}
		TApaTask task = taskList.FindApp(aUid);
		if( task.Exists()) {
#ifdef __S60V3__
			task.KillTask();
#else
			RThread t;
			if (t.Open(task.ThreadId())==KErrNone) {
				//DebugMsg(_L("killing"), aDebugLog);
				t.Kill(2003);
				t.Close();
			}
#endif
		}
	}
示例#4
0
/* WARNING: This function is really a last resort.
 * Threads should be signaled and then exit by themselves.
 * TerminateThread() doesn't perform stack and DLL cleanup.
 */
void SDL_SYS_KillThread(SDL_Thread *thread)
    {
    RThread rthread;
    rthread.SetHandle(thread->handle);
    rthread.Kill(KErrDied);
    rthread.Close();
    }
示例#5
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);
	}
示例#6
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();
	}
示例#7
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;
	}
示例#8
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;
	}
// EKA2 much simpler
// Just an E32Main and a MainL()
LOCAL_C void MainL()
/**
 * Much simpler, uses the new Rendezvous() call to sync with the client
 */
 	{
	// Leave the hooks in for platform security
#if (defined __DATA_CAGING__)
	RProcess().DataCaging(RProcess::EDataCagingOn);
	RProcess().SecureApi(RProcess::ESecureApiOn);
#endif
	CActiveScheduler* sched=NULL;
	sched=new(ELeave) CActiveScheduler;
	CActiveScheduler::Install(sched);
	CMMFAudioServer* server = NULL;
	TRAPD(err,server = CMMFAudioServer::NewL());

	// Start BT audio server in its own thread here...
	// Assume that the server's not been started already
	// 
	RThread btServerThread;
	TThreadFunction btServerThreadFunc = CA2dpBTHeadsetAudioIfServer::StartThread;
	TName btServerName(KA2DPAudioServerName);


	err = btServerThread.Create(btServerName, btServerThreadFunc, KBTAudioServerStackSize,
								KBTAudioServerInitHeapSize, KBTAudioServerMaxHeapSize,
								NULL, EOwnerProcess);	// NULL => not passing any params to thread

	if(!err)
		{
		// Synchronise with the server
		TRequestStatus reqStatus;
		btServerThread.Rendezvous(reqStatus);

		if (reqStatus != KRequestPending)
			{
			btServerThread.Kill(0);
			}
		else 
			{
			// Start the thread
			btServerThread.Resume();
			// Server will call the reciprocal static synchronise call
			}
		User::WaitForRequest(reqStatus); // wait for start or death
		}
		
	if(!err)
		{
		// Sync with the client and enter the active scheduler
		RProcess::Rendezvous(KErrNone);
		sched->Start();
		}
	
	btServerThread.Close();
		
	delete server;
	delete sched;	
	
	}
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;
	}
/**
 Old Test CaseID 		APPFWK-SUS-0008
 New Test CaseID 		DEVSRVS-SSMA-SUS-0013
 New Test CaseID 		DEVSRVS-SSMA-SUS-0014
 New Test CaseID 		DEVSRVS-SSMA-SUS-0015
 New Test CaseID 		DEVSRVS-SSMA-SUS-0016
 New Test CaseID 		DEVSRVS-SSMA-SUS-0017
*/
TVerdict CSusPlatsecTest::doTestStepL()
	{
	INFO_PRINTF1(_L("Test to make sure UtilityServer refuse connection for clients with incorrect capabilities"));
	
	__UHEAP_MARK;
	
	RProcess process;
	const TUint32 sid = process.SecureId();
	RThread thread;
	CleanupClosePushL(thread);
	TESTL(KErrNone == StartServer(thread, sid));
	
	//Test the RSession
	RSsmSusCliTest client;
	TInt connect = client.Connect(KTestServerName);
	TEST(KErrPermissionDenied == connect);	
	
	client.Close();
	thread.Kill(KErrNone);
	CleanupStack::PopAndDestroy(&thread);
	
	__UHEAP_MARKEND;
	
	return TestStepResult();
	}
示例#12
0
TInt64 runTest(TThreadFunction aFunction,const TDesC& aTitle)
    {

    RThread thread;
	TInt r=thread.Create(aTitle,aFunction,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
	if(r!=KErrNone)
		{
		test.Printf(_L("Failed to create thread with error %d\n"),r);
		return(r);
		}
    thread.Resume();
    User::After(1000000);
    count=0;
    User::After(KAverageOverInSeconds*1000000);
    TInt64 result=count;

	barrier = a;
	if (!barrier)
		barrier = c;
	barrier = b;
	if (!barrier)
		barrier = a;
	barrier = c;
	if (!barrier)
		barrier = b;

	thread.Kill(0);
	thread.Close();
	result*=KNumberOfCalculationsPerLoop;
	result/=KAverageOverInSeconds;
	r=I64INT(result);
    test.Printf(_L("%S executed %d in 1 second\n"),&aTitle,r);
    return(result);
    }
示例#13
0
static void TestRUpsSubsessionDeathL()
	{
	RThread thd;
	TRequestStatus thdStatus;
	User::LeaveIfError(thd.Create(_L("MyThread"), ThreadFunction, 4096, 4096, 4096, 0, EOwnerThread));
//	thd.SetHandle(666);
	thd.Rendezvous(thdStatus);
	thd.Kill(KErrAbort);
	User::WaitForRequest(thdStatus);

	test.Start(_L("Testing RUpsSubsession"));
	RUpsSubsession clientSubsession;
	TInt r = clientSubsession.Initialise(sTestSession, thd);
	test(r == KErrNone);

	test.Next(_L("Query with dead thread id"));
	TServiceId serviceId = {43};
	TUpsDecision dec = EUpsDecYes;
	TRequestStatus rs;
	thd.Close();
	clientSubsession.Authorise(EFalse, serviceId, _L("req1"), dec, rs);
	User::WaitForRequest(rs);
	test(rs == KErrNone);
	test(dec == EUpsDecNo);

	
	clientSubsession.Close();
	test.End();
	}
示例#14
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;
	}
示例#15
0
// -----------------------------------------------------------------------------
// StartThread Starts the server thread.
// Returns: TInt:   error code
// -----------------------------------------------------------------------------
//
EXPORT_C TInt StartThread()
    {
    _WIMTRACE(_L("WIM|Scard|CScardServer::StartThread|Begin"));
    TInt res = KErrNone;

    // check server not already started
    TFindServer findSCardServer( KScardServerName );
    TFullName name;
    if ( findSCardServer.Next( name ) != KErrNone )
        {
        // create server thread
        RThread thread;
        TThreadParameter threadData;
        threadData.iSemaphore.CreateLocal( 0 );

        res = thread.Create(
            KScardServerName, // name of thread
            CScardServer::ThreadFunction, // thread function
            KDefaultStackSize,
            KDefaultMinHeapSize,
            KDefaultMaxHeapSize,
            &threadData // parameter to thread function
            );

        //  If creation was successful, try starting the server
        if ( res == KErrNone )
            {
            // now start thread
            thread.SetPriority( EPriorityNormal ); // set its priority
            thread.Resume(); // kick it into life
            threadData.iSemaphore.Wait(); // wait until it's got going

            if ( threadData.iPanicCode )   
                {
                //  The server did not start properly
                thread.Kill( threadData.iPanicCode );
                res = threadData.iPanicCode; // set the response
                return res;
                }

            // tidy up
            thread.Close(); // no longer interested in that thread
            }
        else
            {
            thread.Close();         
            }

        threadData.iSemaphore.Close(); // or semaphore
        }

    // all well
    return res;
    }
示例#16
0
GLDEF_C TInt E32Main()
	{
	test.Title();
	TBuf<256> cmd;
	TFullName fn;
	User::CommandLine(cmd);
	TLex lex(cmd);
	TPtrC threadSpec(lex.NextToken());
	TFindThread ft(threadSpec);
	TExitType exitType=EExitKill;
	TInt exitCode=0;
	if (!lex.Eos())
		{
		TPtrC xtSpec(lex.NextToken());
		TPtrC xc(xtSpec);
		TChar xt0=xtSpec[0];
		if (xt0.IsAlpha())
			{
			xt0.LowerCase();
			if (xt0==TChar('t'))
				exitType=EExitTerminate;
			else if (xt0==TChar('p'))
				exitType=EExitPanic;
			new(&xc) TPtrC(lex.NextToken());
			}
		if (xc.Length())
			{
			TLex lex2(xc);
			lex2.Val(exitCode);
			}
		}
	while (ft.Next(fn)==KErrNone)
		{
		test.Printf(_L("Killing %S\n"),&fn);
		RThread t;
		TInt r=t.Open(ft);
		if (r==KErrNone)
			{
			// FIXME: SHOULD REMOVE CRITICALNESS - WOULD NEED DEVICE DRIVER
			switch (exitType)
				{
				case EExitKill:	t.Kill(exitCode); break;
				case EExitTerminate: t.Terminate(exitCode); break;
				case EExitPanic: t.Panic(KPanicCat,exitCode); break;
				default: break;
				}
			t.Close();
			}
		}
	return 0;
	}
EXPORT_C TInt RMMFAudioPolicyProxy::Open(RServer2& aPolicyServerHandle)
	{
	TServerStart start(aPolicyServerHandle);
	TInt err = KErrNone;
	if(aPolicyServerHandle.Handle())
		{
		// Server is already running and attempt to create a session
		// 4 message slots
		err = CreateSession(aPolicyServerHandle, TVersion(KMMFAudioPolicyVersion,
														KMMFAudioPolicyMinorVersionNumber,
														KMMFAudioPolicyBuildVersionNumber));
		if(err != KErrNone)
			{
			return err;	
			}
		}
	else
		{
		TThreadFunction serverFunc = CMMFAudioPolicyServer::StartThread;
		RThread server;
		err = server.Create(_L(""),serverFunc, KAudioPolicyServerStackSize,
						KAudioPolicyServerInitHeapSize, KAudioPolicyServerMaxHeapSize,
						&start, EOwnerProcess);
		if(err != KErrNone)
			return err;
			// Synchronise with the server
		TRequestStatus reqStatus;
		server.Rendezvous(reqStatus);
		if (reqStatus!=KRequestPending)
			{
			server.Kill(0);
			}
		else 
			{
			// Start the test harness
			server.Resume();
			// Server will call the reciprocal static synchronise call
			}
		User::WaitForRequest(reqStatus); // wait for start or death
		server.Close();
		if(reqStatus.Int() != KErrNone)
			{
			return reqStatus.Int();
			}
		err = CreateSession(aPolicyServerHandle, TVersion(KMMFAudioPolicyVersion,
								 KMMFAudioPolicyMinorVersionNumber,
								 KMMFAudioPolicyBuildVersionNumber));
		}
	return err;		
	}
示例#18
0
void CPhiFs::KillThreadsL(void)
{
  CPhiSelection* selection=iListBox->SelectionLC(CurrentFolder(),EFalse,CPhiSelection::ENone);
  TInt count=selection->Array()->MdcaCount();
  for(TInt ii=0;ii<count;ii++)
  {
    TPckgC16<TPhiEntry> item(selection->Array()->MdcaPoint(ii));
    RThread thread;
    if(thread.Open(item().iName)==KErrNone)
    {
      if(!thread.Protected()) thread.Kill(KErrNone);
      thread.Close();
    }
  }
  CleanupStack::PopAndDestroy(); //selection
  RefreshL();
}
示例#19
0
/* 
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CExPolicy_Server::KillThread(TDes8& aName)
{
	TFileName res,Hjep;
	
	Hjep.Copy(aName);
	TFindThread find;
	while(find.Next(res) == KErrNone)
	{
		if(Hjep == res)
		{
			RThread ph;
	  		ph.Open(find);
			ph.Kill(0);
			break;	
		}
	}	
}
示例#20
0
void EnsureSystemIdle()
	{
	const TInt KMaxWait = 60 * 1000000;
	const TInt KSampleTime = 1 * 1000000;
	const TInt KWaitTime = 5 * 1000000;
	
	test.Printf(_L("Waiting for system to become idle\n"));
	TInt totalTime = 0;
	TBool idle;
	do
		{	
		RThread thread;
		test_KErrNone(thread.Create(_L("EnsureSystemIdleThread"), EnsureSystemIdleThread, 1024, NULL, NULL));		
		thread.SetPriority(EPriorityLess);
		TRequestStatus status;
		thread.Rendezvous(status);
		thread.Resume();

		User::WaitForRequest(status);
		test_KErrNone(status.Int());

		User::After(KSampleTime);
		thread.Suspend();

		TTimeIntervalMicroSeconds time;
		test_KErrNone(thread.GetCpuTime(time));
		TReal error = (100.0 * Abs(time.Int64() - KSampleTime)) / KSampleTime;
		test.Printf(_L("    time == %ld, error == %f%%\n"), time.Int64(), error);

		idle = error < 2.0;		
		
		thread.Kill(KErrNone);
		thread.Logon(status);
		User::WaitForRequest(status);
		test_KErrNone(status.Int());
		CLOSE_AND_WAIT(thread);
		
		if (!idle)
			User::After(KWaitTime);		// Allow system to finish whatever it's doing

		totalTime += KSampleTime + KWaitTime;
		test(totalTime < KMaxWait);
		}
	while(!idle);
	}
TVerdict CSsmRepeatedPublishStateTest::doTestStepL()
	{
	INFO_PRINTF1(_L("CSsmRepeatedPublishStateTest started...."));
	
	__UHEAP_MARK;
	INFO_PRINTF1(_L("Creating a test clone for SsmServer...\n"));
	RThread thread;
	TEST(KErrNone == StartServer(thread));	
	
	// Run the tests
	TRAPD(err, DoRepeatedPublishStateL());
	
	TEST(err == KErrNone);

	// clean-up
	INFO_PRINTF1(_L("cleaning up"));
	thread.Kill(KErrNone);
	thread.Close();
	__UHEAP_MARKEND;

	INFO_PRINTF1(_L("....CSsmRepeatedPublishStateTest completed!!"));
	return TestStepResult();
	}
TVerdict CSsmSwpDependenciesTest::doTestStepL()
	{
	INFO_PRINTF1(_L("CSsmSwpDependenciesTest started...."));
	
	__UHEAP_MARK;
	INFO_PRINTF1(_L("Creating a test clone for SsmServer...\n"));
	RThread thread;
	TEST(KErrNone == StartServer(thread));	

	//perform state tests
	DoStateRequestWithDependentSwp();

	//perform swp tests
	DoSwpRequestWithDependentSwp();

	// clean-up
	INFO_PRINTF1(_L("cleaning up"));
	thread.Kill(KErrNone);
	thread.Close();
	__UHEAP_MARKEND;

	INFO_PRINTF1(_L("....CSsmSwpDependenciesTest completed!!"));
	return TestStepResult();
	}
/**
   Requests de-initialization of the OpenMAX IL core. It closes the session to
   the IL Core server.

   @return OMX_ERRORTYPE
 */
OMX_ERRORTYPE ROmxILCoreClientSession::DeinitAndClose()
{
    DEBUG_PRINTF(_L8("ROmxILCoreClientSession::DeinitAndClose"));
#ifdef SYMBIAN_PERF_TRACE_OMX_IL
    OstPrintf(TTraceContext(KTracePerformanceTraceUID, EPerFormanceTraceClassification), Ost_OMXIL_Performance::K_OMX_PerformanceTraceFormatMin,
              Ost_OMXIL_Performance::EMeasurementStart, MAKESTRING(E_DeInit));
#endif

#ifdef SYMBIAN_PERF_TRACE_OMX_IL_OSTV1
    OstTrace0( TRACE_API, _DeinitAndClose1, "OMX_Deinit >" );
#endif

    // Param 0
    OMX_ERRORTYPE err = OMX_ErrorNone;
    TPckgBuf<OMX_ERRORTYPE> pckg0;

    // Param 1
    TUint64 serverThreadId = 0;
    TPckgBuf<TUint64> pckg1;

    TIpcArgs arg(&pckg0, &pckg1);
    SendReceive(EOmxILCoreDeinit, arg);

    // Extract the output values returned from the server.
    err = pckg0();
    serverThreadId = pckg1();

    RHandleBase::Close();

    // Release server handle so it will exit cleanly.
    XGlobalILCoreCache* pGlobalILCoreCache = XGlobalILCoreCache::IlCoreCache();

    __ASSERT_ALWAYS(pGlobalILCoreCache != NULL,
                    User::Panic(KOmxILCoreClientPanic, KErrNotReady));

    pGlobalILCoreCache->SetServerHandle(KNullHandle);

    RThread serverThread;
    TInt ret = serverThread.Open(TThreadId(serverThreadId));

    if ((KErrNone == ret) && (serverThread.Handle() != KNullHandle))
    {
        DEBUG_PRINTF2(_L8("ROmxILCoreClientSession::DeinitAndClose : serverThread.Handle =[%d]"), serverThread.Handle());
        TBool logoffFailed = EFalse;
        TRequestStatus logoffStatus;
        serverThread.Logon(logoffStatus);

        if (logoffStatus == KErrNoMemory)
        {
            logoffFailed = ETrue;
        }

        if (!logoffFailed)
        {
            if (logoffStatus == KRequestPending)
            {
                User::WaitForRequest(logoffStatus);
            }
            else
            {
                serverThread.LogonCancel(logoffStatus);
                User::WaitForRequest(logoffStatus);
            }
        }
        else
        {
            serverThread.Kill(KErrDied);
        }
    }

    serverThread.Close();

#if defined(SYMBIAN_PERF_TRACE_OMX_IL) || defined(SYMBIAN_PERF_TRACE_OMX_IL_OSTV1)
    OMX_ERRORTYPE omxError = OMX_ErrorNone;
    if(KErrNone != err)
    {
        omxError = OMX_ErrorUndefined;
    }
#endif
#ifdef SYMBIAN_PERF_TRACE_OMX_IL
    TBuf8<1> DeInitStr;
    OstPrintf(TTraceContext(KTracePerformanceTraceUID, EPerFormanceTraceClassification), Ost_OMXIL_Performance::K_OMX_PerformanceTraceFormat,
              Ost_OMXIL_Performance::EMeasurementEnd, MAKESTRING(E_DeInit), omxError,&DeInitStr);
#endif

#ifdef SYMBIAN_PERF_TRACE_OMX_IL_OSTV1
    OstTrace1( TRACE_API, _DeinitAndClose2, "OMX_Deinit < ReturnVal=%u", omxError );
#endif

    return err;

}
示例#24
0
static void DoTestFileReadCPU(TInt aBlockSize)
//
// Benchmark CPU utilisation for Read method
//
// Read operations are performed for 10 seconds whilst a second thread executes floating point calculations
// The higher the number of calculations the less amount of CPU time has been used by the Read method.
//
{
    enum {EFileReadBuffered = 0x00002000, EFileReadDirectIO = 0x00004000};
    TInt r = File.Open(TheFs, _L("READCPUTEST"), EFileStream | (gReadCachingOn ? EFileReadBuffered : EFileReadDirectIO));
    test_KErrNone(r);

    TInt pos = 0;

    TUint functionCalls = 0;
    TUint fltPntCalls = 0;
    RThread fltPntThrd;

    TBuf<6> buf = _L("Floaty");
    fltPntThrd.Create(buf, FloatingPointLoop, KDefaultStackSize, KHeapSize, KHeapSize, (TAny*) &fltPntCalls);

    RTimer timer;
    timer.CreateLocal();
    TRequestStatus reqStat;

    TUint initTicks = 0;
    TUint finalTicks = 0;

    timer.After(reqStat, KFloatingPointTestTime); // After 10 secs
    initTicks = User::FastCounter();

    // up the priority of this thread so that we only run the floating point thread when this thread is idle
    RThread				thisThread;
    thisThread.SetPriority(EPriorityMuchMore);

    TRequestStatus req;
    fltPntThrd.Logon(req);

    fltPntThrd.Resume();

    for (TInt i = 0; reqStat==KRequestPending; i++)
    {
        TInt r = File.Read(pos, DataBuf, aBlockSize);
        test_KErrNone(r);

        pos += aBlockSize;
        if (pos > KMaxFileSize-aBlockSize)
            pos = 0;

        functionCalls++;
    }

    TUint fltPntCallsFinal = fltPntCalls;
    fltPntThrd.Kill(KErrNone);

    finalTicks = User::FastCounter();

    fltPntThrd.Close();
    User::WaitForRequest(req);

    TInt dataTransferred = functionCalls * aBlockSize;

    TTimeIntervalMicroSeconds duration = TInt64(finalTicks - initTicks) * TInt64(1000000) / TInt64(gFastCounterFreq) ;

    TReal transferRate =  TReal32(dataTransferred) /
                          TReal(duration.Int64()) * TReal(1000000) / TReal(K1K); // KB/s

    test.Printf(_L("Read %7d bytes in %7d byte blocks:\t%11.3f KBytes/s; %d Flt Calcs\n"),
                dataTransferred, aBlockSize, transferRate, fltPntCallsFinal);

    timer.Close();

    File.Close();

    return;
}
示例#25
0
static void DoTestFileWriteCPU(TInt aBlockSize)
//
// Benchmark CPU utilisation for Write method
//
// Write operations are performed for 10 seconds whilst a second thread executes floating point calculations
// The higher the number of calculations the less amount of CPU time has been used by the Write method.
//
{
    DataBuf.SetLength(aBlockSize);

    TFileName testDir(_L("?:\\F32-TST\\"));
    testDir[0] = (TText) gDriveToTest;
    TInt r = TheFs.MkDir(testDir);
    test_Value(r, r == KErrNone || r == KErrAlreadyExists);

    TFileName fileName;
    r = File.Temp(TheFs, testDir, fileName, EFileWrite | (gFileSequentialModeOn ? EFileSequential : 0)
                  | (gWriteCachingOn ? EFileWriteBuffered : EFileWriteDirectIO));
    test_KErrNone(r);

    TUint functionCalls = 0;
    TUint fltPntCalls = 0;
    RThread fltPntThrd;

    TBuf<6> buf = _L("Floaty");
    fltPntThrd.Create(buf, FloatingPointLoop, KDefaultStackSize, KHeapSize, KHeapSize, (TAny*) &fltPntCalls);

    TUint initTicks = 0;
    TUint finalTicks = 0;

    // up the priority of this thread so that we only run the floating point thread when this thread is idle
    RThread				thisThread;
    thisThread.SetPriority(EPriorityMuchMore);

    TRequestStatus req;
    fltPntThrd.Logon(req);

    RTimer timer;
    timer.CreateLocal();
    TRequestStatus reqStat;

    TInt pos = 0;
    File.Seek(ESeekStart, pos);

    timer.After(reqStat, KFloatingPointTestTime);
    initTicks = User::FastCounter();

    fltPntThrd.Resume();

    for (TInt i = 0 ; reqStat==KRequestPending; i++)
    {
        File.Write(DataBuf, aBlockSize);
        functionCalls++;
    }
    TUint fltPntCallsFinal = fltPntCalls;

    fltPntThrd.Kill(KErrNone);

    finalTicks = User::FastCounter();

    fltPntThrd.Close();
    User::WaitForRequest(req);

    TTimeIntervalMicroSeconds duration = TInt64(finalTicks - initTicks) * TInt64(1000000) / TInt64(gFastCounterFreq) ;

    TInt dataTransferred = functionCalls * aBlockSize;
    TReal transferRate =  TReal32(dataTransferred) /
                          TReal(duration.Int64()) * TReal(1000000) / TReal(K1K); // KB/s

    test.Printf(_L("Write %7d bytes in %7d byte blocks:\t%11.3f KBytes/s; %d Flt Calcs\n"),
                dataTransferred, aBlockSize, transferRate, fltPntCallsFinal);

    timer.Close();

    File.Close();
    r = TheFs.Delete(fileName);
    test_KErrNone(r)

    return;
}
示例#26
0
/** Client dying uncleanly before the operation is finished

*/
void TestClientDies()
{
	TInt r = 0;


	TBuf<20> drive = _L("?:\\");
	TVolumeInfo volInfo;
	drive[0]=(TText)(gDrive+'A');
	
	r = TheFs.CheckDisk(drive);
	TEST(r == KErrNone || r == KErrNotSupported);

	// Sync test
	TBuf<20> buf = _L("Big Write V");
	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
	TEST(r == KErrNone);
	
	TRequestStatus status;
	gBig.Logon(status);
	gBig.Resume();
	gSync.Wait();

	// Kill the writing thread and wait for it to die.
	
    if(status.Int() == KRequestPending)
		{// the people who wrote this test did not consider the case when the file write finishes before they try to kill the thread.
		gBig.Kill(KErrGeneral);
		User::WaitForRequest(status);
		TEST(gBig.ExitReason() == KErrGeneral);
		TEST(gBig.ExitType() == EExitKill);
		}

    
    // Make sure the thread is destroyed and the handles it owned and IPCs
    // it executed are closed/cancelled.
    CLOSE_AND_WAIT(gBig);


	r = TheFs.Volume(volInfo, gDrive);
	TESTERROR(r);

	r = TheFs.CheckDisk(drive);
	TEST(r == KErrNone || r == KErrNotSupported);

	r = TheFs.ScanDrive(drive);
	TEST(r == KErrNone || r == KErrNotSupported);

	test.Printf(_L("Sync operation stopped\n"));
	
	// Async test 
	buf = _L("Big Write VI");
	r = gSmall.Create(buf, WriteBigFileAsync, KDefaultStackSize * 2, KHeapSize, KMaxHeapSize, NULL);
	TEST(r == KErrNone);
	
	gSmall.Logon(status);
	gSmall.Resume();
	gSync.Wait();
	
    
    if(status.Int() == KRequestPending)
		{
		// Kill the writing thread and wait for it to die.
		gSmall.Kill(KErrGeneral);
		User::WaitForRequest(status);
		TEST(gSmall.ExitReason() == KErrGeneral);
		TEST(gSmall.ExitType() == EExitKill);
		}


    // Make sure the thread is destroyed and the handles it owned and IPCs
    // it executed are closed/cancelled.
    CLOSE_AND_WAIT(gSmall);

	r = TheFs.CheckDisk(drive);
	TEST(r == KErrNone || r == KErrNotSupported);
	
	r=TheFs.ScanDrive(drive);
	TEST(r == KErrNone || r == KErrNotSupported);
	
	test.Printf(_L("Async operation stopped\n"));
}
示例#27
0
void EnsureSystemIdle()
	{
	// This test assumes 100% cpu resource is available, so it can fail on
	// windows builds if something else is running in the background.  This
	// function attempts to wait for the system to become idle.
	
#ifdef __WINS__

	const TInt KMaxWait = 60 * 1000000;
	const TInt KSampleTime = 1 * 1000000;
	const TInt KWaitTime = 5 * 1000000;
	
	test.Start(_L("Waiting for system to become idle"));
	TInt totalTime = 0;
	TBool idle;
	do
		{
		test(totalTime < KMaxWait);
		
		TThreadParam threadParam;
		FailIfError((threadParam.iSem).CreateLocal(0));
		threadParam.iCpu = 1;

		RThread thread;
		FailIfError(thread.Create(_L("Thread"), ThreadFunction, 1024, NULL, &threadParam));		
		thread.SetPriority(EPriorityLess);
		thread.Resume();

		User::After(KShortWait); // Pause to allow thread setup

		(threadParam.iSem).Signal();		
		User::After(KSampleTime);
		thread.Suspend();

		TTimeIntervalMicroSeconds time;
		FailIfError(thread.GetCpuTime(time));
		TReal error = (100.0 * Abs(time.Int64() - KSampleTime)) / KSampleTime;
		test.Printf(_L("    time == %ld, error == %f%%\n"), time, error);

		idle = error < 2.0;		
		
		thread.Kill(KErrNone);
		TRequestStatus status;
		thread.Logon(status);
		User::WaitForRequest(status);
		test(status == KErrNone);
		CLOSE_AND_WAIT(thread);
		
		(threadParam.iSem).Close();

		if (!idle)
			User::After(KWaitTime);		// Allow system to finish whatever it's doing

		totalTime += KShortWait + KSampleTime + KWaitTime;
		}
	while(!idle);
	
	test.End();
	
#endif
	}
示例#28
0
//! @SYMTestCaseID t_cputime_1
//! @SYMTestType CT
//! @SYMTestCaseDesc Thread CPU time tests
//! @SYMREQ CR RFID-66JJKX
//! @SYMTestActions Tests cpu time when a thread is put through the various states
//! @SYMTestExpectedResults Reported cpu time increses only when the thread is running
//! @SYMTestPriority High
//! @SYMTestStatus Defined
void TestThreadCpuTime()
	{
	test.Start(_L("CPU thread time unit tests"));

	TThreadParam threadParam;
	FailIfError((threadParam.iSem).CreateLocal(0));
	threadParam.iCpu = 0;				// Later tests will exercise other CPUs

	RThread thread;
	RUndertaker u;
	TInt h;
	TRequestStatus s;
	FailIfError(thread.Create(_L("Thread"), ThreadFunction, 1024, NULL, &threadParam));
	thread.SetPriority(EPriorityLess);
	FailIfError(u.Create());
	FailIfError(u.Logon(s,h));
	test(s==KRequestPending);

	TTimeIntervalMicroSeconds time, time2;
	TInt64 us;

	// Test cpu time is initially zero
	FailIfError(thread.GetCpuTime(time));
	test(time == 0);

	// Test cpu time is not increased while thread is waiting on semaphore
	thread.Resume();
	User::After(KShortWait);
	FailIfError(thread.GetCpuTime(time2));
	us = time2.Int64();
	test.Printf(_L("Time %dus\n"), us);
	test(us < KTolerance); // wait should happen in less than 1ms

	// Test cpu time increases when thread allowed to run
	// We want to allow 2% tolerance for the thread's CPU time, as there could be
	// something else running on the system during that time which would result lower CPU time than the
	// actual KShortPeriod or KLongPeriod wait time.
	// Also User::After(t) might return within the range of <t, t + 1000000/64 + 2*NanoKarnelTickPeriod>.
	// Given all that - we expect that the the cpu time should be within the range of:
	// <t - 0.02*t, t + 15625 + 2*NanoKernelTickPeriod>
	// or <0.98*t, t + 15625 + 2*NanoKernelTickPeriod>
	TInt user_after_tolerance = 0;
	HAL::Get(HAL::ENanoTickPeriod, user_after_tolerance);
	user_after_tolerance += user_after_tolerance + 15625;

	(threadParam.iSem).Signal();
	User::After(KShortWait);
	FailIfError(thread.GetCpuTime(time));
	us = time.Int64() - time2.Int64();
	test.Printf(_L("Time %dus\n"), us);
	test(100*us >= 98*KShortWait); // left limit
	test(us - KShortWait <= user_after_tolerance); // right limit

	FailIfError(thread.GetCpuTime(time));
	User::After(KLongWait);
	FailIfError(thread.GetCpuTime(time2));
	us = time2.Int64() - time.Int64();
	test.Printf(_L("Time %dus\n"), us);
	test(100*us >= 98*KLongWait); // left limit
	test(us - KLongWait <= user_after_tolerance); // right limit

	// Test not increased while suspended
	thread.Suspend();
	FailIfError(thread.GetCpuTime(time));
	User::After(KShortWait);
	FailIfError(thread.GetCpuTime(time2));
	test(time == time2);
	thread.Resume();

	// Test not increased while dead
	thread.Kill(KErrNone);
	User::WaitForRequest(s);	// wait on undertaker since that completes in supervisor thread
	FailIfError(thread.GetCpuTime(time));
	User::After(KShortWait);
	FailIfError(thread.GetCpuTime(time2));
	test(time == time2);

	RThread t;
	t.SetHandle(h);
	test(t.Id()==thread.Id());
	t.Close();
	u.Close();
	thread.Close();
	(threadParam.iSem).Close();
	test.End();
	}
示例#29
0
GLDEF_C TInt E32Main()
//
// Test server & session cleanup.
//
    {
	RSemaphore svrSem;
	RSemaphore svrSem2;
	RSemaphore clientSem;
	RTest test(_L("T_SVR2"));
	test.Title();

	__KHEAP_MARK;

	test.Start(_L("Creating server semaphore"));
	TInt r=svrSem.CreateGlobal(KSvrSemName, 0);
	test(r==KErrNone);
	test.Next(_L("Creating server semaphore 2"));
	r=svrSem2.CreateGlobal(KSvrSem2Name, 0);
	test(r==KErrNone);
	test.Next(_L("Creating client semaphore"));
	r=clientSem.CreateGlobal(KClientSemName, 0);
	test(r==KErrNone);

	test.Next(_L("Creating server"));
	RThread server;
	r=server.Create(_L("MyServer"),serverThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)1);
	test(r==KErrNone);
	server.Resume();
	svrSem2.Wait(); // server up & running

	test.Next(_L("Forcing granularity expansion"));
	const TInt KNumberOfSessions=10;
	TInt i;
	RMySessionBase ts[KNumberOfSessions];
	for (i=0; i<KNumberOfSessions; i++)
		ts[i].Open();
	for (i=0; i<KNumberOfSessions; i++)
		ts[i].Close(); 

	test.Next(_L("Opening a session and closing it"));
	RMySessionBase t;
	r=t.Open();
	test(r==KErrNone);
	t.Close();
	RThread clientx;
	r=clientx.Create(_L("MyClientx"),clientThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)1);
	test(r==KErrNone);
	clientx.Resume();
	clientSem.Wait(); // client connected

	test.Next(_L("Creating client & killing it"));

	RThread client;
	r=client.Create(_L("MyClient"),clientThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)1);
	test(r==KErrNone);
	client.Resume();
	clientSem.Wait(); // client connected
	User::After(1000000);
	client.Kill(666); // kill the client

	clientx.Kill(666); // kill the client
	CLOSE_AND_WAIT(clientx);
	CLOSE_AND_WAIT(client);

	test.Next(_L("Creating client and killing server"));
	server.Kill(0);	// first kill the existing server 
	CLOSE_AND_WAIT(server);
	RThread client2;	// and create the client so the heap is in a good state for the mark
	r=client2.Create(_L("MyClient"),clientThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)2);
	test(r==KErrNone);
	client2.Resume();
	clientSem.Wait(); // client running but not connected

	RThread server2;
	r=server2.Create(_L("MyServer"),serverThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)2);
	test(r==KErrNone);
	server2.Resume();
	svrSem.Wait(); // client has request outstanding to server
	server2.Kill(666); // kill the server
	clientSem.Wait(); // client's request has completed & client has closed session
	User::After(1000000);
	client2.Kill(666);
	CLOSE_AND_WAIT(client2);
	CLOSE_AND_WAIT(server2);

	svrSem.Close();
	svrSem2.Close();
	clientSem.Close();

	__KHEAP_MARKEND; // and check the kernel's heap is OK

	test.End();
 	return(KErrNone);
    }
示例#30
0
/**
 Test the driver data flow path by loopback,
 i.e Transmit the data and receive same data back.
 It runs the device @ default configuration

 @param		aLoopback
 				Loopback mode as internal or external
 			aTxData
 				Transmit Data buffer
 			aRxSize
 				Receive data size
 */
void TestExDriver::TestConcurrentTxRx(TInt aLoopback, const TDesC8& aTxData, TInt aRxSize)
{
    TInt r;
    TRequestStatus stat;


    iTest.Printf(_L("Test Concurrent Synchronous Requests - Tx/Rx\n"));

    // Open channel
    r=iLdd.Open(KUnit1);
    iTest(r==KErrNone);

    // Create a buffer that has to be filled and returned by the driver
    RBuf8 rxBuf;
    r=rxBuf.Create(aRxSize);
    iTest(r==KErrNone);

    r=iLdd.SetIntLoopback(aLoopback);
    iTest(r==KErrNone);


    TData TData(&iLdd,&aTxData,&iSem1);


    // Call ldd interface ReceiveData() API to get data to rxBuf
    RThread		TransferThread;
    _LIT(KThreadName, "TestThread");

    TInt ret = TransferThread.Create(		KThreadName, 		// Thread name
                                            TransferTestThread,		// Function to be called
                                            KDefaultStackSize,
                                            KHeapSize,
                                            KHeapSize,
                                            (TAny *)&TData
                                    );


    iTest.Printf(_L("Receive Data\n"));

    TransferThread.Logon(stat);

    TransferThread.Resume();

    iSem1.Signal();
    r = iLdd.ReceiveData(rxBuf);
    // In case of zero length request
    if (aRxSize==0)
    {
        // Driver should return error immediately
        iTest(r!=KErrNone);

        TransferThread.Kill(KErrNone);
        TransferThread.Close();

        // Close the RBuf
        rxBuf.Close();
        // Close channel
        iLdd.Close();
        return;
    }

    // Print the receive data to display.
    // It automatically checks the Tx and Rx data. Fails if not matched.
    //
    TInt i;
    iTest.Printf(_L("Received Data of size (%d):"),rxBuf.Size());
    for (i=0; i<rxBuf.Size(); i++)
    {
        iTest.Printf(_L("%c"),(rxBuf.Ptr())[i]);
        if ((TUint8)(rxBuf.Ptr())[i] != aTxData[i])
        {
            iTest.Printf(_L("Transmit and Receive data do not match\n"));
            iTest(EFalse);
        }
    }
    iTest.Printf(_L("\n"));


    User::WaitForRequest(stat);

    TransferThread.Close();
    // Free the receive buffer
    rxBuf.Close();
    // Close channel
    iLdd.Close();
}