os/persistentdata/featuremgmt/featureregistry/test/compositeromtesting/src/featregSetupTest.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <e32test.h>
sl@0
    17
#include <f32file.h>
sl@0
    18
#include "featregcmn.h"
sl@0
    19
#include <featreg.h>
sl@0
    20
sl@0
    21
LOCAL_D RFs	TheFs;
sl@0
    22
sl@0
    23
LOCAL_D RTest TheTest(_L("featregsetup OOM Test"));
sl@0
    24
sl@0
    25
//Test macros and functions
sl@0
    26
sl@0
    27
LOCAL_C void Check(TInt aValue, TInt aLine)
sl@0
    28
	{
sl@0
    29
	if(!aValue)
sl@0
    30
		{
sl@0
    31
		TheTest(EFalse, aLine);
sl@0
    32
		}
sl@0
    33
	}
sl@0
    34
sl@0
    35
LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
sl@0
    36
	{
sl@0
    37
	if(aValue != aExpected)
sl@0
    38
		{
sl@0
    39
		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
sl@0
    40
		TheTest(EFalse, aLine);
sl@0
    41
		}
sl@0
    42
	}
sl@0
    43
sl@0
    44
#define TEST(arg) ::Check((arg), __LINE__)
sl@0
    45
#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
sl@0
    46
sl@0
    47
/**
sl@0
    48
@SYMTestCaseID			SYSLIB-FEATREG-CT-3373
sl@0
    49
@SYMTestCaseDesc		OOM Test for the function ReadMultipleFeatureFileToBuf
sl@0
    50
@SYMTestPriority		High
sl@0
    51
@SYMTestActions			OOM Testing the function ReadMultipleFeatureFileToBuf
sl@0
    52
						when processing multiple featreg files from different rom section
sl@0
    53
						Test relies on the additional ROFS2 and ROFS3 section
sl@0
    54
						during buildrom time
sl@0
    55
@SYMTestExpectedResults	The test must not fail.
sl@0
    56
@SYMDEF				 	DEF101195
sl@0
    57
*/	
sl@0
    58
static void CompositeOOMTesting()
sl@0
    59
	{
sl@0
    60
		TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3373 Composite OOM Testing "));
sl@0
    61
	TInt failAt=0;
sl@0
    62
	TInt err=KErrNone;
sl@0
    63
	do 
sl@0
    64
		{
sl@0
    65
		__UHEAP_MARK;
sl@0
    66
  
sl@0
    67
		// find out the number of open handles
sl@0
    68
		TInt pHCountStart;
sl@0
    69
		TInt tHCountStart;
sl@0
    70
		RThread().HandleCount(pHCountStart,tHCountStart);
sl@0
    71
sl@0
    72
		RBuf8 buffer;
sl@0
    73
sl@0
    74
		__UHEAP_SETFAIL(RHeap::EDeterministic, failAt++);
sl@0
    75
sl@0
    76
		err=ReadMultipleFeatureFileToBuf(TheFs,KFeatregRomPrivatePath,buffer);
sl@0
    77
sl@0
    78
		__UHEAP_SETFAIL(RHeap::ENone, 0);
sl@0
    79
sl@0
    80
		buffer.Close();
sl@0
    81
sl@0
    82
		// check that no handles have leaked
sl@0
    83
		TInt pHCountEnd;
sl@0
    84
		TInt tHCountEnd;
sl@0
    85
		RThread().HandleCount(pHCountEnd,tHCountEnd);
sl@0
    86
sl@0
    87
		TEST2(pHCountStart,pHCountEnd);
sl@0
    88
		TEST2(tHCountStart,tHCountEnd);
sl@0
    89
		__UHEAP_MARKEND;
sl@0
    90
		} 
sl@0
    91
	while (err == KErrNoMemory);
sl@0
    92
	RDebug::Print(_L("Allocation successful at count=%d"),failAt);
sl@0
    93
 	TEST2(err,KErrNone);	
sl@0
    94
	}
sl@0
    95
sl@0
    96
