os/kernelhwsrv/kerneltest/f32test/rofs/src/t_rofsattrib.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2008-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 the License "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
// Test attribute settings on files
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32std.h>
sl@0
    19
#include <e32std_private.h>
sl@0
    20
#include <e32test.h>
sl@0
    21
#include <f32file.h>
sl@0
    22
#include "utl.h"
sl@0
    23
sl@0
    24
sl@0
    25
sl@0
    26
GLREF_D RFs TheFs;
sl@0
    27
sl@0
    28
RTest	test( _L("T_ROFSATTRIB") );
sl@0
    29
sl@0
    30
_LIT( KFileRsh1, "rsh" );
sl@0
    31
_LIT( KFileRs1, "rs" );
sl@0
    32
_LIT( KFileRh1, "rh" );
sl@0
    33
_LIT( KFileSh1, "sh" );
sl@0
    34
_LIT( KFileS1, "s" );
sl@0
    35
_LIT( KFileH1, "h" );
sl@0
    36
_LIT( KFileR1, "r" );
sl@0
    37
_LIT( KFileR2, "r2" );
sl@0
    38
_LIT( KFileR3, "r3" );
sl@0
    39
_LIT( KFileS2, "s2" );
sl@0
    40
_LIT( KFileS3, "s3" );
sl@0
    41
_LIT( KFileH2, "h2" );
sl@0
    42
_LIT( KFileH3, "h3" );
sl@0
    43
_LIT( KFileRs2, "rs2" );
sl@0
    44
_LIT( KFileRs3, "rs3" );
sl@0
    45
_LIT( KFileRh2, "rh2" );
sl@0
    46
_LIT( KFileRh3, "rh3" );
sl@0
    47
_LIT( KFileRsh2, "rsh2" );
sl@0
    48
_LIT( KFileRsh3, "rsh3" );
sl@0
    49
sl@0
    50
_LIT( KDirectoryBase, "Attrib\\");
sl@0
    51
sl@0
    52
LOCAL_D const TUint KFileListAllAttribs[] =
sl@0
    53
	{
sl@0
    54
	KEntryAttReadOnly | KEntryAttSystem | KEntryAttHidden,	// KFileRsh1
sl@0
    55
	KEntryAttReadOnly | KEntryAttSystem,	// KFileRs1
sl@0
    56
	KEntryAttReadOnly | KEntryAttHidden,	// KFileRh1
sl@0
    57
	KEntryAttSystem	| KEntryAttHidden,// KFileSh1
sl@0
    58
	KEntryAttSystem,	// KFileS1
sl@0
    59
	KEntryAttHidden,	// KFileH1
sl@0
    60
	KEntryAttReadOnly,	// KFileR1
sl@0
    61
	KEntryAttReadOnly,	// KFileR2
sl@0
    62
	KEntryAttReadOnly,	// KFileR3
sl@0
    63
	KEntryAttSystem,	// KFileS2
sl@0
    64
	KEntryAttSystem,	// KFileS3
sl@0
    65
	KEntryAttHidden,	// KFileH2
sl@0
    66
	KEntryAttHidden,	// KFileH3
sl@0
    67
	KEntryAttReadOnly | KEntryAttSystem,	// KFileRs2
sl@0
    68
	KEntryAttReadOnly | KEntryAttSystem,	// KFileRs3
sl@0
    69
	KEntryAttReadOnly | KEntryAttHidden,	// KFileRh2
sl@0
    70
	KEntryAttReadOnly | KEntryAttHidden,	// KFileRh3
sl@0
    71
	KEntryAttReadOnly | KEntryAttSystem | KEntryAttHidden,	// KFileRsh2
sl@0
    72
	KEntryAttReadOnly | KEntryAttSystem | KEntryAttHidden,	// KFileRsh3
sl@0
    73
	};
sl@0
    74
sl@0
    75
