kernel/eka/euser/us_test.cpp
changeset 293 0659d0e1a03c
parent 90 947f0dc9f7a8
equal deleted inserted replaced
291:206a6eaaeb71 293:0659d0e1a03c
     1 // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1994-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   559 	UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)timeout, NULL);
   559 	UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)timeout, NULL);
   560 	return r;
   560 	return r;
   561 	}
   561 	}
   562 
   562 
   563 
   563 
       
   564 /**
       
   565 This should be called before using the __KHEAP_MARK macro in tests that check for
       
   566 kernel heap leaks.
       
   567 
       
   568 It will complete deferred background tasks that would ordinarily run at some point after boot
       
   569 and that would lead to kernel heap allocs/deallocs. For example, unload of lazily loaded DLLs
       
   570 and running the reaper.
       
   571 */
       
   572 EXPORT_C TInt RTest::CompletePostBootSystemTasks()
       
   573 	{
       
   574 	RLoader l;
       
   575 	TInt r = l.Connect();
       
   576 	if(r != KErrNone)
       
   577 		{
       
   578 		Printf(_L("RTEST: Error %d while connecting to loader.\n"), r);
       
   579 		return r;
       
   580 		}
       
   581 
       
   582 	r = l.CancelLazyDllUnload();
       
   583 	if(r != KErrNone)
       
   584 		{
       
   585 		l.Close();
       
   586 		Printf(_L("RTEST: Error %d while canceling Lazy Dll unloading.\n"), r);
       
   587 		return r;
       
   588 		}
       
   589 
       
   590 	r = l.RunReaper();
       
   591 	l.Close();
       
   592 
       
   593 	if(r != KErrNone)
       
   594 		{
       
   595 		Printf(_L("RTEST: Error %d while running the reaper.\n"),r);
       
   596 		return r;
       
   597 		}
       
   598 
       
   599 	// Ensure that any kernel objects asynchronously deleted after the
       
   600 	// above get fully deleted.
       
   601 	r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
       
   602 	if(r != KErrNone)
       
   603 		{
       
   604 		Printf(_L("RTEST: Error %d while attempting to asynchronously delete kernel objects.\n"),r);
       
   605 		}
       
   606 	return r;
       
   607 	}
       
   608