/**
sl@0
    97
@SYMTestCaseID		SYSLIB-FEATREG-CT-3374
sl@0
    98
@SYMTestCaseDesc		Tests the correct list of features are published by featregsetup
sl@0
    99
					in a composite rom with multiple featreg files
sl@0
   100
@SYMTestPriority		High
sl@0
   101
@SYMTestActions		This will be completely testing the functionality from the client side point of view
sl@0
   102
					whether the correct feature content is published.by featregsetup when
sl@0
   103
					reading and processing multiple files.
sl@0
   104
@SYMTestExpectedResults	The test must not fail.
sl@0
   105
@SYMDEF				 	DEF101195
sl@0
   106
                        PDEF113655
sl@0
   107
*/	
sl@0
   108
static void CompositeROMTestingL()
sl@0
   109
	{
sl@0
   110
	/**	
sl@0
   111
	------------------------------------------------------------------
sl@0
   112
	COMPOSITE ROM CONFIGURATION
sl@0
   113
	MOUNTING CORE-ROFS1-ROFS2-ROFS3
sl@0
   114
	F=FEATURE; XF=EXCLUDE_FEATURE DSR=DEFAULT SUPPORTED RANGE
sl@0
   115
	------------------------------------------------------------------
sl@0
   116
	CORE	 F: Fax(0x10279806) Usb(0x1027980B)(already included in DSR),OmaDsHostServers(0x10282663)
sl@0
   117
			XF: -
sl@0
   118
		   DSR: 0x10279806 - 0x10281805 (Default techview)
sl@0
   119
	------------------------------------------------------------------	   							
sl@0
   120
	ROFS2	 F: TestAA  
sl@0
   121
			XF: TestBB, Fax, TestCC
sl@0
   122
		   DSR: 0x10279806 - 0x10281805 (Default techview)
sl@0
   123
		   		0x10288888 - 0x10299999
sl@0
   124
		   		0x102AAAAA - 0x102BBBBB
sl@0
   125
	------------------------------------------------------------------
sl@0
   126
	ROFS3	 F: TestBB, Usb, TestCC (TestCC is in DSR range)
sl@0
   127
			XF: TestAA, Usb    
sl@0
   128
		   DSR: 0x10279806 - 0x10281805 (Default techview)
sl@0
   129
		   		0x102CCCCC - 0x102DDDDD
sl@0
   130
		   		0x1CCCCCCA - 0x1CCCCCCF
sl@0
   131
	------------------------------------------------------------------	
sl@0
   132
	*/
sl@0
   133
		TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3374 Composite ROM Testing "));		
sl@0
   134
	__UHEAP_MARK;
sl@0
   135
	RFeatureRegistry featreg;
sl@0
   136
	User::LeaveIfError(featreg.Open());
sl@0
   137
	CleanupClosePushL(featreg);
sl@0
   138
sl@0
   139
	//SINGLE ENTRY TEST	
sl@0
   140
	//first test that the overriding feature are behaving as expected
sl@0
   141
	TUid TestAA={0x1AAAAAAA};
sl@0
   142
	TUid TestBB={0x1BBBBBBB};
sl@0
   143
	TUid Usb={0x1027980B};
sl@0
   144
	TUid Fax={0x10279806};
sl@0
   145
	TUid OmaDHS={0x10282663};
sl@0
   146
	TUid TestCC={0x1CCCCCCC};
sl@0
   147
	
sl@0
   148
	//as a result of the overriding ROFS3 will disable ROFS2 TestAA
sl@0
   149
	//and ROFS3 will enable ROFS2 TestBB
sl@0
   150
	//and ROFS2 will disable Fax from CORE
sl@0
   151
	//
sl@0
   152
	//PDEF113655: TestCC is in DSR. It is explicitly excluded in ROFS2 and is explicitly
sl@0
   153
	//included in ROFS3. This tests that TestCC has not been optimised out of the config 
sl@0
   154
	//because it is in the DSR  
sl@0
   155
	
sl@0
   156
	TUint32 info=0;
sl@0
   157
	TEST2(featreg.QuerySupport(TestAA),0);
sl@0
   158
	TEST2(featreg.QuerySupport(TestAA,info),0);	
sl@0
   159
	TEST2(info,0);
sl@0
   160
	TEST(featreg.QuerySupport(TestBB)>0);
sl@0
   161
	TEST(featreg.QuerySupport(TestBB,info)>0);	
sl@0
   162
	TEST2(info,1);
sl@0
   163
	TEST2(featreg.QuerySupport(Fax),0);
sl@0
   164
	TEST2(featreg.QuerySupport(Fax,info),0);
sl@0
   165
	TEST2(info,0);
sl@0
   166
	TEST(featreg.QuerySupport(Usb)>0);
sl@0
   167
	TEST(featreg.QuerySupport(Usb,info)>0);	
sl@0
   168
	TEST2(info,1);
sl@0
   169
	TEST(featreg.QuerySupport(OmaDHS)>0);
sl@0
   170
	TEST(featreg.QuerySupport(OmaDHS,info)>0);	
sl@0
   171
	TEST2(info,1);
sl@0
   172
	TEST(featreg.QuerySupport(TestCC)>0);
sl@0
   173
	TEST(featreg.QuerySupport(TestCC,info)>0);	
sl@0
   174
	TEST2(info,1);
sl@0
   175
sl@0
   176
	//DEFAULT SUPPORTED RANGE TEST	
sl@0
   177
	//now check the default CORE range(Exclude the fax as this is disabled)
sl@0
   178
	for (TInt i=0x10279807;i<=0x10281805;i++)
sl@0
   179
		{
sl@0
   180
		TUid featUid={i};
sl@0
   181
		TEST(featreg.QuerySupport(featUid)>0);
sl@0
   182
		TEST(featreg.QuerySupport(featUid,info)>0);		
sl@0
   183
		TEST2(info,1);		
sl@0
   184
		}
sl@0
   185
	//now check the range in ROFS2 and ROFS3
sl@0
   186
	for (TInt j=0x10288888;j<=0x10299999;j++)
sl@0
   187
		{
sl@0
   188
		TUid featUid={j};
sl@0
   189
		TEST(featreg.QuerySupport(featUid)>0);
sl@0
   190
		TEST(featreg.QuerySupport(featUid,info)>0);					
sl@0
   191
		TEST2(info,1);
sl@0
   192
		}
sl@0
   193
	for (TInt k=0x102AAAAA;k<=0x102BBBBB;k++)
sl@0
   194
		{
sl@0
   195
		TUid featUid={k};
sl@0
   196
		TEST(featreg.QuerySupport(featUid)>0);
sl@0
   197
		TEST(featreg.QuerySupport(featUid,info)>0);					
sl@0
   198
		TEST2(info,1);		
sl@0
   199
		}
sl@0
   200
	for (TInt l=0x102CCCCC;l<=0x102DDDDD;l++)
sl@0
   201
		{
sl@0
   202
		TUid featUid={l};
sl@0
   203
		TEST(featreg.QuerySupport(featUid)>0);
sl@0
   204
		TEST(featreg.QuerySupport(featUid,info)>0);
sl@0
   205
		TEST2(info,1);							
sl@0
   206
		}
sl@0
   207
	for (TInt m=0x1CCCCCCA;m<=0x1CCCCCCF;m++)
sl@0
   208
		{
sl@0
   209
		TUid featUid={m};
sl@0
   210
		TEST(featreg.QuerySupport(featUid)>0);
sl@0
   211
		TEST(featreg.QuerySupport(featUid,info)>0);
sl@0
   212
		TEST2(info,1);							
sl@0
   213
		}				
sl@0
   214
	CleanupStack::PopAndDestroy();
sl@0
   215
	__UHEAP_MARKEND;
sl@0
   216
	}
