kerneltest/e32test/misc/t_cputime.cpp
changeset 90 947f0dc9f7a8
parent 36 538db54a451d
child 109 b3a1d9898418
child 176 af6ec97d9189
equal deleted inserted replaced
52:2d65c2f76d7b 90:947f0dc9f7a8
   226 	FailIfError(u.Create());
   226 	FailIfError(u.Create());
   227 	FailIfError(u.Logon(s,h));
   227 	FailIfError(u.Logon(s,h));
   228 	test(s==KRequestPending);
   228 	test(s==KRequestPending);
   229 
   229 
   230 	TTimeIntervalMicroSeconds time, time2;
   230 	TTimeIntervalMicroSeconds time, time2;
       
   231 	TUint us;
   231 	
   232 	
   232 	// Test time is initially zero
   233 	// Test time is initially zero
   233 	FailIfError(thread.GetCpuTime(time));
   234 	FailIfError(thread.GetCpuTime(time));
   234 	test(time == 0);
   235 	test(time == 0);
   235 
   236 
   236 	// Test not increased while waiting on semaphore
   237 	// Test not increased while waiting on semaphore
   237 	thread.Resume();
   238 	thread.Resume();
   238 	User::After(KShortWait);
   239 	User::After(KShortWait);
   239 	FailIfError(thread.GetCpuTime(time));
   240 	FailIfError(thread.GetCpuTime(time));
       
   241 	us = I64LOW(time.Int64());
       
   242 	test.Printf(_L("Time %dus\n"), us);
   240 	test(time < KTolerance); // wait happens in less than 0.5ms
   243 	test(time < KTolerance); // wait happens in less than 0.5ms
   241 
   244 
   242 	// Test increases when thread allowed to run
   245 	// Test increases when thread allowed to run
   243 	(threadParam.iSem).Signal();
   246 	(threadParam.iSem).Signal();
   244 	User::After(KShortWait);
   247 	User::After(KShortWait);
   245 	FailIfError(thread.GetCpuTime(time));
   248 	FailIfError(thread.GetCpuTime(time));
       
   249 	us = I64LOW(time.Int64());
       
   250 	test.Printf(_L("Time %dus\n"), us);
   246 	test(time > (KShortWait - KTolerance));
   251 	test(time > (KShortWait - KTolerance));
       
   252 	User::After(KLongWait);
       
   253 	FailIfError(thread.GetCpuTime(time2));
       
   254 	us = I64LOW(time2.Int64());
       
   255 	test.Printf(_L("Time %dus\n"), us);
       
   256 	test(time2.Int64() - time.Int64() > (KLongWait - KTolerance));
   247 
   257 
   248 	// Test not increased while suspended
   258 	// Test not increased while suspended
   249 	thread.Suspend();
   259 	thread.Suspend();
   250 	FailIfError(thread.GetCpuTime(time));
   260 	FailIfError(thread.GetCpuTime(time));
   251 	User::After(KShortWait);
   261 	User::After(KShortWait);