LOCAL_D const TDesC* KFileListAll[] =
sl@0
    76
	{
sl@0
    77
	&KFileRsh1,
sl@0
    78
	&KFileRs1,
sl@0
    79
	&KFileRh1,
sl@0
    80
	&KFileSh1,
sl@0
    81
	&KFileS1,
sl@0
    82
	&KFileH1,
sl@0
    83
	&KFileR1,
sl@0
    84
	&KFileR2,
sl@0
    85
	&KFileR3,
sl@0
    86
	&KFileS2,
sl@0
    87
	&KFileS3,
sl@0
    88
	&KFileH2,
sl@0
    89
	&KFileH3,
sl@0
    90
	&KFileRs2,
sl@0
    91
	&KFileRs3,
sl@0
    92
	&KFileRh2,
sl@0
    93
	&KFileRh3,
sl@0
    94
	&KFileRsh2,
sl@0
    95
	&KFileRsh3,
sl@0
    96
	NULL
sl@0
    97
	};
sl@0
    98
sl@0
    99
LOCAL_D const TDesC* KFileListReadOnly[] =
sl@0
   100
	{
sl@0
   101
	&KFileRsh1,
sl@0
   102
	&KFileRs1,
sl@0
   103
	&KFileRh1,
sl@0
   104
	&KFileR1,
sl@0
   105
	&KFileR2,
sl@0
   106
	&KFileR3,
sl@0
   107
	&KFileRs2,
sl@0
   108
	&KFileRs3,
sl@0
   109
	&KFileRh2,
sl@0
   110
	&KFileRh3,
sl@0
   111
	&KFileRsh2,
sl@0
   112
	&KFileRsh3,
sl@0
   113
	NULL
sl@0
   114
	};
sl@0
   115
sl@0
   116
LOCAL_D const TDesC* KFileListNotHidden[] =
sl@0
   117
	{
sl@0
   118
	&KFileRs1,
sl@0
   119
	&KFileS1,
sl@0
   120
	&KFileR1,
sl@0
   121
	&KFileR2,
sl@0
   122
	&KFileR3,
sl@0
   123
	&KFileS2,
sl@0
   124
	&KFileS3,
sl@0
   125
	&KFileRs2,
sl@0
   126
	&KFileRs3,
sl@0
   127
	NULL
sl@0
   128
	};
sl@0
   129
sl@0
   130
sl@0
   131
LOCAL_D const TDesC* KFileListNotSystem[] =
sl@0
   132
	{
sl@0
   133
	&KFileRh1,
sl@0
   134
	&KFileH1,
sl@0
   135
	&KFileR1,
sl@0
   136
	&KFileR2,
sl@0
   137
	&KFileR3,
sl@0
   138
	&KFileH2,
sl@0
   139
	&KFileH3,
sl@0
   140
	&KFileRh2,
sl@0
   141
	&KFileRh3,
sl@0
   142
	NULL
sl@0
   143
	};
sl@0
   144
sl@0
   145
sl@0
   146
LOCAL_D const TDesC* KFileListNotSystemAndHidden[] =
sl@0
   147
	{
sl@0
   148
	&KFileRsh1,
sl@0
   149
	&KFileRs1,
sl@0
   150
	&KFileRh1,
sl@0
   151
	&KFileS1,
sl@0
   152
	&KFileH1,
sl@0
   153
	&KFileR1,
sl@0
   154
	&KFileR2,
sl@0
   155
	&KFileR3,
sl@0
   156
	&KFileS2,
sl@0
   157
	&KFileS3,
sl@0
   158
	&KFileH2,
sl@0
   159
	&KFileH3,
sl@0
   160
	&KFileRs2,
sl@0
   161
	&KFileRs3,
sl@0
   162
	&KFileRh2,
sl@0
   163
	&KFileRh3,
sl@0
   164
	&KFileRsh2,
sl@0
   165
	&KFileRsh3,
sl@0
   166
	NULL
sl@0
   167
	};
sl@0
   168
sl@0
   169
sl@0
   170
LOCAL_D const TDesC* KFileListNotSystemOrHidden[] =
sl@0
   171
	{
sl@0
   172
	&KFileR1,
sl@0
   173
	&KFileR2,
sl@0
   174
	&KFileR3,
sl@0
   175
	NULL
sl@0
   176
	};
sl@0
   177
sl@0
   178
sl@0
   179
sl@0
   180
_LIT( KDriveBase, " :\\" );
sl@0
   181
_LIT( KWildCard, "*" );
sl@0
   182
sl@0
   183
sl@0
   184
