kerneltest/f32test/demandpaging/loader/t_pageldrtst.cpp
branchanywhere
changeset 41 d32f34975bbf
parent 33 0173bcd7697c
child 293 0659d0e1a03c
equal deleted inserted replaced
40:04a1b74efd48 41:d32f34975bbf
   118 //! @SYMTestPriority        High
   118 //! @SYMTestPriority        High
   119 //! @SYMTestStatus          Implemented
   119 //! @SYMTestStatus          Implemented
   120 
   120 
   121 #include <e32test.h>
   121 #include <e32test.h>
   122 #include <e32rom.h>
   122 #include <e32rom.h>
       
   123 #include <e32svr.h>
   123 #include <u32hal.h>
   124 #include <u32hal.h>
   124 #include <f32file.h>
   125 #include <f32file.h>
   125 #include <f32dbg.h>
   126 #include <f32dbg.h>
   126 #include <e32msgqueue.h>
   127 #include <e32msgqueue.h>
   127 #include <e32math.h>
   128 #include <e32math.h>
   128 #include <e32btrace.h>
   129 #include <e32btrace.h>
   129 #include <d32btrace.h>
   130 #include <d32btrace.h>
       
   131 #include <d32locd.h>
   130 #include <hal.h>
   132 #include <hal.h>
   131 
   133 
   132 #include "t_hash.h"
   134 #include "t_hash.h"
   133 #include "paging_info.h"
   135 #include "paging_info.h"
   134 
   136 
  4276 	RFile	theInFiles[FILECOUNTMAX];
  4278 	RFile	theInFiles[FILECOUNTMAX];
  4277 	RFile	theOutFiles[FILECOUNTMAX];
  4279 	RFile	theOutFiles[FILECOUNTMAX];
  4278 	TInt	inFileSize[FILECOUNTMAX];
  4280 	TInt	inFileSize[FILECOUNTMAX];
  4279 	TInt	inFilePos[FILECOUNTMAX];
  4281 	TInt	inFilePos[FILECOUNTMAX];
  4280 	TBool	fileOk[FILECOUNTMAX];
  4282 	TBool	fileOk[FILECOUNTMAX];
  4281 	
  4283 
  4282 	TInt	  index;
  4284 	TInt	  index;
  4283 	TFileName newPath;
  4285 	TFileName newPath;
  4284 	TFileName oldPath;
  4286 	TFileName oldPath;
  4285 
  4287 
  4286 	for (index = 0; index < FILECOUNTMAX; index ++)
  4288 	for (index = 0; index < FILECOUNTMAX; index ++)
  4287 		{
  4289 		{
  4288 		fileOk[index] = ETrue;
  4290 		inFileSize[index] = 0;
       
  4291 		inFilePos[index] = 0;
       
  4292 		fileOk[index] = EFalse;
       
  4293 
  4289 		if (index < PAGELDRTST_MAX_DLLS)
  4294 		if (index < PAGELDRTST_MAX_DLLS)
  4290 			{
  4295 			{
  4291 			oldPath.Format(_L("%S%S%d%S"), &KRomPath, &KDllBaseName, index, &TestPlExtNames[KTestMediaBase]);
  4296 			oldPath.Format(_L("%S%S%d%S"), &KRomPath, &KDllBaseName, index, &TestPlExtNames[KTestMediaBase]);
  4292 			newPath.Format(_L("%S%S%d%S"), &aPath, &KDllBaseName, index, &TestPlExtNames[aMediaType]);
  4297 			newPath.Format(_L("%S%S%d%S"), &aPath, &KDllBaseName, index, &TestPlExtNames[aMediaType]);
  4293 			}
  4298 			}
  4303 			}
  4308 			}
  4304 
  4309 
  4305 		retVal = theInFiles[index].Open(aFs, oldPath, EFileRead);
  4310 		retVal = theInFiles[index].Open(aFs, oldPath, EFileRead);
  4306 		if (retVal != KErrNone)
  4311 		if (retVal != KErrNone)
  4307 			{
  4312 			{
  4308 			fileOk[index] = EFalse;
  4313 			DBGS_PRINT((_L("%S : Failed to open for read (%d)\n"), &oldPath, retVal));
  4309 			DBGS_PRINT((_L("%S : Failed to open (%d)\n"), &oldPath, retVal));
  4314 			break;
       
  4315 			}
       
  4316 		retVal = theInFiles[index].Size(inFileSize[index]);
       
  4317 		if (retVal != KErrNone)
       
  4318 			{
       
  4319 			theInFiles[index].Close();
       
  4320 			DBGS_PRINT((_L("%S : Failed to get file size (%d)\n"), &newPath, retVal));
  4310 			break;
  4321 			break;
  4311 			}
  4322 			}
  4312 		retVal = theOutFiles[index].Replace(aFs, newPath, EFileWrite);
  4323 		retVal = theOutFiles[index].Replace(aFs, newPath, EFileWrite);
  4313 		if (retVal != KErrNone)
  4324 		if (retVal != KErrNone)
  4314 			{
  4325 			{
  4315 			fileOk[index] = EFalse;
  4326 			theInFiles[index].Close();
  4316 			DBGS_PRINT((_L("%S : Failed to open (%d)\n"), &newPath, retVal));
  4327 			DBGS_PRINT((_L("%S : Failed to open for write (%d)\n"), &newPath, retVal));
  4317 			break;
  4328 			break;
  4318 			}
  4329 			}
  4319 		retVal = theInFiles[index].Size(inFileSize[index]);
  4330 
  4320 		if (retVal != KErrNone)
  4331 		fileOk[index] = ETrue;
  4321 			{
       
  4322 			fileOk[index] = EFalse;
       
  4323 			DBGS_PRINT((_L("%S : Failed to get file size (%d)\n"), &newPath, retVal));
       
  4324 			break;
       
  4325 			}
       
  4326 		inFilePos[index] = 0;
       
  4327 		}
  4332 		}
  4328 
  4333 
  4329 	const TInt KBufferSize = 3333;
  4334 	const TInt KBufferSize = 3333;
  4330 	TBuf8<KBufferSize> buffer;
  4335 	TBuf8<KBufferSize> buffer;
  4331 
  4336 	TBool stillGoing;
  4332 	TBool stillGoing = ETrue;	
  4337 
  4333 	
  4338 	do
  4334 	while (stillGoing)
       
  4335 		{
  4339 		{
  4336 		stillGoing = EFalse;
  4340 		stillGoing = EFalse;
  4337 		for (index = 0; index < FILECOUNTMAX; index ++)
  4341 		for (index = 0; index < FILECOUNTMAX; index ++)
  4338 			{
  4342 			{
  4339 			if (inFilePos[index] < inFileSize[index])
       
  4340 				{
       
  4341 				if (fileOk[index])
       
  4342 					{
       
  4343 					retVal = theInFiles[index].Read(buffer);
       
  4344 					if (retVal != KErrNone)
       
  4345 						{
       
  4346 						DBGS_PRINT((_L("theInFiles[%d] read failed (%d)\n"), index, retVal));
       
  4347 						fileOk[index] = EFalse;
       
  4348 						break;
       
  4349 						}
       
  4350 					retVal = theOutFiles[index].Write(buffer);
       
  4351 					if (retVal != KErrNone)
       
  4352 						{
       
  4353 						DBGS_PRINT((_L("theOutFiles[%d] Write failed (%d)\n"), index, retVal));
       
  4354 						fileOk[index] = EFalse;
       
  4355 						break;
       
  4356 						}
       
  4357 					retVal = theOutFiles[index].Flush();
       
  4358 					if (retVal != KErrNone)
       
  4359 						{
       
  4360 						DBGS_PRINT((_L("theOutFiles[%d] flush failed (%d)\n"), index, retVal));
       
  4361 						fileOk[index] = EFalse;
       
  4362 						break;
       
  4363 						}
       
  4364 					inFilePos[index] += buffer.Length();
       
  4365 					}
       
  4366 				else
       
  4367 					break;
       
  4368 				}
       
  4369 			if ((inFilePos[index] < inFileSize[index]) && (fileOk[index]))
       
  4370 				{
       
  4371 				stillGoing = ETrue;
       
  4372 				}
       
  4373 			}
       
  4374 			if (!fileOk[index])
  4343 			if (!fileOk[index])
  4375 				break;
  4344 				break;
  4376 		}
  4345 			if (inFilePos[index] < inFileSize[index])
  4377 
  4346 				{
  4378 	TBool allOk = ETrue;
  4347 				retVal = theInFiles[index].Read(buffer);
       
  4348 				if (retVal != KErrNone)
       
  4349 					{
       
  4350 					DBGS_PRINT((_L("theInFiles[%d] read failed (%d)\n"), index, retVal));
       
  4351 					break;
       
  4352 					}
       
  4353 				retVal = theOutFiles[index].Write(buffer);
       
  4354 				if (retVal != KErrNone)
       
  4355 					{
       
  4356 					DBGS_PRINT((_L("theOutFiles[%d] Write failed (%d)\n"), index, retVal));
       
  4357 					break;
       
  4358 					}
       
  4359 				retVal = theOutFiles[index].Flush();
       
  4360 				if (retVal != KErrNone)
       
  4361 					{
       
  4362 					DBGS_PRINT((_L("theOutFiles[%d] flush failed (%d)\n"), index, retVal));
       
  4363 					break;
       
  4364 					}
       
  4365 				inFilePos[index] += buffer.Length();
       
  4366 				if (inFilePos[index] < inFileSize[index])
       
  4367 					stillGoing = ETrue;
       
  4368 				}
       
  4369 			}
       
  4370 		}
       
  4371 	while (stillGoing);
       
  4372 
       
  4373 	TBool allOk = retVal == KErrNone;
  4379 	for (index = 0; index < FILECOUNTMAX; index ++)
  4374 	for (index = 0; index < FILECOUNTMAX; index ++)
  4380 		{
  4375 		{
       
  4376 		if (!fileOk[index])
       
  4377 			{
       
  4378 			allOk = EFalse;
       
  4379 			break;
       
  4380 			}
  4381 		theInFiles[index].Close();
  4381 		theInFiles[index].Close();
  4382 		theOutFiles[index].Close();
  4382 		theOutFiles[index].Close();
  4383 		if (!fileOk[index])
       
  4384 			{
       
  4385 			allOk = EFalse;
       
  4386 			continue;
       
  4387 			}
       
  4388 		if (index < PAGELDRTST_MAX_DLLS)
  4383 		if (index < PAGELDRTST_MAX_DLLS)
  4389 			{
  4384 			{
  4390 			newPath.Format(_L("%S%S%d%S"), &aPath, &KDllBaseName, index, &TestPlExtNames[aMediaType]);
  4385 			newPath.Format(_L("%S%S%d%S"), &aPath, &KDllBaseName, index, &TestPlExtNames[aMediaType]);
  4391 			}
  4386 			}
  4392 		else if (index < (PAGELDRTST_MAX_DLLS + 1))
  4387 		else if (index < (PAGELDRTST_MAX_DLLS + 1))
  4540 	if (!aSilent)
  4535 	if (!aSilent)
  4541 		DBGD_PRINT((_L("Deleting %S\n"), &aFileName));
  4536 		DBGD_PRINT((_L("Deleting %S\n"), &aFileName));
  4542 	TInt retVal = aFileMan->Delete(aFileName);
  4537 	TInt retVal = aFileMan->Delete(aFileName);
  4543 	if (retVal != KErrNone)
  4538 	if (retVal != KErrNone)
  4544 		{
  4539 		{
  4545 		if (TestingReaper && (retVal == KErrInUse))
  4540 		if (TestingReaper)
  4546 			{
  4541 			{
       
  4542 			aFileMan->Attribs(aFileName, KEntryAttNormal, KEntryAttReadOnly, 0);
  4547 			retVal = l.Delete(aFileName);
  4543 			retVal = l.Delete(aFileName);
  4548 			if (retVal != KErrNone)
  4544 			if (retVal != KErrNone)
  4549 				{
  4545 				{
  4550 				DBGS_PRINT((_L("RLoader::Delete %S Failed %d\n"), &aFileName, retVal));
  4546 				DBGS_PRINT((_L("RLoader::Delete %S Failed %d\n"), &aFileName, retVal));
  4551 				}
  4547 				}
  4977 		test.Printf(_L("%S (%d)\n"), &TestNameBuffer, TestWeAreTheTestBase);
  4973 		test.Printf(_L("%S (%d)\n"), &TestNameBuffer, TestWeAreTheTestBase);
  4978 		test.Printf(_L("TestBootedFromMmc %d\n"), TestBootedFromMmc);
  4974 		test.Printf(_L("TestBootedFromMmc %d\n"), TestBootedFromMmc);
  4979 
  4975 
  4980 		if (TestWeAreTheTestBase)
  4976 		if (TestWeAreTheTestBase)
  4981 			CleanupFiles(ETrue);
  4977 			CleanupFiles(ETrue);
  4982  
  4978 
  4983 		CheckFilePresence(TestWeAreTheTestBase);
  4979 		CheckFilePresence(TestWeAreTheTestBase);
  4984 		}
  4980 		}
  4985 
  4981 
  4986 	if (parseResult)
  4982 	if (parseResult)
  4987 		{
  4983 		{