os/kernelhwsrv/kerneltest/f32test/fsstress/t_remses.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // f32test\fsstress\t_remses.cpp
    15 // 
    16 //
    17 
    18 #if !defined(__T_REMFSY_H__)
    19 #include "t_remfsy.h"
    20 #endif
    21 
    22 GLDEF_D TFileName tPath;
    23 
    24 LOCAL_C void printDriveAtt(TInt aDrive,TUint anAtt,RTest& aTest);
    25 LOCAL_C void printDriveInfo(TInt aDrive,TDriveInfo& anInfo, RTest& aTest);
    26 LOCAL_C void DriveInformation(TInt aDrive,TDriveInfo& anInfo,RTest& aTest);
    27 
    28 
    29 void TMultipleSessionTest::Initialise(RFs& aFs)
    30 //
    31 //	Initialise iFs
    32 //
    33 	{
    34 	iFs=aFs;
    35 	}
    36 
    37 
    38 void TMultipleSessionTest::SetSessionPath(TInt aDrive)
    39 //
    40 //	Set the session path for a RFs connection to aDrive
    41 //
    42 	{
    43 	iSessionPath=(_L("?:\\MULTIPLE_SESSION_TEST\\"));
    44 	TChar driveLetter;
    45 	TInt r=iFs.DriveToChar(aDrive,driveLetter);
    46 	test(r==KErrNone);
    47 		
    48 	iSessionPath[0]=(TText)driveLetter;
    49 	r=iFs.SetSessionPath(iSessionPath);
    50 	test(r==KErrNone);
    51 	r=iFs.MkDirAll(iSessionPath);
    52 	test(r==KErrNone || r==KErrAlreadyExists);
    53 	}
    54 
    55 
    56 void TMultipleSessionTest::RunTests(RTest& aTest)
    57 //
    58 //	Run tests on iFs file server session
    59 //
    60 
    61 	{
    62 	
    63 	testDriveList(aTest);
    64 	testDriveInfo(aTest);
    65 	testVolumeInfo(aTest);
    66 //	testPowerDown(aTest);
    67 	testSetVolume(aTest);
    68 	testInitialisation(aTest);
    69 //	testMediaChange(aTest);
    70 	testSubst(aTest);
    71 	MakeAndDeleteFiles(aTest);
    72 	}
    73 
    74 
    75 
    76 void TMultipleSessionTest::testDriveList(RTest& aTest)
    77 //
    78 //	Test the drive list.
    79 //
    80 	{
    81 
    82 	aTest.Next(_L("The drive list"));
    83 	TInt r=iFs.SetSessionPath(iSessionPath);
    84 	TDriveList list;
    85 	r=iFs.DriveList(list);
    86 	aTest(r==KErrNone);
    87 
    88 	for (TInt i=0;i<KMaxDrives;i++)
    89 		{
    90 		TInt att=list[i];
    91 		if (att)
    92 			printDriveAtt(i,att,aTest);
    93 		}
    94 	}
    95 
    96 void TMultipleSessionTest::testDriveInfo(RTest& aTest)
    97 //
    98 //	Test the drive info.
    99 //
   100 	{
   101 	
   102 	aTest.Next(_L("The drive info"));
   103 	TInt r=iFs.SetSessionPath(iSessionPath);
   104 	TDriveList list;
   105 	r=iFs.DriveList(list);
   106 	aTest(r==KErrNone);
   107 	for (TInt i=0;i<KMaxDrives;i++)
   108 		{
   109 		TInt att=list[i];
   110 		if (att)
   111 			{
   112 			TDriveInfo d;
   113 			r=iFs.Drive(d,i);
   114 			//aTest(r==KErrNone);
   115 			printDriveInfo(i,d,aTest);
   116 			aTest.Printf(_L("\n"));
   117 			if (r==KErrNone)
   118 				DriveInformation(i,d, aTest);
   119 			}
   120 		}
   121 	}
   122 /*
   123 void TMultipleSessionTest::testPowerDown(RTest& aTest)
   124 //
   125 //	Test the effect of multiple power downs
   126 //
   127 	{
   128 	aTest.Next(_L("Power Down"));
   129 	
   130 	RTimer timer;
   131 	test(timer.CreateLocal()==KErrNone);
   132 	TTime time;
   133 	TRequestStatus status;
   134 
   135 	for (TInt index=0; index<5; index++)
   136 		{
   137 		aTest.Printf(_L("********** %d **********\n"),(5-index));
   138 		time.HomeTime();
   139 		time+=TTimeIntervalSeconds(8);
   140 		timer.At(status,time);
   141 		UserHal::SwitchOff();			// Switch off
   142 		User::WaitForRequest(status);	// Switch back on
   143 		aTest(status==KErrNone);
   144 		}
   145 	}
   146 
   147 */
   148 /*
   149 void TMultipleSessionTest::testMediaChange(RTest& aTest)
   150 //
   151 //	Test the effect of multiple media changes
   152 //
   153 	{
   154 	aTest.Next(_L("Media Change"));
   155 	TInt drive=CurrentDrive(aTest);
   156 	
   157 	if (drive>KMaxLocalDrives)
   158 		return;
   159 
   160 #if defined (__MARM__)
   161 	if (drive==EDriveC)
   162 		return;
   163 #endif
   164 	
   165 	TLocalDrive theDrive;
   166 	TLocalDriveCaps info;
   167 	TBool changedFlag;
   168 	for (TInt index=0; index<5; index++)
   169 		{
   170 		aTest.Printf(_L("********** %d **********\n"),(5-index));
   171 		changedFlag=EFalse;
   172 		TInt r=theDrive.Connect(drive,changedFlag);
   173 		aTest(r==KErrNone);
   174 		UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change
   175 		aTest(changedFlag);
   176 
   177 		do
   178 			{
   179 			r=theDrive.Caps(info);
   180 			} while (r==KErrNotReady);
   181 //		Wait a second...
   182 //		User::After(1000000);
   183 		}
   184 	}
   185 */
   186 
   187 void TMultipleSessionTest::testVolumeInfo(RTest& aTest)
   188 //
   189 //	Test volume info.
   190 //
   191 	{
   192 
   193 	aTest.Next(_L("The volume info"));
   194 	TInt r=iFs.SetSessionPath(iSessionPath);
   195 	TDriveList list;
   196 	r=iFs.DriveList(list);
   197 	aTest(r==KErrNone);
   198 	for (TInt i=0;i<KMaxDrives;i++)
   199 		{
   200 		TVolumeInfo v;
   201 		if ((r=iFs.Volume(v,i))==KErrNone)
   202 			{
   203 			printDriveInfo(i,v.iDrive,aTest);
   204 			aTest.Printf(_L("   VOL=\"%S\" ID=%08x\n"),&v.iName,v.iUniqueID);
   205 			aTest.Printf(_L("   SIZE=%ldK FREE=%ldK\n"),v.iSize/1024,v.iFree/1024);
   206 			}
   207 		else if (r==KErrNotReady)
   208 			aTest.Printf(_L("%c: Not Ready\n"),i+'A');
   209 		else if (r==KErrPathNotFound)
   210 			aTest.Printf(_L("%c: Not Found\n"),i+'A');
   211 		else
   212 			{
   213 			aTest.Printf(_L("%c: Error %d\n"),i+'A',r);
   214 			aTest.Getch();
   215 			}
   216 		aTest.Printf(_L("\n"));
   217 		}
   218 	}
   219 
   220 
   221 void TMultipleSessionTest::testInitialisation(RTest& aTest)
   222 //
   223 //	Modified from T_SESSION.  Still tests that calls to CheckedClose() are
   224 //	OK, ie, tests bug fix, but doesn't check returned error values since remote drive
   225 //	doesn't necessarily return them.
   226 //
   227 	{
   228 	RFile file;
   229 	RDir dir;
   230 		
   231 	aTest.Next(_L("Test calls to CheckedClose are OK"));
   232 	
   233 	TInt r=iFs.SetSessionPath(iSessionPath);
   234 	TInt count;
   235 	RFormat format;
   236 	r=format.Open(iFs,_L("Z:\\"),EFullFormat,count);
   237 
   238 	aTest((r==KErrAccessDenied)||(r==KErrInUse));
   239 	
   240 	r=dir.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\ERRORTEST\\"),KEntryAttMatchMask);
   241 //	aTest(r==KErrPathNotFound);		
   242 	if (r==KErrNone)
   243 		dir.Close();
   244 	
   245 	r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest1.txt"),EFileRead);
   246 //	aTest(r==KErrNotFound);
   247 	if (r==KErrNone)
   248 		file.Close();
   249 
   250 	r=dir.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\ERRORTEST2\\"),KEntryAttMatchMask);
   251 //	aTest(r==KErrPathNotFound);		
   252 	if (r==KErrNone)
   253 		dir.Close();
   254 
   255 	r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest2.txt"),EFileRead);
   256 //	aTest(r==KErrNotFound);
   257 	if (r==KErrNone)
   258 		file.Close();
   259 
   260 	r=dir.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\ERRORTEST3\\"),KEntryAttMatchMask);
   261 //	aTest(r==KErrPathNotFound);		
   262 	if (r==KErrNone)
   263 		dir.Close();
   264 
   265 	r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest3.txt"),EFileRead);
   266 //	aTest(r==KErrNotFound);
   267 	if (r==KErrNone)
   268 		file.Close();
   269 
   270 	r=file.Open(iFs,_L("\\MULTIPLE_SESSION_TEST\\SessionTest4.txt"),EFileRead);
   271 //	aTest(r==KErrNotFound);
   272 	if (r==KErrNone)
   273 		file.Close();
   274 	}
   275 
   276 
   277 void TMultipleSessionTest::testSubst(RTest& aTest)
   278 //
   279 //	Test the substitute functions
   280 //
   281 	{
   282 
   283 	aTest.Next(_L("Test subst"));
   284 	TInt r=iFs.SetSessionPath(iSessionPath);
   285 	TVolumeInfo v;
   286 	r=iFs.Volume(v);
   287 	aTest(r==KErrNone);
   288 	
   289 	TDriveInfo driveInfo;
   290 	r=iFs.Drive(driveInfo,EDriveO);
   291 	aTest(r==KErrNone);
   292 
   293 	testSetVolume(aTest);
   294 	
   295 	if (driveInfo.iDriveAtt==KDriveAttLocal)
   296 		return;	//	Subst local drives fails
   297 
   298 	TFileName n;
   299 	r=iFs.Subst(n,EDriveO);
   300 	aTest(r==KErrNone);
   301 	aTest(n.Length()==0);
   302 	r=iFs.SetSubst(iSessionPath,EDriveO);
   303 	aTest(r==KErrNone);
   304 	r=iFs.Subst(n,EDriveO);
   305 	aTest(r==KErrNone);
   306 	aTest(n==iSessionPath);
   307 	TVolumeInfo w;
   308 	r=iFs.Volume(w,EDriveO);
   309 	aTest(r==KErrNone);
   310 	aTest(w.iDrive.iType==v.iDrive.iType);
   311 	aTest(w.iDrive.iConnectionBusType==v.iDrive.iConnectionBusType);
   312 	aTest(w.iDrive.iDriveAtt==v.iDrive.iDriveAtt);
   313 	aTest(w.iDrive.iMediaAtt==v.iDrive.iMediaAtt);
   314 	aTest(w.iUniqueID==v.iUniqueID);
   315 	aTest(w.iSize==v.iSize);
   316 	aTest(w.iFree==v.iFree);
   317 	aTest(w.iName==v.iName);
   318 	TDriveInfo d;
   319 	r=iFs.Drive(d,EDriveO);
   320 	aTest(r==KErrNone);
   321 	aTest(d.iDriveAtt==KDriveAttSubsted);
   322 
   323 	aTest.Next(_L("Test real name"));
   324 	r=iFs.RealName(_L("O:\\FILE.XXX"),n);
   325 	aTest(r==KErrNone);
   326 	TFileName substedPath=iSessionPath;
   327 	substedPath.Append(_L("FILE.XXX"));
   328 	aTest(n==substedPath);
   329 
   330 	aTest.Next(_L("Test MkDir, Rename and RmDir on Substed drive"));
   331 	r=iFs.MkDir(_L("C:\\MULTIPLE_SESSION_TEST\\TFSRV\\turgid\\"));
   332 	aTest(r==KErrNone);
   333 	r=iFs.Rename(_L("O:\\turgid"), _L("O:\\facile"));
   334 	aTest(r==KErrNone);
   335 	r=iFs.MkDir(_L("O:\\insipid\\"));
   336 	aTest(r==KErrNone);
   337 	r=iFs.Rename(_L("O:\\insipid"), _L("O:\\glib"));
   338 	aTest(r==KErrNone);
   339 	r=iFs.RmDir(_L("O:\\facile\\"));
   340 	aTest(r==KErrNone);
   341 	r=iFs.RmDir(_L("C:\\MULTIPLE_SESSION_TEST\\TFSRV\\glib\\"));
   342 	aTest(r==KErrNone);
   343 
   344 	r=iFs.SetSubst(_L(""),EDriveO);
   345 	aTest(r==KErrNone);
   346 	r=iFs.Subst(n,EDriveO);
   347 	aTest(r==KErrNone);
   348 	aTest(n==_L(""));
   349 	r=iFs.Drive(d,EDriveO);
   350 	aTest(r==KErrNone);
   351 	aTest(d.iDriveAtt==0);
   352 
   353 	}
   354 
   355 
   356 LOCAL_C TInt CreateFileX(const TDesC& aBaseName,TInt aX, RFs iFs, RTest& aTest)
   357 //
   358 // Create a large file. Return KErrEof or KErrNone
   359 //
   360 	{
   361 
   362 	TBuf<128> fileName=aBaseName;
   363 	fileName.AppendNum(aX);
   364 
   365 	RFile file;
   366 	TInt r=file.Replace(iFs,fileName,EFileWrite);
   367 	if (r==KErrDiskFull)
   368 		return(r);
   369 	if (r!=KErrNone)
   370 		{
   371 		aTest.Printf(_L("ERROR:: Replace returned %d\n"),r);
   372 		aTest.Getch();
   373 		return(KErrDiskFull);
   374 		}
   375 	r=file.SetSize(65536);
   376 	if (r==KErrDiskFull)
   377 		{
   378 		file.Close();
   379 		return(r);
   380 		}
   381 	if (r!=KErrNone)
   382 		{
   383 		aTest.Printf(_L("ERROR:: SetSize returned %d\n"),r);
   384 		aTest.Getch();
   385 		file.Close();
   386 		return(KErrDiskFull);
   387 		}
   388 	file.Close();
   389 	aTest.Printf(_L("Created file %d size 64k\n"),aX);
   390 	return(KErrNone);
   391 	}
   392 
   393 LOCAL_C TInt DeleteFileX(TBuf<128>& aBaseName,TInt aX, RFs iFs, TInt aDrive,RTest& aTest)
   394 //
   395 // Delete a file.
   396 //
   397 	{
   398 
   399 	TBuf<128> fileName=aBaseName;
   400 	fileName.AppendNum(aX);
   401 
   402 	TInt r=iFs.Delete(fileName);
   403 	if (aDrive!=EDriveQ)	//	T_REMFSY may return incorrect value on WINS
   404 		aTest(r==KErrNone);
   405 	aTest.Printf(_L("Deleted File %d\n"),aX);
   406 	return(KErrNone);
   407 	}
   408 
   409 void TMultipleSessionTest::MakeAndDeleteFiles(RTest& aTest)
   410 //
   411 // Create and delete large files in a randomish order
   412 //
   413 	{
   414 
   415 	aTest.Next(_L("Create and delete large files"));
   416 	TInt r=iFs.SetSessionPath(iSessionPath);
   417 	r=iFs.MkDirAll(_L("\\MULTIPLE_SESSION_TEST\\SMALLDIRECTORY\\"));
   418 
   419 	if (CurrentDrive(aTest)!=EDriveQ)	//	T_REMFSY may return incorrect result on WINS
   420 		aTest(r==KErrNone || r==KErrAlreadyExists);
   421 	
   422 	TBuf<128> fileName=_L("\\MULTIPLE_SESSION_TEST\\SMALLDIRECTORY\\FILE");
   423 	r=CreateFileX(fileName,0,iFs,aTest);
   424 	aTest(r==KErrNone);
   425 	r=CreateFileX(fileName,1,iFs,aTest);
   426 	aTest(r==KErrNone);
   427 	r=DeleteFileX(fileName,0,iFs,CurrentDrive(aTest),aTest);	
   428 	aTest(r==KErrNone);
   429 	r=CreateFileX(fileName,2,iFs,aTest);
   430 	aTest(r==KErrNone);
   431 	r=CreateFileX(fileName,1,iFs,aTest);
   432 	aTest(r==KErrNone);
   433 	r=CreateFileX(fileName,3,iFs,aTest);
   434 	aTest(r==KErrNone);
   435 	r=DeleteFileX(fileName,1,iFs,CurrentDrive(aTest),aTest);	
   436 	aTest(r==KErrNone);
   437 	r=CreateFileX(fileName,4,iFs,aTest);
   438 	aTest(r==KErrNone);
   439 	r=DeleteFileX(fileName,2,iFs,CurrentDrive(aTest),aTest);	
   440 	aTest(r==KErrNone);
   441 	r=DeleteFileX(fileName,3,iFs,CurrentDrive(aTest),aTest);	
   442 	aTest(r==KErrNone);
   443 	r=DeleteFileX(fileName,4,iFs,CurrentDrive(aTest),aTest);	
   444 	aTest(r==KErrNone);
   445 	r=CreateFileX(fileName,1,iFs,aTest);
   446 	aTest(r==KErrNone);
   447 	r=DeleteFileX(fileName,1,iFs,CurrentDrive(aTest),aTest);	
   448 	aTest(r==KErrNone);
   449 
   450 	r=iFs.CheckDisk(fileName);
   451 	if (r!=KErrNone && r!=KErrNotSupported)
   452 		aTest.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
   453 	}
   454 
   455 void TMultipleSessionTest::FillUpDisk(RTest& aTest)
   456 //
   457 //	Test that a full disk is ok
   458 //
   459 	{
   460 
   461 	aTest.Next(_L("Fill disk to capacity"));
   462 	TInt r=iFs.SetSessionPath(iSessionPath);
   463 	r=iFs.MkDirAll(_L("\\MULTIPLE_SESSION_TEST\\BIGDIRECTORY\\"));
   464 	if	(CurrentDrive(aTest)!=EDriveQ)	//	T_REMFSY may return incorrect result on WINS
   465 		aTest(r==KErrNone || r==KErrAlreadyExists);
   466 	TInt count=0;
   467 	TFileName sessionPath;
   468 	r=iFs.SessionPath(sessionPath);
   469 	test(sessionPath==iSessionPath);
   470 	aTest(r==KErrNone);
   471 	TBuf<128> fileName=_L("\\MULTIPLE_SESSION_TEST\\BIGDIRECTORY\\FILE");
   472 	FOREVER
   473 		{
   474 		TInt r=CreateFileX(fileName,count,iFs, aTest);
   475 		if (r==KErrDiskFull)
   476 			break;
   477 		aTest(r==KErrNone);
   478 		count++;
   479  #if defined(__WINS__)
   480 		if (count==32 && sessionPath[0]=='C') // Don't fill up disk on NT
   481 			break;
   482  #endif
   483 		}
   484 
   485 	r=iFs.CheckDisk(fileName);
   486 	if (r!=KErrNone && r!=KErrNotSupported)
   487 		{
   488 		aTest.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
   489 		aTest.Getch();
   490 		}
   491 
   492 	while(count--)
   493 		DeleteFileX(fileName,count,iFs,CurrentDrive(aTest),aTest);
   494 
   495 	r=iFs.CheckDisk(fileName);
   496 	if (r!=KErrNone && r!=KErrNotSupported)
   497 		{
   498 		aTest.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
   499 		aTest.Getch();
   500 		}
   501 	}
   502 
   503 
   504 void TMultipleSessionTest::testSetVolume(RTest& aTest)
   505 //
   506 //	Test setting the volume info.
   507 //
   508 	{
   509 
   510 	aTest.Next(_L("Test setting the volume label"));
   511 	TInt r=iFs.SetSessionPath(iSessionPath);
   512 	aTest(r==KErrNone);
   513 #if defined(_UNICODE)
   514 	aTest.Printf(_L("Unicode volume label set not implemented ****\n"));
   515 	return;
   516 #else
   517 	TInt driveNum=CurrentDrive(aTest);
   518 	TVolumeInfo v;
   519 	r=iFs.Volume(v,driveNum);
   520 	aTest(r==KErrNone);
   521 	TFileName n=v.iName;
   522 	aTest.Printf(_L("VOL=\"%S\"\n"),&n);
   523 
   524 	aTest.Next(_L("Set volume label to nothing"));
   525 	r=iFs.SetVolumeLabel(_L(""),driveNum);
   526 	if (r==KErrGeneral)
   527 		return;
   528 	aTest(r==KErrNone);
   529 	r=iFs.Volume(v,driveNum);
   530 	aTest(r==KErrNone);
   531 	aTest(v.iName==_L(""));
   532 	aTest.Printf(_L("VOL=\"%S\"\n"),&v.iName);
   533 
   534 	aTest.Next(_L("Set volume label to ABCDEFGHIJK"));
   535 	r=iFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum);
   536 	aTest(r==KErrNone);
   537 	r=iFs.Volume(v,driveNum);
   538 	aTest(r==KErrNone);
   539 	aTest(v.iName==_L("ABCDEFGHIJK"));
   540 	aTest.Printf(_L("VOL=\"%S\"\n"),&v.iName);
   541 
   542 	aTest.Next(_L("Set volume label back to nothing"));
   543 	r=iFs.SetVolumeLabel(_L(""),driveNum);
   544 	aTest(r==KErrNone);
   545 	r=iFs.Volume(v,driveNum);
   546 	aTest(r==KErrNone);
   547 	aTest(v.iName==_L(""));
   548 	aTest.Printf(_L("VOL=\"%S\"\n"),&v.iName);
   549 
   550 	aTest.Next(_L("Set volume label to original"));
   551 	r=iFs.SetVolumeLabel(n,driveNum);
   552 	aTest(r==KErrNone);
   553 	r=iFs.Volume(v,driveNum);
   554 	aTest(r==KErrNone);
   555 	aTest(v.iName==n);
   556 	aTest.Printf(_L("VOL=\"%S\"\n"),&v.iName);
   557 
   558 #endif
   559 	}
   560 
   561 
   562 LOCAL_C void printDriveAtt(TInt aDrive,TUint anAtt,RTest& aTest)
   563 //
   564 // Print a drive attribute.
   565 //
   566 	{
   567 
   568 	aTest.Printf(_L("%c: "),aDrive+'A');
   569 	if (anAtt&KDriveAttRemote)
   570 		aTest.Printf(_L("REMOTE "));
   571 	else if (anAtt&KDriveAttLocal)
   572 		aTest.Printf(_L("LOCAL "));
   573 	if (anAtt&KDriveAttRom)
   574 		aTest.Printf(_L("ROM "));
   575 	if (anAtt&KDriveAttRedirected)
   576 		aTest.Printf(_L("REDIRECTED "));
   577 	if (anAtt&KDriveAttSubsted)
   578 		aTest.Printf(_L("SUBST "));
   579 	if (anAtt&KDriveAttInternal)
   580 		aTest.Printf(_L("INTERNAL "));
   581 	if (anAtt&KDriveAttRemovable)
   582 		aTest.Printf(_L("REMOVABLE "));
   583 	aTest.Printf(_L("\n"));
   584 	}
   585 
   586 LOCAL_C void printDriveInfo(TInt aDrive,TDriveInfo& anInfo,RTest& aTest)
   587 //
   588 // Print a drive info.
   589 //
   590 	{
   591 
   592 	printDriveAtt(aDrive,anInfo.iDriveAtt,aTest);
   593 	aTest.Printf(_L("   MEDIA-ATT="));
   594 	if (anInfo.iMediaAtt==0)
   595 		aTest.Printf(_L("<none>"));
   596 	if (anInfo.iMediaAtt&KMediaAttVariableSize)
   597 		aTest.Printf(_L("VariableSize "));
   598 	if (anInfo.iMediaAtt&KMediaAttDualDensity)
   599 		aTest.Printf(_L("DualDensity "));
   600 	if (anInfo.iMediaAtt&KMediaAttFormattable)
   601 		aTest.Printf(_L("Formattable "));
   602 	if (anInfo.iMediaAtt&KMediaAttWriteProtected)
   603 		aTest.Printf(_L("WProtected "));
   604 	aTest.Printf(_L("\n   CONNECTION BUS TYPE="));
   605 	switch(anInfo.iConnectionBusType)
   606 		{
   607 	case EConnectionBusInternal: aTest.Printf(_L("Internal\n")); break;
   608 	case EConnectionBusUsb: aTest.Printf(_L("USB\n")); break;
   609 	default:
   610 		aTest.Printf(_L("Unknown value\n"));
   611 		}
   612 	aTest.Printf(_L("   MEDIA="));
   613 	switch(anInfo.iType)
   614 		{
   615 	case EMediaNotPresent: aTest.Printf(_L("Not present\n")); break;
   616 	case EMediaUnknown: aTest.Printf(_L("Unknown\n")); break;
   617 	case EMediaFloppy: aTest.Printf(_L("Floppy\n")); break;
   618 	case EMediaHardDisk: aTest.Printf(_L("Hard disk\n")); break;
   619 	case EMediaCdRom: aTest.Printf(_L("CD Rom\n")); break;
   620 	case EMediaRam: aTest.Printf(_L("Ram\n")); break;
   621 	case EMediaFlash: aTest.Printf(_L("Flash\n")); break;
   622 	case EMediaRom: aTest.Printf(_L("Rom\n")); break;
   623 	case EMediaRemote: aTest.Printf(_L("Remote\n")); break;
   624 	default:
   625 		aTest.Printf(_L("Unknown value\n"));
   626 		}
   627 	}
   628 
   629 LOCAL_C void DriveInformation(TInt aDrive,TDriveInfo& anInfo,RTest& aTest)
   630 //
   631 //	Test the drive info is reasonable
   632 //
   633 	{
   634 
   635 	aTest(anInfo.iConnectionBusType==EConnectionBusInternal || anInfo.iConnectionBusType==EConnectionBusUsb);
   636 	
   637 	if (aDrive==EDriveZ)
   638 		{
   639 		if (anInfo.iType==EMediaNotPresent)
   640 			return;
   641 		
   642 		aTest(anInfo.iMediaAtt==KMediaAttWriteProtected);
   643 		aTest(anInfo.iDriveAtt==(KDriveAttRom|KDriveAttInternal));
   644 		aTest(anInfo.iType==EMediaRom);
   645 		}
   646 	
   647 	else if (aDrive==EDriveC || aDrive==EDriveY)
   648 		{
   649 		if (anInfo.iType==EMediaNotPresent)
   650 			return;
   651 
   652 		aTest(anInfo.iDriveAtt==(KDriveAttLocal|KDriveAttInternal));
   653 		aTest(anInfo.iType==EMediaHardDisk);
   654 		aTest(anInfo.iMediaAtt==(KMediaAttVariableSize|KMediaAttFormattable));
   655 		}
   656 	else if (aDrive==EDriveD || aDrive==EDriveX)
   657 		{
   658 		if (anInfo.iType==EMediaNotPresent)
   659 			return;
   660 
   661 		aTest(anInfo.iDriveAtt==(KDriveAttLocal|KDriveAttRemovable));
   662 		aTest(anInfo.iType==EMediaHardDisk);
   663 		aTest(anInfo.iMediaAtt==KMediaAttFormattable);
   664 		}
   665 	}
   666 
   667 
   668 
   669 GLDEF_C void ReportCheckDiskFailure(TInt aRet,RTest& aTest)
   670 //
   671 // Report the failure of checkdisk
   672 //
   673 	{
   674 
   675 	aTest.Printf(_L("CHECKDISK FAILED: "));
   676 	switch(aRet)
   677 		{
   678 	case 1:	aTest.Printf(_L("File cluster chain contains a bad value (<2 or >maxCluster)\n")); break;
   679 	case 2:	aTest.Printf(_L("Two files are linked to the same cluster\n")); break;
   680 	case 3:	aTest.Printf(_L("Unallocated cluster contains a value != 0\n"));	break;
   681 	case 4:	aTest.Printf(_L("Size of file != number of clusters in chain\n")); break;
   682 	default: aTest.Printf(_L("Undefined Error value %d\n"),aRet);
   683 		}
   684 	aTest.Printf(_L("Press any key to continue\n"));
   685 	aTest.Getch();
   686 	}
   687 
   688 
   689 
   690 TInt TMultipleSessionTest::CurrentDrive(RTest& aTest)
   691 //
   692 // Return the current drive number
   693 //
   694 	{
   695 	TInt r=iFs.SetSessionPath(iSessionPath);
   696 	aTest(r==KErrNone);
   697 	TInt driveNum;
   698 	r=iFs.CharToDrive(iSessionPath[0],driveNum);
   699 	aTest(r==KErrNone);
   700 	return(driveNum);
   701 	}
   702 
   703 
   704 	
   705