Ejemplo n.º 1
0
/** Starts two concurrent client sessions in different directories

*/
LOCAL_C void DoTest2(TThreadFunction aFunction)
	{
	gKillMe = EFalse;

	TBuf<20> buf = _L("Speedy");
	buf.AppendNum(ThreadCount++);
	gT1 = ThreadCount;
	TInt r = gSpeedy.Create(buf, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
	FailIfError(r);

	buf = _L("Speedy");
	buf.AppendNum(ThreadCount++);
	gT2 = ThreadCount;
	r = gSpeedyII.Create(buf, DeleteEntryAccess2, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
	FailIfError(r);

 	gSpeedy.SetPriority(EPriorityLess);
    gSpeedyII.SetPriority(EPriorityLess);
	
	gSpeedy.Resume();
	gSpeedyII.Resume();
	
	client.Wait();
	client.Wait();
	}
Ejemplo n.º 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();	
	}
Ejemplo n.º 3
0
/** Find entry in directory

*/
LOCAL_C TInt FindEntryAccess2(TAny*)
	{
	RFs fs;
	TInt r  = fs.Connect();
	RTest test(_L("test 2")); 
	
	fs.SetSessionPath(gSessionPath);
	
	client.Signal();
	
	FOREVER
		{
			TEntry entry;
			r = fs.Entry(gFindEntryDir2, entry);
			FailIfError(r);
			r = fs.Entry(gFindDir2,entry);
			FailIfError(r);
		}
	}
Ejemplo n.º 4
0
//! @SYMTestCaseID t_cputime_0
//! @SYMTestType CT
//! @SYMTestCaseDesc Fast counter tests
//! @SYMREQ CR RFID-66JJKX
//! @SYMTestActions Compares the high res timer against the nanokernel microsecond tick
//! @SYMTestExpectedResults The differnce measured should be < 1%
//! @SYMTestPriority High
//! @SYMTestStatus Defined
void TestFastCounter()
	{
	test.Start(_L("Comparing NTickCount with FastCounter"));

	TInt tickPeriod = 0;
	FailIfError(HAL::Get(HAL::ENanoTickPeriod, tickPeriod));
	test.Printf(_L("  tick period == %d\n"), tickPeriod);
	
	TInt countFreq = 0;
	FailIfError(HAL::Get(HAL::EFastCounterFrequency, countFreq));
	test.Printf(_L("  count freq == %d\n"), countFreq);

	TBool fcCountsUp = 0;
	FailIfError(HAL::Get(HAL::EFastCounterCountsUp, fcCountsUp));
	test.Printf(_L("  count dir == %S\n"), fcCountsUp ? &KUp : &KDown);

	TUint startTick = User::NTickCount();
	TUint startCount = User::FastCounter();

	User::After(KLongWait);

	TUint endTick = User::NTickCount();
	TUint endCount = User::FastCounter();

	TInt tickDiff = endTick - startTick;
	TInt countDiff = fcCountsUp ? (endCount - startCount) : (startCount - endCount);

	test.Printf(_L("  tick difference == %d\n"), tickDiff);
	test.Printf(_L("  fast count difference == %d\n"), countDiff);

	TInt elapsedTickUs = tickDiff * tickPeriod;
	TInt elapsedCountUs = (TInt)(((TInt64)1000000 * countDiff) / countFreq);

	test.Printf(_L("  tick time == %d\n"), elapsedTickUs);
	test.Printf(_L("  count time == %d\n"), elapsedCountUs);

	TReal diff = (100.0 * Abs(elapsedCountUs - elapsedTickUs)) / elapsedTickUs;

	test.Printf(_L("  %% difference == %f\n"), diff);
	test(diff < 1.0);	
	test.End();
	}
Ejemplo n.º 5
0
/** Starts a concurrent client session

	@param aFunction Thread to be started twice
*/
LOCAL_C void DoTest(TThreadFunction aFunction)
	{
	TBuf<20> buf = _L("Speedy");
	buf.AppendNum(ThreadCount++);
	TInt r = gSpeedy.Create(buf, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
	FailIfError(r);

	buf = _L("Speedy");
	buf.AppendNum(ThreadCount++);
	r = gSpeedyII.Create(buf, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
	FailIfError(r);

	gSpeedy.SetPriority(EPriorityLess);
    gSpeedyII.SetPriority(EPriorityLess);
    
	gSpeedy.Resume();
	gSpeedyII.Resume();
	
	client.Wait();
	client.Wait();
	}
Ejemplo n.º 6
0
TInt ThreadFunction(TAny* aParam)
	{
	if (numCpus > 1)
		{
		TInt& core = (static_cast<TThreadParam*>(aParam))->iCpu;
		FailIfError(SetCpuAffinity(core));
		}

	RSemaphore& semaphore = (static_cast<TThreadParam*>(aParam))->iSem;
	semaphore.Wait();
	for (;;)
		{
		// Spin
		}
	}
Ejemplo n.º 7
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);
	}
Ejemplo n.º 8
0
GLDEF_C TInt E32Main()
	{
	test.Title();
	test.Start(_L("T_CPUTIME"));

	if (numCpus > 1)
		FailIfError(SetCpuAffinity(0));

	TestFastCounter();
	if (GetCpuTimeIsSupported())
		{
		EnsureSystemIdle();
		TestThreadCpuTime();
		TestThreadCpuTime2();
#ifdef __MARM__
		TestThreadCpuTime3();
#endif
		}
	test.End();
	return 0;
	}
Ejemplo n.º 9
0
/** Call all tests

*/
GLDEF_C void CallTestsL()
	{

	TInt r = client.CreateLocal(0);
	FailIfError(r);
	
	CSelectionBox* TheSelector = CSelectionBox::NewL(test.Console());
	
	// Each test case of the suite has an identifyer for parsing purposes of the results
	gTestHarness = 3; 	
	gTestCase = 1;
	
	CreateDirWithNFiles(300, 3);
	PrintHeaders(1, _L("t_fsrdirscan. Directory scanning"));
	
	if(gMode==0) 
		{ // Manual	
		gSessionPath=_L("?:\\");
		TCallBack createFiles(TestFileCreate,TheSelector);
		TCallBack findFile(TestFindEntry,TheSelector);
		TCallBack findFileMC(TestFindEntryMultipleClients,TheSelector);
		TCallBack findFileMCDD(TestFindEntryMultipleClientsDD,TheSelector);
		TCallBack findFilePattern(TestFileFindPattern,TheSelector);
		TheSelector->AddDriveSelectorL(TheFs);
		TheSelector->AddLineL(_L("Create all files"),createFiles);
		TheSelector->AddLineL(_L("Find filename"),findFile);
		TheSelector->AddLineL(_L("Find with mult clients same directory"),findFileMC);
		TheSelector->AddLineL(_L("Find with mult clients dif directories"),findFileMCDD);
		TheSelector->AddLineL(_L("All using glob patterns"),findFilePattern);
		TheSelector->Run();
		}
	else 
		{ // Automatic
		TestAll(TheSelector);
		}
	
	client.Close();
	test.Printf(_L("#~TestEnd_%d\n"), gTestHarness);
	delete TheSelector;
	}
Ejemplo n.º 10
0
/** Call all tests

*/
GLDEF_C void CallTestsL()
	{
	TInt r = client.CreateLocal(0);
	FailIfError(r);
	
	gFileSize = 8;
	
	CSelectionBox* TheSelector = CSelectionBox::NewL(test.Console());
	
	// Each test case of the suite has an identifyer for parsing purposes of the results
	gTestHarness = 6; 	
	gTestCase = 1;

	PrintHeaders(1, _L("t_fsrmkdir. Mkdir"));
	
	if(gMode == 0) 
		{ // Manual
		gSessionPath=_L("?:\\");
		TCallBack createFiles(TestFileCreate, TheSelector);
		TCallBack MkDir(TestMake, TheSelector);
		TCallBack makeMultSame(TestMakeMultSame, TheSelector);
		TCallBack makeMultDif(TestMakeMultDif, TheSelector);
		TCallBack makeAll(TestAll, TheSelector);
		TheSelector->AddDriveSelectorL(TheFs);
		TheSelector->AddLineL(_L("Create all files"), createFiles);
		TheSelector->AddLineL(_L("Mkdir "), MkDir);
		TheSelector->AddLineL(_L("Mkdir mult clients same dir "), makeMultSame);
		TheSelector->AddLineL(_L("Mkdir mult clients dif dir"), makeMultDif);
		TheSelector->AddLineL(_L("Execute all options"), makeAll);
		TheSelector->Run();
		}
	else 
		{ // Automatic
		TestAll(TheSelector);
		}
		
	client.Close();
	test.Printf(_L("#~TestEnd_%d\n"), gTestHarness);
	delete TheSelector;
	}
Ejemplo n.º 11
0
/** Creates files

	@param aSelector Configuration in case of manual execution
*/
LOCAL_C TInt TestAll(TAny* aSelector)
	{
	TInt r = 0;
	TTime startTime;
	TTime endTime;
	TTimeIntervalSeconds timeTaken;

	Validate(aSelector);
	
	gFormat = EFalse; 	// The card won't be formatted after this test execution
	
	startTime.HomeTime();
	
	TestFileCreate(aSelector);
	
	endTime.HomeTime();
	r = endTime.SecondsFrom(startTime, timeTaken);
	FailIfError(r);
	test.Printf(_L("#~TS_Timing_%d,%d=%d\n"), gTestHarness, gTestCase, timeTaken.Int());

	return KErrNone;
	}
Ejemplo n.º 12
0
TInt E32Main()
//
// Benchmark for euser assmblerised functions
//
    {
	CTrapCleanup* trapHandler=CTrapCleanup::New();
	test(trapHandler!=NULL);

    test.Title();
    test.Start(_L("Benchmarks for assemblerised euser functions"));

	TUserBenchmarkList bms;
	TRAPD(err, RunBenchmarkTestsL(bms));
	if (err != KErrNone)
		test.Printf(_L("TestMainL left with %d\n"), err);

	FailIfError(err);
	
	test.End();
	
	delete trapHandler;
	return(KErrNone);
    }
Ejemplo n.º 13
0
/** Delete entry in directory

*/
LOCAL_C TInt DeleteEntryAccess(TAny*)
	{
	RFs fs2;
	TInt r = fs2.Connect();
	TBuf<100> dirfile;
	TBuf<50> filename;
	RFile file2;
	RTest test(_L("test 2")); 
		
	r = fs2.SetSessionPath(gSessionPath);
	filename.Format(KDeleteMe, gT1);
	
	dirfile = gDelEntryDir;
	dirfile.Append(filename);
	
	client.Signal();
	
	FOREVER
		{
		if(!gKillMe)
			{
			r = file2.Create(fs2, dirfile, EFileShareAny|EFileWrite);
			if(r == KErrAlreadyExists) 
				r = file2.Open(fs2, dirfile, EFileShareAny|EFileWrite);
			file2.Close();
			FailIfError(r);
			r = fs2.Delete(dirfile);

			if((r != KErrNone) && (r != KErrInUse)) 
				{
				test.Printf(_L("error = %d\n"), r);
				}

			test(r == KErrNone || r == KErrInUse);
			}
		}
	}
Ejemplo n.º 14
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();
	}
