kerneltest/e32test/hcr/t_hcr.cpp
changeset 291 206a6eaaeb71
parent 90 947f0dc9f7a8
child 293 0659d0e1a03c
equal deleted inserted replaced
289:55a0a1279a7e 291:206a6eaaeb71
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2008-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".
  2089 
  2089 
  2090 	// Reload device driver without a compiled repository this time
  2090 	// Reload device driver without a compiled repository this time
  2091 	test.Next(_L("Reload Device Driver"));
  2091 	test.Next(_L("Reload Device Driver"));
  2092 	HcrSimTest.Close();
  2092 	HcrSimTest.Close();
  2093 	r = User::FreeLogicalDevice(aDriver);
  2093 	r = User::FreeLogicalDevice(aDriver);
  2094 	test_KErrNone(r);
  2094     test_KErrNone(r);
  2095 	r = User::LoadLogicalDevice(aDriver);
  2095 	r = User::LoadLogicalDevice(aDriver);
  2096 	test_KErrNone(r);
  2096 	test_KErrNone(r);
  2097 	r = HcrSimTest.Open(aDriver);
  2097 	r = HcrSimTest.Open(aDriver);
  2098 	test_KErrNone(r);
  2098 	test_KErrNone(r);
  2099 	r = HcrSimTest.InitExtension(ETestNullRepository); // *** The NULL Repository ***
  2099 	r = HcrSimTest.InitExtension(ETestNullRepository); // *** The NULL Repository ***
  2320 
  2320 
  2321 void RomHeaderTests()
  2321 void RomHeaderTests()
  2322 	{
  2322 	{
  2323 	test.Next(_L("Rom Header"));
  2323 	test.Next(_L("Rom Header"));
  2324 #ifdef __WINS__
  2324 #ifdef __WINS__
  2325 	test.Printf(_L("Not available on the emulator.\n"));
  2325 	test.Printf(_L("HCR Core Image DAT File not available on the emulator.\n"));
  2326 #else
  2326 #else
  2327 	const TRomHeader* romheader = (TRomHeader*) UserSvr::RomHeaderAddress();
  2327 	const TRomHeader* romheader = (TRomHeader*) UserSvr::RomHeaderAddress();
  2328 	test.Printf(_L("HCR File Address: %08x\n"), romheader->iHcrFileAddress);
  2328 	test.Printf(_L("HCR Core Image DAT File Address: %08x\n"), romheader->iHcrFileAddress);
  2329 	test(romheader->iHcrFileAddress);
  2329 	if (romheader->iHcrFileAddress && romheader->iPageableRomStart)
  2330 	if (romheader->iPageableRomStart)
       
  2331 		{
  2330 		{
  2332 		// If this is a paged ROM, HCR file must be in the unpaged area
  2331 		// If this is a paged ROM, HCR file must be in the unpaged area
  2333 		test_Compare(romheader->iRomBase + romheader->iPageableRomStart, >, romheader->iHcrFileAddress);
  2332 		test_Compare(romheader->iRomBase + romheader->iPageableRomStart, >, romheader->iHcrFileAddress);
  2334 		}
  2333 		}
  2335 #endif // __WINS__
  2334 #endif // __WINS__
  2336 	}
  2335 	}
  2337 
  2336 
  2338 void HcrRealSettingDiscovery()
  2337 void HcrRealSettingDiscovery()
  2339 	{
  2338 	{
  2340 	test.Next(_L("Setting Discovery"));
  2339 	test.Next(_L("BSP HCR.dll Test Setting Discovery"));
  2341 	TInt r;
  2340 	TInt r;
       
  2341 	TBool anyFound = EFalse;
  2342 	TCategoryUid cat;
  2342 	TCategoryUid cat;
  2343 	test.Printf(_L("Category Element  Type     Len  Value\n"));
  2343 	test.Printf(_L("Category Element  Type     Len  Value\n"));
  2344 	test.Printf(_L("--------------------------------------------------\n"));
  2344 	test.Printf(_L("--------------------------------------------------\n"));
  2345 	for (cat = KHCRUID_ALLOCATED_MIN; cat <= KHCRUID_ALLOCATED_MAX; cat++)
  2345 	for (cat = KHCRUID_ALLOCATED_MIN; cat <= KHCRUID_ALLOCATED_MAX; cat++)
  2346 		{
  2346 		{
  2347 		TInt nosettings;
  2347 		TInt nosettings;
  2348 		nosettings = HcrSimTest.FindNumSettingsInCategory(cat);
  2348 		nosettings = HcrSimTest.FindNumSettingsInCategory(cat);
  2349 		test_Compare(0, <=, nosettings);
  2349 		test_Compare(0, <=, nosettings);
  2350 		if (nosettings > 0)
  2350 		if (nosettings > 0)
  2351 			{
  2351 			{
       
  2352 			anyFound = ETrue;
  2352 			TElementId* elids;
  2353 			TElementId* elids;
  2353 			TSettingType* types;
  2354 			TSettingType* types;
  2354 			TUint16* lens;
  2355 			TUint16* lens;
  2355 			elids = (TElementId*) User::Alloc(nosettings * sizeof(TElementId));
  2356 			elids = (TElementId*) User::Alloc(nosettings * sizeof(TElementId));
  2356 			test_NotNull(elids);
  2357 			test_NotNull(elids);
  2549 			User::Free(elids);
  2550 			User::Free(elids);
  2550 			User::Free(types);
  2551 			User::Free(types);
  2551 			User::Free(lens);
  2552 			User::Free(lens);
  2552 			}
  2553 			}
  2553 		}
  2554 		}
       
  2555 	if (anyFound == EFalse)
       
  2556 		{
       
  2557 		test.Printf(_L("No TEST settings found in BSP HCR.dll\n"));
       
  2558 		}
       
  2559 	test.Printf(_L("--------------------------------------------------\n"));	
  2554 	}
  2560 	}
  2555 void HcrRealRetrieveKernelExtensionTestResults()
  2561 void HcrRealRetrieveKernelExtensionTestResults()
  2556 	{
  2562 	{
  2557 	test.Next(_L("Retrieve kernel extension test results"));
  2563 	test.Next(_L("Retrieve kernel extension test results"));
  2558 	TInt r;
  2564 	TInt r;
  2596 			r = User::LoadLogicalDevice(aDriver);
  2602 			r = User::LoadLogicalDevice(aDriver);
  2597 			}
  2603 			}
  2598 		test_KErrNone(r);
  2604 		test_KErrNone(r);
  2599 		r = HcrSimTest.Open(aDriver);
  2605 		r = HcrSimTest.Open(aDriver);
  2600 		test_KErrNone(r);
  2606 		test_KErrNone(r);
  2601 		//
  2607 		
       
  2608 		// Check the BSP specific HCR-using test kernel extensions were
       
  2609 		// able to retrieve HCR settings during kernel initialisation.
  2602 		HcrRealRetrieveKernelExtensionTestResults();
  2610 		HcrRealRetrieveKernelExtensionTestResults();
       
  2611 		// Discovery of settings, may not print any if repositories for BSP
       
  2612 		// do not contain any test settings.
  2603 		HcrRealSettingDiscovery();
  2613 		HcrRealSettingDiscovery();
  2604 
  2614 
  2605 		// Initialize static variable with the right HCR client type
       
  2606 		if(aDriver.Compare(KTestHcrRealOwn) == 0)
       
  2607 			gHcrThread = KSimOwnThread;
       
  2608 		else if(aDriver.Compare(KTestHcrRealClient) == 0)
       
  2609 			gHcrThread = KSimClientThread;
       
  2610 		else
       
  2611 			test(EFalse);
       
  2612 		//
       
  2613 		TBool smr;
       
  2614 		TBool smrrep;
       
  2615 		r = HcrSimTest.HasRepositoryInSmr(smr, smrrep);
       
  2616 		test_KErrNone(r);
       
  2617 		if (smrrep)
       
  2618 			{
       
  2619 			// File + NAND
       
  2620 			HcrSimTestApiTests(SettingsList6, sizeof(SettingsList6) / sizeof(SSettingC));
       
  2621 			}
       
  2622 		else
       
  2623 			{
       
  2624 			// File
       
  2625 			HcrSimTestApiTests(SettingsList7, sizeof(SettingsList7) / sizeof(SSettingC));
       
  2626 			}
       
  2627 		//
       
  2628 		test.Next(_L("Close LDD"));
  2615 		test.Next(_L("Close LDD"));
  2629 		HcrSimTest.Close();
  2616 		HcrSimTest.Close();
  2630 		r = User::FreeLogicalDevice(aDriver);
  2617 		r = User::FreeLogicalDevice(aDriver);
  2631 		test_KErrNone(r);
  2618 		test_KErrNone(r);
  2632 		}
  2619 		}
  2633 	test.End();
  2620 	test.End();
  2634 	}
  2621 	}
  2635 
  2622 
  2636 void HcrCatRecodsExampleTest(const TDesC& aDriver)
  2623 void HcrCatRecodsExampleTest(const TDesC& aDriver)
  2637     {
  2624     {
  2638     using namespace HCR;
       
  2639 
       
  2640    
       
  2641     test.Start(_L("HCR Record Structured Category Test"));
  2625     test.Start(_L("HCR Record Structured Category Test"));
  2642     test.Next(_L("Load HCR Test driver"));
  2626     test.Next(_L("Load HCR Test driver"));
  2643     
  2627     
  2644     test.Printf(_L("%S\n"), &aDriver);
  2628     test.Printf(_L("%S\n"), &aDriver);
  2645     TInt r;
  2629     TInt r;