os/persistentdata/featuremgmt/featureregistry/test/compositeromtesting/src/featregSetupTest.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/featuremgmt/featureregistry/test/compositeromtesting/src/featregSetupTest.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,320 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <e32test.h>
    1.20 +#include <f32file.h>
    1.21 +#include "featregcmn.h"
    1.22 +#include <featreg.h>
    1.23 +
    1.24 +LOCAL_D RFs	TheFs;
    1.25 +
    1.26 +LOCAL_D RTest TheTest(_L("featregsetup OOM Test"));
    1.27 +
    1.28 +//Test macros and functions
    1.29 +
    1.30 +LOCAL_C void Check(TInt aValue, TInt aLine)
    1.31 +	{
    1.32 +	if(!aValue)
    1.33 +		{
    1.34 +		TheTest(EFalse, aLine);
    1.35 +		}
    1.36 +	}
    1.37 +
    1.38 +LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
    1.39 +	{
    1.40 +	if(aValue != aExpected)
    1.41 +		{
    1.42 +		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
    1.43 +		TheTest(EFalse, aLine);
    1.44 +		}
    1.45 +	}
    1.46 +
    1.47 +#define TEST(arg) ::Check((arg), __LINE__)
    1.48 +#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
    1.49 +
    1.50 +/**
    1.51 +@SYMTestCaseID			SYSLIB-FEATREG-CT-3373
    1.52 +@SYMTestCaseDesc		OOM Test for the function ReadMultipleFeatureFileToBuf
    1.53 +@SYMTestPriority		High
    1.54 +@SYMTestActions			OOM Testing the function ReadMultipleFeatureFileToBuf
    1.55 +						when processing multiple featreg files from different rom section
    1.56 +						Test relies on the additional ROFS2 and ROFS3 section
    1.57 +						during buildrom time
    1.58 +@SYMTestExpectedResults	The test must not fail.
    1.59 +@SYMDEF				 	DEF101195
    1.60 +*/	
    1.61 +static void CompositeOOMTesting()
    1.62 +	{
    1.63 +		TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3373 Composite OOM Testing "));
    1.64 +	TInt failAt=0;
    1.65 +	TInt err=KErrNone;
    1.66 +	do 
    1.67 +		{
    1.68 +		__UHEAP_MARK;
    1.69 +  
    1.70 +		// find out the number of open handles
    1.71 +		TInt pHCountStart;
    1.72 +		TInt tHCountStart;
    1.73 +		RThread().HandleCount(pHCountStart,tHCountStart);
    1.74 +
    1.75 +		RBuf8 buffer;
    1.76 +
    1.77 +		__UHEAP_SETFAIL(RHeap::EDeterministic, failAt++);
    1.78 +
    1.79 +		err=ReadMultipleFeatureFileToBuf(TheFs,KFeatregRomPrivatePath,buffer);
    1.80 +
    1.81 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
    1.82 +
    1.83 +		buffer.Close();
    1.84 +
    1.85 +		// check that no handles have leaked
    1.86 +		TInt pHCountEnd;
    1.87 +		TInt tHCountEnd;
    1.88 +		RThread().HandleCount(pHCountEnd,tHCountEnd);
    1.89 +
    1.90 +		TEST2(pHCountStart,pHCountEnd);
    1.91 +		TEST2(tHCountStart,tHCountEnd);
    1.92 +		__UHEAP_MARKEND;
    1.93 +		} 
    1.94 +	while (err == KErrNoMemory);
    1.95 +	RDebug::Print(_L("Allocation successful at count=%d"),failAt);
    1.96 + 	TEST2(err,KErrNone);	
    1.97 +	}
    1.98 +
    1.99 +/**
   1.100 +@SYMTestCaseID		SYSLIB-FEATREG-CT-3374
   1.101 +@SYMTestCaseDesc		Tests the correct list of features are published by featregsetup
   1.102 +					in a composite rom with multiple featreg files
   1.103 +@SYMTestPriority		High
   1.104 +@SYMTestActions		This will be completely testing the functionality from the client side point of view
   1.105 +					whether the correct feature content is published.by featregsetup when
   1.106 +					reading and processing multiple files.
   1.107 +@SYMTestExpectedResults	The test must not fail.
   1.108 +@SYMDEF				 	DEF101195
   1.109 +                        PDEF113655
   1.110 +*/	
   1.111 +static void CompositeROMTestingL()
   1.112 +	{
   1.113 +	/**	
   1.114 +	------------------------------------------------------------------
   1.115 +	COMPOSITE ROM CONFIGURATION
   1.116 +	MOUNTING CORE-ROFS1-ROFS2-ROFS3
   1.117 +	F=FEATURE; XF=EXCLUDE_FEATURE DSR=DEFAULT SUPPORTED RANGE
   1.118 +	------------------------------------------------------------------
   1.119 +	CORE	 F: Fax(0x10279806) Usb(0x1027980B)(already included in DSR),OmaDsHostServers(0x10282663)
   1.120 +			XF: -
   1.121 +		   DSR: 0x10279806 - 0x10281805 (Default techview)
   1.122 +	------------------------------------------------------------------	   							
   1.123 +	ROFS2	 F: TestAA  
   1.124 +			XF: TestBB, Fax, TestCC
   1.125 +		   DSR: 0x10279806 - 0x10281805 (Default techview)
   1.126 +		   		0x10288888 - 0x10299999
   1.127 +		   		0x102AAAAA - 0x102BBBBB
   1.128 +	------------------------------------------------------------------
   1.129 +	ROFS3	 F: TestBB, Usb, TestCC (TestCC is in DSR range)
   1.130 +			XF: TestAA, Usb    
   1.131 +		   DSR: 0x10279806 - 0x10281805 (Default techview)
   1.132 +		   		0x102CCCCC - 0x102DDDDD
   1.133 +		   		0x1CCCCCCA - 0x1CCCCCCF
   1.134 +	------------------------------------------------------------------	
   1.135 +	*/
   1.136 +		TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3374 Composite ROM Testing "));		
   1.137 +	__UHEAP_MARK;
   1.138 +	RFeatureRegistry featreg;
   1.139 +	User::LeaveIfError(featreg.Open());
   1.140 +	CleanupClosePushL(featreg);
   1.141 +
   1.142 +	//SINGLE ENTRY TEST	
   1.143 +	//first test that the overriding feature are behaving as expected
   1.144 +	TUid TestAA={0x1AAAAAAA};
   1.145 +	TUid TestBB={0x1BBBBBBB};
   1.146 +	TUid Usb={0x1027980B};
   1.147 +	TUid Fax={0x10279806};
   1.148 +	TUid OmaDHS={0x10282663};
   1.149 +	TUid TestCC={0x1CCCCCCC};
   1.150 +	
   1.151 +	//as a result of the overriding ROFS3 will disable ROFS2 TestAA
   1.152 +	//and ROFS3 will enable ROFS2 TestBB
   1.153 +	//and ROFS2 will disable Fax from CORE
   1.154 +	//
   1.155 +	//PDEF113655: TestCC is in DSR. It is explicitly excluded in ROFS2 and is explicitly
   1.156 +	//included in ROFS3. This tests that TestCC has not been optimised out of the config 
   1.157 +	//because it is in the DSR  
   1.158 +	
   1.159 +	TUint32 info=0;
   1.160 +	TEST2(featreg.QuerySupport(TestAA),0);
   1.161 +	TEST2(featreg.QuerySupport(TestAA,info),0);	
   1.162 +	TEST2(info,0);
   1.163 +	TEST(featreg.QuerySupport(TestBB)>0);
   1.164 +	TEST(featreg.QuerySupport(TestBB,info)>0);	
   1.165 +	TEST2(info,1);
   1.166 +	TEST2(featreg.QuerySupport(Fax),0);
   1.167 +	TEST2(featreg.QuerySupport(Fax,info),0);
   1.168 +	TEST2(info,0);
   1.169 +	TEST(featreg.QuerySupport(Usb)>0);
   1.170 +	TEST(featreg.QuerySupport(Usb,info)>0);	
   1.171 +	TEST2(info,1);
   1.172 +	TEST(featreg.QuerySupport(OmaDHS)>0);
   1.173 +	TEST(featreg.QuerySupport(OmaDHS,info)>0);	
   1.174 +	TEST2(info,1);
   1.175 +	TEST(featreg.QuerySupport(TestCC)>0);
   1.176 +	TEST(featreg.QuerySupport(TestCC,info)>0);	
   1.177 +	TEST2(info,1);
   1.178 +
   1.179 +	//DEFAULT SUPPORTED RANGE TEST	
   1.180 +	//now check the default CORE range(Exclude the fax as this is disabled)
   1.181 +	for (TInt i=0x10279807;i<=0x10281805;i++)
   1.182 +		{
   1.183 +		TUid featUid={i};
   1.184 +		TEST(featreg.QuerySupport(featUid)>0);
   1.185 +		TEST(featreg.QuerySupport(featUid,info)>0);		
   1.186 +		TEST2(info,1);		
   1.187 +		}
   1.188 +	//now check the range in ROFS2 and ROFS3
   1.189 +	for (TInt j=0x10288888;j<=0x10299999;j++)
   1.190 +		{
   1.191 +		TUid featUid={j};
   1.192 +		TEST(featreg.QuerySupport(featUid)>0);
   1.193 +		TEST(featreg.QuerySupport(featUid,info)>0);					
   1.194 +		TEST2(info,1);
   1.195 +		}
   1.196 +	for (TInt k=0x102AAAAA;k<=0x102BBBBB;k++)
   1.197 +		{
   1.198 +		TUid featUid={k};
   1.199 +		TEST(featreg.QuerySupport(featUid)>0);
   1.200 +		TEST(featreg.QuerySupport(featUid,info)>0);					
   1.201 +		TEST2(info,1);		
   1.202 +		}
   1.203 +	for (TInt l=0x102CCCCC;l<=0x102DDDDD;l++)
   1.204 +		{
   1.205 +		TUid featUid={l};
   1.206 +		TEST(featreg.QuerySupport(featUid)>0);
   1.207 +		TEST(featreg.QuerySupport(featUid,info)>0);
   1.208 +		TEST2(info,1);							
   1.209 +		}
   1.210 +	for (TInt m=0x1CCCCCCA;m<=0x1CCCCCCF;m++)
   1.211 +		{
   1.212 +		TUid featUid={m};
   1.213 +		TEST(featreg.QuerySupport(featUid)>0);
   1.214 +		TEST(featreg.QuerySupport(featUid,info)>0);
   1.215 +		TEST2(info,1);							
   1.216 +		}				
   1.217 +	CleanupStack::PopAndDestroy();
   1.218 +	__UHEAP_MARKEND;
   1.219 +	}
   1.220 +	
   1.221 +/**
   1.222 +@SYMTestCaseID		SYSLIB-FEATREG-CT-3375
   1.223 +@SYMTestCaseDesc		Tests Corrupt file handling of ReadMultipleFeatureFileToBuf
   1.224 +@SYMTestPriority		High
   1.225 +@SYMTestActions		This test will test that if one of the configuration files is corrupt, the
   1.226 +					ReadMultipleFeatureFileToBuf function will always return KErrCorrupt, also
   1.227 +					ensure there is no memory leak when it returned KErrCorrupt.
   1.228 +@SYMTestExpectedResults	The test must not fail.
   1.229 +@SYMDEF				 DEF101195
   1.230 +*/
   1.231 +static void CompositeCorruptFileTesting()	
   1.232 +	{
   1.233 +		TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3375 Composite Corrupt Testing "));
   1.234 +	__UHEAP_MARK;
   1.235 +	
   1.236 +	//both test files will be stored in z:\featregcomposite
   1.237 +	//the featreg.cfg is ok but featreg.cfg[1-0] is a corrupt file
   1.238 +	_LIT(KTestDirectory,"z:\\featregcomposite\\");
   1.239 +	RBuf8 buffer;
   1.240 +	TInt err=ReadMultipleFeatureFileToBuf(TheFs,KTestDirectory,buffer);	
   1.241 +	TEST2(err,KErrCorrupt);
   1.242 +	
   1.243 +	__UHEAP_MARKEND;
   1.244 +	}
   1.245 +
   1.246 +
   1.247 +/**
   1.248 +@SYMTestCaseID		SYSLIB-FEATREG-CT-3471
   1.249 +@SYMTestCaseDesc		List Config Files Names Under Featreg Data cage
   1.250 +@SYMTestPriority		High
   1.251 +@SYMTestActions		This test returns in a list format the names of all the featreg config files in its data cage.
   1.252 +					In order to validate EC114 Changes for FeatReg
   1.253 +@SYMTestExpectedResults	Names of featreg config files is returned.
   1.254 +@SYMDEF				 DEF104374
   1.255 +*/
   1.256 +static void OutputFileNameL()
   1.257 +	{
   1.258 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3471 "));
   1.259 +	_LIT(KFeatRegDir,"z:\\private\\102744CA\\*");
   1.260 +	
   1.261 +	CDir* dirList;
   1.262 +	
   1.263 +	User::LeaveIfError(TheFs.GetDir(KFeatRegDir, KEntryAttMaskSupported,ESortByName,dirList));
   1.264 +	
   1.265 +	RDebug::Print(_L("These are the files under z:\\private\\102744CA\\ "));
   1.266 +	
   1.267 +	for (TInt i=0;i<dirList->Count();i++)
   1.268 +		{
   1.269 +		RDebug::Print(_L(" %S "), &(*dirList)[i].iName);
   1.270 +		}
   1.271 +	    
   1.272 +	delete dirList;	
   1.273 +	}
   1.274 +
   1.275 +
   1.276 +//Note that tests can be run in both emulator(automatic) and hardware(manual) however with some difference:
   1.277 +//Emulator: Test relies on pre-generated cfg files which is copied and removed using a batch file
   1.278 +//Hardware: Test will rely on the buildrom to generate the cfg files for each rom section, as this involes
   1.279 +//			flashing additional rom sections to Techviwe NAND2 rom, this test is manual
   1.280 +LOCAL_C void RunTestL()
   1.281 +	{
   1.282 +	User::LeaveIfError(TheFs.Connect());
   1.283 +	
   1.284 +	CompositeCorruptFileTesting();
   1.285 +	CompositeOOMTesting();	
   1.286 +	CompositeROMTestingL();
   1.287 +	
   1.288 +	OutputFileNameL();
   1.289 +	
   1.290 +	TheFs.Close();
   1.291 +	}
   1.292 +
   1.293 +LOCAL_C TInt MainL()
   1.294 +{
   1.295 +	CActiveScheduler* scheduler = new(ELeave)CActiveScheduler;
   1.296 +	CActiveScheduler::Install(scheduler);
   1.297 +
   1.298 +	TRAPD(err,RunTestL());
   1.299 +    TEST2(err, KErrNone);
   1.300 +    
   1.301 +	delete scheduler;
   1.302 +}
   1.303 +
   1.304 +GLDEF_C TInt E32Main()
   1.305 +	{
   1.306 +	__UHEAP_MARK;
   1.307 +
   1.308 +	TheTest.Title();
   1.309 +	TheTest.Start(_L("Featregsetup Composite Testing"));
   1.310 +
   1.311 +	CTrapCleanup* cleanup = CTrapCleanup::New();
   1.312 +
   1.313 +    TRAPD(err,MainL());
   1.314 +	TEST2(err, KErrNone);
   1.315 +
   1.316 +	delete cleanup;
   1.317 +	
   1.318 +	TheTest.End();
   1.319 +	TheTest.Close();
   1.320 +	
   1.321 +	__UHEAP_MARKEND;
   1.322 +	return(0);
   1.323 +	}