Ejemplo n.º 15
0
/** Time the creation of a directory inside each type of directory with multiple threads ongoing

	@param aN Number of files in the directory
	@param aStep 	Test step
*/
LOCAL_C void MakeDirM(TInt aN, TInt aStep) 
	{
	TBuf16<100> dir1;
	TBuf16<100> dir2;
	TBuf16<100> dir3;
    TBuf16<100> dir4;
	
	TInt r = 0;
	TTime startTime;
	TTime endTime;
	TTimeIntervalMicroSeconds timeTaken(0);
	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
	
	if(aN <= gFilesLimit) 
		{
		dir1 = gSessionPath;
		dir2 = gSessionPath;
		dir3 = gSessionPath;
		
		dir4.Format(KDirMultipleName2, 1, aN);
		dir1.Append(dir4);
		dir4.Format(KDirMultipleName2, 2, aN);
		dir2.Append(dir4);	
		dir4.Format(KDirMultipleName2, 3, aN);
		dir3.Append(dir4);
		
		if(gTypes >= 1) 
			{
			gDelEntryDir = dir1;
			gDelEntryDir2 = dir1;
			
			dir1.Append(KNewDir);
			DoTest2(DeleteEntryAccess);
			
			startTime.HomeTime();
			
			r = TheFs.MkDir(dir1);
			FailIfError(r);
			
			endTime.HomeTime();
			
			DoTestKill();
			
			timeTaken = endTime.MicroSecondsFrom(startTime);
			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
			
			TheFs.RmDir(dir1);
			}
		
		if(gTypes >= 2) 
			{
			gDelEntryDir = dir2;
			gDelEntryDir2 = dir2;
			dir2.Append(KNewDir);
			
			DoTest2(DeleteEntryAccess);

			startTime.HomeTime();

			r = TheFs.MkDir(dir2);
			FailIfError(r);
			
			endTime.HomeTime();
			DoTestKill();

			timeTaken = endTime.MicroSecondsFrom(startTime);
			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
			
			TheFs.RmDir(dir2);
			}
		
		if(gTypes >= 3) 
			{
			gDelEntryDir = dir3;
			gDelEntryDir2 = dir3;
			dir3.Append(KNewDir);
			DoTest2(DeleteEntryAccess);

			startTime.HomeTime();

			r = TheFs.MkDir(dir3);
			FailIfError(r);
			
			endTime.HomeTime();
			DoTestKill();

			timeTaken = endTime.MicroSecondsFrom(startTime);
			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
			
			TheFs.RmDir(dir3);
			}
		}
	
	PrintResult(aStep, 1, aN);
	PrintResultTime(aStep, 2, timeTaken1);
	PrintResultTime(aStep, 3, timeTaken2);
	PrintResultTime(aStep, 4, timeTaken3);

	}
