kerneltest/e32test/prime/t_timer.cpp
changeset 33 0173bcd7697c
parent 0 a41df078684a
child 87 2f92ad2dc5db
child 102 ef2a444a7410
child 126 2b2a51c87b12
equal deleted inserted replaced
31:56f325a607ea 33:0173bcd7697c
    31 // Platforms/Drives/Compatibility:
    31 // Platforms/Drives/Compatibility:
    32 // All.
    32 // All.
    33 // Assumptions/Requirement/Pre-requisites:
    33 // Assumptions/Requirement/Pre-requisites:
    34 // Failures and causes:
    34 // Failures and causes:
    35 // Base Port information:
    35 // Base Port information:
    36 // 
    36 //
    37 //
    37 //
    38 
    38 
    39 // the following was used to help debug emulator implemenation of user mode callbacks
    39 // the following was used to help debug emulator implemenation of user mode callbacks
    40 //#define REQUEST_STATUS_POLL_SOAK_TEST  
    40 //#define REQUEST_STATUS_POLL_SOAK_TEST  
    41 
    41 
    84 TBool RequestIsComplete(TRequestStatus& s)
    84 TBool RequestIsComplete(TRequestStatus& s)
    85 	{
    85 	{
    86 	return s != KRequestPending;
    86 	return s != KRequestPending;
    87 	}
    87 	}
    88 
    88 
       
    89 
    89 LOCAL_C void testRel()
    90 LOCAL_C void testRel()
    90 //
    91 //
    91 // Test relative timers.
    92 // Test relative timers.
    92 //
    93 //
    93 	{
    94 	{
    94 
       
    95 	test.Start(_L("After 0"));
    95 	test.Start(_L("After 0"));
    96 	RTimer t;
    96 	RTimer t;
    97 	TInt r=t.CreateLocal();
    97 	TInt r=t.CreateLocal();
    98 	test(r==KErrNone);
    98 	test(r==KErrNone);
    99 	TRequestStatus s;
    99 	TRequestStatus s;
   100 	t.After(s,0);
   100 	t.After(s,0);
   101 	test(s==KRequestPending || s==KErrNone);
   101 	test(s==KRequestPending || s==KErrNone);
   102 	User::WaitForRequest(s);
   102 	User::WaitForRequest(s);
   103 	test(s==KErrNone);
   103 	test(s==KErrNone);
   104 //
   104 
   105 	test.Next(_L("After 1 tenth"));
   105 	test.Next(_L("After 1 tenth"));
   106 	t.After(s,100000);
   106 	t.After(s,100000);
   107 #ifdef __WINS__
   107 #ifdef __WINS__
   108 	// On WINS we can't guarantee thread scheduling so timer may already have
   108 	// On WINS we can't guarantee thread scheduling so timer may already have
   109 	// completed before we get to test the status. Therefore, allow KErrNone.
   109 	// completed before we get to test the status. Therefore, allow KErrNone.
   113 #else
   113 #else
   114 	test(s==KRequestPending);
   114 	test(s==KRequestPending);
   115 #endif
   115 #endif
   116 	User::WaitForRequest(s);
   116 	User::WaitForRequest(s);
   117 	test(s==KErrNone);
   117 	test(s==KErrNone);
   118 //
   118 
   119 	test.Next(_L("After -1 millionth"));
   119 	test.Next(_L("After -1 millionth"));
   120 	RThread thread;
   120 	RThread thread;
   121 	r=thread.Create(_L("After -1"),AfterNegative,KDefaultStackSize,NULL,&thread);
   121 	r=thread.Create(_L("After -1"),AfterNegative,KDefaultStackSize,NULL,&thread);
   122 	test(r==KErrNone);
   122 	test(r==KErrNone);
   123 	thread.Logon(s);
   123 	thread.Logon(s);
   130 	test(thread.ExitCategory()==_L("USER"));
   130 	test(thread.ExitCategory()==_L("USER"));
   131 	test(thread.ExitReason()==ERTimerAfterTimeNegative);
   131 	test(thread.ExitReason()==ERTimerAfterTimeNegative);
   132 	test(thread.ExitType()==EExitPanic);
   132 	test(thread.ExitType()==EExitPanic);
   133 	CLOSE_AND_WAIT(thread);
   133 	CLOSE_AND_WAIT(thread);
   134 	User::SetJustInTime(justInTime);
   134 	User::SetJustInTime(justInTime);
   135 //
   135 
   136 	test.Next(_L("After 1 second"));
   136 	test.Next(_L("After 1 second"));
   137 	t.After(s,1000000);
   137 	t.After(s,1000000);
   138 	test(s==KRequestPending);
   138 	test(s==KRequestPending);
   139 	User::WaitForRequest(s);
   139 	User::WaitForRequest(s);
   140 	test(s==KErrNone);
   140 	test(s==KErrNone);
   141 //
   141 
   142 	test.Next(_L("After 1 second polling"));
   142 	test.Next(_L("After 1 second polling"));
   143 	t.After(s,1000000);
   143 	t.After(s,1000000);
   144 	test(s==KRequestPending);
   144 	test(s==KRequestPending);
   145 	// Have to be careful the compiler doesn't optimise this away
   145 	// Have to be careful the compiler doesn't optimise this away
   146 	while(!RequestIsComplete(s))
   146 	while(!RequestIsComplete(s))
   147 		; // poll
   147 		; // poll
   148 	test(s==KErrNone);
   148 	test(s==KErrNone);
   149 	User::WaitForRequest(s);
   149 	User::WaitForRequest(s);
   150 //
   150 
   151 	test.Next(_L("Cancel"));
   151 	test.Next(_L("Cancel"));
   152 	t.After(s,1000000);
   152 	t.After(s,1000000);
   153 	test(s==KRequestPending);
   153 	test(s==KRequestPending);
   154 	t.Cancel();
   154 	t.Cancel();
   155 	User::WaitForRequest(s);
   155 	User::WaitForRequest(s);
   156 	test(s==KErrCancel);
   156 	test(s==KErrCancel);
   157 	t.Close();
   157 	t.Close();
   158 //
   158 
   159 	test.Next(_L("Request twice"));
   159 	test.Next(_L("Request twice"));
   160 	r=thread.Create(_L("After twice"),AfterTwice,KDefaultStackSize,NULL,&thread);
   160 	r=thread.Create(_L("After twice"),AfterTwice,KDefaultStackSize,NULL,&thread);
   161 	test(r==KErrNone);
   161 	test(r==KErrNone);
   162 	thread.Logon(s);
   162 	thread.Logon(s);
   163 	test(s==KRequestPending);
   163 	test(s==KRequestPending);
   168 	test(thread.ExitCategory()==_L("KERN-EXEC"));
   168 	test(thread.ExitCategory()==_L("KERN-EXEC"));
   169 	test(thread.ExitReason()==ETimerAlreadyPending);
   169 	test(thread.ExitReason()==ETimerAlreadyPending);
   170 	test(thread.ExitType()==EExitPanic);
   170 	test(thread.ExitType()==EExitPanic);
   171 	CLOSE_AND_WAIT(thread);
   171 	CLOSE_AND_WAIT(thread);
   172 	User::SetJustInTime(justInTime);
   172 	User::SetJustInTime(justInTime);
   173 //
   173 
   174 	test.End();
   174 	test.End();
   175 	}
   175 	}
   176 
   176 
   177 #ifdef REQUEST_STATUS_POLL_SOAK_TEST
   177 #ifdef REQUEST_STATUS_POLL_SOAK_TEST
   178 
   178 
   194 		statuses[i] = 1;
   194 		statuses[i] = 1;
   195 		}
   195 		}
   196 
   196 
   197 	TInt totalComplete = 0;
   197 	TInt totalComplete = 0;
   198 	TInt totalWaiting = 0;
   198 	TInt totalWaiting = 0;
   199 	
   199 
   200 	while(PollTestRunning)
   200 	while(PollTestRunning)
   201 		{
   201 		{
   202 		for (i = 0 ; i < KMaxTimers ; ++i)
   202 		for (i = 0 ; i < KMaxTimers ; ++i)
   203 			{
   203 			{
   204 			switch(statuses[i].Int())
   204 			switch(statuses[i].Int())
   205 				{
   205 				{
   206 				case KRequestPending:
   206 				case KRequestPending:
   207 					// do nothing
   207 					// do nothing
   208 					++totalWaiting;
   208 					++totalWaiting;
   209 					break;
   209 					break;
   210 					
   210 
   211 				case KErrNone:
   211 				case KErrNone:
   212 					User::WaitForRequest(statuses[i]);
   212 					User::WaitForRequest(statuses[i]);
   213 					++totalComplete;
   213 					++totalComplete;
   214 					// fall through
   214 					// fall through
   215 
   215 
   223 				default:
   223 				default:
   224 					return statuses[i].Int();
   224 					return statuses[i].Int();
   225 				}
   225 				}
   226 			}
   226 			}
   227 		}
   227 		}
   228 		
   228 
   229 	for (i = 0 ; i < KMaxTimers ; ++i)
   229 	for (i = 0 ; i < KMaxTimers ; ++i)
   230 		{
   230 		{
   231 		User::WaitForRequest(statuses[i]);
   231 		User::WaitForRequest(statuses[i]);
   232 		if (statuses[i].Int() != KErrNone)
   232 		if (statuses[i].Int() != KErrNone)
   233 			return statuses[i].Int();
   233 			return statuses[i].Int();
   243 	const TInt KMaxThreads = 10;
   243 	const TInt KMaxThreads = 10;
   244 	const TInt KSecondsToTest = 60;
   244 	const TInt KSecondsToTest = 60;
   245 
   245 
   246 	RThread threads[KMaxThreads];
   246 	RThread threads[KMaxThreads];
   247 	TRequestStatus statuses[KMaxThreads];
   247 	TRequestStatus statuses[KMaxThreads];
   248 	
   248 
   249 	test.Start(_L("Test polling"));
   249 	test.Start(_L("Test polling"));
   250 
   250 
   251 	PollTestRunning = ETrue;
   251 	PollTestRunning = ETrue;
   252 
   252 
   253 	TInt i;
   253 	TInt i;
   257 		threads[i].Logon(statuses[i]);
   257 		threads[i].Logon(statuses[i]);
   258 		threads[i].Resume();
   258 		threads[i].Resume();
   259 		}
   259 		}
   260 
   260 
   261 	User::After(KSecondsToTest * 1000 * 1000);
   261 	User::After(KSecondsToTest * 1000 * 1000);
   262 	
   262 
   263 	PollTestRunning = EFalse;
   263 	PollTestRunning = EFalse;
   264 
   264 
   265 	for (i = 0 ; i < KMaxThreads ; ++i)
   265 	for (i = 0 ; i < KMaxThreads ; ++i)
   266 		{
   266 		{
   267 		User::WaitForRequest(statuses[i]);
   267 		User::WaitForRequest(statuses[i]);
   268 		test_KErrNone(statuses[i].Int());
   268 		test_KErrNone(statuses[i].Int());
   269 		test_Equal(EExitKill, threads[i].ExitType());
   269 		test_Equal(EExitKill, threads[i].ExitType());
   270 		threads[i].Close();
   270 		threads[i].Close();
   271 		}
   271 		}
   272 	
   272 
   273 	test.End();
   273 	test.End();
   274 	}
   274 	}
   275 
   275 
   276 #endif
   276 #endif
   277 
   277 
       
   278 
   278 LOCAL_C void testHomeTime()
   279 LOCAL_C void testHomeTime()
   279 //
   280 //
   280 // Test HomeTime.
   281 // Test HomeTime.
   281 //
   282 //
   282 	{
   283 	{
   283 
       
   284     TTime t1, t2;
   284     TTime t1, t2;
   285     t1.HomeTime();
   285     t1.HomeTime();
   286     for (TInt x=0;x<100;x++)
   286     for (TInt x=0;x<100;x++)
   287         {
   287         {
   288         do
   288         do
   342 	test(s==KRequestPending);
   342 	test(s==KRequestPending);
   343 	t.AtUTC(s,time+TTimeIntervalSeconds(2));
   343 	t.AtUTC(s,time+TTimeIntervalSeconds(2));
   344 	return KErrNone;
   344 	return KErrNone;
   345 	}
   345 	}
   346 
   346 
       
   347 
   347 LOCAL_C void testAbs()
   348 LOCAL_C void testAbs()
   348 //
   349 //
   349 // Test absolute timers.
   350 // Test absolute timers.
   350 //
   351 //
   351 	{
   352 	{
   352 
       
   353 	test.Start(_L("Now -1"));
   353 	test.Start(_L("Now -1"));
   354 	RTimer t;
   354 	RTimer t;
   355 	TInt r=t.CreateLocal();
   355 	TInt r=t.CreateLocal();
   356 	test(r==KErrNone);
   356 	test(r==KErrNone);
   357 	TRequestStatus s;
   357 	TRequestStatus s;
   359 	time.UniversalTime();
   359 	time.UniversalTime();
   360 	t.AtUTC(s,time+TTimeIntervalSeconds(-2));
   360 	t.AtUTC(s,time+TTimeIntervalSeconds(-2));
   361 	test(s==KErrUnderflow);  // =KRequestPending
   361 	test(s==KErrUnderflow);  // =KRequestPending
   362 	User::WaitForRequest(s);
   362 	User::WaitForRequest(s);
   363 	test(s==KErrUnderflow);
   363 	test(s==KErrUnderflow);
   364 //
   364 
   365 	TTime time2;
   365 	TTime time2;
   366 	test.Next(_L("Synchronise to clock"));
   366 	test.Next(_L("Synchronise to clock"));
   367 	time.UniversalTime();
   367 	time.UniversalTime();
   368     TDateTime dateTime=time.DateTime();
   368     TDateTime dateTime=time.DateTime();
   369 	dateTime.SetMicroSecond(0);
   369 	dateTime.SetMicroSecond(0);
   393 	test(s==KErrNone);
   393 	test(s==KErrNone);
   394 	delay=time2.MicroSecondsFrom(time);
   394 	delay=time2.MicroSecondsFrom(time);
   395 	// Test we are in the same second as the requested time...
   395 	// Test we are in the same second as the requested time...
   396 	test(delay>=TTimeIntervalMicroSeconds(0));
   396 	test(delay>=TTimeIntervalMicroSeconds(0));
   397 	test(delay<TTimeIntervalMicroSeconds(1000000));
   397 	test(delay<TTimeIntervalMicroSeconds(1000000));
   398 //
   398 
   399 	test.Next(_L("UTC vs local"));
   399 	test.Next(_L("UTC vs local"));
   400 	TTimeIntervalSeconds savedOffset = User::UTCOffset();
   400 	TTimeIntervalSeconds savedOffset = User::UTCOffset();
   401 	User::SetUTCOffset(3600);
   401 	User::SetUTCOffset(3600);
   402 	
   402 
   403 	time.HomeTime();
   403 	time.HomeTime();
   404 	time += TTimeIntervalSeconds(1);
   404 	time += TTimeIntervalSeconds(1);
   405 	t.At(s,time);
   405 	t.At(s,time);
   406 	test(s==KRequestPending);
   406 	test(s==KRequestPending);
   407 	User::WaitForRequest(s);
   407 	User::WaitForRequest(s);
   409 	test(s==KErrNone);
   409 	test(s==KErrNone);
   410 	delay=time2.MicroSecondsFrom(time);
   410 	delay=time2.MicroSecondsFrom(time);
   411 	// Test we are in the same second as the requested time...
   411 	// Test we are in the same second as the requested time...
   412 	test(delay>=TTimeIntervalMicroSeconds(0));
   412 	test(delay>=TTimeIntervalMicroSeconds(0));
   413 	test(delay<TTimeIntervalMicroSeconds(1000000));
   413 	test(delay<TTimeIntervalMicroSeconds(1000000));
   414 	
   414 
   415 	time.UniversalTime();
   415 	time.UniversalTime();
   416 	time += TTimeIntervalSeconds(1);
   416 	time += TTimeIntervalSeconds(1);
   417 	t.AtUTC(s,time);
   417 	t.AtUTC(s,time);
   418 	test(s==KRequestPending);
   418 	test(s==KRequestPending);
   419 	User::WaitForRequest(s);
   419 	User::WaitForRequest(s);
   421 	test(s==KErrNone);
   421 	test(s==KErrNone);
   422 	delay=time2.MicroSecondsFrom(time);
   422 	delay=time2.MicroSecondsFrom(time);
   423 	// Test we are in the same second as the requested time...
   423 	// Test we are in the same second as the requested time...
   424 	test(delay>=TTimeIntervalMicroSeconds(0));
   424 	test(delay>=TTimeIntervalMicroSeconds(0));
   425 	test(delay<TTimeIntervalMicroSeconds(1000000));
   425 	test(delay<TTimeIntervalMicroSeconds(1000000));
   426 	
   426 
   427 	User::SetUTCOffset(savedOffset);	
   427 	User::SetUTCOffset(savedOffset);	
   428 //
   428 
   429 	test.Next(_L("Cancel"));
   429 	test.Next(_L("Cancel"));
   430 	time.UniversalTime();
   430 	time.UniversalTime();
   431 	t.AtUTC(s,time+TTimeIntervalSeconds(10));
   431 	t.AtUTC(s,time+TTimeIntervalSeconds(10));
   432 	test(s==KRequestPending);
   432 	test(s==KRequestPending);
   433 	t.Cancel();
   433 	t.Cancel();
   434 	User::WaitForRequest(s);
   434 	User::WaitForRequest(s);
   435 	test(s==KErrCancel);
   435 	test(s==KErrCancel);
   436 	t.Close();						
   436 	t.Close();						
   437 //
   437 
   438 	test.Next(_L("Request twice"));
   438 	test.Next(_L("Request twice"));
   439 	RThread thread;
   439 	RThread thread;
   440 	r=thread.Create(_L("At twice"),AtTwice,KDefaultStackSize,NULL,&thread);
   440 	r=thread.Create(_L("At twice"),AtTwice,KDefaultStackSize,NULL,&thread);
   441 	test(r==KErrNone);
   441 	test(r==KErrNone);
   442 	thread.Logon(s);
   442 	thread.Logon(s);
   449 	test(s==ETimerAlreadyPending);
   449 	test(s==ETimerAlreadyPending);
   450 	test(thread.ExitCategory()==_L("KERN-EXEC"));
   450 	test(thread.ExitCategory()==_L("KERN-EXEC"));
   451 	test(thread.ExitReason()==ETimerAlreadyPending);
   451 	test(thread.ExitReason()==ETimerAlreadyPending);
   452 	test(thread.ExitType()==EExitPanic);
   452 	test(thread.ExitType()==EExitPanic);
   453 	CLOSE_AND_WAIT(thread);
   453 	CLOSE_AND_WAIT(thread);
   454 //
   454 
   455 	r=thread.Create(_L("At After"),AtAfter,KDefaultStackSize,NULL,&thread);
   455 	r=thread.Create(_L("At After"),AtAfter,KDefaultStackSize,NULL,&thread);
   456 	test(r==KErrNone);
   456 	test(r==KErrNone);
   457 	thread.Logon(s);
   457 	thread.Logon(s);
   458 	test(s==KRequestPending);
   458 	test(s==KRequestPending);
   459 	User::SetJustInTime(EFalse);
   459 	User::SetJustInTime(EFalse);
   463 	test(s==ETimerAlreadyPending);
   463 	test(s==ETimerAlreadyPending);
   464 	test(thread.ExitCategory()==_L("KERN-EXEC"));
   464 	test(thread.ExitCategory()==_L("KERN-EXEC"));
   465 	test(thread.ExitReason()==ETimerAlreadyPending);
   465 	test(thread.ExitReason()==ETimerAlreadyPending);
   466 	test(thread.ExitType()==EExitPanic);
   466 	test(thread.ExitType()==EExitPanic);
   467 	CLOSE_AND_WAIT(thread);
   467 	CLOSE_AND_WAIT(thread);
   468 //
   468 
   469 	r=thread.Create(_L("After At"),AfterAt,KDefaultStackSize,NULL,&thread);
   469 	r=thread.Create(_L("After At"),AfterAt,KDefaultStackSize,NULL,&thread);
   470 	test(r==KErrNone);
   470 	test(r==KErrNone);
   471 	thread.Logon(s);
   471 	thread.Logon(s);
   472 	test(s==KRequestPending);
   472 	test(s==KRequestPending);
   473 	User::SetJustInTime(EFalse);
   473 	User::SetJustInTime(EFalse);
   477 	test(s==ETimerAlreadyPending);
   477 	test(s==ETimerAlreadyPending);
   478 	test(thread.ExitCategory()==_L("KERN-EXEC"));
   478 	test(thread.ExitCategory()==_L("KERN-EXEC"));
   479 	test(thread.ExitReason()==ETimerAlreadyPending);
   479 	test(thread.ExitReason()==ETimerAlreadyPending);
   480 	test(thread.ExitType()==EExitPanic);
   480 	test(thread.ExitType()==EExitPanic);
   481 	CLOSE_AND_WAIT(thread);
   481 	CLOSE_AND_WAIT(thread);
   482 //
   482 
   483 	test.End();
   483 	test.End();
   484 	}
   484 	}
   485 
   485 
   486 TInt LockTwice(TAny*)
   486 TInt LockTwice(TAny*)
   487 	{
   487 	{
   494 	t.Lock(stat, ETwelveOClock);
   494 	t.Lock(stat, ETwelveOClock);
   495 	t.Lock(stat, ETwelveOClock);
   495 	t.Lock(stat, ETwelveOClock);
   496 	return KErrNone;
   496 	return KErrNone;
   497 	}
   497 	}
   498 
   498 
       
   499 
   499 LOCAL_C void testLock()
   500 LOCAL_C void testLock()
   500 //
   501 //
   501 // Test locked timers
   502 // Test locked timers
   502 //
   503 //
   503 	{
   504 	{
   504 
       
   505 	test.Start(_L("Test synchronise to ETwelveOClock"));
   505 	test.Start(_L("Test synchronise to ETwelveOClock"));
   506 	RTimer t;
   506 	RTimer t;
   507 	TTime time,time2;
   507 	TTime time,time2;
   508 	test(t.CreateLocal()==KErrNone);
   508 	test(t.CreateLocal()==KErrNone);
   509 	TRequestStatus stat;
   509 	TRequestStatus stat;
   582 	test(stat==KErrCancel);
   582 	test(stat==KErrCancel);
   583 	t.Lock(stat,EThreeOClock);
   583 	t.Lock(stat,EThreeOClock);
   584 	User::WaitForRequest(stat);
   584 	User::WaitForRequest(stat);
   585 	// EThreeOClock should be more than one second away from the previous timer expiration
   585 	// EThreeOClock should be more than one second away from the previous timer expiration
   586 	test(stat==KErrGeneral);
   586 	test(stat==KErrGeneral);
   587 //
   587 
   588 	test.Next(_L("Lock twice"));
   588 	test.Next(_L("Lock twice"));
   589 	RThread thread;
   589 	RThread thread;
   590 	TInt r=thread.Create(_L("Lock twice"),LockTwice,KDefaultStackSize,NULL,&thread);
   590 	TInt r=thread.Create(_L("Lock twice"),LockTwice,KDefaultStackSize,NULL,&thread);
   591 	test(r==KErrNone);
   591 	test(r==KErrNone);
   592 	thread.Logon(stat);
   592 	thread.Logon(stat);
   599 	test(stat==ETimerAlreadyPending);
   599 	test(stat==ETimerAlreadyPending);
   600 	test(thread.ExitCategory()==_L("KERN-EXEC"));
   600 	test(thread.ExitCategory()==_L("KERN-EXEC"));
   601 	test(thread.ExitReason()==ETimerAlreadyPending);
   601 	test(thread.ExitReason()==ETimerAlreadyPending);
   602 	test(thread.ExitType()==EExitPanic);
   602 	test(thread.ExitType()==EExitPanic);
   603 	CLOSE_AND_WAIT(thread);
   603 	CLOSE_AND_WAIT(thread);
   604 //
   604 
   605 	
       
   606 #if !(defined(__EPOC32__) && defined(__X86__))
   605 #if !(defined(__EPOC32__) && defined(__X86__))
   607 	TInt muid = 0;
   606 	TInt muid = 0;
   608 	HAL::Get(HAL::EMachineUid, muid);
   607 	HAL::Get(HAL::EMachineUid, muid);
   609 	if(muid!=HAL::EMachineUid_Lubbock && muid!=HAL::EMachineUid_NE1_TB)
   608 	if(muid!=HAL::EMachineUid_Lubbock && muid!=HAL::EMachineUid_NE1_TB && muid!=HAL::EMachineUid_STE8500)
   610 		{
   609 		{
   611 		test.Next(_L("Test sequential locks fail over on/off"));
   610 		test.Next(_L("Test sequential locks fail over on/off"));
   612 		RTimer tat;
   611 		RTimer tat;
   613 		TRequestStatus sat;
   612 		TRequestStatus sat;
   614 		r=tat.CreateLocal();
   613 		r=tat.CreateLocal();
   615 		TTime now;
   614 		TTime now;
   616 		now.UniversalTime();
   615 		now.UniversalTime();
   617 		tat.At(sat, now+TTimeIntervalSeconds(10)); // turn on in 10 seconds
   616 		tat.AtUTC(sat, now+TTimeIntervalSeconds(10)); // turn on in 10 seconds
       
   617 		test(sat==KRequestPending);
   618 		t.Lock(stat, ETwelveOClock);
   618 		t.Lock(stat, ETwelveOClock);
   619 		User::WaitForRequest(stat);
   619 		User::WaitForRequest(stat);
   620 		test(stat==KErrGeneral);
   620 		test(stat==KErrGeneral);
   621 		t.Lock(stat, EElevenOClock);
   621 		t.Lock(stat, EElevenOClock);
   622 		User::WaitForRequest(stat);
   622 		User::WaitForRequest(stat);
   644 //
   644 //
   645 // Bug HA-255
   645 // Bug HA-255
   646 // Test locked timers abort when the system time changes
   646 // Test locked timers abort when the system time changes
   647 //
   647 //
   648 	{
   648 	{
   649 
       
   650     RTimer rr;
   649     RTimer rr;
   651 	TRequestStatus stat;
   650 	TRequestStatus stat;
   652     rr.CreateLocal();
   651     rr.CreateLocal();
   653     rr.Lock(stat, ETwelveOClock);
   652     rr.Lock(stat, ETwelveOClock);
   654     User::WaitForRequest(stat);
   653     User::WaitForRequest(stat);
   655     test(stat==KErrGeneral);
   654     test(stat==KErrGeneral);
   656     RTimer rrr;
   655     RTimer rrr;
   657     rrr.CreateLocal();
   656     rrr.CreateLocal();
   658     rrr.After(stat, 1000000);
   657     rrr.After(stat, 1000000);
   659     User::WaitForRequest(stat);
   658     User::WaitForRequest(stat);
   660     
   659 
   661 	RTimer r;
   660 	RTimer r;
   662 	TRequestStatus sstat;
   661 	TRequestStatus sstat;
   663 	TTime t;
   662 	TTime t;
   664 	r.CreateLocal();
   663 	r.CreateLocal();
   665 	r.Lock(stat,ETwelveOClock);
   664 	r.Lock(stat,ETwelveOClock);
   706 	rr.Close();
   705 	rr.Close();
   707 	rrr.Close();
   706 	rrr.Close();
   708 	}
   707 	}
   709 
   708 
   710 void testInactivity()
   709 void testInactivity()
   711 //
   710 	{
   712 //
       
   713 //
       
   714 	{
       
   715 	
       
   716 	test.Start(_L("Test User::ResetInactivityTime()"));
   711 	test.Start(_L("Test User::ResetInactivityTime()"));
   717 	RTimer t,t2;
   712 	RTimer t,t2;
   718 	TRequestStatus stat,stat2;
   713 	TRequestStatus stat,stat2;
   719 	t.CreateLocal();
   714 	t.CreateLocal();
   720 	t2.CreateLocal();
   715 	t2.CreateLocal();
   752 	User::After(5000000);
   747 	User::After(5000000);
   753 	test(stat!=KRequestPending);
   748 	test(stat!=KRequestPending);
   754 	test.End();
   749 	test.End();
   755 	}
   750 	}
   756 
   751 
       
   752 
   757 GLDEF_C TInt E32Main()
   753 GLDEF_C TInt E32Main()
   758 //
   754 //
   759 // Test timers.
   755 // Test timers.
   760 //
   756 //
   761     {
   757     {
   762 
       
   763 	test.Title();
   758 	test.Title();
   764 	TInt r=HAL::Get(HAL::EMachineUid,MachineUid);
   759 	TInt r=HAL::Get(HAL::EMachineUid,MachineUid);
   765 	test(r==KErrNone);
   760 	test(r==KErrNone);
   766 	test.Start(_L("Testing relative timers"));
   761 	test.Start(_L("Testing relative timers"));
   767 	testRel();
   762 	testRel();
   768 //
   763 
   769 #ifdef REQUEST_STATUS_POLL_SOAK_TEST
   764 #ifdef REQUEST_STATUS_POLL_SOAK_TEST
   770 	test.Next(_L("Testing polling"));
   765 	test.Next(_L("Testing polling"));
   771 	testPoll();
   766 	testPoll();
   772 #endif
   767 #endif
   773 //
   768 
   774     test.Next(_L("Testing HomeTime()"));
   769     test.Next(_L("Testing HomeTime()"));
   775     testHomeTime();
   770     testHomeTime();
   776 //
   771 
   777 	test.Next(_L("Testing absolute timers"));
   772 	test.Next(_L("Testing absolute timers"));
   778 	testAbs();
   773 	testAbs();
   779 //
   774 
   780 	test.Next(_L("Testing locked timers"));
   775 	test.Next(_L("Testing locked timers"));
   781 	testLock();
   776 	testLock();
   782 //
   777 
   783 	test.Next(_L("Testing changing time"));
   778 	test.Next(_L("Testing changing time"));
   784 	testChange();
   779 	testChange();
   785 //
   780 
   786 	test.Next(_L("Testing inactivity timers"));
   781 	test.Next(_L("Testing inactivity timers"));
   787 	testInactivity();
   782 	testInactivity();
   788 //
   783 
   789 	test.End();
   784 	test.End();
   790 	return(KErrNone);
   785 	return(KErrNone);
   791     }
   786     }
   792 
   787