equal
deleted
inserted
replaced
33 _LIT(KUp, "up"); |
33 _LIT(KUp, "up"); |
34 _LIT(KDown, "down"); |
34 _LIT(KDown, "down"); |
35 |
35 |
36 const TInt KLongWait = 3000000; // 3 seconds |
36 const TInt KLongWait = 3000000; // 3 seconds |
37 const TInt KShortWait = 100000; // 0.1 seconds |
37 const TInt KShortWait = 100000; // 0.1 seconds |
38 const TInt KTolerance = 500; // 0.5 ms |
38 const TInt KTolerance = 1000; // 1 ms |
39 const TInt numCpus = UserSvr::HalFunction(EHalGroupKernel, EKernelHalNumLogicalCpus, 0, 0); |
39 const TInt numCpus = UserSvr::HalFunction(EHalGroupKernel, EKernelHalNumLogicalCpus, 0, 0); |
40 |
40 |
41 #define FailIfError(EXPR) \ |
41 #define FailIfError(EXPR) \ |
42 { \ |
42 { \ |
43 TInt aErr = (EXPR); \ |
43 TInt aErr = (EXPR); \ |
213 { |
213 { |
214 test.Start(_L("CPU thread time unit tests")); |
214 test.Start(_L("CPU thread time unit tests")); |
215 |
215 |
216 TThreadParam threadParam; |
216 TThreadParam threadParam; |
217 FailIfError((threadParam.iSem).CreateLocal(0)); |
217 FailIfError((threadParam.iSem).CreateLocal(0)); |
218 threadParam.iCpu = 1; |
218 threadParam.iCpu = 0; // Later tests will exercise other CPUs |
219 |
219 |
220 RThread thread; |
220 RThread thread; |
221 RUndertaker u; |
221 RUndertaker u; |
222 TInt h; |
222 TInt h; |
223 TRequestStatus s; |
223 TRequestStatus s; |
241 |
241 |
242 // Test increases when thread allowed to run |
242 // Test increases when thread allowed to run |
243 (threadParam.iSem).Signal(); |
243 (threadParam.iSem).Signal(); |
244 User::After(KShortWait); |
244 User::After(KShortWait); |
245 FailIfError(thread.GetCpuTime(time)); |
245 FailIfError(thread.GetCpuTime(time)); |
246 test(time > (KShortWait - 2 * KTolerance)); |
246 test(time > (KShortWait - KTolerance)); |
247 |
247 |
248 // Test not increased while suspended |
248 // Test not increased while suspended |
249 thread.Suspend(); |
249 thread.Suspend(); |
250 FailIfError(thread.GetCpuTime(time)); |
250 FailIfError(thread.GetCpuTime(time)); |
251 User::After(KShortWait); |
251 User::After(KShortWait); |
418 |
418 |
419 GLDEF_C TInt E32Main() |
419 GLDEF_C TInt E32Main() |
420 { |
420 { |
421 test.Title(); |
421 test.Title(); |
422 test.Start(_L("T_CPUTIME")); |
422 test.Start(_L("T_CPUTIME")); |
423 |
423 |
424 if (numCpus > 1) |
424 if (numCpus > 1) |
425 FailIfError(SetCpuAffinity(0)); |
425 FailIfError(SetCpuAffinity(0)); |
426 |
426 |
427 TestFastCounter(); |
427 TestFastCounter(); |
428 if (GetCpuTimeIsSupported()) |
428 if (GetCpuTimeIsSupported()) |