Ejemplo n.º 16
0
/** Find last.txt with TFindFile and with two threads accessing the 2 directories

	@param aN Number of files in the directory
	@param aStep 	Test step
*/
LOCAL_C void FindFileMD1(TInt aN, TInt aStep) 
	{
	TBuf16<100> dir1;
	TBuf16<100> dir2;
	TBuf16<100> dir3;
    TBuf16<100> dir4;
    TBuf16<100> dirtemp;
	
	TInt r = 0;
	TFindFile find(TheFs);
	TTime startTime;
	TTime endTime;
	TTimeIntervalMicroSeconds timeTaken(0);
	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 

	if(aN <= gFilesLimit) 
		{
		dir1 = gSessionPath;
		dir2 = gSessionPath;
		dir3 = gSessionPath;

		dirtemp.Format(KDirMultipleName2, 1, aN);
		dir1.Append(dirtemp);

		dirtemp.Format(KDirMultipleName, 2, aN);
		dir2.Append(dirtemp);

		dirtemp.Format(KDirMultipleName, 3, aN);
		dir3.Append(dirtemp);
		
		dir4 = gSessionPath;
		dirtemp.Format(KDirMultipleName, 3, 300);
		
		dir4.Append(dirtemp);
		
		gFindDir = dir1;
		gFindDir2 = dir4;
		
		dir1.Append(KCommonFile);
		dir2.Append(KCommonFile);
		dir3.Append(KCommonFile);
		dir4.Append(KCommonFile);
		
		gFindEntryDir = dir1;
		gFindEntryDir2 = dir4;
		

		TheFs.SetSessionPath(gSessionPath);
		
		dir4.Format(KDirMultipleName, 1, aN);
		
		if(gTypes >= 1) 
			{	
			DoTest2(FindEntryAccess);

			startTime.HomeTime();
	 		r = find.FindByPath(dir1, &dir4);
			FailIfError(r);
			endTime.HomeTime();
			
			DoTestKill();
			
			timeTaken = endTime.MicroSecondsFrom(startTime);
			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
			}

		if(gTypes >= 2) 
			{	
			dir4 = gSessionPath; 
			dirtemp.Format(KDirMultipleName, 2, aN);
			dir4.Append(dirtemp);
			gFindDir = dir4;
			gFindEntryDir=dir2;

			DoTest2(FindEntryAccess);
			dir4.Format(KDirMultipleName, 2, aN);
	
			startTime.HomeTime();

			r = find.FindByPath(dir2,&dir4);
			test(r==KErrNone);
			endTime.HomeTime();
			timeTaken=endTime.MicroSecondsFrom(startTime);
			DoTestKill();
			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
			}
		
		if(gTypes>=3) 
			{	
			dir4 = gSessionPath; 
			dirtemp.Format(KDirMultipleName, 3, aN);
			dir4.Append(dirtemp);

			gFindDir = dir4;
			gFindEntryDir=dir2;
			
			DoTest2(FindEntryAccess);
			dir4.Format(KDirMultipleName, 3, aN);
		
			startTime.HomeTime();

			r=find.FindByPath(dir3,&dir4);
			test(r==KErrNone);
			
			endTime.HomeTime();
			DoTestKill();
			
			timeTaken=endTime.MicroSecondsFrom(startTime);
			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
			}
		}
	
	PrintResult(aStep, 1, aN);
	PrintResultTime(aStep, 2, timeTaken1);
	PrintResultTime(aStep, 3, timeTaken2);
	PrintResultTime(aStep, 4, timeTaken3);
	}