sl@0
   217
	
sl@0
   218
/**
sl@0
   219
@SYMTestCaseID		SYSLIB-FEATREG-CT-3375
sl@0
   220
@SYMTestCaseDesc		Tests Corrupt file handling of ReadMultipleFeatureFileToBuf
sl@0
   221
@SYMTestPriority		High
sl@0
   222
@SYMTestActions		This test will test that if one of the configuration files is corrupt, the
sl@0
   223
					ReadMultipleFeatureFileToBuf function will always return KErrCorrupt, also
sl@0
   224
					ensure there is no memory leak when it returned KErrCorrupt.
sl@0
   225
@SYMTestExpectedResults	The test must not fail.
sl@0
   226
@SYMDEF				 DEF101195
sl@0
   227
*/
sl@0
   228
static void CompositeCorruptFileTesting()	
sl@0
   229
	{
sl@0
   230
		TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3375 Composite Corrupt Testing "));
sl@0
   231
	__UHEAP_MARK;
sl@0
   232
	
sl@0
   233
	//both test files will be stored in z:\featregcomposite
sl@0
   234
	//the featreg.cfg is ok but featreg.cfg[1-0] is a corrupt file
sl@0
   235
	_LIT(KTestDirectory,"z:\\featregcomposite\\");
sl@0
   236
	RBuf8 buffer;
sl@0
   237
	TInt err=ReadMultipleFeatureFileToBuf(TheFs,KTestDirectory,buffer);	
sl@0
   238
	TEST2(err,KErrCorrupt);
sl@0
   239
	
sl@0
   240
	__UHEAP_MARKEND;
sl@0
   241
	}