LOCAL_C void TestFileAttribsL(TInt aDriveToTest)
sl@0
   185
	{
sl@0
   186
	CDir* dir;
sl@0
   187
sl@0
   188
	TFileName name(KDriveBase);
sl@0
   189
	name[0] = TText('A' + aDriveToTest);
sl@0
   190
	name.Append( KDirectoryBase );
sl@0
   191
	name.Append( KWildCard );
sl@0
   192
sl@0
   193
	TInt r = TheFs.GetDir( name, KEntryAttMatchMask, ESortNone, dir );
sl@0
   194
	TEST_FOR_ERROR( r );
sl@0
   195
	test( dir->Count() > 0 );
sl@0
   196
sl@0
   197
	TInt i;
sl@0
   198
	TEntry e;
sl@0
   199
	for( i = 0; KFileListAll[i]; i++ )
sl@0
   200
		{
sl@0
   201
		e = dir->operator[](i);
sl@0
   202
		test.Printf( _L("Found entry %S"), &e.iName );
sl@0
   203
		test( e.iName == *KFileListAll[i] );
sl@0
   204
sl@0
   205
		// check attributes
sl@0
   206
		TEST_FOR_MATCH( e.iAtt, KFileListAllAttribs[i] );
sl@0
   207
		}
sl@0
   208
	TEST_FOR_MATCH( i, dir->Count() );
sl@0
   209
	delete dir;
sl@0
   210
	}
sl@0
   211
sl@0
   212
sl@0
   213
LOCAL_C void TestScanFilesL( const TDesC* aFileList[], TUint aAttribMask, TInt aDriveToTest )
sl@0
   214
	//
sl@0
   215
	// Tests scanning a directory with attribute mask
sl@0
   216
	//
sl@0
   217
	{
sl@0
   218
	CDir* dir;
sl@0
   219
sl@0
   220
	TFileName name(KDriveBase);
sl@0
   221
	name[0] = TText('A' + aDriveToTest);
sl@0
   222
	name.Append( KDirectoryBase );
sl@0
   223
	name.Append( KWildCard );
sl@0
   224
sl@0
   225
	TInt r = TheFs.GetDir( name, aAttribMask, ESortNone, dir );
sl@0
   226
	TEST_FOR_ERROR( r );
sl@0
   227
sl@0
   228
	test( dir->Count() > 0 );
sl@0
   229
sl@0
   230
	TInt i;
sl@0
   231
	TEntry e;
sl@0
   232
	for( i = 0; aFileList[i]; i++ )
sl@0
   233
		{
sl@0
   234
		e = dir->operator[](i);
sl@0
   235
		test.Printf( _L("Found entry %S"), &e.iName );
sl@0
   236
		test( e.iName == *aFileList[i] );
sl@0
   237
		}
sl@0
   238
	TEST_FOR_MATCH( i, dir->Count() );
sl@0
   239
	delete dir;
sl@0
   240
	}
sl@0
   241
sl@0
   242
sl@0
   243
sl@0
   244
sl@0
   245
sl@0
   246
//************************
sl@0
   247
// Entry point
sl@0
   248
sl@0
   249
void DoTestL(TInt aDriveToTest)
sl@0
   250
	{
sl@0
   251
	test.Title();
sl@0
   252
	test.Start( _L("Testing ROFS directory structure") );
sl@0
   253
	
sl@0
   254
	const TUint KNotSystem = KEntryAttReadOnly | KEntryAttHidden;
sl@0
   255
	const TUint KNotHidden = KEntryAttReadOnly | KEntryAttSystem;
sl@0
   256
	const TUint KNotSystemOrHidden = KEntryAttNormal;
sl@0
   257
sl@0
   258
	test.Next( _L("Checking attributes of files") );
sl@0
   259
	TestFileAttribsL(aDriveToTest);
sl@0
   260
	test.Next( _L("Testing not system") );
sl@0
   261
	TestScanFilesL( KFileListNotSystem, KNotSystem, aDriveToTest );
sl@0
   262
	test.Next( _L("Testing not hidden") );
sl@0
   263
	TestScanFilesL( KFileListNotHidden, KNotHidden, aDriveToTest );
sl@0
   264
	test.Next( _L("Testing not system or hidden") );
sl@0
   265
	TestScanFilesL( KFileListNotSystemOrHidden, KNotSystemOrHidden, aDriveToTest );
sl@0
   266
	test.End();
sl@0
   267
	}