Ejemplo n.º 17
0
bool	SimpleAudioDriver::start(IOService* inProvider)
{
	//	start the superclass
    bool theAnswer = IOService::start(inProvider);
    if(theAnswer)
	{
		//	create the work loop
		mWorkLoop = IOWorkLoop::workLoop();
		FailIfNULL(mWorkLoop, theAnswer = kIOReturnNoResources, Failure, "SimpleAudioDriver::start: couldn't allocate the work loop");
		
		//	create the command gate
		mCommandGate = IOCommandGate::commandGate(this);
		FailIfNULL(mWorkLoop, theAnswer = kIOReturnNoResources, Failure, "SimpleAudioDriver::start: couldn't allocate the command gate");
		
		//	attach it to the work loop
		mWorkLoop->addEventSource(mCommandGate);
		
		//	initialize the stuff tracked by the IORegistry
		mSampleRate = 44100;
		setProperty(kSimpleAudioDriver_RegistryKey_SampleRate, mSampleRate, sizeof(mSampleRate) * 8);
		
		mIOBufferFrameSize = 16384;
		setProperty(kSimpleAudioDriver_RegistryKey_RingBufferFrameSize, mIOBufferFrameSize, sizeof(mIOBufferFrameSize) * 8);
		
		char theDeviceUID[128];
		snprintf(theDeviceUID, 128, "SimpleAudioDevice-%d", static_cast<int>(random() % 100000));
		setProperty(kSimpleAudioDriver_RegistryKey_DeviceUID, theDeviceUID);

		//	allocate the IO buffers
		IOReturn theError = allocateBuffers();
		FailIfError(theError, theAnswer = false, Failure, "SimpleAudioDriver::start: allocating the buffers failed");
		
		//	initialize the timer that stands in for a real interrupt
		theError = initTimer();
		FailIfError(theError, freeBuffers(); theAnswer = false, Failure, "SimpleAudioDriver::start: initializing the timer failed");
		
		//	initialize the controls
		theError = initControls();
		FailIfError(theError, theAnswer = false, Failure, "SimpleAudioDriver::start: initializing the controls failed");
		
		//	publish ourselves
		registerService();
	}

    return theAnswer;

Failure:
	if(mCommandGate != NULL)
	{
		if(mWorkLoop != NULL)
		{
			mWorkLoop->removeEventSource(mCommandGate);
			mCommandGate->release();
			mCommandGate = NULL;
		}
	}
	
	if(mWorkLoop != NULL)
	{
		mWorkLoop->release();
		mWorkLoop = NULL;
	}
	
	freeBuffers();
	destroyTimer();
	
	return theAnswer;
}
Ejemplo n.º 18
0
/** Find last.txt by opening the file and with two threads accessing the current 
	directory and other one 

	@param aN Number of files in the directory
	@param aStep 	Test step
*/
LOCAL_C void FindFileMD2(TInt aN, TInt aStep) 
	{
	TBuf16<100> dir1;
	TBuf16<100> dir2;
	TBuf16<100> dir3;
	TBuf16<100> dir4;
	TBuf16<100> dirtemp;

	TInt r = 0;

	TTime startTime;
	TTime endTime;
	TTimeIntervalMicroSeconds timeTaken(0);
	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 

	RFile file;
	
	if(aN <= gFilesLimit) 
		{
		dir1 = gSessionPath;
		dir2 = gSessionPath;
		dir3 = gSessionPath;

		dirtemp.Format(KDirMultipleName2, 1, aN);
		dir1.Append(dirtemp);
		gFindDir = dir1;
		
		dirtemp.Format(KDirMultipleName2, 2, aN);
		dir2.Append(dirtemp);

		dirtemp.Format(KDirMultipleName2, 3, aN);
		dir3.Append(dirtemp);
			
		dir1.Append(KCommonFile);
		gFindEntryDir = dir1;
		
		dir4 = gSessionPath;
		dirtemp.Format(KDirMultipleName, 3, 300);
		dir4.Append(dirtemp);

		
		if(gTypes >= 1) 
			{	
			gFindDir2 = dir4;
			dir4.Append(KCommonFile);
			gFindEntryDir2 = dir4;

			DoTest2(FindEntryAccess);

			User::After(200);
			
			startTime.HomeTime();
			
			r = file.Open(TheFs,dir1,EFileShareAny|EFileWrite);
			FailIfError(r);
			
			endTime.HomeTime();
			
			timeTaken = endTime.MicroSecondsFrom(startTime);

			file.Close();
			DoTestKill();
			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
			}
		
		if(gTypes >= 2) 
			{	
			gFindDir = dir2;
			dir2.Append(KCommonFile);
			gFindEntryDir = dir2;
			DoTest2(FindEntryAccess);
			
			User::After(200);
			startTime.HomeTime();

			r = file.Open(TheFs, dir2, EFileShareAny|EFileWrite);
			FailIfError(r);
			
			endTime.HomeTime();
			timeTaken = endTime.MicroSecondsFrom(startTime);
			file.Close();
			DoTestKill();
			
			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
			}
			
		if(gTypes >= 3) 
			{	
			gFindDir = dir3;	
			dir3.Append(KCommonFile);
			gFindEntryDir = dir3;
			DoTest2(FindEntryAccess);

			User::After(200);
			startTime.HomeTime();

			r = file.Open(TheFs, dir3, EFileShareAny|EFileWrite);
			FailIfError(r);
			
			endTime.HomeTime();
			timeTaken=endTime.MicroSecondsFrom(startTime);
			DoTestKill();
			
			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
			file.Close();
			}
		}

	PrintResult(aStep, 1, aN);
	PrintResultTime(aStep, 2, timeTaken1);
	PrintResultTime(aStep, 3, timeTaken2);
	PrintResultTime(aStep, 4, timeTaken3);
	}