sl@0
   242
sl@0
   243
sl@0
   244
/**
sl@0
   245
@SYMTestCaseID		SYSLIB-FEATREG-CT-3471
sl@0
   246
@SYMTestCaseDesc		List Config Files Names Under Featreg Data cage
sl@0
   247
@SYMTestPriority		High
sl@0
   248
@SYMTestActions		This test returns in a list format the names of all the featreg config files in its data cage.
sl@0
   249
					In order to validate EC114 Changes for FeatReg
sl@0
   250
@SYMTestExpectedResults	Names of featreg config files is returned.
sl@0
   251
@SYMDEF				 DEF104374
sl@0
   252
*/
sl@0
   253
static void OutputFileNameL()
sl@0
   254
	{
sl@0
   255
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-FEATREG-CT-3471 "));
sl@0
   256
	_LIT(KFeatRegDir,"z:\\private\\102744CA\\*");
sl@0
   257
	
sl@0
   258
	CDir* dirList;
sl@0
   259
	
sl@0
   260
	User::LeaveIfError(TheFs.GetDir(KFeatRegDir, KEntryAttMaskSupported,ESortByName,dirList));
sl@0
   261
	
sl@0
   262
	RDebug::Print(_L("These are the files under z:\\private\\102744CA\\ "));
sl@0
   263
	
sl@0
   264
	for (TInt i=0;i<dirList->Count();i++)
sl@0
   265
		{
sl@0
   266
		RDebug::Print(_L(" %S "), &(*dirList)[i].iName);
sl@0
   267
		}
sl@0
   268
	    
sl@0
   269
	delete dirList;	
sl@0
   270
	}
sl@0
   271
sl@0
   272
sl@0
   273
//Note that tests can be run in both emulator(automatic) and hardware(manual) however with some difference:
sl@0
   274
//Emulator: Test relies on pre-generated cfg files which is copied and removed using a batch file
sl@0
   275
//Hardware: Test will rely on the buildrom to generate the cfg files for each rom section, as this involes
sl@0
   276
//			flashing additional rom sections to Techviwe NAND2 rom, this test is manual
sl@0
   277
LOCAL_C void RunTestL()
sl@0
   278
	{
sl@0
   279
	User::LeaveIfError(TheFs.Connect());
sl@0
   280
	
sl@0
   281
	CompositeCorruptFileTesting();
sl@0
   282
	CompositeOOMTesting();	
sl@0
   283
	CompositeROMTestingL();
sl@0
   284
	
sl@0
   285
	OutputFileNameL();
sl@0
   286
	
sl@0
   287
	TheFs.Close();
sl@0
   288
	}
sl@0
   289
sl@0
   290
LOCAL_C TInt MainL()
sl@0
   291
{
sl@0
   292
	CActiveScheduler* scheduler = new(ELeave)CActiveScheduler;
sl@0
   293
	CActiveScheduler::Install(scheduler);
sl@0
   294
sl@0
   295
	TRAPD(err,RunTestL());
sl@0
   296
    TEST2(err, KErrNone);
sl@0
   297
    
sl@0
   298
	delete scheduler;
sl@0
   299
}
sl@0
   300
sl@0
   301
GLDEF_C TInt E32Main()
sl@0
   302
	{
sl@0
   303
	__UHEAP_MARK;
sl@0
   304
sl@0
   305
	TheTest.Title();
sl@0
   306
	TheTest.Start(_L("Featregsetup Composite Testing"));
sl@0
   307
sl@0
   308
	CTrapCleanup* cleanup = CTrapCleanup::New();
sl@0
   309
sl@0
   310
    TRAPD(err,MainL());
sl@0
   311
	TEST2(err, KErrNone);
sl@0
   312
sl@0
   313
	delete cleanup;
sl@0
   314
	
sl@0
   315
	TheTest.End();
sl@0
   316
	TheTest.Close();
sl@0
   317
	
sl@0
   318
	__UHEAP_MARKEND;
sl@0
   319
	return(0);
sl@0
   320
	}