Ejemplo n.º 19
0
/** Find last.txt with TFindFile and with two threads accessing the 2 directories

	@param aN 		Number of files in the directory
	@param aWild 	Wildcard string to be used in the search
	@param aStep 	Test step
*/
LOCAL_C void FindFileWild1(TInt aN, const TDesC& aWild, TInt aStep) 
	{
	TBuf16<100> dir1;
	TBuf16<100> dir2;
	TBuf16<100> dir3;
    TBuf16<100> dir4;

	CDir* dir;
	TInt r = 0;

	TFindFile find(TheFs);
	
	TTime startTime;
	TTime endTime;
	TTimeIntervalMicroSeconds timeTaken(0);
	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
	
	if(aN <= gFilesLimit) 
		{
		dir1 = gSessionPath;
		dir2 = gSessionPath;
		dir3 = gSessionPath;
		
		dir4.Format(KDirMultipleName2, 1, aN);
		dir1.Append(dir4);
		
		dir4.Format(KDirMultipleName2, 2, aN);
		dir2.Append(dir4);
		
		dir4.Format(KDirMultipleName2, 3, aN);
		dir3.Append(dir4);
		
		if(gTypes >= 1) 
			{	
			dir4.Format(KDirMultipleName, 1, aN);
			startTime.HomeTime();
			
			r = find.FindWildByPath(aWild, &dir1, dir);
			FailIfError(r);
			
			endTime.HomeTime();

			timeTaken = endTime.MicroSecondsFrom(startTime);
			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
			delete dir;
			}
		
		if(gTypes >= 2) 
			{	
			startTime.HomeTime();

			r = find.FindWildByPath(_L("*.txt"), &dir2, dir);
			FailIfError(r);

			endTime.HomeTime();
			timeTaken = endTime.MicroSecondsFrom(startTime);
			
			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
			delete dir;
			}
		
		if(gTypes >= 3) 
			{	
			startTime.HomeTime();
			
			r = find.FindWildByPath(_L("*.txt"), &dir3, dir);
			FailIfError(r);
			
			endTime.HomeTime();
			timeTaken=endTime.MicroSecondsFrom(startTime);
			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
			delete dir;
			}
		}
	
	PrintResult(aStep, 1, aN);
	PrintResultTime(aStep, 2, timeTaken1);
	PrintResultTime(aStep, 3, timeTaken2);
	PrintResultTime(aStep, 4, timeTaken3);
	}
Ejemplo n.º 20
0
TBool DoTestThreadCpuTime2()  // Returns ETrue if test passed
	{
	test.Start(_L("Testing time shared between threads"));

	if (numCpus > 1)
		{
		test.Printf(_L("** SMP system detected - not testing time shared between threads until load balancing optimized **\n"));
		return ETrue;
		}

	const TInt KMaxThreads = 4;

	TThreadParam threadParam;
			
	RThread* threads = NULL;
	threads = new(ELeave) RThread[numCpus*KMaxThreads];
	FailIfError((threadParam.iSem).CreateLocal(0));

	TBool pass = ETrue;
	for (TInt numThreads = 1 ; pass && numThreads <= KMaxThreads ; ++numThreads)
		{
		test.Printf(_L("  testing with %d threads on each of %d CPUs:\n"), numThreads, numCpus);

		TInt i, j, k;
		for (i = 0 ; i < numThreads ; ++i)
			{
			for (j = 0 ; j < numCpus ; ++j)
				{
				TBuf<16> name;
				name.AppendFormat(_L("Thread%d%d"), i, j);
				threadParam.iCpu = j;
				k = i+j*KMaxThreads;
				FailIfError(threads[k].Create(name, ThreadFunction, 1024, NULL, &threadParam));
				threads[k].SetPriority(EPriorityLess);
				threads[k].Resume();
				}
			}

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

		(threadParam.iSem).Signal(numThreads*numCpus);		
		User::After(KLongWait);
		for (i = 0 ; i < numThreads ; ++i)
			for (j = 0 ; j < numCpus ; ++j)
				threads[i+j*KMaxThreads].Suspend();

		TInt expected = KLongWait / numThreads;
		for (i = 0 ; i < numThreads ; ++i)
			{
			for (j = 0 ; j < numCpus ; ++j)
				{
				k = i+j*KMaxThreads;
				TTimeIntervalMicroSeconds time;
				FailIfError(threads[k].GetCpuTime(time));

				TReal error = (100.0 * Abs(time.Int64() - expected)) / expected;
			
				test.Printf(_L("    %d%d: time == %ld, error == %d%%\n"), i, j, time.Int64(), TInt(error));

				if (error >= 5.0)
					pass = EFalse;

				threads[k].Kill(KErrNone);
				TRequestStatus status;
				threads[k].Logon(status);
				User::WaitForRequest(status);
				test(status == KErrNone);
				CLOSE_AND_WAIT(threads[k]);
				}
			}
		}

	(threadParam.iSem).Close();
	test.End();

	return pass;
	}
Ejemplo n.º 21
0
/** Find last.txt with TFindFile and with two threads accessing the 2 directories

	@param aN 		Number of files in the directory
	@param aWild 	Wildcard string to be used in the search
	@param aStep 	Test step
*/
LOCAL_C void FindFileWild3(TInt aN, const TDesC& aWild, TInt aStep) 
	{
	TBuf16<100> dir1;
	TBuf16<100> dir2;
	TBuf16<100> dir3;
    TBuf16<100> dir4;
    TBuf16<100> temp;
    TBuf16<100> temp2;
	
	TInt r = 0;
	TFindFile find(TheFs);
	TTime startTime;
	TTime endTime;
	TTimeIntervalMicroSeconds timeTaken(0);
	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 

	CDir* dir;

	if(aN <= gFilesLimit) 
		{
		dir1 = gSessionPath;
		dir2 = gSessionPath;
		dir3 = gSessionPath;
		
		dir4.Format(KDirMultipleName2, 1, aN);
		dir1.Append(dir4);
			
		temp=gSessionPath;
		dir4.Format(KDirMultipleName, 3, 300);
		
		temp.Append(dir4);
		gFindDir = dir1;
		gFindDir2 = temp;
		
		temp2 = gFindDir;
		temp2.Append(KCommonFile);
		gFindEntryDir = temp2;
		temp2 = gFindDir2;
		temp2.Append(KCommonFile);
		gFindEntryDir2 = temp2;

		if(gTypes >= 1) 
			{	
			DoTest2(FindEntryAccess);
			
			dir4.Format(KDirMultipleName, 1, aN);
			startTime.HomeTime();
			
			r = find.FindWildByPath(aWild, &dir1, dir);
			FailIfError(r);
			
			endTime.HomeTime();
			DoTestKill();
			delete dir;
			
			timeTaken = endTime.MicroSecondsFrom(startTime);
			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
			}
		
		if(gTypes >= 2) 
			{	
			dir4.Format(KDirMultipleName2, 2, aN);
			dir2.Append(dir4);

			temp = dir2;
			temp.Append(KCommonFile);
			gFindDir = dir2;
			gFindEntryDir = temp;

			DoTest2(FindEntryAccess);

			startTime.HomeTime();

			r = find.FindWildByPath(aWild, &dir2, dir);
			FailIfError(r);
			
			endTime.HomeTime();
			DoTestKill();
			delete dir;
	
			timeTaken = endTime.MicroSecondsFrom(startTime);	
			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
			}
			
		if(gTypes >= 3) 
			{	
			dir4.Format(KDirMultipleName2, 3, aN);
			dir3.Append(dir4);

			temp = dir3;
			temp.Append(KCommonFile);
			gFindDir = dir3;
			gFindEntryDir = temp;
			
			DoTest2(FindEntryAccess);

			startTime.HomeTime();

			r = find.FindWildByPath(aWild, &dir3, dir);
			FailIfError(r);
			
			endTime.HomeTime();
			DoTestKill();
			delete dir;
			
			timeTaken = endTime.MicroSecondsFrom(startTime);
			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
			}
		}
	
	PrintResult(aStep, 1, aN);
	PrintResultTime(aStep, 2, timeTaken1);
	PrintResultTime(aStep, 3, timeTaken2);
	PrintResultTime(aStep, 4, timeTaken3);
	}
Ejemplo n.º 22
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
	}